-
Notifications
You must be signed in to change notification settings - Fork 1
/
pizza.py
63 lines (50 loc) · 1.54 KB
/
pizza.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
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Python version, author: Stian Husemoen
import random, pprint, calendar, time, sys, math
meal = 0.4
persons = int(sys.argv[1])
prize_max = 1200
prize_cheap = 119
# menyen med vekttall
menu = [("Pappas spesial", 4, 159),
("Texas", 3, 149),
("Blue Hawai", 7, 149),
("Floriad", 4, 149),
("Buffalo", 4, 149),
("Chicken", 4, 149),
("New York", 0, 149),
("Las Vegas", 6, 149),
("Vegetarianer", 0, 149),
("FILADELFIA", 4, 149),
("Hot Chicago", 7, 149),
("Hot Express", 5, 149),
("Kebab pizza spesial", 3, 169),
("Egenkomponert, Pepperoni, Biff, Bacon, Skinke, løk", 9, 159),
("Egenkomponert, Biff, Pepperoni, Bacon, Skinke, Tacokjøtt",
9, 159),
]
# et buffer vi kan velge fra
buf = []
# på onsdager er det billig
if calendar.weekday(*time.localtime()[:3]) == 2:
for pizza in menu: buf += ([(pizza[0], prize_cheap)] * pizza[1])
else:
for pizza in menu: buf += ([(pizza[0], pizza[2])] * pizza[1])
prize_sum = 0
pizzas = {}
sum = 0
for i in range(int(math.ceil(persons * meal))):
# trekk neste pizza
next = buf.pop(random.randrange(len(buf)))
if prize_sum + next[1] >= prize_max:
break
else:
if pizzas.has_key(next):
pizzas[next] += 1
else:
pizzas[next] = 1
sum += 1
prize_sum += next[1]
pprint.pprint(pizzas)
print "sum:", prize_sum