The proposed solution has been developed and tested with Python version 3.11.4.
The solution traverse_city_py requires a correctly formatted input. For convenience a generation script has been provided.
Run the generate_city_x.py script and provide city size N as an input argument e.g.
python generate_city_x.py 300
This will create a text file in the correct format named cityX.txt
Run the traverse_city_x.py script with the cityX.txt located in the same directory.
Example format is visible below. For completeness' sake, a text file (cityX.txt) has also been provided with the correct line break character.
5
1 1 9 1 1
3 1 9 7 1
4 1 9 1 1
5 1 1 1 5
6 1 9 3 1