diff options
| author | Reiner Herrmann <reiner@reiner-h.de> | 2014-08-31 20:21:45 +0200 |
|---|---|---|
| committer | Reiner Herrmann <reiner@reiner-h.de> | 2014-08-31 20:35:09 +0200 |
| commit | 95341b61b030c9e1290f3b326cb7ec584f543aea (patch) | |
| tree | 852386fa04d32eb859bca11c0eff7b5ef9e50f00 /061.py | |
| parent | 571164d977f91925c4c76a292f74f5f93d09ae23 (diff) | |
Diffstat (limited to '061.py')
| -rw-r--r-- | 061.py | 53 |
1 files changed, 53 insertions, 0 deletions
@@ -0,0 +1,53 @@ + +import sys + +triangle = set([ n*(n+1)/2 for n in range(45,141) ]) +square = set([ n*n for n in range(32,99) ]) +pentagonal = set([ n*(3*n-1)/2 for n in range(26,82) ]) +hexagonal = set([ n*(2*n-1) for n in range(23,71) ]) +heptagonal = set([ n*(5*n-3)/2 for n in range(21,64) ]) +octagonal = set([ n*(3*n-2) for n in range(19,59) ]) + +whole = set(triangle | square | pentagonal | hexagonal | heptagonal | octagonal) + + +def check_cond(testset): + check = 0 + for e in testset: + if e in octagonal: + check |= 1 + elif e in heptagonal: + check |= 2 + elif e in hexagonal: + check |= 4 + elif e in pentagonal: + check |= 8 + elif e in square: + check |= 16 + elif e in triangle: + check |= 32 + return check == 63 + +for i0 in whole: + t0 = i0 % 100 + tail0 = [ n for n in whole if t0*100 < n < (t0+1)*100 ] + for i1 in tail0: + t1 = i1 % 100 + tail1 = [ n for n in whole if t1*100 < n < (t1+1)*100 ] + for i2 in tail1: + t2 = i2 % 100 + tail2 = [ n for n in whole if t2*100 < n < (t2+1)*100 ] + for i3 in tail2: + t3 = i3 % 100 + tail3 = [ n for n in whole if t3*100 < n < (t3+1)*100 ] + for i4 in tail3: + t4 = i4 % 100 + tail4 = [ n for n in whole if t4*100 < n < (t4+1)*100 ] + for i5 in tail4: + if i5 % 100 != i0 / 100: + continue + s = set([i0, i1, i2, i3, i4, i5]) + if len(s) == 6 and check_cond(s): + print sum(s) + sys.exit(0) + |
