Created
April 13, 2012 10:49
-
-
Save takluyver/2375802 to your computer and use it in GitHub Desktop.
Google Codejam: IPython notebook template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "GCJ Template" | |
}, | |
"nbformat": 3, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"collapsed": true, | |
"input": [ | |
"def readline_ints():", | |
" return [int(num) for num in fin.readline().strip().split()]" | |
], | |
"language": "python", | |
"outputs": [], | |
"prompt_number": 1 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"# Update this with the filename", | |
"fname = \"A-sample\"", | |
"with open(fname+\".in\",\"r\") as fin, open(fname+\".out\",\"w\") as fout:", | |
"", | |
" numcases = readline_ints()[0]", | |
" print(numcases, \"cases\")", | |
" ", | |
" for caseno in range(1, numcases+1):", | |
" # Code goes here", | |
" ", | |
" outstr = \"Case #%d: %s\" % (caseno, result)", | |
" fout.write(outstr + \"\\n\")", | |
" print(outstr)" | |
], | |
"language": "python", | |
"outputs": [], | |
"prompt_number": 2 | |
} | |
] | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# <nbformat>3</nbformat> | |
# <codecell> | |
def readline_ints(): | |
return [int(num) for num in fin.readline().strip().split()] | |
# <codecell> | |
# Update this with the filename | |
fname = "A-sample" | |
with open(fname+".in","r") as fin, open(fname+".out","w") as fout: | |
numcases = readline_ints()[0] | |
print(numcases, "cases") | |
for caseno in range(1, numcases+1): | |
# Code goes here | |
outstr = "Case #%d: %s" % (caseno, result) | |
fout.write(outstr + "\n") | |
print(outstr) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment