1- #!/usr/bin/python2 -sS
1+ #!/usr/bin/python3 -sS
22
3- from __future__ import print_function
43
54import io
65import sys
@@ -20,44 +19,44 @@ correct = True
2019
2120# Speak the to program a few times, check what it does, and output the last
2221# line.
23- for i in range (10 , 20 ) + [0 ]:
22+ for i in list ( range (10 , 20 ) ) + [0 ]:
2423 x = i + input_value
2524 # Write a question to the candidate executable.
26- fifo_to_user1 .write ("%d\n " % x )
25+ fifo_to_user1 .write (b "%d\n " % x )
2726 # Read their response.
2827 l = fifo_from_user1 .readline ()
2928 # EOF?
30- if l == '' :
29+ if l == b '' :
3130 correct = False
3231 break
3332 # These are the only things we expect from our stub.
34- if l .strip () != 'correct %d' % x :
33+ if l .strip () != b 'correct %d' % x :
3534 correct = False
3635 break
3736
3837 correct = correct and (int (l .split ()[1 ]) == x )
3938
4039 # Write a question to the candidate executable.
41- fifo_to_user2 .write ("%d\n " % x )
40+ fifo_to_user2 .write (b "%d\n " % x )
4241 # Read their response.
4342 l = fifo_from_user2 .readline ()
4443 # EOF?
45- if l == '' :
44+ if l == b '' :
4645 correct = False
4746 break
4847 # These are the only things we expect from our stub.
49- if l .strip () != 'correct %d' % (- x ):
48+ if l .strip () != b 'correct %d' % (- x ):
5049 correct = False
5150 break
5251
5352 correct = correct and (int (l .split ()[1 ]) == - x )
5453else :
5554 # Tell stub to exit.
56- fifo_to_user1 .write ("0\n " )
57- fifo_to_user2 .write ("0\n " )
55+ fifo_to_user1 .write (b "0\n " )
56+ fifo_to_user2 .write (b "0\n " )
5857
5958# This file exists just for convenience.
60- io .open ("output.txt" , "wb" ).write (l + "\n " )
59+ io .open ("output.txt" , "wb" ).write (l + b "\n " )
6160
6261# This is the final score.
6362if correct :
0 commit comments