Cody

Problem 44367. Inscribed Pentagon? 2

Created by goc3 in Community

Your function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The pentagon may or may not be centered on the circle. The function should return one of the following values:

 -1: the pentagon is not centered on the circle (within 5% of r)^
  0: the pentagon is completely enclosed within the circle but is not inscribed
  1: the pentagon is inscribed in the circle (within ±0.02)
  2: the vertices of the pentagon extend beyond the circle

Points will be rounded to the nearest hundredth. See the test cases for examples. (There will not be a case where some vertices are within the circle and others without.)

^ Due to the asymmetric nature of the pentagon, its centroid does not coincide with center of its inscribing circle, hence the ±5% tolerance window.

Solution Stats

37.56% Correct | 62.44% Incorrect
Last solution submitted on May 28, 2019

Problem Comments