8 kyu

Pythagorean Triple

2,650 of 17,992elexie

Description:

Given an unsorted array of 3 positive integers [ n1, n2, n3 ], determine if it is possible to form a Pythagorean Triple using those 3 integers.

A Pythagorean Triple consists of arranging 3 integers, such that:

a2 + b2 = c2

Examples

[5, 3, 4] : it is possible to form a Pythagorean Triple using these 3 integers: 32 + 42 = 52

[3, 4, 5] : it is possible to form a Pythagorean Triple using these 3 integers: 32 + 42 = 52

[13, 12, 5] : it is possible to form a Pythagorean Triple using these 3 integers: 52 + 122 = 132

[100, 3, 999] : it is NOT possible to form a Pythagorean Triple using these 3 integers - no matter how you arrange them, you will never find a way to satisfy the equation a2 + b2 = c2

Return Values

  • For Python: return True or False
  • For JavaScript: return true or false
  • Other languages: return 1 or 0 or refer to Sample Tests.
Algebra
Mathematics
Fundamentals

More By Author:

Check out these other kata created by elexie

Stats:

CreatedJun 27, 2017
PublishedJun 27, 2017
Warriors Trained25333
Total Skips813
Total Code Submissions55308
Total Times Completed17992
Java Completions2650
Python Completions6598
C++ Completions4294
JavaScript Completions4195
C Completions512
PHP Completions399
Scala Completions15
CoffeeScript Completions12
Total Stars152
% of votes with a positive feedback rating89% of 1752
Total "Very Satisfied" Votes1431
Total "Somewhat Satisfied" Votes263
Total "Not Satisfied" Votes58
Total Rank Assessments40
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • elexie Avatar
  • anter69 Avatar
  • lszcs Avatar
  • AcesOfGlory Avatar
  • Chrono79 Avatar
  • ltison Avatar
  • Madjosz Avatar
  • rowcased Avatar
  • ZED.CWT Avatar
  • trashy_incel Avatar
  • akar-0 Avatar
  • khanhtranngoccva Avatar
  • benjaminzwhite Avatar
  • KayleighWasTaken Avatar
Ad