-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday_six.py
28 lines (15 loc) · 858 Bytes
/
day_six.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
def get_distinct_letter_count(letter_string):
return len("".join(set(letter_string)))
def get_distinct_letter_count_per_group_sum(input):
grouped_input = split_into_groups(input)
return sum(map(lambda x: get_distinct_letter_count(x), grouped_input))
def split_into_groups(form_answers):
return [x.replace("\n", "") for x in form_answers.split("\n\n")]
def get_unanimous_letter_count_per_group_sum(input):
return sum([get_unanimous_letter_count(*x) for x in split_into_groups_including_count(input)])
def get_unanimous_letter_count(letter_string, group_count):
return sum([(1 if letter_string.count(x) >= group_count else 0) for x in set(letter_string)])
def split_into_groups_including_count(form_answers):
return [(x.replace("\n", ""), x.count("\n") + 1) for x in form_answers.split("\n\n")]
input = None
# not 3486