#!/usr/bin/env python3 import sys L = [] with open(sys.argv[1], 'r') as f: L = f.readlines() L = [x.strip() for x in L] # part 1 groups = [set()] for i in L: if i == '': groups.append(set()) else: for ii in i: groups[-1].add(ii) total = 0 for i in groups: total += len(i) print(total) # part 1 groups = [{'people': 0}] for i in L: if i == '': groups.append({'people': 0}) else: groups[-1]['people'] += 1 for ii in i: if ii not in groups[-1]: groups[-1][ii] = 1 else: groups[-1][ii] += 1 total = 0 for i in groups: for ii in i: if ii != 'people' and i[ii] == i['people']: total += 1 print(total)