Triangle Quest 2

Sort by

recency

|

1163 Discussions

|

  • + 0 comments

    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.

    import io, sys; print(12345678987654321, file=(b := io.StringIO())); s = b.getvalue()
    {sys.stdout.write(s[:i + 1] + s[17 - i:]) for i in range(int(input()))} #enableJavaCurlyBraces=True
    
  • + 0 comments

    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!

  • + 0 comments

    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 one print() or for 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 the print() statement. Even that is considered to be "related to strings". FFS!

    Anyway, my inelegant solution is…

    for i in range(int(input())):
        print(123456789 // 10**(8 - i) * 10**(i) + 87654321 % 10**(i))
    

    Not as neat as the problem setter's code, but I think it's fairly unique.

  • + 0 comments

    Here is HackerRank Triangle Quest 2 in python solution - https://programmingoneonone.com/hackerrank-triangle-quest-2-solution-in-python.html

  • + 0 comments

    for i in range(1, int(input()) + 1): print(int(10 ** i / 9) ** 2)