The version I initially wrote sorted the numbers and worked largest first. It made little difference on the sample so I posted a simplified version.
Sure, but I wrote that particular pathological case specifically for the version of the algorithm you posted.
I know your algorithm would work (and be much quicker than most) for all of the example inputs within AoC but, as I've said before, I'm talking about people choosing to use AoC to learn how to solve the general case and not just get the two stars each day before moving on.
If you provided an algorithm that worked largest case first I can provide a different pathological case that will attempt to maximise runtime for that version of the algorithm.
For most problems this back and forth can be repeated again and again until the program tends to be an implementation of the optimal algorithm.
You should try the
https://onlinejudge.org/ coding puzzles. The difference between AoC and those is that with the OnlineJudge ones you don't get to see the final input your program is tested against, you submit your code (in whatever language you want) for that one. The examples that are given are all quite simplistic and the input your program is actually tested on is specifically crafted to stretch the designs of most programs to the limit. It's much harder when anything less than an optimal solution just comes back with "Time exceeded, execution aborted" each time.