I re-used and extended the parser combinators I wrote for day 2 (see, that investment is paying off already!) but I'm not entirely happy with my solution. My instinct was Parse don't validate but with AoC you never know what's coming in part 2. The bit about cheating the system in the initial description made me think the second part might have to deal with the invalid records in some way. So I kept the PasswordData as a simple HashMap for maximum flexibility. Now I know the full requirements I might come back later and implement a proper parse-don't-validate approach.
I'm guessing this is rust? I'm impressed by your structure! It's clear to understand the code and nice that you have tests! Hopefully I'll learn to add more tests as well some day 🙏 haha
I re-used and extended the parser combinators I wrote for day 2 (see, that investment is paying off already!) but I'm not entirely happy with my solution. My instinct was Parse don't validate but with AoC you never know what's coming in part 2. The bit about cheating the system in the initial description made me think the second part might have to deal with the invalid records in some way. So I kept the
PasswordData
as a simpleHashMap
for maximum flexibility. Now I know the full requirements I might come back later and implement a proper parse-don't-validate approach.I'm guessing this is rust? I'm impressed by your structure! It's clear to understand the code and nice that you have tests! Hopefully I'll learn to add more tests as well some day 🙏 haha
Thanks. Yes, it's Rust. I like to approach these problems as if I was producing production code. That's the only type worth practicing, right? :-)