Files
freecodecamp--freecodecamp/curriculum/challenges/english/blocks/daily-coding-challenges-python/6939b873185d8e00d453563e.md
T
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

1.8 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
6939b873185d8e00d453563e Challenge 159: Integer Hypotenuse 29 challenge-159

--description--

Given two positive integers representing the lengths for the two legs (the two short sides) of a right triangle, determine whether the hypotenuse is an integer.

The length of the hypotenuse is calculated by adding the squares of the two leg lengths together and then taking the square root of that total (a2 + b2 = c2).

--hints--

is_integer_hypotenuse(3, 4) should return True.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_integer_hypotenuse(3, 4), True)`)
}})

is_integer_hypotenuse(2, 3) should return False.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_integer_hypotenuse(2, 3), False)`)
}})

is_integer_hypotenuse(5, 12) should return True.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_integer_hypotenuse(5, 12), True)`)
}})

is_integer_hypotenuse(10, 10) should return False.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_integer_hypotenuse(10, 10), False)`)
}})

is_integer_hypotenuse(780, 1040) should return True.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_integer_hypotenuse(780, 1040), True)`)
}})

is_integer_hypotenuse(250, 333) should return False.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_integer_hypotenuse(250, 333), False)`)
}})

--seed--

--seed-contents--

def is_integer_hypotenuse(a, b):

    return a

--solutions--

import math
def is_integer_hypotenuse(a, b):
    total = a*a + b*b
    c = math.isqrt(total)
    return c*c == total