Skip to content

Latest commit

 

History

History

RJPlog

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Day 18: Operation Order

This solution is written in Kotlin.

The original puzzle can be found at https://adventofcode.com/2020/day/18

$ kotlin day2018_1_2.kts

First Star

How does it work:

All lines of the puzzle input are read into a list. For each entry in that list the results are calculated by stripping down to parts with don’t contain brackets any more. For these parts the result is calculated. In the original equation the calculated part of the equation is replaced with the result and with this equation the procedure is repeated, until there are no brackets any more. For all list entrys the results are summed up as the result of part 1

link:day2018_1_2.kts[role=include]

Second Star

How does it work:

This works the same way as part1, only the rules for calculation are changed, therefore the algorithm sligtly changed

link:day2018_1_2.kts[role=include]

Finally, print out the solution for both puzzles:

link:day2018_1_2.kts[role=include]