-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNCPC_E.py
52 lines (35 loc) · 1.12 KB
/
NCPC_E.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
import time
start_time = time.time()
def rotate(l, n):
return l[n:] + l[:n]
def pick_player(navneliste, rhyme_len, n):
indeks = (rhyme_len - 1)% n
spiller_i = navneliste[indeks]
navneliste.remove(navneliste[indeks])
rest = navneliste
if len(navneliste) > 1:
rest = rotate(navneliste, indeks % len(navneliste))
return spiller_i, rest
#print(rotate(['Kalle','Lisa','Rakel'],3-1))
#print(rotate(['Kalle','Rakel'],2-1))
def opgave_e(input):
lines = input.split('\n')
word_count = len(lines[0].split())
n = int(lines[1])
navne = lines[2:]
hold_1 = []
hold_2 = []
turn = 0
for i in reversed(range(n)):
spiller_i, navne = pick_player(navne, word_count, i + 1)
if turn == 0:
hold_1.append(spiller_i)
turn = 1
else:
hold_2.append(spiller_i)
turn = 0
return hold_1, hold_2
print(opgave_e('eeny meeny miny\n4\nKalle\nLisa\nAlvar\nRakel'))
print(opgave_e('every other \n3\nA\nB\nC'))
print("--- %s seconds ---" % (time.time() - start_time))
#print(pick_player(['Kalle','Lisa','Alvar','Rakel'],5,4))