Skip to content

Instantly share code, notes, and snippets.

@codeeval
Created October 3, 2011 02:13
Show Gist options
  • Save codeeval/1258294 to your computer and use it in GitHub Desktop.
Save codeeval/1258294 to your computer and use it in GitHub Desktop.
Sample code to read in test cases
# On CodeEval, test cases are read in from a file which is the first argument to your program
# Open the file and read in line by line. Each line represents a different test case
# (unless given different instructions in the challenge description)
import sys
test_cases = open(sys.argv[1], 'r')
for test in test_cases:
# ignore test if it is an empty line
# 'test' represents the test case, do something with it
# ...
# ...
test_cases.close()
@savcha-v
Copy link

Please show me an example for python3, if you need to pass a parameter to the function, how do I issue the code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment