Skip to content

Instantly share code, notes, and snippets.

@jameskyle
Created March 14, 2016 01:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jameskyle/6a8047a3945f561fd15b to your computer and use it in GitHub Desktop.
Save jameskyle/6a8047a3945f561fd15b to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import json
problem = None
fights = None
def mapit(st):
st = st.replace("T", "True").replace("F", "False").replace("{", "[")
st = st.replace("}", "]")
return st
with open("problem.txt") as probfile:
problem = probfile.read().strip()
problem = eval(mapit(problem))
with open("outcomes.txt") as outcomesfile:
fights = outcomesfile.read()
fights = eval(mapit(fights))
result = {
'atEstablishment': problem,
'fightOccurred': fights,
}
with open("output.json", "w") as json_file:
json_file.write(json.dumps(result, indent=4, sort_keys=True))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment