Project Euler #136: Singleton difference

Sort by

recency

|

8 Discussions

|

  • + 0 comments

    my code is working on the testcases i am providing correctfully but does not work for even a single testcase given by hackerrank. Not runtime , but also wrong answers , it says. I have tried for a lot of custom testcases and it works on them

  • + 0 comments

    Only the last test case not passing please help

  • + 2 comments

    YES! I did it!

    • + 0 comments

      Awesome! My code is still too slow, you are the best :)

    • + 1 comment

      Hey how to do it? Do the brute force is the only way to do it? Any hint for any other solution?

      • + 0 comments

        With a bit of math (modular arithmetic), you can restrict solutions only to some particular values of n, and with a limited range for the variables, so you can check all solutions (for uniqueness) within the required boundary range in a reasonable time.

  • + 1 comment

    With correct submissions around only 15% of total, I wonder why this problem was classified as "easy"...

    • + 0 comments

      agreed, this should be classified at least "difficult". My solution calculates the original euler 136 question for [1,50000000] in 3s, which is obviously too slow for the HR version, but still wasn't easy to get to. Back to the drawingboard!

  • + 0 comments

    way to solution

    13^2−10^2−7^2=20 (a+x)^2 - a^2 - (a-x)^2 = n

    a^2+2ax+x^2-a^2-(a^2-2ax+x^2) = n

    a^2+2ax+x^2-a^2-a^2+2ax-x^2 = n 4ax-a^2 = n a(4x-a) = n

    Since n, x and a are integers it raises following conditions,

    n%a==0;

    The interesing thing is that, n should be perfectly divisible by a

    4x-a = n/a 4x = n/a + a