Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.
Forum Search
Highly Rated Users
Forum Statistics
UsersTotal Post History
- Posts:
- 45705
- Topics:
- 9398
7-Day Post History
- New Posts:
- 343
- New Topics:
- 81
- Active Topics:
- 90
Our newest member
Other
-
FAQ
All times are UTC [ DST ]
Google Ads
LTD Puzzle 2: Regular Pentagon
Forum rules
Always post answers in a "Hidecode" tag, so that others have a chance to answer the question too.
Always post answers in a "Hidecode" tag, so that others have a chance to answer the question too.
13 posts • Page 1 of 1
Please wait...
LTD Puzzle 2: Regular Pentagon
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.
For added points, make it work for any regular polygon (and even further added points for calculating the area)
<courtesy of damber, its' not my wacky spelling
/>
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)
<courtesy of damber, its' not my wacky spelling
And we have contraptions like computers that cheat you out of becoming. Bill Gates says, "Wait till you see what your computer can become." But it's you who should be doing the becoming, not the damn fool computer.
My Crummy Web Page
My Crummy Web Page
-

AlexCuse - LTD Admin

-








- Posts: 3532
- Joined: Tue Oct 09, 2007 5:26 pm
- Location: Pennsylvania, US
Re: Regular Pentagon
Code is hidden, SHOW
P.S. I'm not sure what "only whole units can be used" means. Please clarify and I will correct, probably by multiplying to get rid of any decimal point.

Last edited by Emtucifor on Tue Jun 17, 2008 5:30 pm, edited 2 times in total.
It's more cheesier if you do it right the first time!
-

Emtucifor - Senior Sage

-










- Posts: 2152
- Joined: Fri May 30, 2008 9:30 pm
- Location: California
Re: Regular Pentagon
Erik - don't worry about the whole numbers thing, it was initially intended to keep things simple, but as the puzzle scope changed it doesn't really make sense to keep it in, so I've edited it out.
a smile is worth a thousand kind words, so smile, it's easy! 
CODE: $5
WORKING CODE: $500
PROPERLY DESIGNED & WORKING CODE: Priceless

CODE: $5
WORKING CODE: $500
PROPERLY DESIGNED & WORKING CODE: Priceless
-

damber - LTD Admin

-





- Posts: 1959
- Joined: Tue Oct 09, 2007 1:48 pm
- Location: North Wales, UK
Re: Regular Pentagon
You do not have the required permissions to view the files attached to this post.
-George
-

gmmastros - LTD Admin

-










- Posts: 1184
- Joined: Tue Oct 09, 2007 5:19 pm
Re: Regular Pentagon
ErikE wrote:P.S. I'm not sure what "only whole units can be used" means. Please clarify and I will correct, probably by multiplying to get rid of any decimal point.
I don't know how many decimal points you need but sql server has a pi function built in
- SELECT PI()
Denis The SQL Menace
SQL Server Code,Tips and Tricks, Performance Tuning
SQL Blog
Personal and/or non database related blog
SQL Server Code,Tips and Tricks, Performance Tuning
SQL Blog
Personal and/or non database related blog
o
o
o @..@
(----)
( )--( )
o0..0o
-

SQLDenis - LTD Admin

-










- Posts: 11780
- Joined: Wed Oct 10, 2007 6:43 pm
- Location: Princeton, New Jersey, USA,World, Solar System, Milky Way, Universe and Beyond
Re: Regular Pentagon
George,
I think you've been doing polygon math FAR too long for me to compete with. Good work.
I was thinking last night that my code is flawed because it can accumulate errors as it goes. I was thinking about the problem incorrectly. I should have calculated each point from the center as you did. Then half my variables could be disposed of...
I think you've been doing polygon math FAR too long for me to compete with. Good work.
I was thinking last night that my code is flawed because it can accumulate errors as it goes. I was thinking about the problem incorrectly. I should have calculated each point from the center as you did. Then half my variables could be disposed of...
It's more cheesier if you do it right the first time!
-

Emtucifor - Senior Sage

-










- Posts: 2152
- Joined: Fri May 30, 2008 9:30 pm
- Location: California
Re: Regular Pentagon
Now that I think about it, You missed one thing George:
Shouldn't be too tough though.
Its' not going to win any shortest code contests because I created my own types and enabled them convert between each other, but here goes (anything to liven this thread up a bit). C# on the console
Given a grid co-ordinate (x,y) as the centre point of a regular pentagon
Shouldn't be too tough though.
Its' not going to win any shortest code contests because I created my own types and enabled them convert between each other, but here goes (anything to liven this thread up a bit). C# on the console
Code is hidden, SHOW
And we have contraptions like computers that cheat you out of becoming. Bill Gates says, "Wait till you see what your computer can become." But it's you who should be doing the becoming, not the damn fool computer.
My Crummy Web Page
My Crummy Web Page
-

