Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from itertools import permutations
- octa, hepta, hexa, penta, sq, tri = [], [], [], [], [], []
- for a in range(1, 10**10):
- temp = int(a*(3*a-2))
- if temp < 1000:
- continue
- if temp > 9999:
- break
- octa.append(temp)
- for a in range(1, 10**10):
- temp = int(a*(5*a-3)/2)
- if temp < 1000:
- continue
- if temp > 9999:
- break
- hepta.append(temp)
- for a in range(1, 10**10):
- temp = int(a*(2*a-1))
- if temp < 1000:
- continue
- if temp > 9999:
- break
- hexa.append(temp)
- for a in range(1, 10**10):
- temp = int(a*(3*a-1)/2)
- if temp < 1000:
- continue
- if temp > 9999:
- break
- penta.append(temp)
- for a in range(1, 10**10):
- temp = int(a**2)
- if temp < 1000:
- continue
- if temp > 9999:
- break
- sq.append(temp)
- for a in range(1, 10**10):
- temp = int(a*(a+1)/2)
- if temp < 1000:
- continue
- if temp > 9999:
- break
- tri.append(temp)
- def check(shape, num):
- for x in range(int(str(num)[-2:] + "01"), int(str(num)[-2:] + "99") + 1):
- if x in shape:
- return x
- return 0
- choices = list(permutations([tri, sq, penta, hexa, hepta]))
- for b in octa:
- print(octa.index(b))
- for d in choices:
- answer, current, nums = b, b, 0
- for c in d:
- if check(c, current) > 0:
- current = check(c, current)
- answer += current
- nums += 1
- else:
- break
- if (nums == 5) and (check(octa, current) == b):
- print(answer)
- quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement