![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jan 2006
Posts: 1
Rep Power: 0
![]() |
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) |
|
|
|
|
|
#2 |
|
Programming Guru
![]() |
We don't do homework.
__________________
|
|
|
|
|
|
#3 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
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.
|
|
|
|
|
|
#4 | |
|
Expert Programmer
|
Quote:
![]()
__________________
|
|
|
|
|
|
|
#5 |
|
Professional Programmer
|
I'll give ya a hint if you ask for it on aim
![]() |
|
|
|
|
|
#6 | |
|
Professional Programmer
|
Quote:
|
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|