diff options
author | RossTheRoss <msattr@gmail.com> | 2019-10-23 12:29:57 -0500 |
---|---|---|
committer | RossTheRoss <msattr@gmail.com> | 2019-10-23 12:29:57 -0500 |
commit | 8150a69a0f4fdfcbb5192a8ed0ed7410592d9f01 (patch) | |
tree | 482343647fd0c116da3ee88bad9e62904296782b /csci1913 | |
parent | Do things! (diff) | |
download | homework-8150a69a0f4fdfcbb5192a8ed0ed7410592d9f01.tar homework-8150a69a0f4fdfcbb5192a8ed0ed7410592d9f01.tar.gz homework-8150a69a0f4fdfcbb5192a8ed0ed7410592d9f01.tar.bz2 homework-8150a69a0f4fdfcbb5192a8ed0ed7410592d9f01.tar.lz homework-8150a69a0f4fdfcbb5192a8ed0ed7410592d9f01.tar.xz homework-8150a69a0f4fdfcbb5192a8ed0ed7410592d9f01.tar.zst homework-8150a69a0f4fdfcbb5192a8ed0ed7410592d9f01.zip |
s p a c i n g
Diffstat (limited to 'csci1913')
-rw-r--r-- | csci1913/Python/project1_strap012.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/csci1913/Python/project1_strap012.py b/csci1913/Python/project1_strap012.py index 2422d5d..79b3f17 100644 --- a/csci1913/Python/project1_strap012.py +++ b/csci1913/Python/project1_strap012.py @@ -38,9 +38,9 @@ class Grammar: def rule(self, left, right): if left not in self.dictionary: - self.dictionary[left]=(Rule(left,right),) + self.dictionary[left] = (Rule(left,right),) else: - self.dictionary[left]+=(Rule(left, right),) + self.dictionary[left] += (Rule(left, right),) def generate(self): if 'Start' in self.dictionary: @@ -49,21 +49,21 @@ class Grammar: raise RuntimeError def select(self, left): - rules=self.dictionary[left] - total=0 - c=0 + rules = self.dictionary[left] + total = 0 + c = 0 #Some of the loops are probably not needed for m in range (0, len(rules)): - total+=rules[m].count + total += rules[m].count index = self.r.choose(total) for c in range (0, len(rules)): index -= rules[c].count - if index<=0: + if index <= 0: break chosen = rules[c] for n in range (0, len(rules)): if rules[n] is not chosen: - rules[n].count+=1 + rules[n].count += 1 return chosen.right def generating(self,strings): |