mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-06-16 19:09:17 -04:00
reorganize dir
Signed-off-by: Mia Steinkirch <mia.steinkirch@gmail.com>
This commit is contained in:
parent
1b6f705e7c
commit
a8e71c50db
276 changed files with 23954 additions and 0 deletions
other_resources/Project-Euler
26
other_resources/Project-Euler/009-special_pyt.py
Normal file
26
other_resources/Project-Euler/009-special_pyt.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/python3
|
||||
# mari von steinkirch @2013
|
||||
# steinkirch at gmail
|
||||
|
||||
|
||||
|
||||
def special_pyt(n):
|
||||
for i in range(3, n):
|
||||
for j in range(i+1, n):
|
||||
c = calc_c(i,j)
|
||||
if i + j + c == n:
|
||||
return i*j*c
|
||||
|
||||
def calc_c(a, b):
|
||||
return (a**2 + b**2)**0.5
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
assert(special_pyt(3+4+5) == (3*4*5))
|
||||
print(special_pyt(1000))
|
||||
print('Tests Passed!')
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue