Puzzle - Regular Pentagon
This week, the puzzle is entitled "Regular Pentagon" and the rules are:
Given a grid co-ordinate (x,y) as the centre point of a regular
pentagon, and the sum of the length of the sides, return the
co-ordinates of each point as: "Top", "MidLeft", "MidRight",
"BottomLeft", "BottomRight" and the distance from the centre to each of
This should work for any possible position of the centre point, and any length of the sides.
- All Sides are equal length in a Regular Pentagon
- x = horizontal scale, y=vertical
- scale increments can be anything you wish.. mm, cm, inches, feet, etc (doesn't matter) - though only whole units can be used
For added points, make it work for any regular polygon (and even further added points for calculating the area)
Again, any programming language is acceptable and we are looking for interesting methods that you can come up with to solve the puzzle. Remember, it's just a bit of fun and we'd like to think it will enjoyable for you to come up with a great way to solve it!