Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Google Code Jam 2004 QR Problem 1
import sys
# Problem: https://code.google.com/codejam/contest/2974486/dashboard#s=p0
# Reference: http://codereview.stackexchange.com/a/154360/73051
def main():
submit = False
filename = "A-small-practice"
if submit:
sys.stdout = open(filename + ".out", "w")
msg = ["Bad magician!", set()] + ["Volunteer cheated!"] * 3
lines = [i[:-1] for i in open(filename + ".in")]
for i in range(int(lines[0])):
offset = (i * 10) + 1
a = set(lines[offset + 0 + int(lines[offset + 0])].split(" "))
b = set(lines[offset + 5 + int(lines[offset + 5])].split(" "))
msg[1] = a.intersection(b)
if len(msg[1]) == 1:
msg[1] = msg[1].pop()
print("Case #" + str(i + 1) + ": " + str(msg[len(msg[1])]))
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment