diff options
| author | Scimon <simon.proctor@gmail.com> | 2021-08-16 09:09:50 +0100 |
|---|---|---|
| committer | Scimon <simon.proctor@gmail.com> | 2021-08-16 09:09:50 +0100 |
| commit | a40d5274a80b7dc86d043433b77928857d904698 (patch) | |
| tree | 839fa66142ee3a743bedfe86cc486a5b6573accc /challenge-125/stuart-little/python/ch-1.py | |
| parent | c976e26a845911cf0226844acfc1e4c0e497c8c1 (diff) | |
| parent | 2d08dfcd1f2742e1621be6950a42614b4dbea797 (diff) | |
| download | perlweeklychallenge-club-a40d5274a80b7dc86d043433b77928857d904698.tar.gz perlweeklychallenge-club-a40d5274a80b7dc86d043433b77928857d904698.tar.bz2 perlweeklychallenge-club-a40d5274a80b7dc86d043433b77928857d904698.zip | |
Merge branch 'master' of github.com:Scimon/perlweeklychallenge-club
Diffstat (limited to 'challenge-125/stuart-little/python/ch-1.py')
| -rwxr-xr-x | challenge-125/stuart-little/python/ch-1.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/challenge-125/stuart-little/python/ch-1.py b/challenge-125/stuart-little/python/ch-1.py new file mode 100755 index 0000000000..f35cf52624 --- /dev/null +++ b/challenge-125/stuart-little/python/ch-1.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python + +# run <script> <number> + +import math +import sys + +def trps(n): + triples=[] + triples.extend([[x, math.floor(math.sqrt(n**2-x**2)), n] for x in range(1,math.ceil((n+1)/2)+1) if x<n and x**2 + math.floor(math.sqrt(n**2-x**2))**2 == n**2 ]) + triples.extend([ [math.floor((math.floor(n**2/x)-x)/2),n,math.floor((math.floor(n**2/x)+x)/2)] for x in [i for i in range(1,n) if n**2 % i == 0 and i%2==(math.floor(n**2/i))%2]]) + return triples + +sol = trps(int(sys.argv[1])) +if len(sol)>0: + [print(i) for i in sol] + sys.exit() +print(-1) |
