質問編集履歴
3
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -110,8 +110,150 @@
|
|
110
110
|
|
111
111
|
|
112
112
|
|
113
|
+
### 追記
|
114
|
+
|
113
|
-
|
115
|
+
can110さんのコードを使って下のように変更しました。
|
116
|
+
|
114
|
-
|
117
|
+
```Python
|
118
|
+
|
115
|
-
|
119
|
+
import random
|
120
|
+
|
121
|
+
|
122
|
+
|
116
|
-
|
123
|
+
seat_1 = [2,3,4,5,6,7,8,12,13,15,19,22,30,31]
|
124
|
+
|
125
|
+
seat_2 = [2,3,4,5,6,7,8,13,15,16,19,20,22,25,26,30,31,36]
|
126
|
+
|
127
|
+
seat_3 = [2,4,6,7,8,14,15,16,20,25,26,30,33,36,37]
|
128
|
+
|
129
|
+
seat_4 = [1,2,4,6,7,8,14,15,16,17,20,23,25,26,28,30,33,36,37]
|
130
|
+
|
131
|
+
seat_5 = [1,2,4,6,7,8,14,16,17,20,23,25,26,28,30,33,36,37]
|
132
|
+
|
133
|
+
seat_6 = [29]
|
134
|
+
|
135
|
+
seat_7 = [2,3,6,7,8,10,15,16,19,22,25,30,31,36]
|
136
|
+
|
137
|
+
seat_8 = [2,6,7,8,10,14,15,16,25,30,33,36,37]
|
138
|
+
|
139
|
+
seat_9 = [1,2,6,7,8,10,14,15,16,17,23,25,28,30,33,36,37]
|
140
|
+
|
141
|
+
seat_10 = [1,2,6,7,8,14,16,17,23,25,28,30,32,33,36,37]
|
142
|
+
|
143
|
+
seat_11 = [1,2,4,6,7,8,14,16,17,18,23,28,30,32,33,34,37]
|
144
|
+
|
145
|
+
seat_12 = [5,6,7,8,12,13,22,30,31]
|
146
|
+
|
147
|
+
seat_13 = [5,6,7,8,13,22,30,31]
|
148
|
+
|
149
|
+
seat_14 = [6,7,8,10,16,22,30,31]
|
150
|
+
|
151
|
+
seat_15 = [6,7,8,10,14,16,21,30,33,37]
|
152
|
+
|
153
|
+
seat_16 = [1,6,7,8,10,14,16,17,21,23,28,30,33,37]
|
154
|
+
|
155
|
+
seat_17 = [1,6,7,8,14,16,17,21,23,28,30,33,37]
|
156
|
+
|
157
|
+
seat_18 = [1,4,6,7,8,14,16,17,18,23,28,30,32,33,34,37]
|
158
|
+
|
159
|
+
seat_19 = [5,6,7,8,12,13,22,30]
|
160
|
+
|
161
|
+
seat_20 = [5,6,7,8,13,22,24,30]
|
162
|
+
|
163
|
+
seat_21 = [6,7,8,10,16,22,24,30]
|
164
|
+
|
165
|
+
seat_22 = [6,7,8,10,14,16,21,30,33,37]
|
166
|
+
|
167
|
+
seat_23 = [1,6,7,8,10,14,16,17,21,23,28,30,33,37]
|
168
|
+
|
169
|
+
seat_24 = [1,6,7,8,14,16,17,21,23,28,30,33,37]
|
170
|
+
|
171
|
+
seat_25 = [1,4,6,7,8,14,16,17,18,23,28,30,32,33,34,37]
|
172
|
+
|
173
|
+
seat_26 = [5,6,7,8,12,13,22,30]
|
174
|
+
|
175
|
+
seat_27 = [5,6,7,8,13,22,24,30]
|
176
|
+
|
177
|
+
seat_28 = [6,7,8,10,16,22,24,30]
|
178
|
+
|
179
|
+
seat_29 = [6,7,8,10,14,16,24,30,33,37]
|
180
|
+
|
181
|
+
seat_30 = [1,6,7,8,10,14,16,17,23,28,30,33,37]
|
182
|
+
|
183
|
+
seat_31 = [1,6,7,8,14,16,17,23,28,30,33,37]
|
184
|
+
|
185
|
+
seat_32 = [1,4,6,7,8,14,16,17,18,23,28,30,32,33,34,37]
|
186
|
+
|
187
|
+
seat_33 = [4,5,6,7,8,13,22,24,27,30]
|
188
|
+
|
189
|
+
seat_34 = [27]
|
190
|
+
|
191
|
+
seat_35 = [11]
|
192
|
+
|
193
|
+
seat_36 = [9]
|
194
|
+
|
195
|
+
seat_37 = [35]
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
seats = [seat_1,seat_2,seat_3,seat_4,seat_5,
|
202
|
+
|
203
|
+
seat_6,seat_7,seat_8,seat_9,seat_10,
|
204
|
+
|
205
|
+
seat_11,seat_12,seat_13,seat_14,seat_15,
|
206
|
+
|
207
|
+
seat_16,seat_17,seat_18,seat_19,seat_20,
|
208
|
+
|
209
|
+
seat_21,seat_22,seat_23,seat_24,seat_25,
|
210
|
+
|
211
|
+
seat_26,seat_27,seat_28,seat_29,seat_30,
|
212
|
+
|
213
|
+
seat_31,seat_32,seat_33,seat_34,seat_35,
|
214
|
+
|
215
|
+
seat_36,seat_37]
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
# (席番号, 候補リスト)に整形
|
220
|
+
|
221
|
+
seats = [(i+1,v) for i,v in enumerate(seats)]
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
ret = []
|
226
|
+
|
227
|
+
while seats:
|
228
|
+
|
229
|
+
# 候補の少ない席から抽選する
|
230
|
+
|
231
|
+
i = seats.index(min(seats, key=lambda v:len(v[1])))
|
232
|
+
|
233
|
+
seat = seats.pop(i) # popによって今から抽選する席番号は取り除かれる
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
# 抽選
|
238
|
+
|
239
|
+
person = random.choice(seat[1]) # 当選した人番号
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
# 結果を保存
|
244
|
+
|
245
|
+
ret.append((seat[0], person)) # (席番号, 人番号)
|
246
|
+
|
247
|
+
|
248
|
+
|
117
|
-
|
249
|
+
# 各席から当選した人を取り除く
|
250
|
+
|
251
|
+
seats = [ (seat[0], [p for p in seat[1] if p != person]) for seat in seats]
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
ret.sort(key=lambda v:v[0]) # 結果を席番号順に
|
256
|
+
|
257
|
+
print(ret)
|
258
|
+
|
259
|
+
```
|
2
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,11 +16,7 @@
|
|
16
16
|
|
17
17
|
実行してみると表示されたリストに普通に重複が含まれており、何回実行しても重複のないリストが得られません。
|
18
18
|
|
19
|
-
```
|
20
19
|
|
21
|
-
エラーメッセージ
|
22
|
-
|
23
|
-
```
|
24
20
|
|
25
21
|
|
26
22
|
|
1
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -34,7 +34,7 @@
|
|
34
34
|
|
35
35
|
|
36
36
|
|
37
|
-
seat_1 = [2,4,5,6]
|
37
|
+
seat_1 = [1,2,4,5,6]
|
38
38
|
|
39
39
|
seat_2 = [1,2,3,4,5,6]
|
40
40
|
|
@@ -74,9 +74,9 @@
|
|
74
74
|
|
75
75
|
return result
|
76
76
|
|
77
|
-
|
78
77
|
|
79
|
-
|
78
|
+
|
79
|
+
|
80
80
|
|
81
81
|
#重複がない場合にTrue になる関数を定義
|
82
82
|
|