Welcome to BrainDen.com - Brain Teasers Forum
|Welcome to BrainDen.com - Brain Teasers Forum. Like most online communities you must register to post in our community, but don't worry this is a simple free process. To be a part of BrainDen Forums you may create a new account or sign in if you already have an account.
As a member you could start new topics, reply to others, subscribe to topics/forums to get automatic updates, get your own profile and make new friends.
Of course, you can also enjoy our collection of amazing optical illusions and cool math games.
If you like our site, you may support us by simply clicking Google "+1" or Facebook "Like" buttons at the top.
If you have a website, we would appreciate a little link to BrainDen.
Thanks and enjoy the Den :-)
Guest Message by DevFuse
Robots on an infinite number line.
2 replies to this topic
Posted 20 November 2013 - 06:15 PM
Two robots are parachuted onto a spot of a discrete number line that stretches infinitely in either direction. They are an unknown distance apart. Where they land, they drop their parachute. They begin executing the same set of instructions at the same time. Unfortunately, these are not very good robots, and they only understand commands in character form. There is only room for 10 instructions.
Possible instructions are as follows:
L: Move left one space
R: Move right one space
S: Skip the next instruction if and only if there is a parachute at my feet
0-9: Move to this position in the instructions (If the instructions are LRS1, the 1 would move the robot back to the 'R')
Every step takes the same amount of time to execute, including parachute skips and moving through the instructions. There is no variable storage. The robots begin executing from step 0. What set of instructions will result in the two robots ultimately finding each other on the infinite number line in every case? There are multiple possible answers.
Posted 20 November 2013 - 07:26 PM
Spoiler for Fun little programming problem...
Edited by Pickett, 20 November 2013 - 07:28 PM.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users