Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 77c633a

Browse files
Viliam PucikViliam Pucik
Viliam Pucik
authored and
Viliam Pucik
committed
formatting
1 parent d3fb01f commit 77c633a

File tree

6 files changed

+26
-6
lines changed

6 files changed

+26
-6
lines changed

‎2015/11.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ def solve(password):
1414

1515
for suffix in product(letters[letters.index(password[-i]) + 1 :], *([letters] * (i - 1))):
1616
candidate = prefix + "".join(suffix)
17-
if r.search(candidate) and any(candidate[j : j + 3] in triplets for j in range(len(candidate) - 2)):
17+
if r.search(candidate) and any(
18+
candidate[j : j + 3] in triplets for j in range(len(candidate) - 2)
19+
):
1820
found = candidate
1921
break
2022

‎2020/04.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import sys
33
import re
44

5+
# fmt:off
56
fields = {
67
"byr": lambda x: 1920 <= int(x) <= 2002,
78
"iyr": lambda x: 2010 <= int(x) <= 2020,
@@ -11,7 +12,7 @@
1112
"ecl": lambda x: x in ("amb", "blu", "brn", "gry", "grn", "hzl", "oth"),
1213
"pid": lambda x: re.fullmatch(r"\d{9}", x),
1314
}
14-
15+
# fmt:on
1516
present = 0
1617
valid = 0
1718

‎2020/19.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import sys
33
import regex
44

5+
56
# Kudos to https://github.com/taddeus/advent-of-code/blob/master/2020/19_regex.py
67
def solve(rules, messages):
78
def expand(value):

‎2021/12.py‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
caves[a].append(b)
1010
caves[b].append(a)
1111

12+
1213
# Recursive version with result caching
1314
@cache
1415
def dfs(parent, lowers, duplicate):
@@ -21,15 +22,21 @@ def dfs(parent, lowers, duplicate):
2122
duplicate = True
2223
lowers |= {parent}
2324

24-
return sum(dfs(child, frozenset(lowers), duplicate) for child in caves[parent] if child != "start")
25+
return sum(
26+
dfs(child, frozenset(lowers), duplicate) for child in caves[parent] if child != "start"
27+
)
2528

2629

2730
for duplicate in True, False:
2831
print(dfs("start", frozenset(), duplicate))
2932

3033
# Slightly slower, non recursive version with result caching
3134
for duplicate in True, False:
32-
count, search, cache = 0, deque((child, frozenset(), duplicate, None) for child in caves["start"]), {}
35+
count, search, cache = (
36+
0,
37+
deque((child, frozenset(), duplicate, None) for child in caves["start"]),
38+
{},
39+
)
3340

3441
while search:
3542
parent, lowers, duplicate, start = search.popleft()
@@ -54,6 +61,10 @@ def dfs(parent, lowers, duplicate):
5461
duplicate = True
5562
lowers |= {parent}
5663

57-
search.extendleft((child, frozenset(lowers), duplicate, None) for child in caves[parent] if child != "start")
64+
search.extendleft(
65+
(child, frozenset(lowers), duplicate, None)
66+
for child in caves[parent]
67+
if child != "start"
68+
)
5869

5970
print(count)

‎2021/15.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,8 @@
3333
yd, ym = divmod(y, width)
3434
data["weight"] = (m[xm][ym] + xd + yd - 1) % 9 + 1
3535

36-
print(nx.shortest_path_length(g, source=(0, 0), target=(i * height - 1, i * width - 1), weight="weight"))
36+
print(
37+
nx.shortest_path_length(
38+
g, source=(0, 0), target=(i * height - 1, i * width - 1), weight="weight"
39+
)
40+
)

‎2022/14.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from itertools import pairwise
33
from collections import deque
44

5+
56
# Kudos to https://www.reddit.com/r/adventofcode/comments/zli1rd/comment/j061f6z
67
def solve(check, path=deque([500])):
78
while True:

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /