Skip to content

Instantly share code, notes, and snippets.

@gnyman
Created December 9, 2022 07:07
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 gnyman/a5e7fd0831e6390b4ab7b6e28bcbd165 to your computer and use it in GitHub Desktop.
Save gnyman/a5e7fd0831e6390b4ab7b6e28bcbd165 to your computer and use it in GitHub Desktop.
Given a 2d array of integers between 0-9. Check the path from each of the integers toward any edge of the array. Only straight paths needs to be considered, up, down, right, left. Count how many of the integers have lower integers on the path towards any edge.
Then multiply the count in each direction together up*down*left*right and assign store that count as a score for that integer.
Integers on the edge will always have a score of zero.
The input will be in this format and should be read from a file called sample.txt
30373
25512
65332
33549
35390
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment