pythagorean-triplet: Add missing constraints to description#1365
pythagorean-triplet: Add missing constraints to description#1365coriolinus merged 1 commit intoexercism:masterfrom
Conversation
Added missing constraint to the Pythagorean triplet problem that is outlined in the linked Project Euler problem.
coriolinus
left a comment
There was a problem hiding this comment.
Looks good! Thanks for contributing this, @TheBestJohn!
I have performed ad-hoc examination of canonical-data.json which shows that all triplets in the canonical data correctly conform to this rule, so no updates should be required there:
Thu Oct 11 18:57:57 DST 2018
Python 3.7.0 (default, Aug 6 2018, 20:07:46)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>> with open('canonical-data.json') as cd:
... data = json.load(cd)
...
>>> triplets = []
>>> for case in data['cases']:
... triplets.extend(case['expected'])
...
>>> for (a, b, c) in triplets:
... if a >= b or b >= c:
... print(f"malformed: ({a}, {b}, {c})")
...
>>>|
I now plan to wait until Monday the 15th. This is to give other maintainers the chance to look at this and make comments and request changes if desired. If there are no objections, I plan to merge this on that date. I do not object if another maintainer wants to merge this before then. |
rpottsoh
left a comment
There was a problem hiding this comment.
Thanks for taking the time to improve this exercise @TheBestJohn. Also, thanks @coriolinus for the thorough review and look into the canonical data. 👍
petertseng
left a comment
There was a problem hiding this comment.
It is interesting because for the problem as currently stated in the description, finding the product a * b * c, there is no need to impose an ordering between these three. However, for the problem posed in the canonical data, the ordering does matter. (the fact that the description and canonical data are not in agreement is noted in #1211 currently)
So, since we will eventually want this a < b < c, there's no problem with having it now.
Ah yes I should have stated that I looked into the data and found no conflicts when submitting the pull request. also @rpottsoh no problem :) I just figured that it would definitely affect the performance of generated answers. Every result I bruteforce where As @petertseng says |
Added missing constraint to the Pythagorean triplet problem that is outlined in the linked Project Euler problem.