-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLOOK AND SAY.py
More file actions
159 lines (155 loc) · 2.92 KB
/
Copy pathLOOK AND SAY.py
File metadata and controls
159 lines (155 loc) · 2.92 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
def lookandsay(number):
result = ""
repeat = number[0]
number = number[1:] + " "
times = 1
for actual in number:
if actual != repeat:
result += str(times) + repeat
times = 1
repeat = actual
else:
times += 1
return result
table= []
ettable = [1112,
1112133,
111213322112,
111213322113,
1113,
11131,
111311222112,
111312,
11131221,
1113122112,
1113122113,
11131221131112,
111312211312,
11131221131211,
111312211312113211,
111312211312113221133211322112211213322112,
111312211312113221133211322112211213322113,
11131221131211322113322112,
11131221133112,
1113122113322113111221131221,
11131221222112,
111312212221121123222112,
111312212221121123222113,
11132,
1113222,
1113222112,
1113222113,
11133112,
12,
123222112,
123222113,
12322211331222113112211,
13,
131112,
13112221133211322112211213322112,
13112221133211322112211213322113,
13122112,
132,
13211,
132112,
1321122112,
132112211213322112,
132112211213322113,
132113,
1321131112,
13211312,
1321132,
13211321,
132113212221,
13211321222113222112,
1321132122211322212221121123222112,
1321132122211322212221121123222113,
13211322211312113211,
1321133112,
1322112,
1322113,
13221133112,
1322113312211,
132211331222113112211,
13221133122211332,
22,
3,
3112,
3112112,
31121123222112,
31121123222113,
3112221,
3113,
311311,
31131112,
3113112211,
3113112211322112,
3113112211322112211213322112,
3113112211322112211213322113,
311311222,
311311222112,
311311222113,
3113112221131112,
311311222113111221,
311311222113111221131221,
31131122211311122113222,
3113112221133112,
311312,
31132,
311322113212221,
311332,
3113322112,
3113322113,
312,
312211322212221121123222113,
312211322212221121123222112,
32112]
mas1 = [i for i in range(1,100)]
print('Введите число')
num = input("")
a = True
b = False
a1 = 0
b1 = 0
num1 = num
num2 = num
num3 = num
num4 = num
modul = ''
modul1 = ''
sliv = ''
print('Введите кол-во чисел в последовательти')
g = int(input()) + 1
for i in range(g):
num1 = lookandsay(num1)
for m in range(len(num1) + 1):
mas1[i] = len(num1)
num2 = num1[0:m + 1]
if len(num2) == len(num1):
break
num4 = num1
num3 = num1[m + 1:len(num1)]
modul = num2
modul1 = num3
for w in range(1,3):
num2 = lookandsay(num2)
num3 = lookandsay(num3)
for w in range(1,3):
num4 = lookandsay(num4)
sliv = num2 + num3
if sliv == num4:
print(a, modul, ':', modul1)
a1 += 1
if modul in ettable:
if modul not in table:
table.append(modul)
if modul1 in ettable:
if modul1 not in table:
table.append(modul1)
else:
print(b, modul, ':', modul1)
b1 += 1
print('true =', a1)
print('false =', b1)
print('b/a', b1 / a1)
print(table)