# Help the soldiers!

This is a discussion on Help the soldiers! within the C Programming forums, part of the General Programming Boards category; Hi, Please help me on this one....just tell me some basic algorithm to solve this problem........... A group of soldiers ...

1. ## Help the soldiers!

Hi,

A group of soldiers is surrounded by an overwhelming army force. There is no hope for victory, but there is a single horse to escape. The soldiers agree to a pact to determine which of them is to escape on the horse and summon help. Every soldier writes his name on a piece of paper and drops it in a hat. Then they form a circle. A random number n is selected. A name is picked from the hat. Starting with the soldier whose name is picked, they count clockwise around the circle. The soldier on which the count reaches n is removed from the circle. The count begins from the soldier who sat next to the removed soldier, moving in the clockwise direction. This continues until all but one soldier have been removed. The last soldier takes the horse and escapes.
Required output:
Using the technique used by the soldiers, display the sequence in which the soldiers are eliminated from the circle.
Show which soldier escapes with the horse.
Note:
Input a list of names of soldiers.
There is no restriction on the number of soldiers.
Make a circular list of the names of soldiers.
Generate a random number n, which should be greater than 0 and less than the number of soldiers.
Minimum size for soldier name=10.
Also:
Implement it using circular linked list of a structure “node”, which contains a field for name of soldier and a pointer to the next node.

2. The Homework Policy for this site discourages us from doing the homework for people, and due to the amount of people asking, I had a signature made for me that represents my POV on it.

We can help you if you have trouble, however. Therefore, you'd be best off to come up with a solution to your homework problem, and work on it. If you have trouble with code, we might be able to help you with it. The bottom line is that we would like to help you with stuff you've already done, not do new stuff for you.

Many of us can say from experience that these simple exercises are extremely beneficial to learning how to program. Someone on these forums likened learning to program to learning how to paint. Unless you actually do it, you can't get good at it. You can only learn so much from watching and reading through code just like watching someone else paint.

First make sure you understand the problem. Then work out a simple solution on paper. Then work on translating the solution to extremely detailed steps in English or equivalent natural language. Finally, translate the result of that last step into C.

Give us an idea where you're stuck with this, and let's go from there.