All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Algorithms
Firing Line (Posted on 2004-08-25) Difficulty: 3 of 5
There is a group of N soldiers arranged in a straight line, standing side by side. Soldier number 1 is at the extreme left and soldier "N" is at the extreme right. Each soldier has a rifle that can be fired only once, a primitive timer, understands a finite list of commands, and can exist in a finite number of states, like a finite state machine.

Each soldier has the ability to communicate only with the two adjacent soldiers, and has no means of communication with more distant soldiers. The i-th soldier can not see or hear any signals given by the (i+2)th soldier, for example. There are no radios, cell phones, or megaphones.

Your mission as the commander is to devise an algorithm by which all soldiers fire their weapons simultaneously. Soldiers 1 and N are aware of the fact that they are "different" in that they each have only one neighbor. Other than that, however, the soldiers are initially all identical. The algorithm has to work for any value of N>2.

The primitive timers are synchronized and tick off once a second. Once a soldier receives new information, the earliest he can respond in any way is on the next tick of the clock. (I would say he/she, except that they are all identical). A soldier can give a signal to each neighbor simultaneously, based on the information he received one tick earlier. Whenever a soldier's state changes, his neighbors are aware of this one tick later. At time=0, soldier 1 is given the command to start the firing procedure

1. Devise an algorithm that results in all N soldiers firing simultaneously
2. As a function of N, how many clock ticks does this take?

See The Solution Submitted by Larry    
Rating: 3.3333 (3 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
More Information | Comment 9 of 14 |

My apologies for not stating the problem as clearly as I should have; and also for being out of town.  This was the first I've seen any of the answers.

First:  Nikki's Scenario B is what I had in mind.

Second:  The first soldier can't be told how many soldiers are in the line.  In fact, in general, the soldiers can't count high enough to be able to interpret a number as large as N.  I don't have a complete understanding of finite state machines, but the concept I have is that IF they could count up to an abitrarily large number, then they would need an arbitrarily large number of states.  They don't have that many states.

Think of cellular automata, like the game of Life, but in this case the cells are not in a 2D grid like Life, but in a long array.  All are in the same state initially except the first and last cell.  After 1 tick, the second cell may be in a different state.  As a hint, I believe these automata need only about a dozen states to accomplish the task for an arbitrary number N, but it takes way more than 2N ticks.

Sorry for the confusion.

  Posted by Larry on 2004-08-27 10:44:41
Please log in:
Remember me:
Sign up! | Forgot password

Search body:
Forums (2)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (4)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Copyright © 2002 - 2020 by Animus Pactum Consulting. All rights reserved. Privacy Information