Hi I'm new to programming so sorry if i seem very inexperienced.
When I ran my magic trick program I wasn't able to get the correct answer for
every case. Can anyone help me find the problem in my program? I can't seem to
find what's wrong
s_input = open("/home/pi/Desktop/Code Jam Practice/Code Jam 2014/Magic
Trick/A-small-practice.in", "r")
s_output = open("/home/pi/Desktop/Code Jam Practice/Code Jam 2014/Magic
Trick/A-small-practice.out", "w")
case_total = int(s_input.readline())
case_number = 1
#Test Case while case > 0
def test_case():
global case_total
global case_number
first_guess = int(s_input.readline().replace("\n", ""))
grid_1 = []
#Make grid 1
for i in range(0,4):
row = grid_1.append(s_input.readline().replace("\n", "").split(" "))
second_guess = int(s_input.readline().replace("\n", ""))
grid_2 = []
#Make grid 2
for i in range(0,4):
row = grid_2.append(s_input.readline().replace("\n", "").split(" "))
num_count = 0
for i in grid_1[first_guess - 1]:
if i in grid_2[second_guess - 1]:
num_count += 1
#Check Answer
if num_count > 1:
answer = "Bad magician!"
elif num_count == 1:
answer = i
elif num_count == 0:
answer = "Volunteer cheated!"
#Return Answer
s_output.write("Case #%s: %s\n" % (case_number, answer))
case_total -= 1
case_number += 1
print answer
#run
while case_total > 0:
test_case()
s_input.close()
s_output.close()
--
You received this message because you are subscribed to the Google Groups
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-code/0caee8c6-18f8-4d63-9c53-b65fc2d35316%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.