diff --git a/config.json b/config.json index af84e4d..e1db125 100644 --- a/config.json +++ b/config.json @@ -753,7 +753,7 @@ }, { "slug": "pythagorean-triplets", - "name": "pythagorean-triplets", + "name": "Pythagorean Triplet", "uuid": "630a11f5-e640-4e4d-af01-30f3bbcf495c", "practices": [], "prerequisites": [], diff --git a/exercises/practice/pythagorean-triplets/.docs/instructions.md b/exercises/practice/pythagorean-triplets/.docs/instructions.md index e69de29..ced833d 100644 --- a/exercises/practice/pythagorean-triplets/.docs/instructions.md +++ b/exercises/practice/pythagorean-triplets/.docs/instructions.md @@ -0,0 +1,23 @@ +# Description + +A Pythagorean triplet is a set of three natural numbers, {a, b, c}, for which, + +```text +a² + b² = c² +``` + +and such that, + +```text +a < b < c +``` + +For example, + +```text +3² + 4² = 5². +``` + +Given an input integer N, find all Pythagorean triplets for which `a + b + c = N`. + +For example, with N = 1000, there is exactly one Pythagorean triplet for which `a + b + c = 1000`: `{200, 375, 425}`. diff --git a/exercises/practice/pythagorean-triplets/.docs/introduction.md b/exercises/practice/pythagorean-triplets/.docs/introduction.md new file mode 100644 index 0000000..3453c6e --- /dev/null +++ b/exercises/practice/pythagorean-triplets/.docs/introduction.md @@ -0,0 +1,19 @@ +# Introduction + +You are an accomplished problem-solver, known for your ability to tackle the most challenging mathematical puzzles. +One evening, you receive an urgent letter from an inventor called the Triangle Tinkerer, who is working on a groundbreaking new project. +The letter reads: + +> Dear Mathematician, +> +> I need your help. +> I am designing a device that relies on the unique properties of Pythagorean triplets — sets of three integers that satisfy the equation a² + b² = c². +> This device will revolutionize navigation, but for it to work, I must program it with every possible triplet where the sum of a, b, and c equals a specific number, N. +> Calculating these triplets by hand would take me years, but I hear you are more than up to the task. +> +> Time is of the essence. +> The future of my invention — and perhaps even the future of mathematical innovation — rests on your ability to solve this problem. + +Motivated by the importance of the task, you set out to find all Pythagorean triplets that satisfy the condition. +Your work could have far-reaching implications, unlocking new possibilities in science and engineering. +Can you rise to the challenge and make history? diff --git a/exercises/practice/pythagorean-triplets/.meta/config.json b/exercises/practice/pythagorean-triplets/.meta/config.json index bfe2a02..76fb6c8 100644 --- a/exercises/practice/pythagorean-triplets/.meta/config.json +++ b/exercises/practice/pythagorean-triplets/.meta/config.json @@ -1,5 +1,8 @@ { "authors": ["blakelewis"], + "contributors": [ + "SimaDovakin" + ], "files": { "solution": [ "pythagorean-triplets.rkt" @@ -11,5 +14,7 @@ ".meta/example.rkt" ] }, - "blurb": "Find Pythagorean triplets with a given sum" + "blurb": "Given an integer N, find all Pythagorean triplets for which a + b + c = N.", + "source": "A variation of Problem 9 from Project Euler", + "source_url": "https://projecteuler.net/problem=9" } diff --git a/exercises/practice/pythagorean-triplets/.meta/tests.toml b/exercises/practice/pythagorean-triplets/.meta/tests.toml new file mode 100644 index 0000000..719620a --- /dev/null +++ b/exercises/practice/pythagorean-triplets/.meta/tests.toml @@ -0,0 +1,31 @@ +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. + +[a19de65d-35b8-4480-b1af-371d9541e706] +description = "triplets whose sum is 12" + +[48b21332-0a3d-43b2-9a52-90b2a6e5c9f5] +description = "triplets whose sum is 108" + +[dffc1266-418e-4daa-81af-54c3e95c3bb5] +description = "triplets whose sum is 1000" + +[5f86a2d4-6383-4cce-93a5-e4489e79b186] +description = "no matching triplets for 1001" + +[bf17ba80-1596-409a-bb13-343bdb3b2904] +description = "returns all matching triplets" + +[9d8fb5d5-6c6f-42df-9f95-d3165963ac57] +description = "several matching triplets" + +[f5be5734-8aa0-4bd1-99a2-02adcc4402b4] +description = "triplets for large number"