# digitizer.py - functionality for producing vertical strings # of digits. Here is a gallery: # 0000 1 22222 33333 44 55555 66666 77777 88888 9999 # 00 00 11 2 3 4 4 5 6 7 8 8 9 9 # 00 00 1 22222 33333 44444 55555 66666 7 88888 9999 # 00 00 1 2 3 4 5 6 6 7 8 8 9 # 0000 11111 22222 33333 4 55555 66666 7 88888 999 def toString(n): # First, we need to create a list of digit values. # Then, we call a function that actually creates # strings for individual digits. We need to return # whole string of potentially several digits. # Notice the order of concatenation! s = "" while n > 0: print "Next digit to process is " + str(n%10) s = getDigit(n % 10) + s n /= 10 return s + ":)" def getDigit(d): if d == 0: return " 0000 \n00 00\n00 00\n00 00\n 0000\n\n" elif d == 1: return " 1 \n 11 \n 1 \n 1 \n11111\n\n" elif d == 2: return "22222\n 2\n22222\n2 \n22222\n\n" elif d == 3: return "33333\n 3\n33333\n 3\n33333\n\n" elif d == 4: return " 44 \n 4 4 \n44444\n 4 \n 4 \n\n" elif d == 5: return "55555\n5 \n55555\n 5\n55555\n\n" elif d == 6: return "66666\n6 \n66666\n6 6\n66666\n\n" elif d == 7: return "77777\n 7 \n 7 \n 7 \n7 \n\n" elif d == 8: return "88888\n8 8\n88888\n8 8\n88888\n\n" else: return " 9999\n9 9\n 9999\n 9 \n999 \n\n"