Puzzling tests for Pythagorean Triplets

My solution to the Prolog Pythagorean Triples exercise initially failed. After some exploration I discovered 2 unexpected aspects to the tests:

  1. 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.
  2. 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.

I think modifying the tests to ignore the ordering makes the most sense.

It should be a compound term, but I agree that it is confusing and that we should just use lists.

Would you be up for a PR t fix these issues?

Sure. Thanks for your feedback.

1 Like