freeCodeCamp/curriculum/challenges/english/10-coding-interview-prep/project-euler/problem-91-right-triangles-with-integer-coordinates.english.md
mrugesh 22afc2a0ca feat(learn): python certification projects (#38216)
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
Co-authored-by: Kristofer Koishigawa <scissorsneedfoodtoo@gmail.com>
Co-authored-by: Beau Carnes <beaucarnes@gmail.com>
2020-05-27 13:19:08 +05:30

2.1 KiB

id, challengeType, isHidden, title, forumTopicId
id challengeType isHidden title forumTopicId
5900f3c71000cf542c50feda 5 false Problem 91: Right triangles with integer coordinates 302208

Description

The points P (x1, y1) and Q (x2, y2) are plotted at integer co-ordinates and are joined to the origin, O(0,0), to form ΔOPQ.

a graph plotting points P (x_1, y_1) and Q(x_2, y_2) at integer coordinates that are joined to the origin O (0, 0)

There are exactly fourteen triangles containing a right angle that can be formed when each co-ordinate lies between 0 and 2 inclusive; that is, 0 ≤ x1, y1, x2, y2 ≤ 2.

a diagram showing the 14 triangles containing a right angle that can be formed when each coordinate is between 0 and 2

Given that 0 ≤ x1, y1, x2, y2 ≤ 50, how many right triangles can be formed?

Instructions

Tests

tests:
  - text: <code>rightTrianglesIntCoords()</code> should return a number.
    testString: assert(typeof rightTrianglesIntCoords() === 'number');
  - text: <code>rightTrianglesIntCoords()</code> should return 14234.
    testString: assert.strictEqual(rightTrianglesIntCoords(), 14234);

Challenge Seed

function rightTrianglesIntCoords() {
  // Good luck!
  return true;
}

rightTrianglesIntCoords();

Solution

// solution required