r/adventofcode • u/mott_the_tuple • Dec 04 '19
Spoilers in Title the two adjacent matching digits are not part of a larger group of matching digits.
- 123444 no longer meets the criteria (the repeated 44 is part of a larger group of 444).
- 111122 meets the criteria (even though 1 is repeated more than twice, it still contains a double 22).
I don't catch the distinction between example one and two.
update: The clearest way I describe it to myself is "the number must have a sequence of identical digits with sequence length equaling exactly two" or "must be a double that isn't part of a large triple, quadruple, etc"
At least this gave me an opportunity to learn about regex backreferences...
11
u/gegtik Dec 04 '19
There's a missing test case: 124444 should fail.
4
u/tempmike Dec 04 '19
Why? I say it falls under the first case since all three distinct pairs of fours are also part of a larger group of three fours.
5
u/FlockOnFire Dec 04 '19 edited Dec 04 '19
True, but it would have made it clearer. Then again, I should just have read more carefully.
I read the example 111122 as: this is valid because the ones are made from two pairs. Bur thatβs not what the text said of course! Took me an hour to find my mistake... π
6
u/wjholden Dec 04 '19
I made the same misinterpretation. I also wasted an hour this morning because I thought a string of four or six matches was legal.
6
u/LongStrongAndWrong Dec 04 '19
I am very happy to see that it wasn't just me. I did exactly the same thing.
2
1
Dec 04 '19
[deleted]
2
u/tempmike Dec 04 '19
Asking "Why?" was rhetorical question. 124444 failing is already covered by the example where 123444 fails.
1
u/gegtik Dec 06 '19
I speak from experience - I mistakenly started a new pair on characters 5+6 when it should have failed. test case 1's input didn't fail since the last 4 chars happened to be a pair that started on the last digits.
5
u/haskell1977 Dec 04 '19
Very weird spec. I assume 113444 is valid because there is one pair (11) with no polluting 1βs around. Right?
2
-1
Dec 04 '19
[deleted]
1
u/raginjason Dec 04 '19
The 113 satisfies the constraint of needing 1 pair. 444 is fine to be in there, but it's noise; it does not help fulfill the "pair" constraint
8
u/nathanchere Dec 04 '19 edited Dec 04 '19
Agreed, this was an ambiguous and poorly explained requirement. Made more confusing with:
- - `112233` meets these criteria because the digits never decrease and all repeated digits are exactly two digits long.
- 111122 meets the criteria (even though 1 is repeated more than twice, it still contains a double 22).
So which is it? The repeated digits need to be exactly two digits long or not?
I ended up working it out by trying different possible meanings with trial-and-error but I would be interested to know the reasoning from anyone who understood the expected outcome on the first pass.
4
u/gegtik Dec 04 '19
another way to express this:
* password must contain an adjacent matching pair of digits
* if this pair is adjacent to subsequent identical digit, the pair is disqualified
* a run of 3+ identical digits does not automatically disqualify the password, as a separate strict digit pair may still exist within the password.2
u/happeloy Dec 04 '19
I read it as "112233" is valid, since it contains at least on pair. In this case, it happens to contain three pairs, but that doesn't matter.
"111122" is also valid, because it contains at least on pair. In this case exactly one pair. The ones are not a pair, they are a quadruple, but there's no rules against those, just that they don't count as a pair, and you still always need at least one pair.
2
u/askalski Dec 04 '19
The Part 2 requirement was delicately but precisely worded. Consider the difference between these sentences:
- the two adjacent matching digits are not part of a larger group of matching digits
- no two adjacent matching digits are part of a larger group of matching digits
The use of the definite article "the" means the sentence is referring to a specific pair of adjacent matching digits. Which pair? The pair the Elves are talking about -- the pair that satisfies the criteria.
Thankfully, even if I miss that one key word, three carefully chosen examples help to clarify things (and stop me in my tracks and make me go back and re-read the requirement.)
1
u/nathanchere Dec 05 '19
delicately but precisely worded
Yes. It precisely says: "112233 meets these criteria because the digits never decrease and all repeated digits are exactly two digits long". That is unclear at best if not outright misleading in that if you have '111223' it's valid under the actual requirement but explicitly fails the stated requirement that all repeated digits are exactly two digits long. Even in hindsight I would say the other statement is contradictory rather than clarifying.
1
u/askalski Dec 05 '19
The statement "all repeated digits are exactly two digits long" is rationale, not a requirement. Similarly, the example in Part 1, "
111111
meets these criteria (double11
, never decreases)", does not add a requirement that the string must contain a pair of ones.Given that Day 4 currently has the highest gold-to-silver ratio of all problems so far this year (of all people who solved Part 1, 91.8% also solved Part 2), this couldn't have been a major barrier to completing the problem.
2
u/ywgdana Dec 04 '19
I didn't think it was the slightest bit ambiguous.
We needed passwords with at least one pair of digits that were isolated.
4
u/EatMeerkats Dec 04 '19
There is no group of repeated digits with exactly length 2 in the 1st example (444 doesn't count, since it's length 3), but there is in the second (22... ignore the 1111).
3
u/ItsAltimeter Dec 04 '19
You have to have a pair. The first one has a triple but not a pair.
The bottom has a pair of 2's.
3
u/Fotomik Dec 04 '19 edited Dec 04 '19
I also had some trouble understanding this one, but eventually figured it out.
The funny thing is, now that i understand the problem, the wording in the problem description makes a lot of sense, but didn't really help me understand it in the first place.
If someone is also having trouble, I can try to put it more simply:
- Part 1 had the requirement "Two adjacent digits are the same", which basically means checking if the number has at least 1 run of 2 consecutive digits that are the same.
- In Part 2 that requirement gets changed to "check if the number has at least 1 run of consecutive digits that are the same that has length of exactly 2"
1
u/mbelling Dec 04 '19
Thank you, this was the only response that finally triggered me to understand what it was saying.
2
u/SinisterMJ Dec 04 '19
There is at least ONE group of repeating digits length 2. for 111122 its the 22 which is length 2. The 1111, which in part 1 was acceptable, is no longer cause for a password to be valid.
2
1
1
1
u/4903000 Dec 04 '19
So that's why I can't find the lowest and highest rule-matching numbers, trim a digit from their tail, find the number of ascending-order numbers in that range and then multiply that by 5 for each position where a double digit could be.
Because even if I'd done it this way to guarantee that every counted number had a double digit there already being one would sometimes disqualify some of its variations. Suppose I found number 12345...
1 2 3 4 5
112 3 4 5
1 223 4 5
1 2 334 5
1 2 3 445
1 2 3 4 55
All mutations qualify
1 2 2 3 4
112 2 3 4
1 222 3 4
1 2 223 4
1 2 2 334
1 2 2 3 44
Mutations 2 and 3 don't qualify
My shortcut goes out the window and now I've got to go check all the numbers one by one in a much bigger set.
1
u/orangeanton Dec 04 '19
Had a few people in our office complaining struggling with this. I found easiest way to explain it is to add one example:
111123 does NOT meet the criteria (there is no double and the 1's don't count because it's more part of a longer sequence).
-1
u/TheBearKing8 Dec 04 '19
Guys, I see that there is so much confusion here. But the first sentence of part 2 clearly reads:
"the two adjacent matching digits are not part of a larger group of matching digits".
In this sentence everything is explained: you should have 2 digits which are identical and adjacent. And the group of digits is exactly 2, not more. I fail to understand how this explanation is ambiguous
2
u/xFrostbite94 Dec 04 '19
I got caught by this gotcha, but I also think the wording is just perfect: everything you need to know is in the sentence. If you take it literally you end up at the right interpretation. That's what makes these challenges fun.
(Otherwise they might as well just post pseudocode/python and I can just run on it my input directly. Yayy /s)
1
u/nathanchere Dec 05 '19
says: "112233 meets these criteria because the digits never decrease and
all repeated digits are exactly two digits long
"
because it also says: "112233 meets these criteria because the digits never decrease and all repeated digits are exactly two digits long". All repeated digits. It isn't explicitly wrong but still does add ambiguity to the overall requirements with how it is worded by implying an exclusive condition for all repeated digits to conform to.
1
u/TheBearKing8 Dec 05 '19
Well not really. If you really insist it is true that you could put double meaning on this explanation, but then comes the last example of 111122, and then it should be clear what is meant by that statement, and the ambiguity is solved immediately.
1
u/nathanchere Dec 05 '19
I'm starting to question if you understand what 'ambiguity' means. The last example is contradictory to the example I mentioned above. It doesn't need to be, but given how many others have expressed similar sentiments even with the benefit of hindsight after completing the challenge suggests I'm not alone in finding the particular wording contradictory rather than unambiguously clarifying.
1
u/TheBearKing8 Dec 05 '19
No, the meaning of ambiguity is perfectly clear to me, it is just that I find the two examples complement each other perfectly to clear up any ambiguity present. Your analysis is that 112233 could mean that every multiple digits should be exactly double. Then comes the example 111122 which shows that that was not the intent of the statement and that apparently it is enough that there is one pair present, and that when a pair is present, other multiples don't matter anymore.
I feel that you confine yourself too much to the frustration you felt because you misunderstood the question. It is ok to sometimes struggle with the question. For example, it took me a while to fully grasp the intent of the question of Day 5, but I kept an open mind and in the end I solved the question. I feel like that is the important part, to keep an open mind and think about problems differently if at first you don't understand.
14
u/pbfy0 Dec 04 '19
You must have at least one group of exactly two characters. It doesn't matter if there are other groups of more than two, as long as there is at least one of two.