Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- Входные данные: 0,0,0,2,2,0,0,0,0,6,3,0,0,4,0,0,0,0,4,4,0,3,0,0
- Выходные данные: 5,6,1,4,3,2,4,1,3,2,6,5,2,3,6,1,5,4,6,5,4,3,2,1,1,2,5,6,4,3,3,4,2,5,1,6
- '''
- from random import shuffle
- from itertools import permutations
- def check_visibility(data, restrictions):
- forward_check = sum(all(1 if data[current] > backs else 0 for backs in data[:current]) for current in range(1,len(data)+1))
- backprop_check = sum(all(1 if data[current] > forwards else 0 for forwards in data[current+1:]) for current in range(len(data)-2,-1,-1))
- if (restrictions[0] and restrictions[0] != forward_check + 1) or (restrictions[1] and restrictions[1] != backprop_check + 1):
- return False
- return True
- in_ = [int(i) for i in '0,0,0,2,2,0,0,0,0,6,3,0,0,4,0,0,0,0,4,4,0,3,0,0'.split(',')]
- N, E, S, W = [in_[n:n+6] for n in (0,6,12,18)]
- muts = list(permutations([1,2,3,4,5,6],6))
- field_rows = [muts] * 6
- # field_cols = [field_rows[n::6] for n in range(6)]
- for row_ix in range(6):
- print(row_ix)
- field_rows[row_ix] = [row for row in field_rows[row_ix] if check_visibility(row, (W[row_ix], E[row_ix]))]
- print(len(field_rows[row_ix]))
- ans = []
- for row0 in field_rows[0]:
- for row1 in field_rows[1]:
- ans = [row0, row1]
- ans_cols = [ans[n::6] for n in range(2)]
- if not all(1 if check_visibility(col, (N[ix], S[ix])) else 0 for ix, col in enumerate(ans_cols) ):
- continue
- for row2 in field_rows[2]:
- ans = [row0,row1,row2]
- ans_cols = [ans[n::6] for n in range(3)]
- if not all(1 if check_visibility(col, (N[ix], S[ix])) else 0 for ix, col in enumerate(ans_cols) ):
- continue
- print(ans)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement