41 lines
1.0 KiB
Python
41 lines
1.0 KiB
Python
#!/bin/python3
|
|
import sys
|
|
from pprint import pprint
|
|
import numpy as np
|
|
|
|
input_f = sys.argv[1]
|
|
|
|
count = 0
|
|
|
|
#########################################
|
|
# #
|
|
# Part 1 #
|
|
# #
|
|
#########################################
|
|
|
|
with open(input_f) as file:
|
|
for line in file:
|
|
line = line.rstrip().split()
|
|
u,c = np.unique(line,return_counts=True)
|
|
if u[c > 1].size == 0:
|
|
count += 1
|
|
|
|
print(count)
|
|
|
|
#########################################
|
|
# #
|
|
# Part 2 #
|
|
# #
|
|
#########################################
|
|
count = 0
|
|
|
|
with open(input_f) as file:
|
|
for line in file:
|
|
line = line.rstrip().split()
|
|
for idx,x in enumerate(line):
|
|
line[idx] = ''.join(sorted(x))
|
|
u,c = np.unique(line,return_counts=True)
|
|
if u[c > 1].size == 0:
|
|
count += 1
|
|
print(count)
|