Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Google Codejam: IPython notebook template

View gcj_template.ipynb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
{
"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
}
]
}
]
}
View gcj_template.ipynb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
# -*- 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
Something went wrong with that request. Please try again.