Project Euler #75: Singular integer right triangles Discussions | | HackerRank

Project Euler #75: Singular integer right triangles

Sort by

recency

|

13 Discussions

|

  • + 0 comments

    100 points. Python 3

    import math,itertools,bisect
    
    lookup=[0]*(5*10**6+1)
    for v,u in itertools.combinations(range(1,int((5*10**6)**0.5)+1,2),2):
            if u>v and math.gcd(u,v)==1:
                s=u**2+u*v
                for i in range(s,5*10**6+1,s):
                    lookup[i]+=1
    ans=[i for i in range(5*10**6+1) if lookup[i]==1]
    t=int(input().strip())
    for _ in range(t):
        n=int(input().strip())
        count=bisect.bisect_right(ans,n)
        print(count)
    
  • + 0 comments

    ALERT:

    Please don't use Pythagorean Triplets Generate algorithm in Geeks for geeks. Those codes are wrong. Please use this StackExchange instead

  • + 0 comments

    you can find my java solution here

  • + 0 comments

    any one can send code for this answer

  • + 0 comments

    Lazy solution to dumb test cases: precalculate all the counts up to N=5e6 then return the corresponding value for each test case. You really should put more effort (or at least some effort) into reasonable/decent/interesting requirements.