adventofcode/2022/day03/day03_algo.txt
2022-12-03 14:29:51 -05:00

18 lines
No EOL
713 B
Text

Build a function to return the priority int value of the input char, must be case sensitive - do this in a separate class file since it'll probably be needed in P2
Main:
Declare string bagContents
Declare int prioritySum
Open input.txt
Start outer loop, continue while file has more contents
Read line into bagContents
Start middle FOR loop, iterator i, continue until either iterator is bagContents length / 2 OR find a char match
Start inner FOR loop, iterator j, continue until either is bagContents length OR find a char match
Compare bagContents[i] and bagContents[j]
If match, prioritySum += LookupFunctionValue
End inner loop
End middle loop
End outer loop
Print prioritySum to screen