Skip to content
Snippets Groups Projects
Commit 76268ce5 authored by Taddeüs Kroes's avatar Taddeüs Kroes
Browse files

Solved 45

parent fadf1e2b
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python
def tri(n): return n * (n + 1) / 2
def pent(n): return n * (3 * n - 1) / 2
def hexa(n): return n * (2 * n - 1)
funcs = (tri, pent, hexa)
n = [20] * 3
vals = [f(20) for f in funcs]
while len(set(vals)) > 1 or vals[0] == 40755:
mini = 0
minv = None
for i, v in enumerate(vals):
if minv is None or v < minv:
mini = i
minv = v
n[mini] += 1
vals[mini] = funcs[mini](n[mini])
print vals[0]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment