I quite often get the correct solution with very messy code, then tidy up. A few days later I may refactor multiple solutions together to tidy up further.
It would be nice to store the 'correct' answer in the #[aoc(day1,part1)] line, or maybe a 2nd annotation, which then gets assert_eq!ed in the surrounding code.
That way, once I know the correct answer, I could store it in code and be sure my solutions are all still correct.
Of course I could manually put in the asserts, but that might be verbose?
Alternatively, if there were a version of assert_eq! which returned one of its arguments, that could be quite succinct...
(also, this solution wouldn't work great for the 'graphical' problems where the answer is letters made from a grid of # and space characters)
I quite often get the correct solution with very messy code, then tidy up. A few days later I may refactor multiple solutions together to tidy up further.
It would be nice to store the 'correct' answer in the
#[aoc(day1,part1)]
line, or maybe a 2nd annotation, which then getsassert_eq!
ed in the surrounding code.That way, once I know the correct answer, I could store it in code and be sure my solutions are all still correct.
Of course I could manually put in the asserts, but that might be verbose?
Alternatively, if there were a version of
assert_eq!
which returned one of its arguments, that could be quite succinct...(also, this solution wouldn't work great for the 'graphical' problems where the answer is letters made from a grid of # and space characters)