Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Two Chickens Riddle
#1
Two chickens are placed at different points on a straight line of infinite length. When they are first placed down, they each lay down an egg to mark their starting points.


You must program each chicken to ensure that the chickens will eventually crash into each other. A program can consist of the following four instructions:
  • Go left one space

  • Go right one space

  • Skip the next instruction if there is egg in my current spot

  • Go to a label

Quote:[Note that a "label" is a name that refers to a line of your code. For example, you could label the third line of your program "surveying". Then, the instruction "goto surveying" would jump to line 3 and start executing from there on the next cycle.]




A chicken will carry out one instruction per second. Both chickens need not have the same program. Note that you won't know ahead of time which chicken is on the left and which is on the right.

GL&HF, Post your solutions here
Code:
{
 "name" : "Federico",
 "version" : "2.0",
 "Age" : "23",
 "description" : "Ambitious and eclectic person"
}

  


Forum Jump:


Users browsing this thread:
1 Guest(s)