Skip to content

Instantly share code, notes, and snippets.

@apple1417
Created December 19, 2017 00:23
Show Gist options
  • Save apple1417/61faf60f7a8ca5d06f272ab442ca79bd to your computer and use it in GitHub Desktop.
Save apple1417/61faf60f7a8ca5d06f272ab442ca79bd to your computer and use it in GitHub Desktop.
import xml.etree.ElementTree as xml
hints = {}
for tetro in xml.parse("TetrominoInstances.xml").getroot().iter("TetrominoInstanceData"):
world = tetro.find("Level").text
puzzle = tetro.find("PuzzleTitle").text
hint = tetro.find("PuzzleHint").text
if not puzzle or not hint:
continue
puzzle = puzzle.split("=")[-1][:-1]
hint = hint.split("=")[-1][:-1]
if world not in hints:
hints[world] = {}
hints[world][puzzle] = hint
# with open("output.txt", "w") as f:
# for world in sorted(hints.keys()):
# f.write(world + ":\n")
# for tetro in hints[world]:
# f.write("{}: {}\n".format(tetro, hints[world][tetro]))
# f.write("\n")
with open("tetros.txt", "w") as f:
for world in sorted(hints.keys()):
f.write(world + "\n")
for tetro in sorted(hints[world].keys()):
f.write(tetro + "\n")
with open("hints.txt", "w") as f:
for world in sorted(hints.keys()):
f.write("\n")
for tetro in sorted(hints[world].keys()):
f.write(hints[world][tetro] + "\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment