And this?
So another bug.
Then I don’t know why this error is coming. I cannot even test it, so sorry.
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!
So I went ahead and optimized this daily challenge…
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
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.
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 -
Well, thank you for the awesome challenge, and 4 days of frustration!
Was not expecting that at all when I made it. Sry!
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.
Thanks!
Why would a challenge be bad?
Be positive
Thank you all!
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.