diff --git a/.gitignore b/.gitignore index d2e9efd..670d88c 100644 --- a/.gitignore +++ b/.gitignore @@ -200,5 +200,3 @@ DerivedData/ ## Gcc Patch /*.gcno - - diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..7b23e8a --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,20 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.3.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + +- repo: https://github.com/psf/black + rev: 22.6.0 + hooks: + - id: black + # It is recommended to specify the latest version of Python + # supported by your project here, or alternatively use + # pre-commit's default_language_version, see + # https://pre-commit.com/#top_level-default_language_version + language_version: python3.9 diff --git a/01/ex1.in b/01/ex1.in index 59dad67..167e291 100644 --- a/01/ex1.in +++ b/01/ex1.in @@ -7,4 +7,4 @@ 240 269 260 -263 \ No newline at end of file +263 diff --git a/02/AoC2/main.swift b/02/AoC2/main.swift index a64ebee..55f6ac6 100644 --- a/02/AoC2/main.swift +++ b/02/AoC2/main.swift @@ -13,10 +13,10 @@ var horizontalPosition = 0 let fileContent = try! String(contentsOfFile: CommandLine.arguments[1]) for line in fileContent.trimmingCharacters(in: .newlines).components(separatedBy: .newlines) { let parts = line.components(separatedBy: " ") - + let direction = parts[0] let number = Int(parts[1])! - + switch direction { case "forward": horizontalPosition += number @@ -37,10 +37,10 @@ var horizontalPositionB = 0 for line in fileContent.trimmingCharacters(in: .newlines).components(separatedBy: .newlines) { let parts = line.components(separatedBy: .whitespaces) - + let direction = parts[0] let number = Int(parts[1])! - + switch direction { case "up": aim -= number diff --git a/06/ex6.in b/06/ex6.in index a7af2b1..55129f1 100644 --- a/06/ex6.in +++ b/06/ex6.in @@ -1 +1 @@ -3,4,3,1,2 \ No newline at end of file +3,4,3,1,2 diff --git a/13/13.py b/13/13.py index 3e25d55..ddf8c54 100644 --- a/13/13.py +++ b/13/13.py @@ -8,11 +8,11 @@ np.set_printoptions(threshold=sys.maxsize, linewidth=1000) def print_sheet(grid): print( str(grid) - .replace("False", ".") - .replace("True", "#") .replace("[", "") .replace("]", "") .replace(" ", "") + .replace("True", "▓") + .replace("False", "░") ) diff --git a/14/input14.in b/14/input14.in index 776112d..331c91b 100644 --- a/14/input14.in +++ b/14/input14.in @@ -99,4 +99,4 @@ OK -> O FH -> H KV -> S FO -> C -VS -> B \ No newline at end of file +VS -> B diff --git a/17/ex17.in b/17/ex17.in index f40609b..a07e02d 100644 --- a/17/ex17.in +++ b/17/ex17.in @@ -1 +1 @@ -target area: x=20..30, y=-10..-5 \ No newline at end of file +target area: x=20..30, y=-10..-5 diff --git a/17/input17.in b/17/input17.in index 1bd3d95..6659aae 100644 --- a/17/input17.in +++ b/17/input17.in @@ -1 +1 @@ -target area: x=137..171, y=-98..-73 \ No newline at end of file +target area: x=137..171, y=-98..-73 diff --git a/18/18.py b/18/18.py new file mode 100644 index 0000000..b9730f7 --- /dev/null +++ b/18/18.py @@ -0,0 +1,38 @@ +import sys + + +class SnailfishNumber: + def __init__(self, pair) -> None: + self._pair = pair + self.reduce() + + def reduce(self): + while self.explode(): + pass + + while self.explode(): + pass + + def explode(self) -> bool: + pass + + def split(self) -> bool: + pass + + def __repr__(self) -> str: + return f"SnailfishNumber({self._pair})" + + def __str__(self) -> str: + return self._pair + + def __add__(self, p2: "SnailfishNumber") -> "SnailfishNumber": + return SnailfishNumber([self._pair, p2._pair]) + + +if __name__ == "__main__": + numbers = [] + + for line in sys.stdin.readlines(): + numbers.append(SnailfishNumber(eval(line.strip()))) + + print(numbers) diff --git a/18/ex18.in b/18/ex18.in new file mode 100644 index 0000000..e69de29 diff --git a/18/input18.in b/18/input18.in new file mode 100644 index 0000000..d0ba419 --- /dev/null +++ b/18/input18.in @@ -0,0 +1,100 @@ +[[[[4,6],4],[1,7]],[[[1,6],[8,4]],[1,1]]] +[[[[8,5],[9,2]],1],[[2,5],[[9,4],[5,9]]]] +[[[[7,3],0],[8,9]],6] +[[6,[[7,2],[6,2]]],[[[9,8],9],[9,6]]] +[2,[[[9,2],6],[[5,3],[6,7]]]] +[[[5,[9,6]],0],[[[2,8],[7,0]],[7,[4,4]]]] +[[[[5,0],2],[0,1]],4] +[2,[8,8]] +[[[[2,5],[6,8]],[[9,8],4]],[[[2,3],[5,8]],[9,5]]] +[[[[0,7],[9,4]],[[1,0],9]],[[[8,8],[7,2]],[3,[6,5]]]] +[[[[3,2],8],1],[[4,[3,4]],[[6,5],[0,6]]]] +[[[7,8],8],[0,[5,2]]] +[[3,[3,3]],[[[6,9],[1,1]],[6,[2,9]]]] +[[[[9,7],[6,8]],4],[[[8,2],[2,9]],[8,[6,2]]]] +[[[[7,3],2],[9,6]],[[[1,7],[0,0]],[4,9]]] +[[8,[7,[1,0]]],7] +[[[7,[5,1]],0],[[8,[5,3]],4]] +[1,[[[2,6],2],[1,[6,0]]]] +[[[5,8],[[9,1],1]],[[3,[5,0]],5]] +[[[[1,5],[4,9]],8],[[7,0],6]] +[9,[[0,[1,0]],6]] +[[[[6,8],6],9],[[7,3],2]] +[[9,[[8,7],4]],[[[4,0],[9,0]],[8,1]]] +[[[2,[4,4]],[7,[0,1]]],[8,[[8,6],[4,0]]]] +[0,9] +[[[[1,8],[7,4]],[[5,0],[6,1]]],[5,7]] +[[[[8,2],[9,2]],[8,[8,4]]],[0,4]] +[[[[0,7],[5,8]],3],6] +[[[7,[3,4]],[3,[1,5]]],2] +[[[1,[4,2]],5],[[1,2],1]] +[[[[8,2],[0,9]],1],[[[9,0],[3,5]],[8,[8,0]]]] +[[[0,5],[1,[3,3]]],[[[1,0],[5,2]],[7,5]]] +[[[4,[7,3]],[0,9]],[[2,0],8]] +[[[[2,2],8],[7,1]],5] +[[1,[[3,8],7]],[[7,[5,8]],[4,[1,7]]]] +[[[[2,7],4],[8,[9,1]]],[[5,2],[4,3]]] +[[2,[7,2]],[[8,[0,8]],[0,[4,2]]]] +[[6,[6,[7,4]]],[[7,[2,0]],[[8,2],8]]] +[[[7,[1,7]],[[4,1],4]],[1,[4,6]]] +[1,[[1,0],[[0,3],[6,9]]]] +[[[[8,6],0],[[2,8],[3,0]]],[[[8,2],7],[[3,0],5]]] +[[[[2,8],4],[2,[0,7]]],[[3,[1,2]],[[8,0],[4,2]]]] +[1,8] +[[5,6],6] +[[[[1,0],[3,6]],[[4,0],1]],[0,7]] +[[[5,[9,6]],[7,[1,2]]],2] +[[[6,4],[[5,6],[1,8]]],[[[9,0],[7,7]],[[5,8],[6,8]]]] +[8,5] +[5,[[[6,8],8],0]] +[[[[5,7],[0,0]],[6,[0,0]]],[[[5,5],3],[[1,1],[3,4]]]] +[[[4,0],[[8,6],2]],[[3,[3,1]],[[2,8],[7,2]]]] +[[[8,7],[[5,5],[5,3]]],4] +[[[[5,4],1],[3,4]],[3,5]] +[[[6,5],[[6,3],6]],4] +[[[[2,2],[7,1]],[6,6]],[[8,[8,7]],[[1,6],[3,0]]]] +[[4,[[5,0],[7,4]]],[3,1]] +[[[3,[5,8]],5],[1,[[9,6],3]]] +[[0,[[3,0],[8,7]]],[[1,3],3]] +[5,[[3,[3,3]],[3,6]]] +[[[[7,3],8],3],[2,[[9,8],2]]] +[[[2,4],[[1,2],5]],[[[1,2],[6,0]],3]] +[[9,[[1,1],[1,7]]],[1,[2,[9,1]]]] +[[[5,[0,0]],5],[6,[0,1]]] +[[3,[[6,5],7]],[[7,8],3]] +[[5,[2,6]],8] +[[6,[0,[3,0]]],[1,2]] +[3,[[[3,7],2],[[4,0],6]]] +[[[8,[2,7]],[4,1]],[[2,[4,2]],3]] +[[3,2],[[[8,8],[8,6]],[[5,3],1]]] +[1,[2,[[3,2],[2,9]]]] +[8,[[9,1],[[8,4],[9,9]]]] +[[[4,[4,6]],[1,8]],[[7,7],[[7,4],3]]] +[[[8,2],[[9,7],[0,8]]],[[4,4],[[6,1],5]]] +[[[3,[6,6]],[[8,6],[3,7]]],[[7,9],[[5,3],8]]] +[[[8,9],[8,6]],[[[3,3],[2,9]],[[6,6],9]]] +[8,[[[3,0],5],2]] +[[[[1,3],1],[[1,9],4]],[7,[3,1]]] +[[[[9,3],3],[[6,8],7]],[[[2,0],3],[8,[3,6]]]] +[[[[7,1],[8,1]],[[4,6],[5,9]]],[[[4,5],3],5]] +[6,[[3,[0,0]],[6,6]]] +[[[[8,8],[7,6]],3],[[[7,7],[1,1]],[[1,8],[1,4]]]] +[[9,[8,[3,4]]],[[6,2],[1,5]]] +[[5,[3,3]],[5,[0,5]]] +[[[[8,9],5],[1,9]],[[5,[2,8]],[[6,4],[9,4]]]] +[2,6] +[[[[1,4],8],5],[5,[0,[1,7]]]] +[[[[1,0],[9,9]],[0,9]],[[[5,4],[1,6]],[9,[6,7]]]] +[[[7,1],5],[[3,2],5]] +[[9,[[8,8],[7,0]]],[5,[3,[1,3]]]] +[[[[5,2],[7,5]],[4,[6,7]]],[[[8,1],6],[2,[6,6]]]] +[[[5,7],[6,[8,2]]],[8,2]] +[[[[5,7],8],[[9,8],2]],[[2,8],[[7,6],3]]] +[[1,[[1,6],1]],[0,[[5,9],[9,1]]]] +[[[[1,4],[5,0]],[[5,5],[9,3]]],[[6,4],[4,[4,6]]]] +[7,[[5,[4,8]],[[5,9],2]]] +[[[[2,9],[1,8]],[4,2]],0] +[[5,[[0,9],[3,7]]],[2,[6,[4,8]]]] +[[0,[5,5]],0] +[[[5,0],[[0,5],8]],[6,[[8,7],[6,5]]]] +[[[5,[8,2]],[8,4]],[[6,2],[8,[7,0]]]] diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..71e4f7c --- /dev/null +++ b/Pipfile @@ -0,0 +1,11 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] + +[dev-packages] + +[requires] +python_version = "3.9" diff --git a/requiremnets.txt b/requiremnets.txt index 296d654..24ce15a 100644 --- a/requiremnets.txt +++ b/requiremnets.txt @@ -1 +1 @@ -numpy \ No newline at end of file +numpy