diff options
author | RossTheRoss <msattr@gmail.com> | 2019-10-20 10:01:41 -0500 |
---|---|---|
committer | RossTheRoss <msattr@gmail.com> | 2019-10-20 10:01:41 -0500 |
commit | 02fbf3575c0f763d97c03b0749e581db8e0e5d1e (patch) | |
tree | 362a36c436fefbd9de2cebcde70d1e981eae4191 | |
parent | Almost done (diff) | |
download | homework-02fbf3575c0f763d97c03b0749e581db8e0e5d1e.tar homework-02fbf3575c0f763d97c03b0749e581db8e0e5d1e.tar.gz homework-02fbf3575c0f763d97c03b0749e581db8e0e5d1e.tar.bz2 homework-02fbf3575c0f763d97c03b0749e581db8e0e5d1e.tar.lz homework-02fbf3575c0f763d97c03b0749e581db8e0e5d1e.tar.xz homework-02fbf3575c0f763d97c03b0749e581db8e0e5d1e.tar.zst homework-02fbf3575c0f763d97c03b0749e581db8e0e5d1e.zip |
Done with project???
-rw-r--r-- | csci1913/Python/project1_strap012.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/csci1913/Python/project1_strap012.py b/csci1913/Python/project1_strap012.py index 8355400..2422d5d 100644 --- a/csci1913/Python/project1_strap012.py +++ b/csci1913/Python/project1_strap012.py @@ -51,16 +51,16 @@ class Grammar: def select(self, left): rules=self.dictionary[left] total=0 - chosenOne=0 + c=0 + #Some of the loops are probably not needed for m in range (0, len(rules)): total+=rules[m].count index = self.r.choose(total) - chosen=rules[0] - while index > 0: - index-=rules[chosenOne].count - chosenOne+=1 - else: - chosen=rules[chosenOne] + for c in range (0, len(rules)): + index -= rules[c].count + if index<=0: + break + chosen = rules[c] for n in range (0, len(rules)): if rules[n] is not chosen: rules[n].count+=1 |