Slashdot Mirror


Solving Feynman's Unsolved Puzzle?

An anonymous reader asks: "In The Feynman Lectures on Computation, Richard Feynman poses an interesting little puzzle involving the synchronization of finite state machines acting as generals and soldiers. While he was able to find an answer to the problem, the minimum time solution apparently eluded him, and he ended his description of the puzzle with the following Fermat-like declaration: 'Somebody has actually found a solution with this minimum time. That is very difficult though, and you should not be so ambitious. It is a nice problem, however, and I often spend time on airplanes trying to figure it out. I haven't cracked it yet.' My best attempt performs at about 3N, not quite the minimum time of 2N-2. So I'm asking Slashdot: Has anyone ever come across the minimum time solution to this puzzle? Or maybe someone here can figure it out!"

"Here is the full description of the problem, in Feynman's own words. Please remember that these are finite state machines, so you can't use any methods that involve counting the number of soldiers or assigning a number to each soldier.

Problem 3.4: Before turning to Turing machines, I will introduce you to a nice FSM problem that you might like to think about. It is called the 'Firing Squad' problem. We have an arbitrarily long line of identical finite state machines that I call 'soldiers'. Let us say there are N of them. At one end of the line is a 'general', another FSM. Here is what happens. The general shouts 'Fire'. The puzzle is to get all of the soldiers to fire simultaneously, in the shortest possible time, subject to the following constraints: firstly, time goes in units; secondly, the state of each FSM at time T+1 can only depend on the state of its next-door neighbors at time T; thirdly, the method you come up with must be independent of N, the number of soldiers. At the beginning, each FSM is quiescent. Then the general spits out a pulse, 'fire', and this acts as an input for the soldier immediately next to him. This soldier reacts as in some way, enters a new state, and this in turn affects the soldier next to him and so on down the line. All the soldiers interact in some way, yack yack yack, and at some point they become synchronized and spit out a pulse representing their 'firing'. (The general, incidentally, does nothing on his own initiative after starting things off.)

There are different ways of doing this, and the time between the general issuing his order and the soldiers firing is usually found to be between 3N and 8N. It is possible to prove that the soldiers cannot fire earlier than T=2N-2 since there would not be enough time for all the required information to move around. Somebody has actually found a solution with this minimum time. That is very difficult though, and you should not be so ambitious. It is a nice problem, however, and I often spend time on airplanes trying to figure it out. I haven't cracked it yet."

