回答編集履歴
1
追記
test
CHANGED
@@ -41,3 +41,45 @@
|
|
41
41
|
|
42
42
|
|
43
43
|
(menuの定義に注意してください)
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
----
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
色々とやり方はあると思いますが一例として。
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
```python
|
56
|
+
|
57
|
+
import random
|
58
|
+
|
59
|
+
from collections import Counter
|
60
|
+
|
61
|
+
from itertools import chain
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
K = ['にんじん','たまねぎ','じゃがいも','肉']
|
66
|
+
|
67
|
+
R = ['肉','メンマ']
|
68
|
+
|
69
|
+
H = ['肉','にんじん']
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
menu = {'K': K, 'R': R, 'H': H}
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
kondate = random.sample(menu.keys(), 2)
|
78
|
+
|
79
|
+
material = Counter(chain.from_iterable(menu[k] for k in kondate))
|
80
|
+
|
81
|
+
print(kondate)
|
82
|
+
|
83
|
+
print(material)
|
84
|
+
|
85
|
+
```
|