aboutsummaryrefslogtreecommitdiffstats
path: root/csci1913/Python
diff options
context:
space:
mode:
authorRossTheRoss <msattr@gmail.com>2019-10-20 10:01:41 -0500
committerRossTheRoss <msattr@gmail.com>2019-10-20 10:01:41 -0500
commit02fbf3575c0f763d97c03b0749e581db8e0e5d1e (patch)
tree362a36c436fefbd9de2cebcde70d1e981eae4191 /csci1913/Python
parentAlmost done (diff)
downloadhomework-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???
Diffstat (limited to '')
-rw-r--r--csci1913/Python/project1_strap012.py14
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