Skip to content

Instantly share code, notes, and snippets.

@adamkal
Last active December 29, 2015 00:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save adamkal/7589289 to your computer and use it in GitHub Desktop.
Save adamkal/7589289 to your computer and use it in GitHub Desktop.
coding dojo
from itertools import *
def split_to_parts(arr, size):
i = 0
for x in range(9):
yield arr[x*size:x*size+3]
cmp = [9, 158, 155, 57, 179, 183, 137, 191, 251]
def parse_file(file_name):
total = []
with open(file_name) as f:
for line in f:
arr = map(int, map(lambda x: x!=" ", line))
total.append([x for x in split_to_parts(arr, 3)] )
total = zip(*total)
total2 = []
for t in total:
total2.append(eval('0b' + ''.join(map(str, list(chain(*t))))))
for x in total2:
print cmp.index(x) + 1,
if __name__ == "__main__":
import sys
print sys.argv[1]
parse_file(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment