Mark Smith

ASP.NET, SQL Server, HTML, CSS and other random thoughts!

Puzzle - Regular Pentagon

First of all, thank you to everyone who took part in the Friday The Thirteenths puzzle at LessThanDot. We had some great entries from all types of different languages such as .NET, SQL Server, VB6, VBA, ASP, VBScript, Javascript, Java, Perl, Ruby and Python! It was a great response from everyone and it was a very nice introduction to our first weekly puzzle so once again thank you to all contributors.

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 the points.

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!

 

Posted: Jun 16 2008, 06:14 PM by ca8msm | with 2 comment(s)
Filed under: ,

Comments

No Comments