Tracks
/
Elixir
Elixir
/
Exercises
/
Pythagorean Triplet
Pythagorean Triplet

Pythagorean Triplet

Medium

Instructions

A Pythagorean triplet is a set of three natural numbers, {a, b, c}, for which,

a² + b² = c²

and such that,

a < b < c

For example,

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}.

Slow tests

One or several of the tests of this exercise have been tagged as :slow, because they might take a long time to finish. For this reason, they will not be run on the platform by the automated test runner. If you are solving this exercise directly on the platform in the web editor, you might want to consider downloading this exercise to your machine instead. This will allow you to run all the tests and check the efficiency of your solution.

Edit via GitHub The link opens in a new window or tab
Elixir Exercism

Ready to start Pythagorean Triplet?

Sign up to Exercism to learn and master Elixir with 57 concepts, 158 exercises, and real human mentoring, all for free.