marking5/bf_test4.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Wed, 02 Nov 2022 21:49:42 +0000
changeset 430 274c865b3878
parent 286 5c57c407e27b
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
286
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
     1
import CW10a._
253
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
assert(run("[-]", Map(0 -> 100)) == Map(0 -> 0))
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
assert(run("[->+<]", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10))
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
assert(run("[>>+>>+<<<<-]", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42))
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
val hw_urban = """+++++[->++++++++++<]>--<+++[->>++++++++++
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
                  <<]>>++<<----------[+>.>.<+<]"""
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
assert(run(hw_urban) == Map(0 -> 0, 1 -> 58, 2 -> 32))
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
val hw_urban1 = """++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
                   +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++."""
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
assert(run(hw_urban1) == Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87))