diff options
author | Matthew Strapp <msattr@gmail.com> | 2019-09-11 16:07:13 -0500 |
---|---|---|
committer | Matthew Strapp <msattr@gmail.com> | 2019-09-11 16:07:13 -0500 |
commit | 227ce7f3207e963c6580ac39f8286ca47a787195 (patch) | |
tree | 5b4047a97a7b32a828dbce3b23d4c47690626c23 /csci1913/lab1 | |
parent | More lab (diff) | |
download | homework-227ce7f3207e963c6580ac39f8286ca47a787195.tar homework-227ce7f3207e963c6580ac39f8286ca47a787195.tar.gz homework-227ce7f3207e963c6580ac39f8286ca47a787195.tar.bz2 homework-227ce7f3207e963c6580ac39f8286ca47a787195.tar.lz homework-227ce7f3207e963c6580ac39f8286ca47a787195.tar.xz homework-227ce7f3207e963c6580ac39f8286ca47a787195.tar.zst homework-227ce7f3207e963c6580ac39f8286ca47a787195.zip |
Almost done
Diffstat (limited to '')
-rw-r--r-- | csci1913/lab1/lab1_strap012.py | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/csci1913/lab1/lab1_strap012.py b/csci1913/lab1/lab1_strap012.py index 0e89112..e04cf82 100644 --- a/csci1913/lab1/lab1_strap012.py +++ b/csci1913/lab1/lab1_strap012.py @@ -25,7 +25,7 @@ def solve(v, e): def solving(v,q): if left(q)==v: return q - elif type(left(q)): + elif type(left(left(q))) is not tuple: if op(left(q))=='+': return solvingAdd(v, q) elif op(left(q))=='-': @@ -34,30 +34,33 @@ def solving(v,q): return solvingMultiply(v, q) elif op(left(q))=='/': return solvingDivide(v, q) + else: + solving(v,left(q)) def solvingAdd(v,q): if isInside(v, left(left(q))): - return (left(left(q)), '=', (right(q), '-', right(left(q)))) + return left(left(q)), '=', (right(q), '-', right(left(q))) else: - return (right(left(q)), '=', (right(q), '-', left(right(q)))) + return right(left(q)), '=', (right(q), '-', left(left(q))) def solvingSubtract(v,q): if isInside(v, left(left(q))): - return left(left(q)) + return left(left(q)), '=', (right(q), '+', right(left(q))) else: - return right(left(q)) + return right(left(q)), '=', (left(left(q)), '-', right(q)) def solvingMultiply(v,q): if isInside(v, left(left(q))): - return left(left(q)) + return left(left(q)), '=', (right(q), '/', right(left(q))) else: - return right(left(q)) + return right(left(q)), '=', (right(q), '/', left(left(q))) def solvingDivide(v,q): if isInside(v, left(left(q))): - return left(left(q)) + return left(left(q)), '=', (right(q), '*', right(left(q))) else: - return right(left(q)) + return right(left(q)), '=', (left(left(q)), '/', right(q)) + # # TESTS. Test the equation solver for CSci 1913 Lab 1. |