[Tutor] Interview questions in python and wxpython
Ricardo Aráoz
ricaraoz at gmail.com
Sun Jan 20 00:14:30 CET 2008
bob gailer wrote:
> Varsha Purohit wrote:
>> Hello All,
>> I have an interview in python program development. Can i know
>> some interview questions in python ? If you know any website where i
>> can refer that would be helpful.
> My first engineering job interview went thus:
>
> "We need someone to help us design antennas."
>
> "I know nothing about antennas."
>
> "Here's your desk and books. Start reading. You have 3 weeks to get up
> to speed."
>
>
> An associate of mine interviewing at MS was given the a"lien railroad
> car" problem to check out his analytical skills and problem solving
> techniques. My version of this problem is:
>
> Two railroad cars drop from space. Parachutes assist them to land at
> random points on a linear railroad track of infinite length. The chutes
> detach and lay next to the track beside the cars.
>
> Each car is equipped with a rudimentary computer that can move the car
> and notice when it is next to a parachute. Both cars have the same
> program. The program starts once the parachute has detached. There is no
> communication between cars.
>
> Each program line begins with an optional label followed by a command.
> Commands are:
>
> Move one car's length left
> Move one car's length right
> Do nothing
> Goto label
> If car is next to a parachute Goto label
>
> Each car will respond to move commands, and can tell when it is next to
> a parachute. Moving one car's length takes it out of parachute observing
> range.
>
> Your mission is to write a program that will run (independently of
> course) on both computers. The goal is to get the cars to meet. We don't
> care what happens after that.
>
> Your meta-mission is to propose ideas, state assumptions and ask questions.
>
> I request of any of us who wants to tackle this to not reveal the
> solution for a while so some discussion can take place.
Ok, I'll bite.
First, the instructions make no sense. There is no left and right! In a
railroad there is forward and backwards, and these are relative to the
directions the cars dropped at which I assume will be random. So "move
fwd" has the same meaning as "move bck" as there is no common reference
system (at least you mentioned none).
Anyway the program is obvious:
label1
Move one car's length fwd
If car is next to a parachute Goto label2
do nothing
goto label1
label2
Move one car's length fwd
goto label2
This will give you 75% probability that the cars meet (they will never
meet if they land facing opposite ways).
More information about the Tutor
mailing list