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.
 
 

36 lines
1.0 KiB

#!/usr/bin/env python3
import sys
if __name__ == '__main__':
lines = open(sys.argv[1]).readlines()
for i, line in enumerate(lines):
lines[i] = list(line[:-1])
for line in lines:
for j, b in enumerate(line):
if b == 'n' or b == 's':
line[j] = line[j] + line.pop(j+1)
for a, line in enumerate(lines):
for i in range(len(line)):
for j in range(i+1, len(line)):
x, y = line[i], line[j]
if (x == 'e' and y == 'w') or (x == 'w' and y == 'e') or (x == 'se' and y == 'sw') or (x == 'sw' and y == 'se') or (x == 'ne' and y == 'nw') or (x == 'nw' and y == 'ne'):
line[j] = ''
line[i] = ''
line.sort()
lines[a] = ''.join(line)
dict = {}
for di in lines:
if di in dict:
dict[di] += 1
else:
dict[di] = 1
count = 0
for a in dict.values():
if a % 2 == 1:
count += 1
print(count)