id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

peter@norvig.com numbers > pythag
prev  |  next  |  chance

A Pythagorean triplet is a set of three numbers [a, b, c], that could represent the length of the sides of a right triangle, so that a**2 + b**2 == c**2. We will agree to always write the triplets with a <= b <= c, and we will only consider positive integer-lengthed sides. Write the function pythag(p) which finds a Pythagorean triplet with perimeter p (the perimeter is a+b+c) or returns False if there is no such triplet.


pythag(11) → False
pythag(12) → [3, 4, 5]
pythag(13) → False

...Save, Compile, Run (ctrl-enter)

def pythag(p):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Difficulty: 250 Post-solution available

Copyright Nick Parlante 2017 - privacy