templates3/knight3.scala
author Christian Urban <urbanc@in.tum.de>
Tue, 05 Nov 2019 00:41:02 +0000
changeset 313 dea46bdfd648
parent 296 12dc251fc47e
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
214
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
// Finding a single tour on a "mega" board
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
//=========================================
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
296
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 214
diff changeset
     4
object CW8c {
214
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
// !!! Copy any function you need from file knight1.scala !!!
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
// !!! or knight2.scala                                   !!! 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
//
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
// If you need any auxiliary function, feel free to 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
// implement it, but do not make any changes to the
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
// templates below.
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
type Pos = (Int, Int)    // a position on a chessboard 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
type Path = List[Pos]    // a path...a list of positions
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
//(9) Implement a function that searches for a 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
//    you have to be careful to write a tail-recursive version as this 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
//    function will be called with dimensions of up to 70 * 70
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
//    and starting field (0, 0). It has to produce a solution within
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
//    30 seconds.
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
//def tour_on_mega_board(dim: Int, path: Path) : Option[Path] = ...
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
296
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 214
diff changeset
    26
}