r/adventofcode • u/daggerdragon • Dec 04 '19
SOLUTION MEGATHREAD -🎄- 2019 Day 4 Solutions -🎄-
--- Day 4: Secure Container ---
Post your solution using /u/topaz2078's paste or other external repo.
- Please do NOT post your full code (unless it is very short)
- If you do, use old.reddit's four-spaces formatting, NOT new.reddit's triple backticks formatting.
(Full posting rules are HERE if you need a refresher).
Reminder: Top-level posts in Solution Megathreads are for solutions only. If you have questions, please post your own thread and make sure to flair it with Help.
Advent of Code's Poems for Programmers
Note: If you submit a poem, please add [POEM] somewhere nearby to make it easier for us moderators to ensure that we include your poem for voting consideration.
Day 3's winner #1: "untitled poem" by /u/glenbolake!
To take care of yesterday's fires
You must analyze these two wires.
Where they first are aligned
Is the thing you must find.
I hope you remembered your pliers
Enjoy your Reddit Silver, and good luck with the rest of the Advent of Code!
View all comments
Show parent comment
1
u/PendragonDaGreat Dec 04 '19 edited Dec 04 '19
Actually both of those examples you gave are ok.
What the second part is saying is that there is a section of the password that if you were to count all the groups matching digits as substrings there is at least one group of length 2.
133344splits into1, 333, 44<- 44 is exactly length two, therefore this is a valid password,133444splits into1, 33, 444<- 33 is exactly length two, therefore this password is also valid.an example of an invalid password might be
123444which splits into1, 2, 3, 444there is no substring of exactly length two.111222splits into111, 222again, no substring exactly length twoMy counting method worked because the digits where guaranteed to be monotonically increasing which means that all digits of the same value must have been next to each other.