6 ms·
Same here. I would've really like if the spec specifically mentioned the possibility of that one edge case ahead of time instead of having to sift through the 1
by jjice 3y ago
Same here. I would've really like if the spec specifically mentioned the possibility of that one edge case ahead of time instead of having to sift through the 1000 lines of input.
No hate on AOC though, I really respect all the hard work that goes into it.
- frantathefranta 3y agoYeah I was sort of lucky that my edge case was on the last line, still took a full hour of wondering why my solution was wrong though.
- wjholden 3y agoWhat was this edge case you encountered? My code worked...after I finally read the problem closely enough.
- shever73 3y agoFor me it was a lack of specific instructions on how to handle overlaps. The edge case that frustrated me for a while was "oneight" at the end of a line. My initial code made it look like this "1ight", when it should have been "18".
- WJW 3y agoWhen searching for the last number in the line I just reversed the line and scanned through it looking for the reversed strings for the number: one -> eno two -> owt three -> eerht etc It makes the entire solution extremely simple, though a little verbose.
- nucleardog 3y agoYeah I was a little confused about all the people saying they've already given up on day 1. Seems like everyone's just really overcomplicating this. Why is everyone jumping to "replace the word strings with the digits" instead of just doing exactly what the problem says and... finding the first and last occurrence? 1. Build a list of values with corresponding string matches: [ 0 => ['zero', '0'], 1 => ['one', '1'], ...] 2. Loop through that and find the index of each within the input string, maintaining the lowest seen index + associated value. 3. When done, return value. To find the last occurrence... just reverse the input string and all the search strings. I'm not even sure it's all that verbose. If you exclude the part where I hardcoded an array of ten digits, it was... 11 lines of code, a third of which are closing braces. I'm sure I could cut it in half if I used some builtins for mapping/reducing/etc.
- skydhash 3y ago> I'm not even sure it's all that verbose Mine is. But that's because I don't bother DRYing it and making it more clever (yanking and pasting is faster than thinking)
- skydhash 3y agoSame here. I'm using regex and I was wondering how to make it go backwards. After a moment of thought, that seems silly, so I just reversed the string and the regex and do the scan.
- cjauvin 3y agoI find some problems of AoC are sometimes on the thin line between "it's interesting and I might learn something new" vs "wasting my time with under-specified or ambiguous problem specs".. Part 2 of Day 1 lies dangerously in the latter, for me.
- shever73 3y ago> No hate on AOC though, I really respect all the hard work that goes into it. 100% with you on this. Last year was the first year I'd had time to complete it, and I always love the challenge.
- AdamH12113 3y agoUnless the question has been edited recently, it did. There are multiple lines in the second example input that show the overlap: > eightwothree > 4nineeightseven2 > zoneight234 I test my AoC solutions incrementally by printing output, so I found that I was failing to produce the correct list of numbers in a line right away. I suppose if you're taking a faster approach and just trying to extract the first and last numbers that it's easier to miss. It's always a good idea to look at the example input, though.
- tymscar 3y agoYes, same. I keep seeing people say this on discord and reddit, but that edge case was shown twice in the example.
- agoose77 3y agoIt shows an overlap, but it doesn't indicate how one should parse it.
- criddell 3y agoIt showed "eightwothree" to be 83. Or is that not what you are talking about?
- jacksontheel 3y agoIf it had shown "eightwo" as the last part of a string, then people with overlap would fail the example because they'd be finding "eight" where "two" would be correct. Having it at the beginning means it was overlooked, at least for me. Though, I have no problem with the "spec". This a code puzzle game, so figuring that out was part of the fun, in my opinion
- philomath_mn 3y agoSo are you saying that overlapped characters can be used for both numbers? Meaning: - eightwothree -> 823 (answer 83) - 4nineeightseven2 -> 49872 (answer 42) - zoneight234 -> z18234 (answer 14) I interpreted the instructions as saying to take the first match from the left and not count the overlaps. Unfortunately this gives the same answer as the overlap interpretation on the examples given in the problem statement: all the overlaps occurred in the middle where they didn't matter. If they had shown oneight -> answer: 18 then I would have understood the spec.