Author | Message |
---|---|
rabbott
Posts: 1649
|
Posted 20:36 Feb 11, 2014 |
Thanks again to Amata for send me my files! Regarding the SpaceShip race problem, which we talked about Monday, I like the insight underlying Sherry's solution. It isn't necessary to propagate the SpaceShips; all one needs are the times when the passings occur. Rather than look through all the times, though, one can just look at the pairs of SpaceShips that will pass each other and compute the times of passings. def race(ships: Vector[(Int, Int)]): Seq[(Double, Int, Int)] = { One of the things that I like about this solution is that it took multiple minds. This also uses Jeff's trick to zipWithIndex and than increment the index to get the ship id.
Last edited by rabbott at
20:54 Feb 11, 2014.
|