Daily Challenge #78

And this?

image

So another bug.

1 Like

Then I don’t know why this error is coming. I cannot even test it, so sorry.
:sob:

Soo, guys. I selected @vknow360’s solution, because he has less blocks than everyone. I know, in some other DC’s, the answer will be selected by who was the first, but i don’t think this is a good idea. We should select the best kode and not the earliest.

Yoshi

Btw, thanks for you to participate! :stuck_out_tongue:

3 Likes

So I went ahead and optimized this daily challenge… :crazy_face:

Here’s the timeline:
Coming up with the basic idea: 0.5 days
Creating functions to solve by hand: 1 day, 2 notebook pages, a lot of whiteboard scribbling, debugging in MS Paint (I’m not even kidding).
Creating and debugging a functional Python program: 1.5 days
Blockly adaptation: 2 hours

…and then I forgot to post. It was done on 8th June.

Python solution
def niner_backend(sum, x):
    if x == 1:
        return(sum + 9)
    elif x == 0:
        return 0
    else:
        ninestr = int("9"+((x-1)*"0"))
        return (niner_backend(sum + ninestr*len(str(ninestr)), x-1))

def niner(sum, x):
    n = 0
    nout = niner_backend(0, n)
    while nout < x:
        n += 1
        nout = niner_backend(0, n)
    n -= 1
    nout = niner_backend(0, n)
    if n > 0:
        g = int(n*"9")
    else:
        g = 0
    return nout, g

def digiMap(n): #! IT WORKS!!! -K, 8th June 2020, some time in the evening.
    #print("Mapping digit: " + str(n))
    b = niner(0, n)[0]
    d = n - b
    g = niner(0, n)[1]
    a = len(str(g+1))
    l = d % a
    if l == 0:
        l = a
    z = d//a
    x = a - l
    if l == 1:
        if a != 1:
            return ((z//(10**x)) + 1)%(10**(x+1))
        else:
            return (z//(10**x))%(10**(x+1))
    else:
        if (z//(10**x)) > 0:
            if l != a:
                return int(str((z//(10**x)))[::-1][0])
            else:
                return int(str((z//(10**x))-1)[::-1][0])
        else:
            return 0
Blockly solution
Proof of functionality

The Python solution evaluated the (1x10^150)th digit in 0.1 seconds. The algorithm submitted by the others, for context, evaluated the 270000th digit.

1 Like

it is just AMAZING. So much kode, and so distinctive! very very nice, @Kanishka_Developer!!!
I was very surprised someone again replied here, and I was like -

1 Like

Well, thank you for the awesome challenge, and 4 days of frustration! :joy:

Was not expecting that at all when I made it. Sry!
:sweat_smile:

And no thanks, this was far the worst challenge.

Nah, far from it. The satisfaction at the end when the outputs got validated, totally made up for the existential crisis. :rofl:

1 Like

Thanks! :blush: :smiling_face_with_three_hearts:

Why would a challenge be bad? :grin:
Be positive :muscle:

Thank you all! :smiley_cat: :smiley_cat: :smiley_cat:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.