main_marking4/knight1_test3a.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Sat, 11 Mar 2023 22:01:53 +0000
changeset 463 0315d9983cd0
parent 424 daf561a83ba6
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 386
diff changeset
     1
import M4a._
386
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     2
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     3
def count_all_tours_urban(dim: Int) = {
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     4
  for (i <- (0 until dim).toList; 
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     5
       j <- (0 until dim).toList) yield count_tours(dim, List((i, j)))
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     6
}
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     7
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
     8
import scala.concurrent._
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
     9
import scala.concurrent.duration._
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    10
import ExecutionContext.Implicits.global
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    11
import scala.language.postfixOps 
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    12
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    13
lazy val f = Future {
386
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    14
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    15
assert(count_all_tours_urban(1) == List(1))
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    16
assert(count_all_tours_urban(2) == List(0, 0, 0, 0))
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    17
assert(count_all_tours_urban(3) == List(0, 0, 0, 0, 0, 0, 0, 0, 0))
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    18
assert(count_all_tours_urban(4) == List(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    19
}
386
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    20
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    21
Await.result(f, 32 second)
386
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    22