Compare commits
7 commits
6a6552f6fc
...
2637d63c4e
Author | SHA1 | Date | |
---|---|---|---|
Bruno BELANYI | 2637d63c4e | ||
Bruno BELANYI | fd625a110a | ||
Bruno BELANYI | 06481d39fa | ||
Bruno BELANYI | 8c13d5954e | ||
Bruno BELANYI | 31c0f09981 | ||
Bruno BELANYI | 46864fc490 | ||
Bruno BELANYI | fcb74b375f |
|
@ -65,7 +65,7 @@ def build_graph(grid: RawGrid) -> Graph:
|
|||
|
||||
|
||||
def solve(G: Graph, start: str) -> int:
|
||||
@lru_cache(2 ** 20)
|
||||
@lru_cache(2**20)
|
||||
def reachable_keys(src: str, found: FrozenSet[str]) -> List[Tuple[str, int]]:
|
||||
queue = []
|
||||
distance: DefaultDict[str, Union[float, int]] = defaultdict(lambda: inf)
|
||||
|
@ -97,7 +97,7 @@ def solve(G: Graph, start: str) -> int:
|
|||
|
||||
return reachable
|
||||
|
||||
@lru_cache(2 ** 20)
|
||||
@lru_cache(2**20)
|
||||
def min_steps(
|
||||
src: str, keys_to_find: int, found: FrozenSet[str] = frozenset()
|
||||
) -> int:
|
||||
|
|
|
@ -65,7 +65,7 @@ def build_graph(grid: RawGrid) -> Graph:
|
|||
|
||||
|
||||
def solve(G: Graph, start: str) -> int:
|
||||
@lru_cache(2 ** 20)
|
||||
@lru_cache(2**20)
|
||||
def reachable_keys(src: str, found: FrozenSet[str]) -> GraphInfo:
|
||||
queue = []
|
||||
distance: DefaultDict[str, Union[float, int]] = defaultdict(lambda: inf)
|
||||
|
@ -97,7 +97,7 @@ def solve(G: Graph, start: str) -> int:
|
|||
|
||||
return reachable
|
||||
|
||||
@lru_cache(2 ** 20)
|
||||
@lru_cache(2**20)
|
||||
def min_steps(
|
||||
sources: str, keys_to_find: int, found: FrozenSet[str] = frozenset()
|
||||
) -> Union[float, int]:
|
||||
|
|
20
2022/d01/ex1/ex1.py
Executable file
20
2022/d01/ex1/ex1.py
Executable file
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
def solve(input: list[list[int]]) -> int:
|
||||
return max(map(sum, input), default=0)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
input = [
|
||||
[int(line) for line in group.split("\n") if line]
|
||||
for group in sys.stdin.read().split("\n\n")
|
||||
if group
|
||||
]
|
||||
print(solve(input))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
2244
2022/d01/ex1/input
Normal file
2244
2022/d01/ex1/input
Normal file
File diff suppressed because it is too large
Load diff
21
2022/d01/ex2/ex2.py
Executable file
21
2022/d01/ex2/ex2.py
Executable file
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
def solve(input: list[list[int]]) -> int:
|
||||
totals: list[int] = sorted(map(sum, input), reverse=True)
|
||||
return sum(totals[:3])
|
||||
|
||||
|
||||
def main() -> None:
|
||||
input = [
|
||||
[int(line) for line in group.split("\n") if line]
|
||||
for group in sys.stdin.read().split("\n\n")
|
||||
if group
|
||||
]
|
||||
print(solve(input))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
2244
2022/d01/ex2/input
Normal file
2244
2022/d01/ex2/input
Normal file
File diff suppressed because it is too large
Load diff
62
flake.lock
62
flake.lock
|
@ -1,12 +1,28 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1668681692,
|
||||
"narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "009399224d5e398d03b22badca40a37ac85412a1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"futils": {
|
||||
"locked": {
|
||||
"lastModified": 1638122382,
|
||||
"narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=",
|
||||
"lastModified": 1667395993,
|
||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "74f7e4319258e287b0f9cb95426c9853b282730b",
|
||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -16,37 +32,63 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"gitignore": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"pre-commit-hooks",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1660459072,
|
||||
"narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "gitignore.nix",
|
||||
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "gitignore.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1638286143,
|
||||
"narHash": "sha256-A+rgjbIpz3uPRKHPXwdmouVcVn5pZqLnaZHymjkraG4=",
|
||||
"lastModified": 1669809720,
|
||||
"narHash": "sha256-RMT77f6CPOYtLLQ2esj+EJ1BPVWxf4RDidjrSvA5OhI=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "29d1f6e1f625d246dcf84a78ef97b4da3cafc6ea",
|
||||
"rev": "227de2b3bbec142f912c09d5e8a1b4e778aa54fb",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"pre-commit-hooks": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat",
|
||||
"flake-utils": [
|
||||
"futils"
|
||||
],
|
||||
"gitignore": "gitignore",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
],
|
||||
"nixpkgs-stable": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1637745948,
|
||||
"narHash": "sha256-DmQG1bZk24eS+BAHwnHPyYIadMLKbq0d1b//iapYIPU=",
|
||||
"lastModified": 1669829516,
|
||||
"narHash": "sha256-laWMD/TZzyrulu8xLNoSPertXOxjRD7BrcAVwKl+NyQ=",
|
||||
"owner": "cachix",
|
||||
"repo": "pre-commit-hooks.nix",
|
||||
"rev": "c3b4f94350b0e59c2546fa85890cc70d03616b9c",
|
||||
"rev": "471c7f1ecace25e39099206431300322632d25c4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
type = "github";
|
||||
owner = "NixOS";
|
||||
repo = "nixpkgs";
|
||||
ref = "nixos-unstable";
|
||||
ref = "nixpkgs-unstable";
|
||||
};
|
||||
|
||||
pre-commit-hooks = {
|
||||
|
@ -24,6 +24,7 @@
|
|||
inputs = {
|
||||
flake-utils.follows = "futils";
|
||||
nixpkgs.follows = "nixpkgs";
|
||||
nixpkgs-stable.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -62,6 +63,7 @@
|
|||
mypy
|
||||
z3
|
||||
]))
|
||||
pyright
|
||||
];
|
||||
|
||||
inherit (self.checks.${system}.pre-commit) shellHook;
|
||||
|
|
Loading…
Reference in a new issue