gobanos/cargo-aoc

Getting the part2 result as a by-product of solving part1

joncol opened this issue · 2 comments

Does someone have a good suggestion on how to organize the code when your solution of part1 also yields the answer to part2? Would I use a global to store the part2 result, and then just return that in the part2 function? Or is there a cleaner way to do it?

Your part1 function is a standard function, you should be able to call it from part2

I was just thinking of a nice way to store the result, so I don't have to do the same calculations twice. Maybe there's some nice memoization crate I could use.