Browse the beatiful github pages here.
How to parse the input files for the Advent of Code 2022 coding challenge.
If can't parse the input file, you can't solve the problem.
This repository provides general guidelines to parse the input files in Python. It starts with very simple files, almost trivial, but continue up to input files that need a complex parsing strategy.
- Basic of reading files on Python
- Eliminate new line character (“\n”)
- Divide input files (puzzle days) into categories:
-
Usually I mean to parse as to get the data from a file into anPython object that is easy to either iterate, analyse or transform thus facilitating solving the problem.
-
Different people may think different approaches to represent the data. For instance, a particular data can be store in a list of lists, or into a dictionary. There could be more parsing strategies that I’m not seeing.
-
Also, I'm not considering getting the data into objects from custom classes.