You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

52 lines
1.4 KiB

#!/usr/bin/env python3
import sys
from termcolor import colored
def show(tile):
for line in tile:
print(colored(''.join(line), 'blue'))
print('\n')
def fliph(tile):
next = ['n'] * 10
for i in range(0,len(tile)):
next[i] = tile[len(tile)-i-1]
return next
def flipv(tile):
for i in range(0, len(tile)):
tile[i] = tile[i][::-1]
return tile
def rotate(tile):
next = [['o' for i in range(len(tile[0]))] for j in range(len(tile))]
for i in range(0, len(tile)):
for j in range(0, len(tile[1])):
next[len(tile[1])-j-1][i] = tile[i][j]
return next
def options(tile):
return [tile,
fliph(tiles[t]),
rotate(tiles[t]),
rotate(rotate(tiles[t])),
rotate(rotate(rotate(tiles[t]))),
fliph(rotate(tiles[t])),
fliph(rotate(rotate(tiles[t]))),
fliph(rotate(rotate(rotate(tiles[t]))))]
if __name__ == '__main__':
tilestrings = open(sys.argv[1]).read().split('\n\n')
tiles = {}
for tile in tilestrings:
tid, *data = tile.split('\n')
try:
tid = tid.rstrip(':').split(' ')[1]
except IndexError: continue
grid = [[c for c in line] for line in data if len(line) >= 1]
tiles[int(tid)] = grid
for t in tiles:
print(colored(str(t), 'red'))