Skip to content

Latest commit

 

History

History
49 lines (34 loc) · 1.26 KB

README.md

File metadata and controls

49 lines (34 loc) · 1.26 KB

Image Services Practical task 1

Shapes and holes

Your task is to write tests for and write a function to determine if a given triangle fits in another triangle.

The function should take the dimensions of two triangles (as arrays) and checks if the first triangle fits into the second one.

Examples

doesTriangleFit([1, 1, 1], [1, 1, 1]); // true

doesTriangleFit([1, 1, 1], [2, 2, 2]); // true

doesTriangleFit([1, 2, 3], [1, 2, 2]); // false

doesTriangleFit([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.
  • Googling is allowed.

Practical task 2

You have the same problem as described in Task 1, except instead of triangle edge lengths - your function should accept triangle point coordinates.

Example

// https://www.geogebra.org/calculator/q4jqxdt3
doesTriangleFit(
	[
		[4, 2],
		[4, 3],
		[6, 3],
	],
	[
		[1, 2],
		[4, 4],
		[7, 1],
	]
); // false

And just in case you get stuck - a hint that IMHO this simple PNP algorithm can be quite handy for this.