This is the Day 2 puzzle from Advent of Code. I realize I'm quite late, but I've started working on the puzzles. I would appreciate it if someone could confirm whether my solution is correct (I was able to solve the puzzle and obtain the right answers, but I still want to make sure I did things the correct way).
Part 1:
Since the young Elf was just doing silly patterns, you can find the invalid IDs by looking for any ID which is made only of some sequence of digits repeated twice. So, 55 (5 twice), 6464 (64 twice), and 123123 (123 twice) would all be invalid IDs.
Part 2:
Now, an ID is invalid if it is made only of some sequence of digits repeated at least twice. So, 12341234 (1234 two times), 123123123 (123 three times), 1212121212 (12 five times), and 1111111 (1 seven times) are all invalid IDs.
What both want:
part 1 : What do you get if you add up all of the invalid IDs?
part 2 : What do you get if you add up all of the invalid IDs using these new rules?