Does the Triangle Fit into the Triangular Hole?

Published by Matt in

Create a function that takes the dimensions of two triangles (as arrays) and checks if the first triangle fits into the second one.

Examples

does_triangle_fit([1, 1, 1], [1, 1, 1]) ➞ true

does_triangle_fit([1, 1, 1], [2, 2, 2]) ➞ true

does_triangle_fit([1, 2, 3], [1, 2, 2]) ➞ false

does_triangle_fit([1, 2, 4], [1, 2, 6]) ➞ false

Notes

  • Triangle fits if it has the same or smaller size as the hole.
  • The function should return false if the triangle with that dimensions is not possible.
Watch a quick demo on how Edabit works.