samples.tutorials.to_sort
Class U2planning

java.lang.Object
  extended by samples.tutorials.PatternExample
      extended by samples.tutorials.to_sort.U2planning
All Implemented Interfaces:
Example

public class U2planning
extends PatternExample

benchmark proposed by Michel Lemaitre.

The U2 problem

"U2" has a Christmas concert that starts in 17 minutes and they must all cross a bridge to get there. All four men begin on the same side of the bridge. You must help them across to the other side. It is night. There is one flashlight. A maximum of two people can cross at one time. Any party who crosses, either 1 or 2 people, must have the flashlight with them. The flashlight must be walked back and forth, it cannot be thrown, etc. Each band member walks at a different speed. A pair must walk together at the rate of the slower man's pace:

For example: if Bono and Larry walk across first, 10 minutes have elapsed when they get to the other side of the bridge. If Larry then returns with the flashlight, a total of 20 minutes have passed and you have failed the mission. Notes: There is no trick behind this. It is the simple movement of resources in the appropriate order. There are two known answers to this problem. This is based on a question Microsoft gives to all prospective employees.
Note: Microsoft expects you to answer this question in under 5 minutes! Good Luck! REMEMBER - all the parameters you need to solve the problem are given to you! That means all 4 guys ARE AT THE OTHER SIDE in 17 minutes. 2 guys at a time MAX on the bridge at any time AND they HAVE to have the ONE flashlight with them.


Nested Class Summary
static class U2planning.Person
           
 
Field Summary
protected  U2planning.Person adam
           
protected  U2planning.Person bono
           
protected  U2planning.Person edge
           
protected  U2planning.Person flashlight
           
protected  U2planning.Person larry
           
protected  U2planning.Person[] persons
           
 
Fields inherited from class samples.tutorials.PatternExample
model, solver
 
Fields inherited from interface samples.tutorials.Example
LOGGER
 
Constructor Summary
U2planning()
           
 
Method Summary
 void buildModel()
           
 void buildSolver()
           
static void main(String[] args)
           
 void prettyOut()
           
 void solve()
           
 
Methods inherited from class samples.tutorials.PatternExample
execute, execute, printDescription, readArgs
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bono

protected U2planning.Person bono

edge

protected U2planning.Person edge

adam

protected U2planning.Person adam

larry

protected U2planning.Person larry

flashlight

protected U2planning.Person flashlight

persons

protected U2planning.Person[] persons
Constructor Detail

U2planning

public U2planning()
Method Detail

buildModel

public void buildModel()
Specified by:
buildModel in class PatternExample

buildSolver

public void buildSolver()
Specified by:
buildSolver in class PatternExample

solve

public void solve()
Specified by:
solve in class PatternExample

prettyOut

public void prettyOut()
Specified by:
prettyOut in class PatternExample

main

public static void main(String[] args)


Copyright © 2012. All Rights Reserved.