SHARE
TWEET

pattern calculator

liucijus Nov 27th, 2012 39 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def createPatternDictionary(pattern):
  2.     rules = {1: ('...', '.'), 2: ('..x', '.'), 4: ('.x.', '.'), 8: ('.xx', '.'),
  3.              16: ('x..', '.'), 32: ('x.x', '.'), 64: ('xx.', '.'), 128: ('xxx', '.')}
  4.     left = pattern
  5.     for i in sorted(rules.keys(), reverse=True):
  6.         if left - i >= 0:
  7.             left = left - i
  8.             rules[i] = rules[i][0], 'x'
  9.     return rules
RAW Paste Data
Pastebin PRO Summer Special!
Get 60% OFF on Pastebin PRO accounts!
Top