We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Math
- Triangle Quest 2
- Discussions
Triangle Quest 2
Triangle Quest 2
Sort by
recency
|
1163 Discussions
|
Please Login in order to post a comment
New non-mathematical solution in Python using string-like operations and Java-like curly braces.
I'm biased, but I think this is very hacky.
I've found a…
HackerRank compiler bug
Not satisfied that a non-mathematical couldn't pass the tests, I decided to try some other clever solutions. I tried code with only ONE for statement. However, the compiler is buggy and it counts a format() call as a second for statement! Would this pass the tests if it weren't for the for bug? I don't know!
I HATED this challenge.
I would have saved a lot of time if the compiler error messages were more clear. At first, I got an error about using
str()
. Then, many times I got error messages about using more than oneprint()
orfor
statement. I was using only one of each, but it turns out that if a comment in the code mentioned either of those keywords, it would cause the error, too! FFS!Finally, I got past those errors when I realized I should remove the comments. Then I got an error message about using a "string literal". I was using
sep='\n'
in theprint()
statement. Even that is considered to be "related to strings". FFS!Anyway, my inelegant solution is…
Not as neat as the problem setter's code, but I think it's fairly unique.
Here is HackerRank Triangle Quest 2 in python solution - https://programmingoneonone.com/hackerrank-triangle-quest-2-solution-in-python.html
for i in range(1, int(input()) + 1): print(int(10 ** i / 9) ** 2)