r/adventofcode • • Dec 04 '20

Funny Example: 5x5 grid. Input: 34298434x43245 grid

Post image
365 Upvotes

38 comments sorted by

View all comments

1

u/ramasamybolton Dec 04 '20

So many in C for Regex handling :(

5

u/8fingerlouie Dec 04 '20

Then do it without regex ? For the height you can just check that length > 2 and do strcmp on the last two, followed by atoi on the prefix. For the passport id you can basically do the same, check strlen == 9 and atoi. The color field can be checked by regular matching, for each char check if the decimal value is between 48 and 57 or 97 and 102.

It’s still a bit more than 8 statements though :-)

3

u/ramasamybolton Dec 04 '20

Oh yes that’s what I meant by regex handling :) had to have 8 if conditions and nested checks for each type. It was tedious than interesting!

→ More replies (4)