This commit is contained in:
2022-07-07 16:45:18 +02:00
parent 73ae6f90f2
commit 88563913ff
14 changed files with 181 additions and 14 deletions

2
.gitignore vendored
View File

@@ -200,5 +200,3 @@ DerivedData/
## Gcc Patch
/*.gcno

20
.pre-commit-config.yaml Normal file
View File

@@ -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

View File

@@ -7,4 +7,4 @@
240
269
260
263
263

View File

@@ -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

View File

@@ -1 +1 @@
3,4,3,1,2
3,4,3,1,2

View File

@@ -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", "")
)

View File

@@ -99,4 +99,4 @@ OK -> O
FH -> H
KV -> S
FO -> C
VS -> B
VS -> B

View File

@@ -1 +1 @@
target area: x=20..30, y=-10..-5
target area: x=20..30, y=-10..-5

View File

@@ -1 +1 @@
target area: x=137..171, y=-98..-73
target area: x=137..171, y=-98..-73

38
18/18.py Normal file
View File

@@ -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)

0
18/ex18.in Normal file
View File

100
18/input18.in Normal file
View File

@@ -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]]]]

11
Pipfile Normal file
View File

@@ -0,0 +1,11 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
[dev-packages]
[requires]
python_version = "3.9"

View File

@@ -1 +1 @@
numpy
numpy