-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFoldingCube.py
More file actions
77 lines (61 loc) · 1.7 KB
/
FoldingCube.py
File metadata and controls
77 lines (61 loc) · 1.7 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
# Watkins, jmw4dx
components = []
for i in range(6):
components.append([c for c in input().strip()])
# print("old")
# for row in components:
# print("".join(row))
def getR(row):
return components[row]
def getC(column):
c = []
for row in components:
c.append(row[column])
return c
def get(row, column):
return components[row][column]
def chainRow(row):
top = 0
currTop = 0
for i in range(6):
if components[row][i] == "#":
currTop += 1
else:
top = max(top, currTop)
currTop = 0
return max(top, currTop)
def chainColumn(column):
top = 0
currTop = 0
for i in range(6):
if components[i][column] == "#":
currTop += 1
else:
top = max(top, currTop)
currTop = 0
return max(top, currTop)
while (getR(0) == ['.', '.', '.', '.', '.', '.']):
components.pop(0)
components.append(['.', '.', '.', '.', '.', '.'])
while (getC(0) == ['.', '.', '.', '.', '.', '.']):
for row in components:
row.pop(0)
row.append('.')
print("new")
for i in range(6):
print("".join(getR(i)), chainRow(i))
print("".join([str(chainColumn(i)) for i in range(6)]))
longR = [chainRow(i) for i in range(6)]
longC = [chainColumn(i) for i in range(6)]
answer = False
for nums in [longR, longC]:
if nums[0:3] in [[2,3,1], [1,3,2], [1,4,1], [3,3,0]]:
answer = True
for nums1, nums2 in [[longR, longC], [longC, longR]]:
if nums1[0:3] == [2,2,2] and nums2[0:4] == [1,2,2,1]:
answer = True
options = {
False: "cannot fold",
True: "can fold"
}
print(options[answer])