-
Notifications
You must be signed in to change notification settings - Fork 0
/
Trinity153.py
84 lines (69 loc) · 2.04 KB
/
Trinity153.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
import turtle
import math
drawing = turtle.Turtle()
drawing.speed(10000)
pwr = 3
def CubicAllDigits(n):
r = 0
for i in str(n):
# print("i=", i, "^3=", Cubic(int(i)))
r += int(i)**pwr
return (r)
def MultipleOf3P(n):
if n % pwr == 0.0:
return True
return False
def drawingColor(n):
if n==7:return "LightGray"
if n==8: return "Gray"
if (n==9): return "LightYellow"
if (n==10): return "Yellow"
if (n == 11): return "Green"
if (n == 12): return "Blue"
if (n == 13): return "Orange"
if (n == 14): return "Red"
if (n == 15): return "Purple"
return "LightBlue"
def main(s1, s2, max_steps):
maxSteps = 0
#angle = 365.0/(s2-s1)
angle=3
drawing.color('red', 'yellow')
drawing.begin_fill()
i1 = int(s1)
i2 = int(s2)
for i in range(i1, i2 + 1):
steps = 1
if (MultipleOf3P(i)):
j = CubicAllDigits(i)
print()
print(i)
print("Steps 1 =>", j)
while j != 153:
steps = steps + 1
j = CubicAllDigits(j)
print("Steps", steps, "=>", j)
drawing.down()
drawing.setposition(0, 0)
drawing.forward(steps * 30)
drawing.color(drawingColor(steps))
drawing.right(angle)
drawing.up()
if steps > maxSteps:
maxSteps = steps
maxStepsNum = i
if (maxSteps >= max_steps):
return print("maxStepsNum", maxStepsNum, "maxSteps", maxSteps)
print("maxStepsNum", maxStepsNum, "maxSteps", maxSteps)
# todo visualize the array up to 100 million, to see if any steps are over 15
# already tested to 10M and not found. Question: can this be proved mathematically?
main(str(1),
str(100),16)
'''Very large numbers
main(str(9999**1000),
str(9999**1000)+"100",16)
'''
print("End")
'''The smallest number to reach 153 in 16 cycles will be more than
1061042524005486968, so not advisable to try it.
'''