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.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #142: Perfect Square Collection
  4. Discussions

Project Euler #142: Perfect Square Collection

Problem
Submissions
Leaderboard
Discussions

Sort 12 Discussions, By:

votes

Please Login in order to post a comment

  • maruthismith
    6 years ago+ 1 comment

    I understand the problem clearly. But i dont have any idea how to generate triplets.

    3|
    Permalink
  • LittleFox
    6 years ago+ 1 comment

    Not a so easy problem. I found 10560 triples for x under 10^12 but it takes 47s to my python program to find them which is quick enough to pass the first 7 test cases but not the last one.

    My program is based on pythagorean triples :

    x+y = a²
    x-y = b²
    x+z = c²
    x-z = d²
    y+z = e²
    y-z = f²
    => 
    a² = c² + f² with c>f
    a² = d² + e² with c>e and (c+d)%2 = 0
    c²-e² = b²
    

    So I generate all pythagorean triples with hypotenuse = a in ascending order then for each combinations of pythagorean triples with same a, I test all the 3 left constraints (c>e, (c+d)%2 = 0 and c²-e² = b²).

    I have not much idea how to improve that. Can we skip some pythagorean triplets? Can we have some constraint on d and e to avoid to test twice with them reversed?

    I found some other way to solve that but did not implement it yet : https://sites.google.com/site/tpiezas/0020. What did you implemented?

    1|
    Permalink
  • vijay6_vit
    3 years ago+ 0 comments

    I am bit confused with the problem statements.

    0|
    Permalink
  • jbaum517
    6 years ago+ 0 comments

    Passed all test cases except #7 and #8.. Anybody have any tips about why this might be? To me my algorithm works when N>=3000, but apparently not?

    It's not a timeout issue as I'm returning answers fast.

    0|
    Permalink
  • thirumuscat
    6 years ago+ 1 comment

    error: no suitable method found for valueOf(BigInteger)

    for (BigInteger x =BigInteger.valueOf(1234567890);x.compareTo(BigInteger.ZERO) > 0;x=x.subtract(BigInteger.ONE)) { for (BigInteger y =BigInteger.valueOf(x);y.compareTo(BigInteger.ZERO) > 0;y = y.subtract(BigInteger.ONE)) { for (BigInteger z = BigInteger.valueOf(y); z.compareTo(BigInteger.ZERO) > 0; z = z.subtract(BigInteger.ONE))

    pls help!!!

    0|
    Permalink
Load more conversations

Need Help?


View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature