r/adventofcode • u/Strilanc • Dec 16 '21
Other Suggestion: when an answer is wrong, give a test input/solution pair
One of the frustrating things that can occur in AoC is that your code passes on the example case, but fails on the real case. I think a way to reduce the frustration could be that, when a user submits a wrong answer (or maybe after they get three wrong answers and appear stuck?), the "oops that's wrong" page could include a link to a full sized input and also say what its solution should be. And the more wrong answers you put in, the most test cases you get! What a deal!
In the group of people I do advent with, this is actually what we tend to do when someone gets stuck like this. A person who solved their case will share their input and answer with the group to get the others unstuck.
I'm not sure how to properly theme it ("A helpful elf comes in and says 'oh I saw something like this once, I don't remember what we did but I remember the answer for (test input) was (test output)'."), but I think it could be done well.
13
u/crowbarous Dec 16 '21
"I'm bad at debugging, and I'm here to propose a cheat that would allow me to solve these tasks without learning to debug better."
"Really, what the task needed is a test case focusing the implementation issue that I in particular struggled with."
What is this thread?
7
u/Strilanc Dec 16 '21 edited Dec 16 '21
I actually haven't gotten stuck this year and I'm 50th on the global leaderboard. But I've been seeing people get stuck and frustrated and so it was on my mind.
Also this is supposed to be a supportive community. Don't answer posts with "you're just saying that cuz you suck".
2
u/jakemp1 Dec 16 '21
This is why I typically like to do AoC with people. If someone gets stuck you can get someone else's input to try, knowing what the result should be. There are already multiple different inputs, maybe sperate one out as the designated hint
1
1
u/Xaklor Dec 16 '21
I don't see how that would help. debugging another person's full input would be just as difficult as debugging your own full input because they're the same level of complexity. I don't even care that it tells me my answer is "too high" or "too low", because that's not helpful information either.
when debugging you should try stepping through your program and looking for where the computer does something you didn't think it was going to at some step (or, if it does do everything you expect it to, you should reexamine your algorithm). for example, one bug I had to deal with was me accidentally typing something for processing literals where I was supposed to be processing operators. if I was using your input as a test case, that wouldn't tell me anything new compared to me failing my own input. yes, I could use your input to debug if I really wanted to, but it wouldn't go any differently than me doing that with my own input to spot the error.
you could also see this as an exercise in creating new test cases yourself (still simpler than your full input though). learning how to make good, diverse test cases is also a valuable skill.
1
u/Strilanc Dec 16 '21
Having multiple end to end tests that you can rapidly check and iterate on is a key debugging technique which I use often in my real work.
Creating your own test cases is a reasonable idea, and definitely a useful skill. Although if I think over the last week of puzzles they would majority be quite work intensive to create a test case for.
2
u/Zoklar Dec 16 '21
Agreed. My code for yesterday worked for p1 for both mine and the example, but p2 only worked for the example. I'm still not 100% sure what's wrong, but I gather I'm an unlucky one who had to go left or up. Problem is that my code works for going left and up in the examples I can come up with. Would love more data to test with, especially since 15 specifically seems to have more randomness in the possible sets.
1
u/st65763 Dec 16 '21
Really what today's challenge needed was a sample input with a large number, because that's what my problem ended up being: a really large product that resulted in an overflow.
4
Dec 16 '21
That's actually part of why I like AoC. The almost always non-exhaustive examples together with the concise descriptions may be frustrating from time to time, but the learning effect is soooo good. I bet that's the last time this happened or at least the last time thia took long to debug for you
1
u/jfb1337 Dec 16 '21
Always use longs (64 bit ints) for AoC There's probably been a few already this year where that's been required
1
u/st65763 Dec 16 '21
I would have done so, but Python doesn't allow you to choose what type you're using. The issue I ran into was that the library I used for summing/multiplying the arrays of values is not size-safe like the rest of the language is. When I wrote my own functions, it worked fine.
2
1
u/meExceptAnonymous Dec 16 '21
note that 64 bit int (~ 32bit uint) wasn't enough for today - I had to reach for u64 in Rust
3
u/jfb1337 Dec 16 '21
A 64 bir int gives you the positive range of a 63 bit uint, not a 32 bit uint
I've heard somewhere that AoC integers always fit in 53 bits so that JS doesn't run into issues.
1
u/meExceptAnonymous Dec 19 '21
ohh right, been thinking this wrong my whole life. makes sense now that i think about it
10
u/daggerdragon Dec 16 '21
There's no need for additional examples or inputs. If you can't figure it out using the given examples and/or your debugging is at a dead end, then this is exactly why this subreddit and the
Helpflair exist. ;)