Created
December 19, 2017 00:23
-
-
Save apple1417/61faf60f7a8ca5d06f272ab442ca79bd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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