Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 17th, 2006, 2:58 PM   #1
tany
Newbie
 
Join Date: Jan 2006
Posts: 1
Rep Power: 0 tany is on a distinguished road
Can someone help me in writing a code for this problem??

Your computer has a dual personality. One personality is called Fido, another is called Dido. Now Fido and Dido each have infinite perfectly circular coins of radius "r" and a perfectly circular table of radius "R" and centered on the origin (0,0). For simplicity, let us assume that R=c*r where c is a positive (> 0) integer constant. Further, for the table edges assume that as long even one point comprising the coin is on the table, this coin floats in the air and doesn't fall off the table.

You have to write a program that makes Fido and Dido play against each other by placing coins one-by-one, taking turns, on the table. Fido always starts the game by placing a coin anywhere on the empty table initially. Coins cannot be placed on top of each other (there is only 1 layer). So you can't for example put a coin with edges on top of one or more coins. The person who has no place left on the table to place a coin when her/his turn comes will *lose* the game.

You have to come up with a sure shot way of ensuring that Fido always wins no matter what. Program Dido so that he always places coins randomly on the table subject to the conditions above. (Hint: If you program Fido right, he will always win no matter what strategy Dido uses to place coins; even non-randomly, even if he teams up with a big brother Cray supercomputer and thinks for a zillion years between each turn!!). Your algorithm should be a Polynomial time and Polynomial space solution in R, c and r (No NP here please!).

Your program will accept as input parameter c and r (signed positive integers). It will then simply display a list of coordinates that Fido and Dido place their coins on:

example:

Enter c, r: 10 1
Turn 1, Fido = (1.342, 2.343)
Turn 1, Dido = (-4.23, 6.24)
Turn 2, Fido = (4.12, 1.2334)
Turn 2, Dido = (6,-1.78)
...
...
...
Turn #, Fido = (...)
Turn #, Dido = (Oops, I lose, no random spot left)
tany is offline   Reply With Quote
Old Jan 17th, 2006, 3:02 PM   #2
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 5 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
We don't do homework.
__________________

tempest is offline   Reply With Quote
Old Jan 17th, 2006, 3:07 PM   #3
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Do some thinking. If you find it hard, it's because it's supposed to be hard. This is called algorithm development - it's a key part of anything to do with computer programming.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Jan 17th, 2006, 4:58 PM   #4
crawforddavid2006
Expert Programmer
 
crawforddavid2006's Avatar
 
Join Date: Apr 2005
Location: Not sure yet
Posts: 579
Rep Power: 0 crawforddavid2006 is an unknown quantity at this point
Send a message via AIM to crawforddavid2006 Send a message via MSN to crawforddavid2006
Quote:
Originally Posted by tempest
We don't do homework.
Yes we do... it's called pay pal
__________________
Quote:
Originally Posted by DaWei View Post
Well, it's better than Pen Islands url....;)

crawforddavid2006 is offline   Reply With Quote
Old Jan 17th, 2006, 5:48 PM   #5
andro
Professional Programmer
 
Join Date: Oct 2005
Location: California
Posts: 294
Rep Power: 3 andro is on a distinguished road
Send a message via AIM to andro
I'll give ya a hint if you ask for it on aim
andro is offline   Reply With Quote
Old Jan 18th, 2006, 12:15 AM   #6
Lich
Professional Programmer
 
Lich's Avatar
 
Join Date: May 2005
Location: Detroit
Posts: 254
Rep Power: 4 Lich is on a distinguished road
Send a message via AIM to Lich Send a message via MSN to Lich
Quote:
Originally Posted by crawforddavid2006
Yes we do... it's called pay pal
tru.dat
__________________
--John Cruz
Web Developer
www.cruzweb.net
Lich is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:43 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC