marking1/collatz_test2.scala
author Christian Urban <urbanc@in.tum.de>
Wed, 24 Jul 2019 15:18:44 +0100
changeset 267 9e0216756771
parent 212 4bda49ec24da
child 281 87b9e3e2c1a7
permissions -rw-r--r--
updated myassert workaround
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
267
9e0216756771 updated myassert workaround
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
     1
def myassert(cond : => Boolean) = {
9e0216756771 updated myassert workaround
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
     2
  try {
9e0216756771 updated myassert workaround
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
     3
    assert(cond)
9e0216756771 updated myassert workaround
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
     4
  } catch { 
9e0216756771 updated myassert workaround
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
     5
    case _ : Throwable => System.exit(1)
9e0216756771 updated myassert workaround
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
     6
  }
9e0216756771 updated myassert workaround
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
     7
}
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
267
9e0216756771 updated myassert workaround
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
     9
myassert(collatz_max(10) == (19, 9))
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
267
9e0216756771 updated myassert workaround
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
    11
myassert(collatz_max(100) == (118, 97))
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
267
9e0216756771 updated myassert workaround
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
    13
myassert(collatz_max(1000) == (178, 871))
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
267
9e0216756771 updated myassert workaround
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
    15
myassert(collatz_max(10000) == (261, 6171))
9e0216756771 updated myassert workaround
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
    16
9e0216756771 updated myassert workaround
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
    17
myassert(collatz_max(100000) == (350, 77031))
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
267
9e0216756771 updated myassert workaround
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
    19
myassert(collatz_max(1000000) == (524, 837799))
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
267
9e0216756771 updated myassert workaround
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
    21
myassert(collatz_max(2) == (1, 2))
9e0216756771 updated myassert workaround
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
    22
9e0216756771 updated myassert workaround
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
    23
myassert(collatz_max(77000) == (339, 52527))