diff options
author | Walter Bender <walter@sugarlabs.org> | 2010-04-03 12:02:54 (GMT) |
---|---|---|
committer | Walter Bender <walter@sugarlabs.org> | 2010-04-03 12:02:54 (GMT) |
commit | dc5d13b1350ad56d01274ef9c8209fa48f609a27 (patch) | |
tree | ec08f9659fa96fccd498710d0931cd2f57988d8b | |
parent | f0e129585ebba52a134c3b72599e7709bc9bab71 (diff) |
fixed summing problem with Nepohualtzintzin
-rw-r--r-- | abacus_window.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/abacus_window.py b/abacus_window.py index 9354c8b..ef12519 100644 --- a/abacus_window.py +++ b/abacus_window.py @@ -17,7 +17,7 @@ import pygtk pygtk.require('2.0') import gtk from gettext import gettext as _ -import math +from math import pow import os try: @@ -177,20 +177,22 @@ class Nepohualtzintzin(): j = i%(self.top_beads+self.bot_beads) if b.state == 1: if j < self.top_beads: - v[r+1] += 5 + v[r+1] += 5*pow(2,self.num_rods-r-1) else: - v[r+1] += 1 + v[r+1] += 1*pow(2,self.num_rods-r-1) # Carry to the left if a rod has a value > 9. for j in range(self.num_rods): if v[len(v)-j-1] > 9: - v[len(v)-j-1] -= 10 - v[len(v)-j-2] += 1 + units = v[len(v)-j-1]%10 + tens = v[len(v)-j-1]-units + v[len(v)-j-1] = units + v[len(v)-j-2] += tens/10 # Convert values to a string. for j in v: if string != '' or j > 0: - string += str(j) + string += str(int(j)) return(string) def hide(self): |