Sort 765 Discussions, By:
Please Login in order to post a comment
for i in range(1,int(input())):
print([0, 1, 22, 333, 4444, 55555, 666666, 7777777, 88888888, 999999999][i])
It doesn't involve strings :P
I'm glad to have learned something new today. However, that "something new" was more maths than programming.
IMO, this problem forces artificial restrictions so as to leave you with only one solution. And if you enjoy recreational mathematics, then you would know it right away, but otherwise you're going to be stuck for a while.
In this respect, it doesn't help to improve programming skill, IMHO. And especially not Python skill (this is an introductory exercise in Python, after all). Which is what Hackerrank is about.
This is just my opinion, of course. I don't know the first thing about constructing a "good" exercise myself :-)
Why this is wrong answer?
print(str(i) * i)
Nice way to go in Math: