From 02fbf3575c0f763d97c03b0749e581db8e0e5d1e Mon Sep 17 00:00:00 2001 From: RossTheRoss Date: Sun, 20 Oct 2019 10:01:41 -0500 Subject: Done with project??? --- csci1913/Python/project1_strap012.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'csci1913') 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 -- cgit v1.2.3