From 95341b61b030c9e1290f3b326cb7ec584f543aea Mon Sep 17 00:00:00 2001 From: Reiner Herrmann Date: Sun, 31 Aug 2014 20:21:45 +0200 Subject: moved files to higher directory after split to new repository --- 061.py | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 061.py (limited to '061.py') diff --git a/061.py b/061.py new file mode 100644 index 0000000..d9688e1 --- /dev/null +++ b/061.py @@ -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) + -- cgit v1.2.3