90 comments

  1. Solving Feynman's Unsolved Puzzle? by keoghp · · Score: 1, Funny

    Is this what people refer to as the slashdot effect!

    --
    For problems, seek only the simplest solution, complexity brings with it more problems.
  2. I'm no math wiz by iq+in+binary · · Score: 2, Insightful

    Define a straight line.....

    Seriously, the straight line might just be the solution to that problem.

    That thought just popped up in my head, feel free to flame me for being open.

    --
    Of all the Universal Constants, here's one I know: Nice guys finish last ;)
    1. Re:I'm no math wiz by Anonymous Coward · · Score: 0

      That's just a way of saying that every soldier can communicate with at most two other soldiers in a direct way. The soldiers at both ends of the line can only communicate with one other soldier (it's not a circle).

    2. Re:I'm no math wiz by Anonymous Coward · · Score: 0

      It's a FSM synchronization problem not a datastructures problem. That means you aren't looking at how to arrange the soldiers or even how they communicate with each other. You are looking for a finite state "program" that each soldier runs that will run starting from the time they receive the message and at whose termination they fire.

    3. Re:I'm no math wiz by Anonymous Coward · · Score: 0

      To write such a program, you need to know which inputs each FSM has, in this case: the states of two neighbors and its own state. The FSMs at the end have one normal neighbor and one which gives the start signal or statically signals end of line (either by not changing state or by constantly being in a special state).

  3. A new kind of science by Anonymous Coward · · Score: 5, Interesting

    Stephen Wolfram's "A New Kind of Science" addresses this puzzle with cellular automata. I remember hearing about it at a lecture at CMU. If my memory serves me right, he has found a solution and it is contained inside his book. You might try looking there.

    1. Re:A new kind of science by iq+in+binary · · Score: 1

      As I drink more caffiene-laiden mud (That's how I like my coffee), I seem to recall hearing about a couple of College students from Kansas solving this problem.

      I don't have a link handy, and I'm too tired to google. Anybody else recall the same?

      --
      Of all the Universal Constants, here's one I know: Nice guys finish last ;)
    2. Re:A new kind of science by dillon_rinker · · Score: 2

      What's the difference between cellular automata and finite state machines? Isn't the former just a whole bunch of the latter?

    3. Re:A new kind of science by Mr.+Slippery · · Score: 2, Insightful
      Stephen Wolfram's "A New Kind of Science" addresses this puzzle with cellular automata.

      Cellular automata are exactly what this problem is asking about! A CA is a bunch of FSMs hooked together. More precisely, a quick Googling says:

      On a regular lattice (repeated structure of points have the same kind of neighborhood) one puts a finite-state machine at each point. The input to the machine is the states of all machines in its neighborhood. The behaviour is to change its state based in a determined way, as a function of the states of its neighbors and its own state. The states of all machines in the lattice are updated synchronously (simultaneously).
      --
      Tom Swiss | the infamous tms | my blog
      You cannot wash away blood with blood
    4. Re:A new kind of science by Mr+Z · · Score: 1

      As I understand it (someone correct me if I'm wrong), cellular automata have an FSM at their heart. Their inputs are determined spatially -- eg. their neighbors outputs serve as inputs. Also, I believe the output of cellular automata's FSM is generally of the form "alive" or "dead". Think, for instance, of Conway's "Life", or the various "Rule XX" that Wolfram examined that lead to him writing ANKOS.

      So, in other words, cellular automata are a bunch of specialized FSMs.

      More arbitrary FSMs can take more arbitrary inputs and produce more arbitrary outputs (or sets of outputs).

      --Joe
    5. Re:A new kind of science by extremely · · Score: 2

      More concisely, CA are a limited group of identical FSMs whos inputs are the current states of their spatial neighbors.

      --

      $you = new YOU;
      honk() if $you->love(perl)

    6. Re:A new kind of science by Paradise+Pete · · Score: 2, Funny
      (someone correct me if I'm wrong)

      This is Slashdot. You don't have to write that part.

    7. Re:A new kind of science by DrLudicrous · · Score: 2

      I have this book- where might I find the treatment of this particular problem? Could someone at least give a chapter, if not page numbers?

    8. Re:A new kind of science by Dachannien · · Score: 1

      CAs don't have to consist of finite-state automata. Still, the question posed by Feynman is definitely relevant to CAs, since each automaton is identical in function.

      The solution is indeed reproduced in Wolfram's book, which I will excerpt in a separate reply if it has not already been quoted.

    9. Re:A new kind of science by A55M0NKEY · · Score: 1
      The input to the machine is the states of all machines in it's neighborhood
      Dos that mean a topological neighborhood? If not that sounds vague.
      --

      Eat at Joe's.

  4. Hmmmmmm by iq+in+binary · · Score: 1

    Define the General (or trigger var?), then.

    As I said, I'm no math wiz, haven't any credits under my name past Mat121 (College Algebra, being interested in calc based phys that'll change). But it seems that problem like these are solved not by the math, but the logic.

    That's one of the great things about being young and dumb like me, everything is open to interpretation.

    --
    Of all the Universal Constants, here's one I know: Nice guys finish last ;)
    1. Re:Hmmmmmm by Anonymous Coward · · Score: 0

      You're no reading whiz either, right?

    2. Re:Hmmmmmm by dave_f1m · · Score: 1

      Ya know, this is what makes me sick anymore. Kids getting "extra credit" and getting 101+ percent grades. Huh? And college's giving credit for Algebra? Come on, "College Algebra" is Mat121!? When I went to college, M101,M102, and M103 were Calc 1,2,3. Sorry, no real comment on your cluelessness, but I just got to ride home in a nice rain/snow mix, my helmut kept fogging up, and my cycle wouldn't run right (I don't think it likes prec.at temps below 35 or so), and I needed to rant about something;-). Oh, and maybe you should look more into majoring in philosophy, although that may be rough too. What you need to do is this spring take a Logic (Phil) or Disco (Descrete Math), Modern Math, or whatever your school call it. Basicly, find something that teaches boolean algebra and/or propositional calculus. - dave f.

    3. Re:Hmmmmmm by iq+in+binary · · Score: 1

      Hey, if it hadn't been for my highschool screwing me over on my credits, I'd be finished with Trig and Calc 1 by now.

      I know I don't know shit. Didn't I say that earlier?

      --
      Of all the Universal Constants, here's one I know: Nice guys finish last ;)
  5. An optimum solution ... by Xner · · Score: 3, Informative
    A certain "A. Walkman" claims to have found the optimum solution in 1966, and published it in "Information and Control":

    Waksman, A. An optimum solution to the firing squad synchronization problem. Information and Control 9 (1966), 66--78.

    Unfortunately, the article does not seem to be available online.
    If anyone decides to take a quick trip down to the library, I would be delighted if they could share the answer.

    --
    Pathman, Free (as in GPL) 3D Pac Man
    1. Re:An optimum solution ... by dillon_rinker · · Score: 5, Informative

      You might be looking for this. It's referenced elsewhere in this discussion, so this is technically redundant, but I thought it'd be useful to have the link handy to this particular post.

  6. isn't this the same as by oliverthered · · Score: 2

    The prisoners and the light bulb (which I can't quite remember).
    Where the prisoners get released after each one has switched the light on.
    You get a best of 2n-2 for this
    2n for switching on and off and -2 because of the first and last prisoner.

    The worst case could be infinate.

    --
    thank God the internet isn't a human right.
  7. Solutions by Anonymous Coward · · Score: 4, Informative
    1. Re:Solutions by Anonymous Coward · · Score: 0

      Moderators are not reading at "0/-1, oldest first", it seems.

    2. Re:Solutions by fruey · · Score: 1

      The page links to several solutions; they appear not to all contain the bugs in the link you gave.

      --
      Conversion Rate Optimisation French / English consultant
    3. Re:Solutions by Anonymous Coward · · Score: 0

      This nice solution
      http://xraysgi.ims.uconn.edu/fsquad/firi ng-solution-mazoyer.html
      allows for a short perl script to do the work.
      Just copy and paste the rules table into rules.txt
      and run ./fsm.pl 80

      #! /usr/bin/perl

      open RULES, "rules.txt";
      while (<RULES>){
      @a=split;
      $F{$a[0].$a[1].$a[2]}=$a[3];
      }
      $n = shift;
      $string="XG";
      $j=2;
      while ($j <= $n){
      $string .= "-";
      $j++;
      }
      $string .= "X";
      print "$string\n";
      while ( ! ( $string =~ /F/ ) ) {
      $k=1;
      $newstring = X;
      while ($k <= $n){
      $newstring .= $F{substr($string,$k-1,3)};
      $k++;
      }
      $newstring .=X;
      $string=$newstring;
      print "$string\n";
      }

  8. The Prisoners and the Light by Xner · · Score: 2, Informative
    If you don't know the puzzle in question (i didn't), here it is:
    100 Prisoners and a Light Bulb There are 100 prisoners, each kept in their own isolated cell. Each day one prisoner is chosen at random and taken into a central room where there is a light. The light is either ON or OFF. The prisoner may view the light and turn it on or off if they like, before being returned to their cell. The prisoner may also guess that all the prisoners have been into the exercise room at some time so far. If they are right then all go free. If they are wrong then everyone is shot. The prisoners are allowed to confer before being imprisoned, but may not communicate once in prison. (You may assume that the light starts OFF) Can you find an algorithm which garauntees release of the prisoners eventually? How many days do you expect to wait for the prisoners to be released? Find an algorithm which has the smallest number of expected days until the prisoners are released. Do this for every possible number of prisoners.
    Thanks to procrastinating.org
    --
    Pathman, Free (as in GPL) 3D Pac Man
    1. Re:The Prisoners and the Light by roju · · Score: 2

      The way the problem is worded, it's impossible to come up with an expected number of days.

      To quote, "Each day one prisoner is chosen at random [...]"
      If the same prisoner happened to be chosen at random EVERY TIME then the prisoners would never be released. Now, the odds of that happening to infinity are 0, but there is a chance that it could happen until the maximum age of the prisoners. It's even more likely that every prisoner gets randomly selected except for one, until they all die.

      To make it possible, we have to assume that each prisoner will only be picked again after every other prisoner has. Perhaps we just shuffle the prisoners into a random order, and loop it. But then the prisoner can just wait until selected again, and then he'll know. Unless we assume that they're all selected before looping back, but that the prisoners don't know that.

      Is that last condition necessary for solving the problem without making it trivial, or did I make a mistake somewhere?

  9. probably wrong by kix · · Score: 1, Interesting

    well, I am quite sure, that this is the wrong answer, since it is way too simple, but could anybody explain, what exactly is wrong with it:

    ok, as the thing said, first all soldiers are in a default do-nothing state, then the first gets the fire! message, with a counter 0, then increments the counter and passes it to the next soldier and goes to the "wait-reply" state. then the next soldier does the same thing and so on, until the end of the line. now, when the last soldier recieves the message - fire, counter is x, it goes to the state "fire after x time ticks", decrements x and passes it on, the next one (since it is in the wait-reply state, it knows to go into this state) recieves the counter, goes into "fire after x ticks", decrements x and passes it on, until we reach the first soldier, who immediately fires (since x is zero), as do all the others, since their counters run out at the same time..

    and since the message passes the line twice, it should take N-2 ticks, assuming we start counting from the time the first soldier gets the message..

    --
    I am SO cool I can keep meat fresh for a WEEK!!!!
    1. Re:probably wrong by dmorin · · Score: 4, Informative

      Finite state machines are not allowed to have counters, or do conditional logic (you need a Turing machine for that). At least, that is a condition I understood to be correct in the problem. Otherwise you're right, it is a little easy.

    2. Re:probably wrong by Anonymous Coward · · Score: 0

      The counter would have to be represented in the state of each soldier-FSM. But this counter would overflow because the same FSMs must be used for arbitrary line-lengths. If your soldiers can count to 10000, then I ask you to make a line of 10001 soldiers.

    3. Re:probably wrong by spencerogden · · Score: 2

      The problem with this is that these are finitestate machines, and the problem stated that the solution cannot depend on N. So to implement a counter in a FSM you need at least as many states as the number you need to count to. This means your FSMs change depending on N.

    4. Re:probably wrong by Paradise+Pete · · Score: 1
      well, I am quite sure, that this is the wrong answer...the first gets the fire! message, with a counter...

      A quote from the article:

      Please remember that these are finite state machines, so you can't use any methods that involve counting
    5. Re:probably wrong by Dachannien · · Score: 1

      Finite state machines are indeed allowed to have counters, as long as the counters are of finite capacity. (The result is that the FSM becomes incredibly large as it expands to hold enough state/transition information for all the non-counter states times the counter capacity.)

    6. Re:probably wrong by BitterOak · · Score: 2
      well, I am quite sure, that this is the wrong answer, since it is way too simple, but could anybody explain, what exactly is wrong with it:

      Actually, your solution would be quite correct if you knew in advance the maximum number of soldiers that are allowed.

      Contrary to what others have said, you can implement counters and conditional logic in FSMs, but in order for it to be a finite state machine, you must specify in the design of the FSM exactly how many states there are as well as the transition rules. Now each possible value for a counter is a separate state, so they must be enumerated in advance. Your soldiers would have 2k+1 states where k is the maximum value allowed for the counter. There is the initial wait state, plus k states after recieving the first message and waiting to pass it along to the next soldier, plus k decrement states.

      Now, the total number of soldiers must be finite, but unlimited. If you design your soldiers with k counter states, what if there are k+1 soldiers? Then your solution would fail.

      So, if the problem were modified so that the maximum possible number of soldiers were specified in advance, then your solution would be a correct minimum-time solution. But if no such maximum is specified, then the solution must be more complicated.

      --
      If I can be modded down for being a troll, can I be modded up for being an orc, or a balrog?
  10. Surely You're Joking by Tuxinatorium · · Score: 3, Funny

    Mr. Feynman!

  11. Please Mod this up! by Anonymous Coward · · Score: 0

    This link includes everything the poster wanted to know, including the 1966 Waksman solution from "Information and Control", and an even "more efficient" one that uses less states.

  12. Conditional logic by 91degrees · · Score: 1

    So does this mean I also can't do something like "switch to state C if N-1 and N+1 are both in state B, and N is in state A?"

    How does an FSM work then? Can we only trigger a change based on a change?

    1. Re:Conditional logic by Anonymous Coward · · Score: 0

      A FSM is a finite set of states (S) and a mapping from state in time n to state in time n+1. For this problem you need to choose a set of states S and define me(n+1)=fn(left(n), me(n), right(n)) as (S, S, S)->S.

    2. Re:Conditional logic by dmorin · · Score: 4, Insightful
      You can do conditional logic in FSM's (my statement was a little too broad), you just have to plan it out ahead of time. Base it on what you know. The only communication you have with N-1 or N+1 is the pulse they send you. As far as I know, an FSM isn't even allowed to have a state called "Waiting for pulse" which then turns into a "If pulse is type 1 go here, else go here" node. Instead you have to put yourself into "Waiting for pulse type 2" state, and then when a pulse comes in, you have toa ssume that's what you got. So you have to know ahead of time what state to put yourself in, you can't be surprised by anything.

      This is why this is such a good problem -- because a giant FSM has the overlying assumption that there are no unknowns, but the problem definition seems to have an unknown in N. It's not really unknown once the system is running, though. The problem is just to build the smaller pieces in such a way that when stuck together, they work correctly regardless of what N is. That's different from saying "they work correctly *because* they know what N is, or can otherwise predict it."

    3. Re:Conditional logic by Anonymous Coward · · Score: 1, Informative

      A FSM is simply a function which statically maps input state to output state. The reason why this is called pulse or signal is that obviously the state of a FSM can only change if one of its inputs change, thus change can cause further change, which is what you expect from a pulse or signal, but no change can not cause change: A FSM cannot "act" spontaneously.

    4. Re:Conditional logic by DJSpray · · Score: 1

      I'm still personally a little confused about this.

      When I've programmed with FSMs, I've always thought of them as graphs of states (points) and transitions (edges). An input (message pulse, word, signal, whatever) then can trigger a state change, which I've usually implemented via some kind of table. The state change is accomplished by a function; in a useful program the state transition could call an arbitrary list of functions that might involve sending other messages to other state machines, etc., or doing other "stuff" with arbitrary side effects, but as far as the state machine is concerned, you would always just move to either a different state or the same state again.

      So I need a little more info to crack this: to pin down some definitions. Just how restrictive are the rules of this little universe?

      - Can each soldier have a DIFFERENT state machine?

      - Obviously the state machine consists of states and transitions. What I'm hearing from dmorin is that my soldier can't distinguish between different messages. In other words, when it gets a "hut!" message it always moves on to the next state. It can't distinguish between hearing the general shout "fire" and some other message like "put your gun away and go home."

      - Time is passing in discrete intervals, say, seconds, but can the "tick" of some global clock also be a message? or is the only message each soldier can hear just the generic "hut!" message from the general at one end or the soldiers on either side?

      - Maybe this is needlessly picky, but would "firing" count as a state? The way I usually think of state machines, "fire" would be what happened when the state machine got a message that triggered the transition between "waiting to fire" and "fired." And "speaking" (issuing a "hut!" message to the soldier on the left and right would also be a transition.

      - Lastly, can the soldier "aim" (distinguish) which soldier he yells "hut!" to? Or will both the soldier on the left and right "hear" him?

      Paul

    5. Re:Conditional logic by Anonymous Coward · · Score: 1, Informative

      - Can each soldier have a DIFFERENT state machine?

      No. This isn't really a restriction, because you could simply encode the different state machines on different subsets of the state set.

      - Obviously the state machine consists of states and transitions. What I'm hearing from dmorin is that my soldier can't distinguish between different messages. In other words, when it gets a "hut!" message it always moves on to the next state. It can't distinguish between hearing the general shout "fire" and some other message like "put your gun away and go home."

      The soldier looks at his own state and the states of his direct neighbors and then chooses his next state. The "messages" are state changes of neighbors. You can also code it so that a single soldier oscillates: *a*->b, *b*->c (* for arbitrary states of the neighbors).

      - Time is passing in discrete intervals, say, seconds, but can the "tick" of some global clock also be a message? or is the only message each soldier can hear just the generic "hut!" message from the general at one end or the soldiers on either side?

      There is no central time information or counter. All FSMs decide on their next state at the same time, based on their current state. If the soldiers need to wait a certain number of time intervals, they have to count themselves.

      - Maybe this is needlessly picky, but would "firing" count as a state? The way I usually think of state machines, "fire" would be what happened when the state machine got a message that triggered the transition between "waiting to fire" and "fired." And "speaking" (issuing a "hut!" message to the soldier on the left and right would also be a transition.

      Firing in this context is when an FSM enters a special state. The task is to create the FSM so that all instances enter one state at the same time and no instance enters this state before that.

      - Lastly, can the soldier "aim" (distinguish) which soldier he yells "hut!" to? Or will both the soldier on the left and right "hear" him?

      If you want to think of it in communication terms: At each time intervall, every soldier tells his direct neighbors his own state. That's it.

    6. Re:Conditional logic by Dachannien · · Score: 1

      To answer your questions:

      Each soldier can view the state of its two adjacent neighbors, and then those states are used to look in the transition table to determine the soldier's state for the next time step.

      Time's only effect is to cause the system to advance to the next time step; i.e., at a clock tick, each soldier examines the state of its two neighbors, looks up the proper transition in its transition table, and changes state accordingly.

      Yes, "fire" is a state, and is generally regarded as required to be a unique state. Transitions have no effect on neighbors until the next clock tick (when the neighbors examine their neighbors' states), so "speaking" isn't a transition. Technically, "speaking" doesn't even occur.

      The soldiers to the left and right of a particular soldier are the only ones who can examine the state of that soldier. They do so only at a clock tick.

      Hope this helps!

  13. Know who could solve this? by dmorin · · Score: 1, Offtopic
    That chick from Stephenson's "Diamond Age". What the hell was her name again? Seems like this would be right up her alley.

    :)

  14. try this. by Anonymous Coward · · Score: 0

    first solder yells out 0, next yells out 1, ... etc.. to N-1... and letting t = their number. At the end, each soldier yells, fire in t, back down the line. Effectively each soldier stores his own countdown on the first pass at the count, when the count comes back his way, he knows to fire in t seconds. This syncs them and solves it in 2n-1 (I think...). How's that?

    1. Re:try this. by Anonymous Coward · · Score: 0

      How's that? Wrong (not a FSM definded independently of N).

  15. Think of it as a table. by Xner · · Score: 1

    Think of it as a table that gives an output state at time t+1 as a function of the input states at time t.

    --
    Pathman, Free (as in GPL) 3D Pac Man
  16. Solutions by cdrudge · · Score: 5, Informative

    For those people wondering about what the 3n solution is, here is a page that describes it: Firing Squad Solution. A decent diagram as to the firing order is here. The page also links to a description about the 2N-2 solution, but claims that it is buggy and only works in certian Ns, not for all values of N.

  17. Okay, thanks guys by 91degrees · · Score: 1

    I think I get the idea.

    So am I corrent if I say my above example is a valid state transition?

    1. Re:Okay, thanks guys by Anonymous Coward · · Score: 0

      The example is a valid state transition, but the transition you gave does not contradict that only change can cause change. The FSM only acts on this rule if the previous state wasn't BAB, because if it was, the current state would be *C* and the rule wouldn't apply.

  18. Chick? by i+chose+quality · · Score: 1

    Nell, dammit... ;-)

    How can you dare not remembering Princess Nell?

    --
    the computer is online
    i am not at it
    what a waste of ressources
  19. Links to several solutions by Linux_ho · · Score: 5, Informative

    Can be found on this page

    --
    include $sig;
    1;
  20. I have a solution... by i_am_nitrogen · · Score: 4, Funny

    But unfortunately it is too large to be contained in this margin.

    1. Re:I have a solution... by StandardDeviant · · Score: 2

      I think I have developed a more concise representation using a perl one-liner, but it is too noisy to be accepted by the lameness filter.




      ;-)

  21. Hmm, I tried by Anonymous Coward · · Score: 0

    I tried with a N=8 set. I don't fully understand what a FSM 'can do', based on what I thought it meant, all of them fired in T=14. Which is coincidentally 2N-2.
    Can anyone give a link to what exactly a FSM is? I don't really understand what they can react to. I had set it up almost 'conditional', but based on a table that listed all possible "pulse" types from both directions. Like if at T=0 N1 and N3 are both "pulse type 6", then at T=1 N2 emits "pulse type 7" and so on...

    1. Re:Hmm, I tried by Anonymous Coward · · Score: 0

      Your understanding of an FSM is about right. The hard part of the problem is that you have to design one FSM which solves the problem for arbitrary line-lengths. This means that the number of possible states of each FSM is fixed. You can not add more states when the line gets longer.

    2. Re:Hmm, I tried by grayrest · · Score: 1

      I'm a Computer Engineering student, so I don't deal with CS theory too much, but my understainding is that a FSM is a conceptual machine that exists in several behaviors or states. When a specific input is given the machine moves from one state to another. A traditional (and simple) example is a stop light which moves (here in the US) from green to yellow to red and then back to green. The input that causes state to switch is a given amount of time passing, the timer isn't part of the FSM but it's output is.

      That's my understanding anyway. My first idea when reading this problem was to have a soldier as a FSM with N+1 states (a state for each soldier but not the last, a quiescent state, and a fire state) the first soldier recieves the instruction from the general (to the left) and gets set to state N-1, the next second the soldier to the right sees he's in N-1 and gets in state N-2. All the N-1 states if recieving no input move n-- for all inputs checking every second, the 1 state (last state in the N chain) decrements to fire. This is essentially a counter and the last guy will get the fire state immediately, all will hit the fire state at the same time. It's done in N seconds (not 2N-2) so obviously my understanding of FSMs isn't in line with the version being used here.

    3. Re:Hmm, I tried by Anonymous Coward · · Score: 0

      The FSMs are a finite set of transitions in a finite set of states. This problem also requires that the problem size ("number of soldiers") must not influence the definition of a single FSM. You have to decide on the size of the state-set and the transition rules without knowing how many soldiers will be lined up. No counting, because you don't know how many fingers you will need.

    4. Re:Hmm, I tried by Anonymous Coward · · Score: 0

      Ah, right, that screws my method over pretty much., because my method uses N+2 states!

    5. Re:Hmm, I tried by GigsVT · · Score: 1

      I'm a Computer Engineering student,

      Surely you realize digital logic is really just a FSM in most cases. I'm surprised you have never studied it that way.

      --
      I've had enough abrasive sigs. Kittens are cute and fuzzy.
    6. Re:Hmm, I tried by dubious9 · · Score: 2

      Reread the problem. The solution has to be independant of N. The same "soldier" should work wether there is 100 or 1000 or them. Thus you can't have a counter dependant on N. BTW where do you go that you don't study FSMs in digital logic, or design classes?

      --
      Why, o why must the sky fall when I've learned to fly?
    7. Re:Hmm, I tried by bethenco · · Score: 1

      That is surprising that they don't teach you digital logic in terms of FSM's (or DFA's). I suppose combinational logic isn't much like FSM's, but sequential logic is nothing but FSM's. In any case, you seem to have a nice clear understanding of what an FSM is (unlike some of the people who have posted (I'm not pointing out anyone in particular)).

      This is tough problem. So far, I haven't been able to come up with any solution independent of N, much less one that finishes within 2N - 2 steps.

      I refuse to lookup a solution. I will try to make one myself. It's kind of odd; I couldn't care less about most of the social ills of the world, and yet mathematical games like this one really inspire me.

  22. mutlithread it! by Anonymous Coward · · Score: 0
    It is possible to prove that the soldiers cannot fire earlier than T=2N-2 since there would not be enough time for all the required information to move around.


    Why not put the general in the middle of the line of soldiers (ie - N becomes 2 lines of N/2)?

  23. +1 Funny by Anonymous Coward · · Score: 0

    Come on you humorless (or clueless) moderators. Mod this man up!

  24. answer for sure by Anonymous Coward · · Score: 0

    Simple rule
    the state of your neighbors change your state if they are 1 and you can only see the state of your neighbour fomr the time before (says so in the rules)

    therefore when teh general yiells fire
    the first soldier turns into a 1
    =1000

    the second second unit 1 is still 1 and unit 2 since unit 1 was at 1 in second 1 turns into 1
    =1100

    the rest is logic try to follow it with these
    =0110
    =1011
    =1001
    =1111

    4 soldiers 6 secs 2n-2

    1. Re:answer for sure by Anonymous Coward · · Score: 0

      and if N=5?

  25. The relationship between FSMs and CAs by LionMage · · Score: 3, Informative

    I did my Bachelor's Thesis on cellular automata and how they can be used to model physical systems. While it's true that any cell's neighbors can provide inputs to a cell's finite state machine, the "output states" can be anything. You aren't limited to a cell being "alive" or "dead." In many CA programs, a given cell's state is often represented by color.

    I've seen many 3- and 4-state CA systems that have been simulated. I've also seen many CA systems with widely divergent definitions of what a "neighbor" is. (The most common cases are where the neighbor is a cell adjacent on one of the four cardinal directions, or where the neighbor is a cell on one of the eight adjacent squares. This assumes a rectilinear or chessboard space.)

    Another error in your description is the statement that cellular automata are a bunch of specialized finite state machines. This implies that each cell could be running a different "program." The truth is, most if not all CA systems run the same "program" on every cell, in lockstep. In other words, cellular automata are a special case of SIMD processing. (I suppose it's possible to construct a MIMD example of CA, but then you run into the problem of how you assign your initial conditions -- i.e., not only do you need to assign an initial state to each cell, but you also need to assign a "program" to each cell.)

    1. Re:The relationship between FSMs and CAs by Mr+Z · · Score: 1

      Thanks for the clarifications! I guess from your description, the Feynman's FSM Firing Squad can be considered a 1-D array of cellular automata, correct?

      BTW, by "specialized", I meant that the notion of FSM embodied in a cellular automata is specialized over the more general notion of a state machine -- that is, cellular automata are a specialized form of FSM. I didn't mean to imply by the word "specialized" that different cells have different programs--although, you could provide for that in a single program by providing disconnected subsets of the states in your single "program" (which also solves the "MIMD initialization problem" you mention offhand).

      Here's an example of what I mean by disconnected subsets. Suppose each cell has 6 states labelled A through F. Suppose A, B and C all have rules for transitioning among A, B and C. Similarly, suppose D, E, F have rules for transitioning among D, E and F. You can't reach A, B, or C if you start in D, E, or F, and vice-versa. If all your cells have programs of this form, then which subprogram a given cell 'runs' depends only on which subset of the allowed statespace you allocate that cell's starting state from.

      --Joe
  26. Wow! by Hubert_Shrump · · Score: 3, Funny

    I didn't know we could also ask Slashdot stuff that may not even have an answer! This is awesome!

    Do you feel the community, people? Because I am totally feeling it right now.

    There are so many things I'd like to know...

    (waits for the inevitible)

    --
    Keep your packets off my GNU/Girlfriend!
    1. Re:Wow! by A55M0NKEY · · Score: 1

      We can ask anything and when we stop asking our questions will be answered.

      --

      Eat at Joe's.

  27. Feeling short by redtail1 · · Score: 4, Funny

    To loosely paraphrase Douglas Adams, I love listening to the sound of stories like these as they whoosh over my head.

  28. That's tricky by 91degrees · · Score: 1

    The best solution I can come up with is this - grouping days into batches of 100

    If prisoner X has entered the room previously on this batch of days, he switches the light on. After the 100th day, if the light is off, the prisoner states that all people have entered the room. Otherwise turn the light off.

    This is arather inefficient thouygh. It relies on all 100 prisoners being randomly selected once in a batch of 100 days. We could probable find some optimisations to this solution though.

  29. Solved by Anonymous Coward · · Score: 0


    http://www.xdr.com/dash/feynman.html

    1. Re:Solved by Anonymous Coward · · Score: 0

      No. Your solution has a number of states proportional to the number of soldiers. The hard part is to do it in a fixed number of states that doesn't depend on the number of soldiers, thus the name "finite state machine."

    2. Re:Solved by Anonymous Coward · · Score: 0

      Oh. I thought he said "Infinite state machine."

  30. thoughts by itzdandy · · Score: 1

    realistically - the general would of course broadcast his order and all soldiers would immediately fire upon hearing the order, so total time til fire would be 1+ execution time, assuming that all soldiers could hear the general and also implying that the speed of sound is not considered a factor.

    in fact, their would be absolutely no way to get a simple state machine to function in this manner, or to fire simultaniously, as it would have either a 0(no function or no action) or a 1(action) state, theirfor the general would be 0 at start, then would change to 1 for fire. the first soldier would then fire as he went to state 1, as a simple state machine has no logic to decide to "fire" or to "pass it on". so by this reasoning, the total time to have all soldiers fire would be N+1, N for the number of soldiers as the second soldier would of coarse fire as a result of the first soldier fireing and etc, and the general would have a time of 1 to give the order.

    N+1.

    now if the soldiers had logic to decide to "ass it on" AND memory and logic to calculate time decimation and N, then 2N-2 would be the only functional solution. this also assumes that not only the general, but the last soldier have different capabilities from the rest of the soldiers, as the last solider must calculate the total and also know to reverse the movement of data back towards the general.

    1. Re:thoughts by Anonymous Coward · · Score: 0

      Read the other comments, dumbass. Perhaps that would prevent you from writing such a load of crap, assuming YOU have enough logic and memory to comprehend what an FSM is.

    2. Re:thoughts by dubious9 · · Score: 2

      as it would have either a 0(no function or no action) or a 1(action) state,

      Why do you assume that there are only two states in the state machine?

      N+1, N for the number of soldiers as the second soldier would of coarse fire as a result of the first soldier fireing and etc, and the general would have a time of 1 to give the order.

      The problem stipulates that all fire at the same time.

      now if the soldiers had logic to decide to "ass it on" AND memory and logic to calculate time decimation and N, then 2N-2

      FSMs only have if-then relationships. They don't have any "memory" to store anything, they only tell you what the next state is going to be based on some input. Nothing about the FSM changes during runtime, thus they can't store arbitrary values.

      Also, I don't follow your logic for saying 2N-2 would be the only solution. Do you actually understand the problem?

      --
      Why, o why must the sky fall when I've learned to fly?
  31. Also probably wrong... by podperson · · Score: 1

    That was my impression too.

    As for finite states, well you can turn this into a state table if you want to (a large number of states to be sure, but not a very large number of bits) but you can only cope with a finite number of soldiers.

    http://xraysgi.ims.uconn.edu/fsquad/firing-solut io n.html

    Having read the state tables for the alleged solutions I am clueless as to how they're supposed to work. A synopsis of the strategy being adopted would be very helpful.

    It seems to me that the initial message to fire MUST take N ticks to propagate to the Nth soldier. The message that the final soldier has been located MUST take N ticks to propagate back to the first soldier. Hence a theoretical limit of 2N + some number.

    Exactly how you store the intermediate information ("wait, you'll get another message soon!") is really just a technical detail for folks who want to program a formal finite state machine (I think they live near people with infinitely long spools of tape) which can't store integers. The rest of us would use your (or a similar) solution and get on with our lives.

  32. As a student in about to take a CompE final; by Anonymous Coward · · Score: 0

    All night tonight I'm going to dream that this will be on the test. I'll tell you all if I wake up with an optimal solution.

  33. I can do it in N (or N+1) by Anonymous Coward · · Score: 0

    Within those constraints.

  34. I FAIL IT! by Anonymous Coward · · Score: 0

    Alas, I was not able to come up with the optimal solution.

    I FAIL IT!

  35. look in the margins by jumbie · · Score: 0


    r*1+a*7

    important proof here

  36. IN SOVIET RUSSIA by jumbie · · Score: 0

    the wrong space deletes me!

    curse my clicky keyboard!

  37. solution in 1 cycle. by Anonymous Coward · · Score: 0

    IQ in binary is on the right track. Nowhere does Feynman say that the line must be straight. Even if you assume that the line is in 1 dimensional space, the solution can be an N dimensional mapping. So, for example, the soldiers might be on the surface of a cylinder, so that the general is next to both ends of the line, simultaneously. If we scale up to N dimensions, then the general can be next to all soldiers simultaneously. Thus, the problem is solved with the minimal time lag of 1 tick of the clock. This means that the solutions that we have seen, are simply the most efficient mappings of N dimensions to 1 dimension. -Bruce I I tried logging in, but slashdot crashed Mozilla 1.2.1

  38. duh by Anonymous Coward · · Score: 0

    Duh. After the general gives the order to fire, the first soldier fires in the first time period. In the second time period, the second soldier fires. In that same time period, the second, the first soldier fires again. Each soldier fires in succession. Each soldier keeps firing in every time period. When the the last soldier fires, all the soldiers will be firing simultaneously. Thus, the answer is N.