rainman002

reddit #98c

Sep 15th, 2012
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. lines = []
  2. output = ''
  3. while True:
  4.     try:
  5.         lines.append(list(raw_input()))
  6.     except EOFError:
  7.         break
  8. lines = map(list, zip(*lines))
  9. numbers = {'+|+|+- -+|+|+':'0',
  10. '+|+|+':'1',
  11. '+ +|+- - -+|+ +':'2',
  12. '+ + +- - -+|+|+':'3',
  13. '+|+-+|+|+':'4',
  14. '+|+ +- - -+ +|+':'5',
  15. '+|+|+- - -+ +|+':'6',
  16. '+-+|+|+':'7',
  17. '+|+|+- - -+|+|+':'8',
  18. '+|+ +- - -+|+|+':'9',
  19. '':''}
  20. match = ''
  21. for line in lines:
  22.     for i in range(10):
  23.         line = ''.join(line).replace('||','|').replace('  ',' ').strip()
  24.     if '-' not in match or '-' not in line:
  25.         match += line
  26.     if line == '' and match in numbers:
  27.         output += numbers[match]
  28.         match = ''
  29. print output
Add Comment
Please, Sign In to add comment