aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--csci1913/lab1/lab1_strap012.py66
-rw-r--r--math2373/lab2.txt4
2 files changed, 67 insertions, 3 deletions
diff --git a/csci1913/lab1/lab1_strap012.py b/csci1913/lab1/lab1_strap012.py
new file mode 100644
index 0000000..43fd8ae
--- /dev/null
+++ b/csci1913/lab1/lab1_strap012.py
@@ -0,0 +1,66 @@
+def left(exp):
+ return exp[0]
+def op(exp):
+ return exp[1]
+def right(exp):
+ return exp[2]
+def isInside(var, e):
+ if left(e)==var or right(e)==var:
+ return True
+ else:
+ return False
+
+
+
+
+
+#
+# TESTS. Test the equation solver for CSci 1913 Lab 1.
+#
+# James Moen
+# 10 Sep 18
+#
+# Every test is followed by a comment which shows what must be printed if your
+# code works correctly. It also shows how many points the test is worth, for a
+# total of 35 possible points.
+#
+
+print(isInside('x', 'x')) # True 1 point
+print(isInside('x', 'y')) # False 1 point
+print(isInside('x', ('x', '+', 'y'))) # True 2 points
+print(isInside('x', ('a', '+', 'b'))) # False 2 points
+print(isInside('+', ('a', '+', 'b'))) # False 2 points
+print(isInside('x', (('m', '*', 'x'), '+', 'b'))) # True 2 points
+
+print(solve('x', (('a', '+', 'x'), '=', 'c')))
+# ('x', '=', ('c', '-', 'a')) 2 points
+
+print(solve('x', (('x', '+', 'b'), '=', 'c')))
+# ('x', '=', ('c', '-', 'b')) 2 points
+
+print(solve('x', (('a', '-', 'x'), '=', 'c')))
+# ('x', '=', ('a', '-', 'c')) 2 points
+
+print(solve('x', (('x', '-', 'b'), '=', 'c')))
+# ('x', '=', ('c', '+', 'b')) 2 points
+
+print(solve('x', (('a', '*', 'x'), '=', 'c')))
+# ('x', '=', ('c', '/', 'a')) 2 points
+
+print(solve('x', (('x', '*', 'b'), '=', 'c')))
+# ('x', '=', ('c', '/', 'b')) 2 points
+
+print(solve('x', (('a', '/', 'x'), '=', 'c')))
+# ('x', '=', ('a', '/', 'c')) 2 points
+
+print(solve('x', (('x', '/', 'b'), '=', 'c')))
+# ('x', '=', ('c', '*', 'b')) 2 points
+
+print(solve('y', ('y', '=', (('m', '*', 'x'), '+', 'b'))))
+# ('y', '=', (('m', '*', 'x'), '+', 'b')) 2 points
+
+print(solve('x', ('y', '=', (('m', '*', 'x'), '+', 'b'))))
+# ('x', '=', (('y', '-', 'b'), '/', 'm')) 2 points
+
+print(solve('a', (('b', '+', 'c'), '=', ('d', '*', (('a', '/', 'e'), '-', 'f')))))
+# ('a', '=', (((('b', '+', 'c'), '/', 'd'), '+', 'f'), '*', 'e')) 5 points \ No newline at end of file
diff --git a/math2373/lab2.txt b/math2373/lab2.txt
index 34ccda8..ed40ff4 100644
--- a/math2373/lab2.txt
+++ b/math2373/lab2.txt
@@ -8,9 +8,7 @@ A =
0 1 5 -6 12
3 -8 1 0 29
-A=Aog
-{Undefined function or variable 'Aog'.
-}
+
Aog=A
Aog =