Results 1 to 6 of 6
Thread: The sweet program
- 10-07-2011, 09:14 AM #1
Member
- Join Date
- Oct 2011
- Posts
- 3
- Rep Power
- 0
The sweet program
hi
i'm new!!!!
my problem:
n children numbered 1 to n are sitting in a circle. starting at child 1, a sweet is passed. after m passes the child holding the sweet is eliminated. if child x gets eliminated he gives the sweet to child x+1 and leaves the ring. that does not count far a pass. the children in the circle close ranks and the game continues with the child who was sitting after the eliminated child,taking the sweet. assume m is constant for each elimination.
write a program that will determine which child would get the sweet in the end.
I'm totally confused please help!!!!!!
Any assistance will be appreciated
- 10-07-2011, 09:22 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,422
- Blog Entries
- 7
- Rep Power
- 29
Re: The sweet program
The original problem is the Josephus problem and it is about people being killed one by one; it was not so sweet ;-)
kind regards,
JosBuild a wall around Donald Trump; I'll pay for it.
- 10-07-2011, 09:48 AM #3
Member
- Join Date
- Oct 2011
- Posts
- 3
- Rep Power
- 0
Re: The sweet program
ok!
that is some hectic maths. how would i formulate the code for the problem.
do you have an example
regards
- 10-07-2011, 10:03 AM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,422
- Blog Entries
- 7
- Rep Power
- 29
Re: The sweet program
Use a boolean array and consider it circular, i.e. hopping off from the end brings you back to the first element. If an element is true, the corresponding person is considered to be alive, else hop to the right again until you hit an element that is still true.
kind regards,
JosBuild a wall around Donald Trump; I'll pay for it.
- 10-07-2011, 10:21 AM #5
Member
- Join Date
- Oct 2011
- Posts
- 3
- Rep Power
- 0
Re: The sweet program
ok let me look that up
thanks
- 10-07-2011, 11:08 AM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,422
- Blog Entries
- 7
- Rep Power
- 29
Similar Threads
-
How to code a program to send messages to a chat program?
By josh2992 in forum New To JavaReplies: 2Last Post: 04-02-2011, 01:57 PM -
How would I open a program from a single button of another program. Help...
By decgaid06 in forum New To JavaReplies: 13Last Post: 03-22-2011, 07:49 AM -
How to execute an External Program through Java program
By Java Tip in forum java.ioReplies: 0Last Post: 04-04-2008, 03:40 PM -
How to execute an External Program through Java program
By JavaBean in forum Java TipReplies: 0Last Post: 10-04-2007, 10:33 PM
Bookmarks