From 3634ba6b823cd07cd962ba361574bf6db87a9482 Mon Sep 17 00:00:00 2001 From: Daniel Mevec Date: Sat, 3 Dec 2022 10:24:05 +0100 Subject: [PATCH] rename function --- 2022/3/3.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/2022/3/3.py b/2022/3/3.py index 1e28a60..a8b0b91 100644 --- a/2022/3/3.py +++ b/2022/3/3.py @@ -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)) \ No newline at end of file