main_templates4/knight3.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Fri, 05 Nov 2021 17:20:01 +0000
changeset 397 085fefce672e
parent 347 4de31fdc0d67
child 428 cdfa6a293453
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
397
085fefce672e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 347
diff changeset
     4
object M4c {
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
347
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 296
diff changeset
    24
def tour_on_mega_board(dim: Int, path: Path) : Option[Path] = ???
214
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
296
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 214
diff changeset
    26
}