Utopia Playing Cards |
But half the time the results were wrong, so obviously the program is doing something wrong, but without looking inside it's very hard to tell just what the problem is. I thought I would be clever and write a second, independent method, of solving the problem, and then programmatically compare the results after each step and so narrow down the location of the bug.
Had more problems getting the second method working. To debug this second method I added a several statements to post intermediate results. The first few attempts produced no useful information, so I added more. The last one produced a clue, which pointed to the bug in the original solution. It was such a gross and obvious error that it's a wonder the program ran, much less passed any tests. Programming is sometimes very weird.
No comments:
Post a Comment