Last active
December 29, 2015 00:58
-
-
Save adamkal/7589289 to your computer and use it in GitHub Desktop.
coding dojo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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