-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMagic.py
More file actions
24 lines (23 loc) · 722 Bytes
/
Magic.py
File metadata and controls
24 lines (23 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
f = open("file.txt")
for i in range(int(f.readline())):
a1 = int(f.readline())
set1 = []
for line in range(4):
set1.append([int(x) for x in f.readline().split(" ")])
selectedRow1 = set1[a1-1]
a2 = int(f.readline())
set2 = []
for line in range(4):
set2.append([int(x) for x in f.readline().split(" ")])
selectedRow2 = set2[a2-1]
cards = []
for card in selectedRow1:
if (card in selectedRow2): cards.append(card)
a = open("out.txt", 'a')
ans = ""
if (len(cards) == 0) : ans = "Volunteer cheated!"
elif(len(cards) > 1) : ans = "Bad magician!"
else: ans = cards[0]
a.write("Case #%i: %s" %(i+1, str(ans) + "\n"))
a.close()
f.close()