rename function
This commit is contained in:
parent
dddaa2ebe7
commit
3634ba6b82
1 changed files with 3 additions and 3 deletions
|
|
@ -41,7 +41,7 @@ def compartments(rucksack:str):
|
|||
l = len(t)//2
|
||||
return t[:l], t[l:]
|
||||
|
||||
def compare(*comps:str) -> str:
|
||||
def find_common(*comps:str) -> str:
|
||||
cs = [set(c) for c in comps]
|
||||
return cs[0].intersection(*cs[1:]).pop()
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ CrZsJsPPZsGzwwsLwLmpwMDw"""
|
|||
|
||||
rucksacks = [compartments(line) for line in lines]
|
||||
|
||||
print(sum([priority[compare(*rucksack)] for rucksack in rucksacks]))
|
||||
print(sum([priority[find_common(*rucksack)] for rucksack in rucksacks]))
|
||||
|
||||
"""
|
||||
As you finish identifying the misplaced items, the Elves come to you with another issue.
|
||||
|
|
@ -95,5 +95,5 @@ Priorities for these items must still be found to organize the sticker attachmen
|
|||
Find the item type that corresponds to the badges of each three-Elf group. What is the sum of the priorities of those item types?
|
||||
"""
|
||||
groups = np.array(lines).reshape(-1,3)
|
||||
badges = [priority[compare(*group)] for group in groups]
|
||||
badges = [priority[find_common(*group)] for group in groups]
|
||||
print(sum(badges))
|
||||
Loading…
Add table
Reference in a new issue