Skip to content

Instantly share code, notes, and snippets.

@vlazzle
Created October 28, 2017 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vlazzle/a3ef350d26b94a497d860c1aa67ad745 to your computer and use it in GitHub Desktop.
Save vlazzle/a3ef350d26b94a497d860c1aa67ad745 to your computer and use it in GitHub Desktop.
def print_abacus(value):
abacus = '00000*****'
for i in range(0, 10):
power_of_ten = 9 - i
row_factor = pow(10, power_of_ten)
num_beads = value / row_factor
if num_beads > 0:
value = value % row_factor
divider = 10 - num_beads
print '|' + abacus[:divider] + ' ' + abacus[divider:] + '|'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment