--- a/marking/knight3b_test.scala Wed Jan 11 12:18:34 2017 +0000
+++ b/marking/knight3b_test.scala Wed Jan 11 14:42:46 2017 +0000
@@ -25,13 +25,12 @@
if (legal_moves_urban(dim, p, y).contains(x)) correct_urban(dim)(y::p) else false
}
-def correct_closed_urban(dim: Int)(path: Path): Boolean =
- correct_urban(dim)(path) && moves_urban(path.head).contains(path.last)
-
+def correct_closed_urban(dim: Int)(p: Path) =
+ correct_urban(6)(p) && moves_urban(p.head).contains(p.last)
lazy val f = Future {
- val tsc = first_closed_tour_heuristic(6, List(List((3, 3)))).get
+ val tsc = first_closed_tour_heuristic(6, List((3, 3))).get
assert(correct_closed_urban(6)(tsc) == true)
}
--- a/marking/mark02 Wed Jan 11 12:18:34 2017 +0000
+++ b/marking/mark02 Wed Jan 11 14:42:46 2017 +0000
@@ -12,7 +12,7 @@
echo "" >> $out
function scala_vars {
- (egrep 'var|return|ListBuffer|mutable' "$1" 2> /dev/null 1> /dev/null)
+ (egrep '\bvar\b|\breturn\b|ListBuffer|mutable' "$1" 2> /dev/null 1> /dev/null)
}
@@ -189,38 +189,6 @@
fi
-# knights3: var, comments test
-#
-#echo "knight3.scala does not contain vars, returns etc?" | tee -a $out
-
-#if (scala_vars knight3.scala)
-#then
-# echo " --> fail" | tee -a $out
-# tsts0=$(( 1 ))
-#else
-# echo " --> success" | tee -a $out
-# tsts0=$(( 0 ))
-#fi
-
-
-# compilation test
-#if [ $tsts0 -eq 0 ]
-#then
-# echo "knight3.scala runs?" | tee -a $out
-#
-# if (scala_compile knight3.scala.bak)
-# then
-# echo " --> success" | tee -a $out
-# tsts1=$(( 0 ))
-# else
-# echo " --> scala did not run knight3.scala" | tee -a $out
-# tsts1=$(( 1 ))
-# fi
-#else
-# tsts1=$(( 1 ))
-#fi
-
-
## final marks
-echo "Overall mark for CW 2, Part 1 " | tee -a $out
+echo "Overall mark for CW 7, Part 1 " | tee -a $out
echo "$marks" | tee -a $out
--- a/marking/mark02b Wed Jan 11 12:18:34 2017 +0000
+++ b/marking/mark02b Wed Jan 11 14:42:46 2017 +0000
@@ -26,7 +26,7 @@
# functional tests
function scala_assert {
- (scala -i "$1" "$2" -e "") # 2> /dev/null 1> /dev/null)
+ (scala -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
}
@@ -65,11 +65,12 @@
tsts1=$(( 1 ))
fi
+
if [ $tsts1 -eq 0 ]
then
- echo " ordered_moves(8, List((3,4), (3,2)), (1, 3)) == List((0,1), (0,5), (2,1), (2,5))" | tee -a $out
- echo " ordered_moves(8, List((4,0)), (0,0)) == List((2,1), (1,2))" | tee -a $out
- echo " ordered_moves(8, List((0,4)), (0,0)) == List((1,2), (2,1))" | tee -a $out
+ echo " ordered_moves(8, List((3,4), (3,2)), (1,3)) == (0,1), (0,5), (2,1), (2,5)" | tee -a $out
+ echo " ordered_moves(8, List((4,0)), (0,0)) == (2,1), (1,2)" | tee -a $out
+ echo " ordered_moves(8, List((0,4)), (0,0)) == (1,2), (2,1)" | tee -a $out
if (scala_assert "knight3.scala.bak" "../../../marking/knight3a_test.scala")
then
@@ -82,7 +83,7 @@
if [ $tsts1 -eq 0 ]
then
- echo " first_closed_tour_heuristic(6, List((3, 3))) found and ok?" | tee -a $out
+ echo " first_closed_tour_heuristic(6, List((3, 3))) is ok?" | tee -a $out
if (scala_assert "knight3.scala.bak" "../../../marking/knight3b_test.scala")
then
@@ -93,20 +94,6 @@
fi
fi
-if [ $tsts1 -eq 0 ]
-then
- echo " first_tour_heuristic(8, List((0,0))) found and ok?" | tee -a $out
- echo " first_tour_heuristic(50, List((0,0))) found and ok?" | tee -a $out
-
- if (scala_assert "knight3.scala.bak" "../../../marking/knight3c_test.scala")
- then
- echo " --> success" | tee -a $out
- marks=$(( marks + 1 ))
- else
- echo " --> test failed" | tee -a $out
- fi
-fi
-
## final marks
echo "Overall mark for CW 7, Part 2" | tee -a $out
--- a/progs/re_sol.scala Wed Jan 11 12:18:34 2017 +0000
+++ b/progs/re_sol.scala Wed Jan 11 14:42:46 2017 +0000
@@ -140,16 +140,13 @@
splits("bb")
first(r, splits("bb"))
replace(r, "abb", "c")
-replace(r, "abb", "")
-replace("aa".% | "bb", "abba" , "")
+val rl = SEQ("a",SEQ("b", "c"))
+val rk = SEQ(SEQ("a", "b"), "c")
-val r = SEQ("a",SEQ("b", "c"))
-val r = SEQ(SEQ("a", "b"), "c")
-
-val rm = der('a', r)
-der('b', r)
-der('c', r)
+val rm = der('a', rk)
+der('b', rk)
+der('c', rk)
der('a', rm)
val rn = der('b', rm)
@@ -163,11 +160,6 @@
// the supposedly 'evil' regular expression (a*)* b
val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))
-
-ders(List.fill(5)('a') , EVIL)
-ders(List.fill(1)('b') , EVIL)
-matcher(EVIL, "a" * 15 ++ "b")
-matcher(EVIL, "b")
println(matcher(EVIL, "a" * 1000 ++ "b"))
println(matcher(EVIL, "a" * 1000))