-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogik.py
50 lines (38 loc) · 901 Bytes
/
logik.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
import random
POZIC = 5
BAREV = 8
zadani = []
for i in range(POZIC):
zadani.append(random.randint(0, BAREV - 1))
print(zadani)
krok = 0
hotovo = False
while not hotovo:
tip_retezec = input("Dodej tip: ")
tip = []
for d in tip_retezec:
tip.append(int(d))
if len(tip) != POZIC:
print("spatne")
continue
krok += 1
cerny = 0
for i in range(POZIC):
if tip[i] == zadani[i]:
cerny += 1
bily = 0
for i in range(BAREV):
v_tipu = 0
v_zadani = 0
for j in range(POZIC):
if tip[j] == zadani[j]:
continue
if tip[j] == i:
v_tipu += 1
if zadani[j] == i:
v_zadani += 1
bily += min(v_tipu, v_zadani)
print(cerny, bily)
if cerny == POZIC:
hotovo = True
print("Splněno po ", krok, "krocích")