AlexCuse - LTD Admin

-








- Posts: 3532
- Joined: Tue Oct 09, 2007 5:26 pm
- Location: Pennsylvania, US
Re: Regular Pentagon
SQLDenis wrote:I don't know how many decimal points you need but sql server has a pi function built in
- SELECT PI()
I know THAT.
1. The Pi() function is very slow.
2. The Pi() function only gives 16 decimal places.
3. The Pi() function's 16th digit is wrong. Not just rounded incorrectly, but wrong any way you look at it.
That's why I didn't use it. Plus, I have Pi memorized to 58 decimal places so typing it out is extremely easy and convenient for me.
It's more cheesier if you do it right the first time!
-

Emtucifor - Senior Sage

-










- Posts: 2152
- Joined: Fri May 30, 2008 9:30 pm
- Location: California
Re: Regular Pentagon
OK, here's mine (ASP.NET / C#):
I tested it as the codebehind of an aspx page, but you can easily change to run in the console etc.
It will accept any coordinate for the centre point, number of sides/points, a positive length for the sides and an offset rotation in degrees from north (so you can rotate the polygon).
It will return all the points with Cartesian X, Y and Polar Coordinates as well as the Area, distance from the centre to the edge at the furthest and nearest point and the relevant angles.
Code is hidden, SHOW
I tested it as the codebehind of an aspx page, but you can easily change to run in the console etc.
It will accept any coordinate for the centre point, number of sides/points, a positive length for the sides and an offset rotation in degrees from north (so you can rotate the polygon).
It will return all the points with Cartesian X, Y and Polar Coordinates as well as the Area, distance from the centre to the edge at the furthest and nearest point and the relevant angles.
a smile is worth a thousand kind words, so smile, it's easy! 
CODE: $5
WORKING CODE: $500
PROPERLY DESIGNED & WORKING CODE: Priceless

CODE: $5
WORKING CODE: $500
PROPERLY DESIGNED & WORKING CODE: Priceless
-

damber - LTD Admin

-





- Posts: 1959
- Joined: Tue Oct 09, 2007 1:48 pm
- Location: North Wales, UK
Re: Regular Pentagon
ErikE wrote:Plus, I have Pi memorized to 58 decimal places so typing it out is extremely easy and convenient for me.
PFFFtttttt, I expected you to have a MotherOfAllValuesOrFunctions table so that you don't have to type it in
BTW, do you know that I have stuff like this "select dateadd(mm, datediff(mm, 0, getdate())-11, 0)" in notes in outlook

Denis The SQL Menace
SQL Server Code,Tips and Tricks, Performance Tuning
SQL Blog
Personal and/or non database related blog
SQL Server Code,Tips and Tricks, Performance Tuning
SQL Blog
Personal and/or non database related blog
o
o
o @..@
(----)
( )--( )
o0..0o
-

SQLDenis - LTD Admin

-










- Posts: 11780
- Joined: Wed Oct 10, 2007 6:43 pm
- Location: Princeton, New Jersey, USA,World, Solar System, Milky Way, Universe and Beyond
Re: Regular Pentagon
AlexCuse wrote:Now that I think about it, You missed one thing George:Given a grid co-ordinate (x,y) as the centre point of a regular pentagon
Shouldn't be too tough though.
Yes Alex. It's not that tough. In fact....
Code is hidden, SHOW
-George
-

gmmastros - LTD Admin

-










- Posts: 1184
- Joined: Tue Oct 09, 2007 5:19 pm
- reshefm
- Newbie

-
- Posts: 2
- Joined: Thu Jun 19, 2008 3:39 pm
The Winners
There are 2 types of winner - a "People's Champion" (the one with the most rating points across all their posts) and the LTD Admin's Champion (selected with our special formula....honest...well, maybe it's just the ones that the admins thought were particularly good
)
So...
People's Champion: joint winners - AlexCuse and gmmastros both scoring 10 points each
LTD Admin's Champion: reshefm - for posting a nice ruby solution
Congratulations to all.. and good luck on next weeks puzzle
)So...
People's Champion: joint winners - AlexCuse and gmmastros both scoring 10 points each
LTD Admin's Champion: reshefm - for posting a nice ruby solution
Congratulations to all.. and good luck on next weeks puzzle

a smile is worth a thousand kind words, so smile, it's easy! 
CODE: $5
WORKING CODE: $500
PROPERLY DESIGNED & WORKING CODE: Priceless

CODE: $5
WORKING CODE: $500
PROPERLY DESIGNED & WORKING CODE: Priceless
-

damber - LTD Admin

-





- Posts: 1959
- Joined: Tue Oct 09, 2007 1:48 pm
- Location: North Wales, UK
13 posts • Page 1 of 1


LTD Social Sitings
Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.