Generating edge cases in programming puzzles

3

Not exactly sure if it belongs in this site, but I always have trouble thinking of all the certain edge cases in any kind of competitive programming or puzzles.

For example, take this kind of problem

Find the size of the smallest list of squares that add up to n

f(16)-> 1 (16)
f(17)-> 2 (16+1)

One intuitive approach would be to take the largest square that fits into n, subtract, and taking the remainder and applying the function on that until n<4. This doesn't work as soon as you go to

f(18)-> 2 (9+9) rather than f(18)-> 3 (16+1+1)

While those edge cases may be easier to derive, many times edge cases will not be as intuitive. What are some general guidelines of finding such edge cases?

bleh

Posted 2019-06-06T21:38:46.917

Reputation: 161

Question was closed 2019-06-07T00:02:32.600

1This is not a programming challenge, but a question about programming challenges, so it should go on meta, I think. – Grimmy – 2019-06-06T23:15:03.980

3@Grimy Personally I'd disagree, since meta is for questions about this site, not about questions about programming challenges. The [tag:tips] tag is a good example of that kind of post being on topic here. However, I think this is irreparably broad as it is. If this were about a specific type of challenge or something, it might fit. Of course, for single challenges we have the sandbox to help with things like this. – FryAmTheEggman – 2019-06-06T23:21:34.883

2I too think this might be better suited to Meta as it is about programming challenges; specifically how to think of edge cases. Unfortunately, I do also think it's too broad as there is no "catch-all" answer; edge cases are, in general, specific to each challenge. – Shaggy – 2019-06-06T23:43:21.500

No answers