-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path61.py
executable file
·105 lines (86 loc) · 1.61 KB
/
61.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env python3
from lib import digits
import itertools
def cyclic(l):
if digits(l[0])[:2] != digits(l[-1])[2:]:
return False
for i in range(1,len(l)):
if digits(l[i])[:2] != digits(l[i-1])[2:]:
return False
return True
p = 0
i = 0
p3 = []
while p < 10000:
p = i*(i+1)/2
if p >= 1000 and p < 10000:
p3.append(int(p))
i += 1
p = 0
i = 0
p4 = []
while p < 10000:
p = i**2
if p >= 1000 and p < 10000:
p4.append(p)
i += 1
p = 0
i = 0
p5 = []
while p < 10000:
p = i*(3*i-1)/2
if p >= 1000 and p < 10000:
p5.append(int(p))
i += 1
p = 0
i = 0
p6 = []
while p < 10000:
p = i*(2*i-1)
if p >= 1000 and p < 10000:
p6.append(int(p))
i += 1
p = 0
i = 0
p7 = []
while p < 10000:
p = i*(5*i-3)/2
if p >= 1000 and p < 10000:
p7.append(int(p))
i += 1
p = 0
i = 0
p8 = []
while p < 10000:
p = i*(3*i-2)
if p >= 1000 and p < 10000:
p8.append(int(p))
i += 1
for i3 in p3:
for i4 in p4:
for i5 in p5:
for i6 in p6:
l = [i3,i4,i5,i6]
ends = set([])
starts = set([])
for i in l:
ends.add("".join(digits(i)[2:]))
starts.add("".join(digits(i)[:2]))
if len(starts & ends) > 0:
for i7 in p7:
l = [i3,i4,i5,i6,i7]
ends = set([])
starts = set([])
for i in l:
ends.add("".join(digits(i)[2:]))
starts.add("".join(digits(i)[:2]))
if len(starts & ends) > 3:
for i8 in p8:
l = [i3,i4,i5,i6,i7,i8]
ends = set([])
starts = set([])
for i in l:
ends.add("".join(digits(i)[2:]))
starts.add("".join(digits(i)[:2]))
if ends == starts:
print(ends, starts, l)