From 52813b2aa2d5534ad5be9e326bad1fcee0ce2fff Mon Sep 17 00:00:00 2001 From: Stegallo Date: Mon, 2 Dec 2024 21:48:52 -0800 Subject: [PATCH 1/8] day3 --- y_2024/day3.py | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 y_2024/day3.py diff --git a/y_2024/day3.py b/y_2024/day3.py new file mode 100644 index 0000000..47b0b19 --- /dev/null +++ b/y_2024/day3.py @@ -0,0 +1,60 @@ +from typing import Optional +import re +from pydantic.dataclasses import dataclass + +from common.aoc import AoCDay + + +@dataclass +class Row: + original: str + # processed: Optional[str] = None + + def __post_init__(self) -> None: + self.processed = "" # self.original + +@dataclass +class Mul: + op1: int + op2: int + + @staticmethod + def from_str(string): + x,y =string.replace(')','').replace('mul(', '').split(',') + return Mul(int(x), int(y)) + + @property + def mult(self): + return self.op1*self.op2 + + +class Day(AoCDay): + def __init__(self, test=0): + super().__init__(__name__, test) + + def _preprocess_input(self): + self.__input_data = [Row(i) for i in self._input_data[0]] + + def _calculate_1(self): + r = 0 + p = re.compile(r'mul\(\d\d?\d?\,\d\d?\d?\)') + for j in self.__input_data: + for i in p.findall(j.original): + r+= Mul.from_str(i).mult + return r + + def _calculate_2(self): + r = 0 + p = re.compile(r"mul\(\d\d?\d?\,\d\d?\d?\)|do\(\)|don't\(\)") + do = True + for j in self.__input_data: + for i in p.findall(j.original): + if i == 'do()': + do = True + continue + if i == 'don\'t()': + do = False + continue + if 'mul' in i and do: + r+= Mul.from_str(i).mult + return r From 9c237687f3e16fc465eec74df59752ca9abfb06b Mon Sep 17 00:00:00 2001 From: Stegallo Date: Tue, 3 Dec 2024 18:33:50 -0800 Subject: [PATCH 2/8] cleanup day3 --- y_2024/day3.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/y_2024/day3.py b/y_2024/day3.py index 47b0b19..671df3b 100644 --- a/y_2024/day3.py +++ b/y_2024/day3.py @@ -20,11 +20,10 @@ class Mul: @staticmethod def from_str(string): - x,y =string.replace(')','').replace('mul(', '').split(',') - return Mul(int(x), int(y)) + return (lambda x,y: Mul(int(x),int(y))) (*string.replace(')','').replace('mul(', '').split(',')) @property - def mult(self): + def prod(self): return self.op1*self.op2 @@ -36,25 +35,24 @@ def _preprocess_input(self): self.__input_data = [Row(i) for i in self._input_data[0]] def _calculate_1(self): - r = 0 - p = re.compile(r'mul\(\d\d?\d?\,\d\d?\d?\)') + result = 0 + p = re.compile(r'mul\(\d{1,3}\,\d{1,3}\)') for j in self.__input_data: for i in p.findall(j.original): - r+= Mul.from_str(i).mult - return r + result+= Mul.from_str(i).prod + return result def _calculate_2(self): - r = 0 - p = re.compile(r"mul\(\d\d?\d?\,\d\d?\d?\)|do\(\)|don't\(\)") + result = 0 + p = re.compile(r"mul\(\d{1,3}\,\d{1,3}\)|do\(\)|don't\(\)") do = True for j in self.__input_data: for i in p.findall(j.original): if i == 'do()': do = True - continue - if i == 'don\'t()': + elif i == 'don\'t()': do = False continue - if 'mul' in i and do: - r+= Mul.from_str(i).mult - return r + elif 'mul' in i and do: + result+= Mul.from_str(i).prod + return result From 1e72dbf17f4e5c60e69c04fd55abb8c6e73c6b29 Mon Sep 17 00:00:00 2001 From: Stegallo Date: Tue, 3 Dec 2024 18:38:49 -0800 Subject: [PATCH 3/8] test cases day3 --- tests/y_2024/test_2024_day3.py | 27 +++++++++++++++++++++++++++ y_2024/day0.py | 32 ++++++++++++++++++++++++++++++++ y_2024/day3.py | 23 +++++++++++------------ 3 files changed, 70 insertions(+), 12 deletions(-) create mode 100644 tests/y_2024/test_2024_day3.py create mode 100644 y_2024/day0.py diff --git a/tests/y_2024/test_2024_day3.py b/tests/y_2024/test_2024_day3.py new file mode 100644 index 0000000..0d5154b --- /dev/null +++ b/tests/y_2024/test_2024_day3.py @@ -0,0 +1,27 @@ +# from __future__ import annotations + +from unittest.mock import mock_open, patch + +from y_2024.day3 import Day + +with patch( + "builtins.open", + mock_open( + read_data="""xmul(2,4)&mul[3,7]!^don't()_mul(5,5)+mul(32,64](mul(11,8)undo()?mul(8,5))""", + ), +): + day = Day() + + +def test__preprocess_input(): + assert True + + +def test_calculate_1(): + r = day._calculate_1() + assert r == 161 + + +def test_calculate_2(): + r = day._calculate_2() + assert r == 48 diff --git a/y_2024/day0.py b/y_2024/day0.py new file mode 100644 index 0000000..6154f2c --- /dev/null +++ b/y_2024/day0.py @@ -0,0 +1,32 @@ +from typing import Optional + +from pydantic.dataclasses import dataclass + +from common.aoc import AoCDay + + +@dataclass +class Row: + original: str + processed: Optional[str] = None + + def __post_init__(self) -> None: + self.processed = "" # self.original + + +class Day(AoCDay): + def __init__(self, test=0): + super().__init__(__name__, test) + + def _preprocess_input(self): + # self.__input_data = [[int(i) for i in chunk] for chunk in self._input_data] + print(f"{self._input_data=}") + self.__input_data = [Row(i) for i in self._input_data[0]] + + def _calculate_1(self): + for x in self.__input_data: + print(f"{x}") + return 0 + + def _calculate_2(self): + return 0 diff --git a/y_2024/day3.py b/y_2024/day3.py index 671df3b..c805f17 100644 --- a/y_2024/day3.py +++ b/y_2024/day3.py @@ -1,5 +1,5 @@ -from typing import Optional import re + from pydantic.dataclasses import dataclass from common.aoc import AoCDay @@ -8,10 +8,7 @@ @dataclass class Row: original: str - # processed: Optional[str] = None - def __post_init__(self) -> None: - self.processed = "" # self.original @dataclass class Mul: @@ -20,11 +17,13 @@ class Mul: @staticmethod def from_str(string): - return (lambda x,y: Mul(int(x),int(y))) (*string.replace(')','').replace('mul(', '').split(',')) + return (lambda x, y: Mul(int(x), int(y)))( + *string.replace(")", "").replace("mul(", "").split(",") + ) @property def prod(self): - return self.op1*self.op2 + return self.op1 * self.op2 class Day(AoCDay): @@ -36,10 +35,10 @@ def _preprocess_input(self): def _calculate_1(self): result = 0 - p = re.compile(r'mul\(\d{1,3}\,\d{1,3}\)') + p = re.compile(r"mul\(\d{1,3}\,\d{1,3}\)") for j in self.__input_data: for i in p.findall(j.original): - result+= Mul.from_str(i).prod + result += Mul.from_str(i).prod return result def _calculate_2(self): @@ -48,11 +47,11 @@ def _calculate_2(self): do = True for j in self.__input_data: for i in p.findall(j.original): - if i == 'do()': + if i == "do()": do = True - elif i == 'don\'t()': + elif i == "don't()": do = False continue - elif 'mul' in i and do: - result+= Mul.from_str(i).prod + elif "mul" in i and do: + result += Mul.from_str(i).prod return result From 664b984359b7563e34f62668bb28e14b1eae717d Mon Sep 17 00:00:00 2001 From: Stegallo Date: Tue, 3 Dec 2024 18:44:12 -0800 Subject: [PATCH 4/8] flake8 --- tests/y_2024/test_2024_day3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/y_2024/test_2024_day3.py b/tests/y_2024/test_2024_day3.py index 0d5154b..bb13f84 100644 --- a/tests/y_2024/test_2024_day3.py +++ b/tests/y_2024/test_2024_day3.py @@ -7,7 +7,7 @@ with patch( "builtins.open", mock_open( - read_data="""xmul(2,4)&mul[3,7]!^don't()_mul(5,5)+mul(32,64](mul(11,8)undo()?mul(8,5))""", + read_data="""xmul(2,4)&mul[3,7]!^don't()_mul(5,5)+mul(32,64](mul(11,8)undo()?mul(8,5))""", # noqa: E501 ), ): day = Day() From 03f51dd707de63378a60795f1d669015a7a03638 Mon Sep 17 00:00:00 2001 From: Stegallo Date: Tue, 3 Dec 2024 21:40:49 -0800 Subject: [PATCH 5/8] day4 --- y_2024/day4.py | 121 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 y_2024/day4.py diff --git a/y_2024/day4.py b/y_2024/day4.py new file mode 100644 index 0000000..b51a193 --- /dev/null +++ b/y_2024/day4.py @@ -0,0 +1,121 @@ +from typing import Optional + +from pydantic.dataclasses import dataclass + +from common.aoc import AoCDay + + +@dataclass +class Row: + original: str + processed: Optional[str] = None + + def __post_init__(self) -> None: + self.processed = "" # self.original + + +class Day(AoCDay): + def __init__(self, test=0): + super().__init__(__name__, test) + + def _preprocess_input(self): + self.__input_data = [[i for i in chunk] for chunk in self._input_data] + self.grid = {} + for y in self.__input_data: + for c, x in enumerate(y): + for i, k in enumerate(x): + self.grid[(c, i)] = k + + def _calculate_1(self): + result = 0 + for y in self.__input_data: + for c, x in enumerate(y): + for i, k in enumerate(x): + if k != "X": + continue + l = (c, i - 1) + r = (c, i + 1) + u = (c - 1, i) + d = (c + 1, i) + lu = (c - 1, i - 1) + ru = (c - 1, i + 1) + ld = (c + 1, i - 1) + rd = (c + 1, i + 1) + if self.grid.get(l) == "M": + if self.grid.get((c, i - 2)) == "A": + if self.grid.get((c, i - 3)) == "S": + result += 1 + if self.grid.get(r) == "M": + if self.grid.get((c, i + 2)) == "A": + if self.grid.get((c, i + 3)) == "S": + result += 1 + if self.grid.get(u) == "M": + if self.grid.get((c - 2, i)) == "A": + if self.grid.get((c - 3, i)) == "S": + result += 1 + if self.grid.get(d) == "M": + if self.grid.get((c + 2, i)) == "A": + if self.grid.get((c + 3, i)) == "S": + result += 1 + if self.grid.get(lu) == "M": + if self.grid.get((c - 2, i - 2)) == "A": + if self.grid.get((c - 3, i - 3)) == "S": + result += 1 + if self.grid.get(ru) == "M": + if self.grid.get((c - 2, i + 2)) == "A": + if self.grid.get((c - 3, i + 3)) == "S": + result += 1 + if self.grid.get(ld) == "M": + if self.grid.get((c + 2, i - 2)) == "A": + if self.grid.get((c + 3, i - 3)) == "S": + result += 1 + if self.grid.get(rd) == "M": + if self.grid.get((c + 2, i + 2)) == "A": + if self.grid.get((c + 3, i + 3)) == "S": + result += 1 + return result + + def _calculate_2(self): + result = 0 + for y in self.__input_data: + for c, x in enumerate(y): + for i, k in enumerate(x): + if k != "A": + continue + lu = (c - 1, i - 1) + ru = (c - 1, i + 1) + ld = (c + 1, i - 1) + rd = (c + 1, i + 1) + + if ( + self.grid.get(lu) == "M" + and self.grid.get(rd) == "S" + and self.grid.get(ru) == "M" + and self.grid.get(ld) == "S" + ): + result += 1 + + if ( + self.grid.get(lu) == "S" + and self.grid.get(rd) == "M" + and self.grid.get(ru) == "S" + and self.grid.get(ld) == "M" + ): + result += 1 + + if ( + self.grid.get(lu) == "M" + and self.grid.get(rd) == "S" + and self.grid.get(ru) == "S" + and self.grid.get(ld) == "M" + ): + result += 1 + + if ( + self.grid.get(lu) == "S" + and self.grid.get(rd) == "M" + and self.grid.get(ru) == "M" + and self.grid.get(ld) == "S" + ): + result += 1 + return result From e6858d464a515d551e46d6b0004867f9f608fd6b Mon Sep 17 00:00:00 2001 From: Stegallo Date: Thu, 5 Dec 2024 20:23:53 -0800 Subject: [PATCH 6/8] day5 --- y_2024/day0.py | 7 ++- y_2024/day5.py | 149 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 154 insertions(+), 2 deletions(-) create mode 100644 y_2024/day5.py diff --git a/y_2024/day0.py b/y_2024/day0.py index 6154f2c..5be1cc0 100644 --- a/y_2024/day0.py +++ b/y_2024/day0.py @@ -21,12 +21,15 @@ def __init__(self, test=0): def _preprocess_input(self): # self.__input_data = [[int(i) for i in chunk] for chunk in self._input_data] print(f"{self._input_data=}") + print(f"{len(self._input_data[0])=}") self.__input_data = [Row(i) for i in self._input_data[0]] def _calculate_1(self): + result = 0 for x in self.__input_data: print(f"{x}") - return 0 + return result def _calculate_2(self): - return 0 + result = 0 + return result diff --git a/y_2024/day5.py b/y_2024/day5.py new file mode 100644 index 0000000..ac80a96 --- /dev/null +++ b/y_2024/day5.py @@ -0,0 +1,149 @@ +from typing import Optional + +from pydantic.dataclasses import dataclass +from collections import defaultdict +from common.aoc import AoCDay + + +@dataclass +class Row: + original: str + processed: Optional[str] = None + + def __post_init__(self) -> None: + self.processed = "" # self.original + +@dataclass +class Rule: + original: str + processed: Optional[str] = None + + def __post_init__(self) -> None: + self.processed = self.original.split('|') + +@dataclass +class Update: + original: str + processed: Optional[str] = None + + def __post_init__(self) -> None: + self.processed = self.original.split(',') + +class Day(AoCDay): + def __init__(self, test=0): + super().__init__(__name__, test) + + def _preprocess_input(self): + # self.__input_data = [[int(i) for i in chunk] for chunk in self._input_data] + # print(f"{self._input_data=}") + # print(f"{len(self._input_data[0])=}") + self.__input_data_1 = [Rule(i) for i in self._input_data[0]] + self.__input_data_2 = [Update(i) for i in self._input_data[1]] + + def _calculate_1(self): + result = 0 + return result + foll=defaultdict(list) + prec=defaultdict(list) + for x in self.__input_data_1: + foll[x.processed[0]].append(x.processed[1]) + prec[x.processed[1]].append(x.processed[0]) + + + # print(foll) + # print(prec) + self.valids = [] + for x in self.__input_data_2: + + valid = True + for c,i in enumerate(x.processed): + for d,j in enumerate(x.processed[c+1:]): + # print(i,j) + if not j in foll[i]: + valid = False + if valid: + # print(f"{x.processed}, {len(x.processed)//2=}") + result+=int(x.processed[len(x.processed)//2]) + self.valids.append(x.processed) + + return result + + def _calculate_2(self): + # print(self.valids) + # return 0 + result = 0 + foll=defaultdict(list) + orfoll=defaultdict(list) + fixed = [] + prec=defaultdict(list) + for x in self.__input_data_1: + foll[x.processed[0]].append(x.processed[1]) + orfoll[x.processed[0]].append(x.processed[1]) + # prec[x.processed[1]].append(x.processed[0]) + print(foll) + + # for k,v in prec.foll(): + # print(k, len(v)) + # return + # first = True + # while True: + # + # if len(foll.keys())<1: + # break + # for i in foll.keys(): + # # + # if len(foll[i])==1: + # if first: + # fixed.append(foll[i][0]) + # first = False + # fixed.append(i) + # del foll[i] + # for k, v in foll.items(): + # new_val = [k for k in v if k!=i] + # foll[k]= new_val + # break + # + # fixed = fixed[::-1] + # fixed = {i: c for c,i in enumerate(fixed)} + # print(fixed) + + + + # return 0 + for x in self.__input_data_2: + + valid = True + for c,i in enumerate(x.processed): + for d,j in enumerate(x.processed[c+1:]): + # print(i,j) + if not j in orfoll[i]: + valid = False + if valid: + # print(f"{x.processed}, {len(x.processed)//2=}") + pass + # result+=int(x.processed[len(x.processed)//2]) + else: + # breakpoint() + proposed = list(x.processed) + valid_p = False + while not valid_p: + ordered = True + # print(proposed) + for i in range(len(proposed)-1): + j = i+1 + # print(proposed, i, j) + if not proposed[j] in foll[proposed[i]]: + ordered = False + proposed[j], proposed[i] = proposed[i], proposed[j] + if ordered: + valid_p = True + break + # print(proposed) + # n = {i:fixed[i] for i in x.processed} + # # print(n) + # sort_n = list(dict(sorted(n.items(), key=lambda item: item[1])).keys()) + # print(sort_n) + + result+=int(proposed[len(proposed)//2]) + + return result From 8a36234a4c5ad38f74034d2b429c7b3f8d3a6083 Mon Sep 17 00:00:00 2001 From: Stegallo Date: Fri, 6 Dec 2024 20:27:11 -0800 Subject: [PATCH 7/8] day6 --- y_2024/day0.py | 5 +++- y_2024/day6.py | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 y_2024/day6.py diff --git a/y_2024/day0.py b/y_2024/day0.py index 5be1cc0..5dc41bf 100644 --- a/y_2024/day0.py +++ b/y_2024/day0.py @@ -21,13 +21,16 @@ def __init__(self, test=0): def _preprocess_input(self): # self.__input_data = [[int(i) for i in chunk] for chunk in self._input_data] print(f"{self._input_data=}") + print(f"{len(self._input_data)=}") print(f"{len(self._input_data[0])=}") - self.__input_data = [Row(i) for i in self._input_data[0]] + # self.__input_data = [Row(i) for i in self._input_data[0]] + self.__input_data = [Row(i) for j in self._input_data for i in j] def _calculate_1(self): result = 0 for x in self.__input_data: print(f"{x}") + ... return result def _calculate_2(self): diff --git a/y_2024/day6.py b/y_2024/day6.py new file mode 100644 index 0000000..cab47aa --- /dev/null +++ b/y_2024/day6.py @@ -0,0 +1,67 @@ +from common.aoc import AoCDay + +DIRS = {"^": (-1, 0), ">": (0, 1), "v": (1, 0), "<": (0, -1)} +RIGHT = {(-1, 0): (0, 1), (0, 1): (1, 0), (1, 0): (0, -1), (0, -1): (-1, 0)} + + +class Day(AoCDay): + _visited_in_1: set[tuple[int]] = set() + + def __init__(self, test=0): + super().__init__(__name__, test) + + def _preprocess_input(self): + self.__input_data = [[i for i in chunk] for chunk in self._input_data] + self.grid = {} + for y in self.__input_data: + for c, x in enumerate(y): + for i, k in enumerate(x): + self.grid[(c, i)] = k + if k in DIRS: + self.starting_point = (c, i) + + def _calculate_1(self) -> int: + grid = {k: v for k, v in self.grid.items()} + position = self.starting_point + direction = DIRS[self.grid[self.starting_point]] + grid[position] = "X" + self._visited_in_1.add(position) + while True: + adhead = (position[0] + direction[0], position[1] + direction[1]) + try: + if grid[adhead] == "#": # obstacle: + direction = RIGHT[direction] + else: + position = adhead + grid[position] = "X" + self._visited_in_1.add(position) + except KeyError: + break + return sum(1 for i in grid.values() if i == "X") + + def _calculate_2(self) -> int: + result = 0 + for i in self._visited_in_1 - {self.starting_point}: + new_grid = {k: v for k, v in self.grid.items()} + new_grid[i] = "#" + result += self.run_in_circe(new_grid) + return result + + def run_in_circe(self, grid) -> bool: + grid = {k: v for k, v in grid.items()} + position = self.starting_point + direction = DIRS[self.grid[self.starting_point]] + visited = {} + while True: + visited[(position, direction)] = True + adhead = (position[0] + direction[0], position[1] + direction[1]) + try: + if grid[adhead] == "#": # obstacle: + direction = RIGHT[direction] + else: + position = adhead + if (position, direction) in visited: + return True + except KeyError: + break + return False From f9d7fe92a402429024beeb47d7a040ff994164d4 Mon Sep 17 00:00:00 2001 From: Stegallo Date: Fri, 6 Dec 2024 20:35:31 -0800 Subject: [PATCH 8/8] format day5 --- y_2024/day5.py | 56 ++++++++++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 32 deletions(-) diff --git a/y_2024/day5.py b/y_2024/day5.py index ac80a96..d1b336b 100644 --- a/y_2024/day5.py +++ b/y_2024/day5.py @@ -13,21 +13,24 @@ class Row: def __post_init__(self) -> None: self.processed = "" # self.original + @dataclass class Rule: original: str - processed: Optional[str] = None + processed: Optional[list[str]] = None def __post_init__(self) -> None: - self.processed = self.original.split('|') + self.processed = self.original.split("|") + @dataclass class Update: original: str - processed: Optional[str] = None + processed: Optional[list[str]] = None def __post_init__(self) -> None: - self.processed = self.original.split(',') + self.processed = self.original.split(",") + class Day(AoCDay): def __init__(self, test=0): @@ -42,28 +45,25 @@ def _preprocess_input(self): def _calculate_1(self): result = 0 - return result - foll=defaultdict(list) - prec=defaultdict(list) + foll = defaultdict(list) + prec = defaultdict(list) for x in self.__input_data_1: foll[x.processed[0]].append(x.processed[1]) prec[x.processed[1]].append(x.processed[0]) - # print(foll) # print(prec) self.valids = [] for x in self.__input_data_2: - valid = True - for c,i in enumerate(x.processed): - for d,j in enumerate(x.processed[c+1:]): + for c, i in enumerate(x.processed): + for d, j in enumerate(x.processed[c + 1 :]): # print(i,j) - if not j in foll[i]: + if j not in foll[i]: valid = False if valid: # print(f"{x.processed}, {len(x.processed)//2=}") - result+=int(x.processed[len(x.processed)//2]) + result += int(x.processed[len(x.processed) // 2]) self.valids.append(x.processed) return result @@ -72,10 +72,10 @@ def _calculate_2(self): # print(self.valids) # return 0 result = 0 - foll=defaultdict(list) - orfoll=defaultdict(list) - fixed = [] - prec=defaultdict(list) + foll = defaultdict(list) + orfoll = defaultdict(list) + # fixed = [] + # prec = defaultdict(list) for x in self.__input_data_1: foll[x.processed[0]].append(x.processed[1]) orfoll[x.processed[0]].append(x.processed[1]) @@ -107,16 +107,13 @@ def _calculate_2(self): # fixed = {i: c for c,i in enumerate(fixed)} # print(fixed) - - # return 0 for x in self.__input_data_2: - valid = True - for c,i in enumerate(x.processed): - for d,j in enumerate(x.processed[c+1:]): + for c, i in enumerate(x.processed): + for d, j in enumerate(x.processed[c + 1 :]): # print(i,j) - if not j in orfoll[i]: + if j not in orfoll[i]: valid = False if valid: # print(f"{x.processed}, {len(x.processed)//2=}") @@ -129,21 +126,16 @@ def _calculate_2(self): while not valid_p: ordered = True # print(proposed) - for i in range(len(proposed)-1): - j = i+1 + for i in range(len(proposed) - 1): + j = i + 1 # print(proposed, i, j) - if not proposed[j] in foll[proposed[i]]: + if proposed[j] not in foll[proposed[i]]: ordered = False proposed[j], proposed[i] = proposed[i], proposed[j] if ordered: valid_p = True break - # print(proposed) - # n = {i:fixed[i] for i in x.processed} - # # print(n) - # sort_n = list(dict(sorted(n.items(), key=lambda item: item[1])).keys()) - # print(sort_n) - result+=int(proposed[len(proposed)//2]) + result += int(proposed[len(proposed) // 2]) return result