My solution to the Prolog Pythagorean Triples exercise initially failed. After some exploration I discovered 2 unexpected aspects to the tests:
- The tests are not merely testing the set of triples returned but also the specific ordering in which they are generated. This order does not seem germane to the problem.
- The triples are expected to be returned in an odd format. Rather than normal Prolog list syntax [A, B, C], the tests expect this syntax (A, B, C). I’m not even sure what this is in Prolog?
?- display((1, 2, 3)).
','(1,','(2,3))
It appears that only 6 other people (including the exercise’s author) have published solutions, so not that many people have encountered these issues.
I just looked at the same exercise in the Common Lisp and Java tracks. Those tests expect specific orders of results too, so Prolog is not any worse.