Hacker News new | past | comments | ask | show | jobs | submit login

I ended up using parser combinator library nom. It's not something I use daily, therefore parsing became a puzzle on its own.

Nom already has a parser for numbers. However, I didn't find an elegant way to take at most one digit. In the end I used take_while_m_n, and mapped it with u64::from_str().

Another challenge was absence of something such as find_all, that would repeatedly try to parse beginning from each character and then return all matches. I ended up writing my own combinator.

https://github.com/drola/AdventOfCode2023/blob/main/src/bin/...




Nice! I also ended up using nom, it was quite fun.

https://github.com/woile/adventofcode/blob/main/2023/day1/sr...


Wow thanks, I was stuck with the iterating part and your solution really helped me :)




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: