-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshapes_1010.py
executable file
·195 lines (173 loc) · 4.27 KB
/
shapes_1010.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
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
class Shape:
#A shape has a set of 2 tuples that indicate
#where the other blocks in that shape are on the grid, relative to
#the (0,0) rootblock (top left corner of that shape's area
def __init__(self):
self.blocks = []
self.namestring = ""
def append(self, point):
self.blocks.append(point)
def __str__(self):
return self.namestring
def __repr__(self):
return self.__str__()
def multistr(self):
min_row = min(self.blocks, key = lambda x: x[0])[0]
max_row = max(self.blocks, key = lambda x: x[0])[0]
min_col = min(self.blocks, key = lambda x: x[1])[1]
max_col = max(self.blocks, key = lambda x: x[1])[1]
row_mod = 2 - ((min_row + max_row) // 2)
col_mod = 2 - ((min_col + max_col) // 2)
returnlist = []
for x in range(5):
returnlist.append([" "]*5)
for block in self.blocks:
row = block[0] + row_mod
col = block[1] + col_mod
returnlist[row][col] = "#"
for x in range(len(returnlist)):
returnlist[x] = "".join(returnlist[x])
return returnlist
def print_round(shapes):
printlist = [" "]*5
for shape in shapes:
multi = shape.multistr()
for row in range(len(multi)):
printlist[row] = printlist[row] + multi[row] + " "
for line in printlist:
print(line)
return
tall_5 = Shape()
tall_5.append((0,0))
tall_5.append((1,0))
tall_5.append((2,0))
tall_5.append((3,0))
tall_5.append((4,0))
tall_5.namestring="Tall 5"
wide_5 = Shape()
wide_5.append((0,0))
wide_5.append((0,1))
wide_5.append((0,2))
wide_5.append((0,3))
wide_5.append((0,4))
wide_5.namestring="Wide 5"
tall_4 = Shape()
tall_4.append((0,0))
tall_4.append((1,0))
tall_4.append((2,0))
tall_4.append((3,0))
tall_4.namestring="Tall 4"
wide_4 = Shape()
wide_4.append((0,0))
wide_4.append((0,1))
wide_4.append((0,2))
wide_4.append((0,3))
wide_4.namestring="Wide 4"
tall_3 = Shape()
tall_3.append((0,0))
tall_3.append((1,0))
tall_3.append((2,0))
tall_3.namestring="Tall 3"
wide_3 = Shape()
wide_3.append((0,0))
wide_3.append((0,1))
wide_3.append((0,2))
wide_3.namestring="Wide 3"
tall_2 = Shape()
tall_2.append((0,0))
tall_2.append((1,0))
tall_2.namestring="Tall 2"
wide_2 = Shape()
wide_2.append((0,0))
wide_2.append((0,1))
wide_2.namestring="Wide 2"
square1 = Shape()
square1.append((0,0))
square1.namestring="1x1 Square"
square2 = Shape()
square2.append((0,0))
square2.append((0,1))
square2.append((1,0))
square2.append((1,1))
square2.namestring="2x2 Square"
square3 = Shape()
square3.append((0,0))
square3.append((0,1))
square3.append((1,0))
square3.append((1,1))
square3.append((0,2))
square3.append((1,2))
square3.append((2,2))
square3.append((2,1))
square3.append((2,0))
square3.namestring="3x3 Square"
L_UL_2 = Shape()
L_UL_2.append((0,0))
L_UL_2.append((0,1))
L_UL_2.append((1,0))
L_UL_2.namestring="2x2 L (UL Corner)"
L_DL_2 = Shape()
L_DL_2.append((0,0))
L_DL_2.append((1,1))
L_DL_2.append((1,0))
L_DL_2.namestring="2x2 L (DL Corner)"
L_UR_2 = Shape()
L_UR_2.append((0,0))
L_UR_2.append((1,1))
L_UR_2.append((0,1))
L_UR_2.namestring="2x2 L (UR Corner)"
L_DR_2 = Shape()
L_DR_2.append((0,0))
L_DR_2.append((0,1))
L_DR_2.append((-1,1))
L_DR_2.namestring="2x2 L (DR Corner)"
L_UL_3 = Shape()
L_UL_3.append((0,0))
L_UL_3.append((0,1))
L_UL_3.append((0,2))
L_UL_3.append((1,0))
L_UL_3.append((2,0))
L_UL_3.namestring="3x3 L (UL Corner)"
L_DL_3 = Shape()
L_DL_3.append((0,0))
L_DL_3.append((2,1))
L_DL_3.append((2,2))
L_DL_3.append((1,0))
L_DL_3.append((2,0))
L_DL_3.namestring="3x3 L (DL Corner)"
L_UR_3 = Shape()
L_UR_3.append((0,0))
L_UR_3.append((0,1))
L_UR_3.append((0,2))
L_UR_3.append((1,2))
L_UR_3.append((2,2))
L_UR_3.namestring="3x3 L (UR Corner)"
L_DR_3 = Shape()
L_DR_3.append((0,0))
L_DR_3.append((0,1))
L_DR_3.append((0,2))
L_DR_3.append((-1,2))
L_DR_3.append((-2,2))
L_DR_3.namestring="3x3 L (DR Corner)"
SHAPES = [
tall_5,
wide_5,
tall_4,
wide_4,
tall_3,
wide_3,
tall_2,
wide_2,
square1,
square2,
square3,
L_UL_2,
L_DL_2,
L_UR_2,
L_DR_2,
L_UL_3,
L_DL_3,
L_UR_3,
L_DR_3]
if __name__ == "__main__":
print_round(tall_5, wide_5, square3, L_DR_3)