Compare commits

...

7 Commits

Author SHA1 Message Date
magical d6b6bb979e day 19 part 2 2024-12-19 05:49:57 +00:00
magical f1ed65a6d9 day 19 part 1 2024-12-19 05:24:17 +00:00
magical e57c5ecfd1 day 18 cleanup 2024-12-18 05:35:28 +00:00
magical cc853a4dcd day 18 part 2 2024-12-18 05:28:30 +00:00
magical 16637ab722 day 18 part 1 2024-12-18 05:19:25 +00:00
magical d1a2b1eeb1 day 17 generic† solution
† mostly, subject to a few broad assumptions
2024-12-17 16:38:38 +00:00
magical 7fcfd8fcb6 day 17 2024-12-17 06:43:51 +00:00
14 changed files with 4338 additions and 0 deletions

5
day17/input 100644
View File

@ -0,0 +1,5 @@
Register A: 46337277
Register B: 0
Register C: 0
Program: 2,4,1,1,7,5,4,4,1,4,0,3,5,5,3,0

56
day17/sol.py 100644
View File

@ -0,0 +1,56 @@
sample = [0,1,5,4,3,0]
input = [2,4,1,1,7,5,4,4,1,4,0,3,5,5,3,0]
def simulate(a, prog, check=False):
b = 0
c = 0
ip = 0
out = []
while ip < len(prog):
op = prog[ip]
r = prog[ip+1]
if op in (0,2,5,6,7):
# combo op
if r == 4:
r = a
elif r == 5:
r = b
elif r == 6:
r = c
elif r == 7:
die
else:
pass # literal
if op == 0: # adv
a = a>>r
elif op == 1: # bxl
b ^= r
elif op == 2: # bst
b = r%8
elif op == 3: # jnz
if a != 0:
ip = r - 2
elif op == 4: # bxc
b ^= c
elif op == 5: # out
out.append(r%8)
if check and out[-1] != prog[len(out)-1]:
return out
elif op == 6:
b = a>>r
elif op == 7:
c = a>>r
ip += 2
print(",".join(str(x) for x in out))
return out
simulate(729, sample)
simulate(46337277, input)

88
day17/sol2.c 100644
View File

@ -0,0 +1,88 @@
#include <stdio.h>
int prog[] = {2,4,1,1,7,5,4,4,1,4,0,3,5,5,3,0};
int plen = sizeof(prog) / sizeof(int);
long reverse(int i, long init) {
long a = init;
// jnz,0
if (i >= plen) {
return init;
}
// in,5
int b = prog[plen-i-1];
// adv,3,
a <<= 3l;
// bxl,4
b ^= 4;
// cdv,5
// bxc,4
long q;
for (q = 0; q < 8; q++) {
if (((q^1) ^ ((((a|q)>>(q^1)))&7)) == b) {
// bst 4
// bxl,1
long x = reverse(i+1, a|q);
if (x >= 0) {
return x;
}
}
}
//error
if (a == 0) {
return -1;
}
return -a;
}
int run(long a) {
int b = 0;
int c = 0;
int i = 0;
// 4:a 5:b 6:c
do {
// bst 4
b = a%8;
//
// bxl,1
b ^= 1;
// cdv,5
c = (a&65535) >> b;
// bxc,4
b ^= c;
// bxl,4
b ^= 4;
// adv,3,
a >>= 3;
// out,5
printf("%d", b%8);
if (i >= plen || (b%8) != prog[i]) {
printf("!");
}
printf(" ");
i++;
// jnz,0
} while (a != 0);
printf("\n");
return 0;
}
int main() {
long a = reverse(0, 0);
printf("%ld\n", a);
run(a);
return 0;
}

85
day17/sol3.c 100644
View File

@ -0,0 +1,85 @@
#include <stdio.h>
int prog[] = {2,4,1,1,7,5,4,4,1,4,0,3,5,5,3,0};
int plen = sizeof(prog) / sizeof(int);
int run(long a, int i, int print) {
long b = 0;
long c = 0;
int ip;
for (ip = 0; ip+2 <= plen; ip += 2) {
int op = prog[ip];
long r = prog[ip+1];
if (op != 1 && op != 3 && op != 4 && r > 3) {
// combo op
if (r == 4) {
r = a;
} else if (r == 5) {
r = b;
} else if (r == 6) {
r = c;
} else if (r >= 7) {
return -1; // invalid
}
}
switch(op) {
case 0: a = a >> r; break; // adv
case 6: b = a >> r; break; // bdv
case 7: c = a >> r; break; // cdv
case 1: b ^= r; break; // bxl
case 2: b = r % 8; break; // bst
case 4: b ^= c; break; // bxc
case 3: if (a != 0) ip = r-2; break; // jnz
case 5: // out
int o = r % 8;
if (print) {
printf("%d ", o);
} else {
if (o != prog[i++]) {
return -2;
}
}
break;
default:
return -1; //invalid
}
}
if (print) printf("\b\n");
return 0;
}
// assumptions:
// - the whole program is a loop
// - 'a' is decoded 3 bits at a time
// - output only affected by higher bits, not lower bits
long reverse(long init, int i) {
if (i < 0) {
return init;
}
for (int b = 0; b < 8; b++) {
long a = init<<3 | b;
if (run(a, i, 0) == 0) {
printf("# %lo\n", a);
long ret = reverse(a, i-1);
if (ret >= 0) {
return ret;
}
}
}
//error
return -3;
}
int main() {
run(46337277, 0, 1);
run(202991746427434L, 0, 1);
long a = reverse(0, plen-1);
printf("%ld\n", a);
if (a >= 0) {
printf("%d\n", run(a, 0, 1));
}
return 0;
}

105
day18/astar.py 100644
View File

@ -0,0 +1,105 @@
from heapq import heappush, heappop
def search(start, is_goal, neighbors, heuristic=None, worst=None):
if heuristic == None:
def heuristic(x):
return 0
if not callable(is_goal):
goal = is_goal
def is_goal(this):
return this == goal
if not isinstance(start, list):
start = [start]
i = 0 # tiebreaker
q = []
for s in start:
i += 1
heappush(q, (heuristic(s), i, s, None))
done = {}
if worst:
best_worst = min(worst(s) for s in start)
while q:
z, _, this, prev = heappop(q)
if this in done:
continue
cost_so_far = z - heuristic(this)
#print(this,z, cost_so_far)
done[this] = (cost_so_far, prev)
if is_goal(this):
#print("astar: visited", len(done), "nodes")
#print("astar: pending", len(q), "nodes")
# reconsruct the path
n = this
path = []
while n is not None:
path.append(n)
_, n = done[n]
path.reverse()
return cost_so_far, this, path
for c, n in neighbors(this):
c = cost_so_far + c
if n not in done or c < done[n][0]:
h = heuristic(n)
if worst:
if c+h > best_worst:
# if the best possible cost for this node
# is worse than the lowest worst-case cost we've seen
# then don't even bother exploring it
continue
w = worst(n)
if c+w < best_worst:
best_worst = c+w
i += 1
heappush(q, (c+h, i, n, this))
return float('inf'), None, []
def test():
data = [
"aabqponm",
"abcryxxl",
"accszzxk",
"acctuvwj",
"abdefghi",
]
#data = [
# "aabbaaba",
# "abcbaaba",
# "accabcbb",
# "accbbbba",
# "abbbabab",
#]
start = (0,0)
goal = (5,2)
def get(x,y):
return ord(data[y][x])
def neighbors(src):
x,y = src
here = get(x,y)
n = []
def push(x,y):
if 0 <= y < len(data):
if 0 <= x < len(data[y]):
if get(x,y) <= here+1:
n.append((1, (x,y)))
push(x-1, y)
push(x+1,y)
push(x, y-1)
push(x, y+1)
return n
def heuristic(n):
return abs(goal[0] - n[0]) + abs(goal[1] - n[1])
c, _, path = search(start, goal, neighbors, heuristic)
print(*data, sep="\n")
print(*path, sep="\n")
assert c == 31, c
if __name__ == '__main__':
test()

3450
day18/input 100644

File diff suppressed because it is too large Load Diff

25
day18/sample1.in 100644
View File

@ -0,0 +1,25 @@
5,4
4,2
4,5
3,0
2,1
6,3
2,4
1,5
0,6
3,3
2,6
5,1
1,2
5,5
2,5
6,5
1,4
0,4
6,4
1,1
6,1
1,0
0,5
1,6
2,0

7
day18/sample2.in 100644
View File

@ -0,0 +1,7 @@
...#...
..#..#.
....#..
...#..#
..#..#.
.#..#..
#.#....

7
day18/sample3.in 100644
View File

@ -0,0 +1,7 @@
<em>O</em><em>O</em>.#<em>O</em><em>O</em><em>O</em>
.<em>O</em>#<em>O</em><em>O</em>#<em>O</em>
.<em>O</em><em>O</em><em>O</em>#<em>O</em><em>O</em>
...#<em>O</em><em>O</em>#
..#<em>O</em><em>O</em>#.
.#.<em>O</em>#..
#.#<em>O</em><em>O</em><em>O</em><em>O</em>

59
day18/sol.py 100644
View File

@ -0,0 +1,59 @@
from collections import defaultdict
import astar
def parse(file):
return [
tuple([int(x) for x in line.strip().split(',')])
for line in file
]
def solve(file, N=71, T=1024):
falling = parse(file)
inf = float('inf')
map = defaultdict(lambda: 1)
for i,p in enumerate(falling):
if i > T:
break
map[p] = 0
sol = _solve(map, N)
print(sol)
print(len(sol[-1])-1)
def _solve(map, N):
start = (0,0) # x,y
end = N-1, N-1
def neighbors(n):
x,y = n
def push(x,y):
if 0 <= x < N and 0 <= y < N:
if map[x,y]:
out.append((1,(x,y)))
out = []
push(x+1,y)
push(x,y+1)
push(x-1,y)
push(x,y-1)
return out
def heuristic(n):
return abs(end[0] - n[0]) + abs(end[1] - n[1])
return astar.search(start, end, neighbors, heuristic)
import math
def solve2(file, N):
falling = parse(file)
map = defaultdict(lambda: 1)
for i,p in enumerate(falling):
map[p] = 0
sol = _solve(map, N)
if math.isinf(sol[0]):
print(p)
break
solve(open("sample1.in"), N=7, T=12)
solve2(open("sample1.in"), N=7)
print()
solve(open("input"), N=71, T=1024)
solve2(open("input"), N=71)

402
day19/input 100644
View File

@ -0,0 +1,402 @@
rwgw, ruwgb, urwbr, wu, uurbubr, gbbr, uwwb, rubgwu, wggwbwr, rugubuww, uw, rgru, rgrr, rrg, rbb, uurbrww, br, uwrwrwgb, bwbw, wgbu, wggu, urg, ugr, ugur, gurrbrr, ubgrruu, bb, rburguu, urgg, wggugggr, brww, bwwgr, wugub, grgg, ugw, grubw, gbwru, rww, wbu, ggwbu, ugurw, ggwb, uubuwgb, bbugw, rgg, wurr, bwbb, wburbb, rbrb, bbrwgw, gwbb, ubggr, gurr, rrr, rburg, uug, bbrubu, bwgu, gwug, guw, buwurgw, rruwggg, ubb, wwb, wbrg, wgr, wgrw, gubrr, rrwru, gbub, rbr, rwr, rubwu, ub, bgwr, gu, ggggwrbr, wrw, grg, rbuwu, bgbr, ugww, wrg, brwub, gruu, gbwbw, wubw, wur, grggwb, uuwuug, wug, rruuw, wgwg, uww, gbgu, rurr, gwguu, gwrwbw, guuww, rbugw, gg, uwbw, ubgrubur, wurrb, rgugurr, wrr, buggb, urwrb, ubuu, rgu, gwggb, uuu, uub, bruubb, bww, uwgb, rrubwg, ubwu, ugu, buwrrbwr, bbr, rbrww, ubuwg, bwwrr, gbwg, bw, gguugu, bgbbw, ggb, wrruuwbr, rug, uur, rgw, gbb, wuwg, r, guug, gwb, wbgr, bbbw, grwgwr, gwg, rurur, bubu, rguu, brb, ugbbbrr, wugrrr, bbw, bbru, bgrbubg, ubw, uruu, wgrgrwwr, bbwrugu, gbbbwur, rubbwbuw, wuwrwbu, brwbru, wub, rbrg, wwbwrbu, grbbu, ubbbwb, urw, gwuw, uu, urwugu, bgw, gw, rbwwwurg, gubr, bbu, rur, rburwgr, gwwgr, gb, rbur, rbw, ug, wurur, gbbrrb, ruuuwugr, wwrgug, gbrugu, wrww, wuwbgw, uwwwgrgb, gww, grwwu, ggu, rrurr, bgr, ubugwu, wwgwur, urrrbw, bwr, wrbgbu, wrwbb, gug, bwu, ruurw, rw, wbb, bbwgwrr, wgg, ugwu, wr, wwwr, w, wbwbuw, guugg, bug, bbbb, brbb, brur, rbg, wuu, wurwgb, rru, urrrbugr, grr, rubu, uugrwbb, bgbrurr, wgw, gub, ugwwgr, urwr, wbwbg, wrrb, rwrgg, ggwgrgw, bwbu, uwb, rg, urr, brrur, wg, u, bu, ubbbrw, brgbbbbu, wgrgu, bgb, ubu, uugubg, bub, rwrr, gggbrw, gwwrww, grub, urgrgw, bru, wgwgb, wubrg, ugrwwbb, wbgwrru, gbwb, wugu, uwwwg, ubr, gwr, bguwb, guwbw, wrb, grw, gwwgbb, wbwwr, grbwub, ubg, bwbgw, rwu, uurb, rbwgur, ubbr, grrr, ubwg, rgwuug, rgb, grrbub, bwb, uwuuubg, wrugb, brurub, wurg, urur, uru, bwwrrr, urwub, uwr, brr, ggg, bbg, bgg, guuruuu, ubwb, uburgbb, gbgrgug, rbwr, uwu, rwwbuugr, ubwwg, wwr, brg, wruububu, bgbb, ww, wrgbu, ugb, gru, bbwgbr, brw, bwwbb, wbr, grbg, wbbb, brbrwwbw, gbgwrrub, wwu, wgb, rruruu, wuggr, urb, bwg, wbg, rbu, wwg, wuw, wrbbugg, rb, rrgrbrg, guu, bwwugr, rwrb, gwbrb, wrugub, ubbrwu, uggbb, ggr, wwru, rgbb, bbgbgrr, wuruw, gbg, ubbwrg, bur, wuwuu, bgu, ruwgur, gbu, wwuwb, ggbgg, ugrbb, bugw, rggrb, rrw, rgwru, ubru, grbbuw, wbrr, wruu, ggw, wbgguuw, rggrugw, gbgwwg, gwwru, gur, rr, wbgb, burbwr, rggu, wgwu, rwuug, gwrbr, wbbwbgb, wurb, gbbuggg, gbbgbg, ur, ugwwu, wgu, bg, urrbgr, gurwg, bbb, urrr, bwurbrr, gbr, gwurb, ugg, uwbbrr, buggr, rub, bwrgbw, uwbb, ububggw, uuwrbbu, rrrwr, ruwgub, bugb, wwrw, gwbg, wwwrrr, urgggwb, gwuwr, www, g, wgrg, wbuwb, grwrg, uuw, wuwgb, buru, rgr, rrgu, urbgb, wgrr, gbuwww, rrgrgw, rgbrg, gugbuw, rrb, rrgbug, ugwbrgw, rwuw, grugrrbr, gbgww, ruw, wubb, gr, ruu, ubbg, brgurb, rwg, gwu, ruwr, grb, uwg, wgww, bgbbrww, buu, rurbgr, rwbw, gwwr, rwwbbugu, grgbr
rubbgwuwbrwgrgrgrbrbbubgbggrbwrurwuggggwrbrgwbrrwb
urwgurrubuguruwuuuruwbbgrbbuwrbwrruuuubbuububuubrw
gguurrubwbuwgrbrrurrgbgburbrrurwbrrrubburuggbbgb
rgbuuwwwgbbwgurrwurgwgrgrbbbuggwgwugbrwb
rwggurbrgwrrwuururwwubgrurwwrubgguububururwb
ggrgrruwwwgrwuubgrggbbwrrgbrwrwgwwububrubguurggbrwbg
ggurrgrggwrwruuwrbrgbrubrbuggugwgrwgwurbub
wwwwuburrwbwugguwuwgwwrbggbwuwuuuuruwwurbwurgbwbggrr
urburguuwwwgrbrbgbbgbgrbgbubguugwubugwgrruuuugbbbbgubggu
guurrgwububururwgugrguuubrwrguurbuuuugrgbuwru
urwuwuuguwwwgrgbuwbgubwuwuurwuwggbwgubrbrguurrgrwb
bwwbbwuwbubgrbbgwuubrrbwgbggubbrbbwrwuuuguugwrwbub
wwwguwbgrrgbrgggwrgwuuwwwgwgwrgbrbgwgwruuruguubruug
gruuwuwbugubrwbbubrubgrruubuwugurbggrrbbbbg
wurubbwuggrrurbwwgrwubgbwguurbrwgwwwgrwuuuggwbguwwr
ggbguwrwguguwubgurgggrguuwugbuwbwwgwburgbwwuwgbrwbub
gwugrwruguwuugubbbrubbwbuwwwrgburrbbguwbgbgwrwb
grgugwwrgggbbbubububwuggrrgwruwrubwbrbbgwrwrggbuwrururrrrg
guwgggwrwrggbgwrrubrwburbuuububrbwrrrgurwugwggr
wuwwugwrbbuuburuururuwwrggbubwwugbuwugbburrwuwbubgbw
ugbggwbgurubbwrgwgggggwggrruubrgrwrgugwwgurrrbwbrwwur
wurubwrrbbgruurbbgurbbubuggubrrwwgbgwrwuuuwrgwbbrbw
rwwbruubgwrrugggwubgwwubwruuwggwrbwwbbrrwb
ugwgbguggggwwbwgwwuggurbwwgrbbuwurugwwrrrgugburruwb
brrrugbwrwbwwurbgbwwuugrbwbrgwgrgrbgrurwgwurgwruuguwbrurwu
rruwrrbgubguurwwugurrgrwbbuuwuburrbwwbbrggwuwr
uuwrburgruurrbuwwguurwbwwbwggrbubrwuuwuuwrbbg
gbbrrwgggbwwggwgwuurubrrurgwgwgbwgubwggrrbggug
wrwuggugbrwuuubbgrbugubbgurgrrburgwrbugrwb
bbbwgbuwbgrgggugrugwwwbwgrrbbbuubuguuugwburrrwrggwrrruwug
urbwwguugwrgbrrrrrrrbbwggrrubwgwugbbbuurugggrg
uugrugurbbruubwgbwbbbwubbrbbgwuuuwggwwwuubrrrwuwubrgrbrw
wbrugrwrwrrgugwugrrugugwubugrrrwbrwbwrggbwurrbgubgwbgbbgrwb
uwwbbubgrrrurgwrbgurugwbbrbbburggguugbwbrbgwbubuwbbgubgwg
rrbwbrbruwurwbwgggwrguwbbubuwuwurwubgwbwwgbubggwbbubbrbr
wwrwggbwwwrgubwrbwuuwbuuuwbrgwwrbrbrguruwrwbrrgrugb
wwbwrrubbbgwurbrbubwwbbbgbrbgbwbbuggrurbrwgwbubguurrwrwwb
rwurrgwuugrubggwbuubrbuwrggguwbgrbbgrgbbuwggbgwrbwgwbuuru
gwrrugbuurgrrwgbggwggguwwrrbgrbwwrrgwwbwubwbwrgbrgbgwwbgu
brrrwbururwwrwwrrgbwbubgbwgrgwwruuuwgugrwwrgbubru
uugbwguruwuwubburrgbbgbbrwrrbubuguugwgwwbw
gwburgbrwgwwubugrrrbuwugrbbwrrguwrbgbbgrggggbwuuwwgwgbww
rwwwbgwuubugurwbwururgbwbwwrwubgwuuruurbwbwgbwwbuwgg
bwwwbuwwrwgurbbwbguwwgwubwuwgwwubbwwwuwuuubbwr
urugrwggbbrburugwggbwbbuubbrbguuggwurgbrbbbgrbwuw
bgrbrbgbgwrrwgugbubbgbrurwrrgbwbbgrwrwbwwb
gbwubwgurggwbbgwwgbrrubguwgwwbrgwgrgwwwgwwbruwrwbuurwb
wuuwrwrbugruurrrrgwurguggbgwubugrugwwuguwwruuwbrrrwwruggb
ugrugbrrwuuwrwuguggwwgggubuwrrbwrugwwuugwbburrbrwb
wrrggbggbrgurbwguurugbwgrgwwgbwbgrbgwrbrwb
bugubbrwbuwugwwrwbgwugbuuubrwbugwrugggbwwrbgbwuurgw
bwrrwbrruuuugugggwgrgrwwrwwgwwgrbggwruwrwwwgrurwgggwbbw
gwwuwbuwwgwuurwwwgbruwuugruuwrgbbwugwbbwbguguw
uwrwwrurwwuwwwuwuubbbwbbrrwwbrrgbwbwggwgwruurrwb
rguuugbrbgrbwbbrwuuwwubwrrwggrwrgwwrgwuubwgbbwubbwbgbrruwu
gbgrgrwgbbbrwgubugwwuuwrrgbwbwgbwuwrugrbururbwrwrwbubrr
ruwrgurgguuurrggrurbuurubrbbguwbbrrbuuuwrgrwb
guurwgbwrbuurrrbugrbgbbrurbubbuugrgbwugbru
uggbgwrrgrrubgbbgwubwurgbbugububwrwbrgwbbbwwrwb
gwwgbbrrurbwwwrrrbruurbruggbrgwbgurbrwggwbrgurbbbwubbuw
wbgrwbuguguwrbbuurbubgubwgwwbrrrrbugurgggbbgb
buurgwggbbwgrrbruwuwruububuubrrbrrwrgbwbbwbwwururbgurbrrgrwb
rbgggbwrugrgwrwgwurggbrbgwgwgwwrbubbrwrbbuurugrrgwbrggbu
grrbbbwwguwbruwggwruwurrgrbgwubbubggwuugwubuwrrugurwb
rrbububbrrbbuwwuuwggbbwuwuwwrwgwwgwgrburbgrgrw
uuurugrbrrgwbrrggurrbubbuwguwuwgrurwbrbgwurwurw
rwubrwbuuuwbggrbwrwgwwrgrbrrbbwgrrwrwrrgbruggwwwgbbrwuuwrg
bburuwbugrggrwggrwbgbbuurwubuuugrbrrwgwgbrggrgggwbuuwbwbuw
wrbrbugwgrbuwrubwgwuwugbrgbwrwrgwururwrrrggrgurrwb
rggrbururgwuuwgbuwuwrruguugwbgubuwrubuwbrggbggbggrwb
gwurbruwrrgrrwbbwuwbgwrgwubbbuburrgbwrwrwb
urbrugbrwurgrgbrruwrbbrgwbrrbrwurbbbugwuugrwguwr
brrgurwwrguuubrggbggwwbgbgrrwwbburwuwrrwggbwubrrbggugubu
rwgwwuugbwrwrguwrrbrgwrurbwurrggwuwuwbgwgwwguurgrwb
guggggubguggwugbgbbwwgurubwugrbwgububbggbbrwb
wgwrguwggbugwwgrrrrwgwwwwrwwubgugwugbwgwggubwubrwb
grwwgbrwbubbwrwwwubugbgrubuuwbgurwurrugbwrgrrr
uugwwbuubggggruwugrurguwwwbrggggggrwwwrbrgugu
rgubgwbwurrguwgwburwubgrgbubbrbrruugrugbgrwwru
wbwwrubbbguggwbuugrgwguruuggurwggrrbruwbwrgbuw
rgugbrwuurrrrrurubrrgguuwbrrwruggubbbubgbwguurburggbrwb
rbuuggwwurwuuwgubgrbrruwrburugurwuubbburrguuruwr
rwurwrbbubgrwgggwwwbruuubwrwuwuwgrgbrgrgbugwrubrrbwbwbwrwb
gwrgbggrwrgbbbuuggbgrrgrrrruurbrwuugbubgbwur
rrurrwuuwuguuwbububrrwugbwuurbbgguwrwrrgrwwgbrggrburwg
ubruwgwbrubwrgbbrbbubggggwrggrgwbgggbgrburuwrbbrurgrgbbww
wrwgubgbwruugwubbggwugbgwwugwrbruuuwrwbbrrrru
rwubrrgbwrbgrbrwggugbbuugrguruwwwugrgurwb
wrgruuwrgguwwbrurbbugbrgruwrgrwggrbwwbwbgwrbrwubwubrwb
bggwugbrbwbgugwuwwurrwrrrwrgrguwuwurwguggwbrrbugrwr
ugubbwurburwrrbbbgwrbgwuwgbubrrgwgubrubrgrbb
gbwuggwruuuguurrwuurubrbwwbbwwuburgwgwurbbubg
uubwugrgburwubbbuururrwrwrgwurbwrrwurrubrwb
urbrwgwbuugbrwgbugggbbwwbuguuubbubwbguuubgbrrbububrru
rrbwwwbgrgwgurwwuwrbgwrwgrruwbgwbgugurwgrbugrbgbrbruw
ugrwbgrbrburugwbgugwugurrgwgrgwwrbgguwgrwrwb
wwbgbrgrwgggrbrugwwrwrbgubgrwguwbwubwwbgguggbbrgugbugrbbr
ubrwgwuwguwbwgguugrrbwuggwubbwwrrurbwruwbuw
gubrwwrbbrwwbuugrbwwugbgwwbbbugwrgbwbwwbwguggb
rurwgbbggugrwbubugrrwugrubuwwwwrwububgwwrwgwbr
wgbbrbbubgrrwwwgugugurbrubbuwbgwwwgwwgwrbwbw
ubgubwgwrwbuubgbbgrwbubugbbbrugrgwurubwgubguwugrrbu
gruuuwggwwwguwwguubggbguguuugwugwwgugwrwb
wrwbrgbgurwgbrbgurbbbggrbgwgubwbbggwrbwgbbu
bggubwbggbgrrrrggwbwbbgrguurrrggwbgurgrgwbuwbwurg
wuwbggrwwwbubrbwgrgrwgbrurggwwwubwwgwgbwuwwuguuwwgggbb
rwrugrubggrbururrwuwurbrwbuuggrbrbuugrwubbruggrbwuuru
wbrgggbwgrwwubbbguuuugrburubbrbrrrwubwgwguu
wrugrwruurrbwwwurggwbbwbuggrbwuruugwrburrwb
rburbbrwwrwgwbrubgwgwrwgrbwurgubuguwwwruuggbbuwwwggrwb
gwuugurgwwwrwwgbrbwwugwgurwbbbrwuwwwgrgbwbbgbbgruwgwwgwrb
rruwgbbwwrugugugrwubgrguguuwggbrrbrbubbwugurbgbubb
uuubwuburgrrwuugububuuwwrwrgbwbbgwgubwwgwgubrrbgbruggbu
wgrwuruuurwwbrwbwgrrwwrgurrbubwrwbgwrggbrrgugbuu
ugwbrgbbbwrgrgwbrguwrbrrgggbbuubgwbwgbgrwbrrwrrrgbrbgg
rgrggguuguwgbgrgrrgwrbbwbgurrrgwbwwguwbgggrbugugrbrurwb
bbwuwgrbbbbwrbrgbrgbbbburgruggrrrrbwrbbrwb
wbwuuwrruwggubggbgwbwwbggwbgbrrruggbwrrrbrwrb
wuubruggbruggbwbwuuugwrrwuwrgbwwbwuwwwrrgwrr
uwwgrbuubwbwbbrwburbrggburubwgguuwbwgbwburggwrgbrwb
ggbrubuwuurubruuubrbrgwuubguwbgbgwrrubrrrwb
rwgbbburwggwwgbbbrruuurbgrgbggrbgruuggbrgggg
rwwbwgwgwwbrbugbuuwbgggggwgrurbgrgwgwrgbbbuugbbgruwgwwwbg
rbwubbwuugwggrruuuugbruwwwwuuuuurgbgwwwgwbggwgbrurww
rwguwwrgugrbuwrwwbbugurrrwubruwugbrwubrwrgrbggbgr
ubbbugrbugrwgwggbwugwwbgwguubugbggbggrbuuwwbbbbbwr
gburuuwbrwrguwbrubgbwgruuwrwgbrwbrwwgwbgwggw
ggwwwguwgbuwrggbugurrrwwwrbrrbgurbbbgbruwrwwrbgrwwbuugrwb
rgbgrbrrubwuggruuwbgggwguuwwwrrrwuwrrgrubbbgrr
uwwgrrbugrrbwgggwuruwuuwggwbgwggwrbbuwbrrruubuguwugbrurwb
brwruwruwggrrubrwugbgbwwuggggruubrruugbgurrgwwugrurbrr
rgbbrrrbubrgbbbuuggruuurguubwgwgrwwgrbbwruwwb
rrbuuwgbuwwwbggrgbuurrbwwbwbwbrwwubuurrggrbg
urgbuwuwwugbrbguugbrbbggwggwgburgwgrwgurrbwwgrbbgw
uubrrugwggwgwbgbbwggwrrwbruwbrwuurgwwugrwgrwg
rgrguwguwrgwwgruggbwwbugbruubgurgrwuwrugbbggbuwrrggrwuug
uwubrubgbbwrgbgugwwwwwubwwubrburbbuurgwrrbwbubrbw
rgrbbwggrbgrrggrgbububggwggwwwwbrubguwgbuwbruwgugrgwrww
bbrwwrwgbgbgbrwwubbrgwuruwbrbubrrburuurwb
uuwgwgubwwbburwgrrbwgwrugrbwwgbggrurgwbuwru
uuggrgwuguuwwrbwrbuwrbrbgbuburuwwbbgbggbbugwwbu
bwbgwgwbrbbbwwbwrwgwbwgurggguwugrubrubrbrbuwwuugubru
uwuwrgwuubbruurbbbururrurrrbrwggbgbbgwrbuwubgbrrgwuurwb
bwgbbrgbbbbuugurgrburrrugbuubgbbwwwwgbuuwuggbgwguubb
uubwbuurbbwgbrgruwbugguguwbubbgrgbbgwbubggrrbwrwb
rrrguwbgwuwwbrrwrrwguwurbgbrburrwgrrburgwbbrruwwrrwbwrb
rruguburbgwgrgbguggggrugrgwbwwbwrbggwwgbruwuwrwwbubgburgr
rurgbwbugrbrgbgrurruwbubugubbgwuubgrwgrwwwgwbwrwbbwb
bbgbwggwgbbwbuugrrubbubgbrbrgubrugugrwbrwwbg
gwgugbburwwwwgbwwubwrwrwuurruuwuwwurugrrrgb
wwwrrrgruwrrrwuubwbrrurwbwrwrwbwggggrrbwuwggg
gbwrwguguggbwwrrbwgwwbwgbbbgwbuwuwrgwwrgbwuurb
guguuugbrbgruwbwbubwurrwggrubruwwggbwwubguub
uubbrubgrwwwuwrwgugbwbgurgrbbrugbrurguwrwwbbuguuuburwb
gubbuuuuubbwubgrwwguruggrbrgrrubuuuurrwrwb
uwwgbgrgrbrrgrguwgubuuwbwgguwbgurbwugbbrgguw
buwbgrggwwubrgrggbwurubgrbuuuwurrbuwurbbbbbrubgbrbuwwwrw
uwbrrbbwwruurgrrgrwruruwuubrgbrwwgwbugrbbrggrbwwbgrrwb
rbwgwbrguubbbugwguwrgrgbggbrruggrwubrwbgbwwuuwrrgwg
rbrbbgwggwuuburggwwrruruuruggwubruwwbrurubwbu
rbubuuurbwrugurggbwwbugbguuuuuwrubbguwrwb
bbwbubwrbuwgubguwrwrwgbgrrwwruurwwrbugrrurwb
bbuguurruwrrbguuuugwrguubwuubrbggrwubgugbwbwrrurugrugrwb
gbuuwurrbrwwrubgurbuubugrrbwubuurwuwwwgbbgbrwbrrrubggrwbgwb
grggrugrrbruuwbbbrrugbbbbuwbrwurrwgbwbuwrwb
bguurbwgwgbgbgrgrbbwgbbwubbwggrbubrwrbrubrbrgrwbburwb
grrrbrrwubuuggrgrurruuwwubwuuwubrrbburbrwwggrwgurgwgggwr
wbgubuuubwuwbrububrbwgrugrrbrrwbugguwwuuugu
rrgwgrguwruwgrwwrbgrgbbbbbwrgbugbggbrrwb
gwbrrgrruurwurburwbgrbggruuurbrbwubguwgrrburbgwwwu
bwwbugbruwrrguubruwbruuwrrwuwbruwgrwgwruwurgrbgurgruguwbg
brgrrbururwguwbburgurgrggbgubuwgruuuurbrrrrwugg
uwrbugwwrwuwgwwbuugbuurbwwbrwwrgrbggbgwwwrbrbwrrubbgrugw
uuggwbwrrwgrruwgggbggbgbubgwgbugwwrggrgbrgrururgugur
bwwwrugrrgbggbggbwubburrgubgwgwwrbwwgwbgurw
gburbuurwgbwgwwgggwbguwuwruububuwububwuwbgg
gbwggbgguwggbgwwrurwggbuburwrrgrbgbbuwuuuwrggwggwb
gbbwwwgbgwurgrbbwbgguwrwrggguwbugwbrgbwurgwuwgrrug
rgbugwrgugwbbbgggrwgwubbbwuurbrbrwbrgrwuurwgrg
ruwbuwurgwbuwrrrgwbrwrrruwwgggwugbwwrgruwgwubbgrwrrrwu
brrbwbbgwwwuururbrbuuwwwuguwwburbrurwuwgbwrbuubrbbww
rrrwrwugurubugbubbgwgrggwbbggbrugwbwrbggburgbrwr
ubrggrgbgwgruggrgrrwbruubwrrurubrbgwrwbggbrgbbrgwbbbr
ggrbbggrurbrbruwwugwrbrwrrbwgbrwwgubwrbrrgrbbwwwruwggww
wugbrbgwwwwrbugbwwrrburuwrbruruwuuuurbuwwwbgrgbrwb
bbgbgruurgbubburgwruwgrwuuubbwbwgugwbrbuuwwgurrurgwwrrb
wwburbbgbwurubrbrurwwgrwgubbgwbgrguuugurbwuwbuwuwuru
bwrgbuwrrrbubbwugbbrrgwgrbbbuguugrwbrurwrugguubbrubuggrwb
rgrwugwgbuuwubwrguuburuuuwuwbgguwuubggrrbugrbugwbgwwubwwbb
wbwrgurwrwrgggbbgggwwrbrbgurggubbbgrgbwbug
rbwbuwgurbbbgwuubwbgrwwubwbbwbgggwurbbbgbuu
wbburugwgrwwwgwwrwrbubrwuwrbgbwgbbwbrrbwbubbwbruubgrug
wrwggwgwwuuubbgrrwggrguubrgurrwuurubwurggwbrbbbugwuuwubwgu
bggrgbruwguurrurrbwuuwgugbrbwbuwwgwrgurggwburbbwgbuw
wwwbbugrrwwbrbwwgwububbuggrgrurggrwgrurruggbburwwgwurwb
rbrrwubgrwrbrbrggwwrurrwbwrurbwgbubggbrrrwwrwb
wuburwgwrwuwggbwwrgwwwugbwbggrurgbrurruwburuugwrwb
gwbwurbrbuurgwwbuuurrubbbrbwgruwuwuuuugwgbbb
wguwrbrbrgbbbggbggbgbgwgwbrggbggwguwurwwbbwbrrrrbwrwgrwb
wwwbruruubrurbugrrwwuburubbguwwrrbbwbbbrgbbubuwrurugr
brurrgggruwgrburwuggugrrbwbuuwbwuubgurwubruwrgwurbrwb
gwrruuwbrbwwbbbuwbwgrgubgggggwubgugubrbgugwuuburubugruwu
uubwruurruwwbrwburwggugggrguuurrgbbwbuggbwbuuurbgrwb
ggwrurbgrwgbbbruuurbbuubrwururgwwbuuwgrgwrgbubugrbrrgg
gubrurubwbrgrwwgggwwbwwguubbgggbggwbwwrguwrgwuggr
rwwugrbggburrrrbgwwgwgrurbbrguwrrbbbruwubgrgbrrwb
bgrrrbbgrguwgwwgurwwwrwugwwgrgrrwwguugbbruruuuwburbbuur
gwrgubrbubbbbrggrrbgwuwwbgbbuubugwgrwubgbbr
bwwwgwguwrrguruugwwbwgrgrwwbbwbrrgwbburuubbugbbrgggw
wburrbwwgubwbbwrbrgrwrbwugwuwwgwuugwwwgurgrguwuwgrgruu
wggrrrbgbgwurwrrwbrubbwbrwgrrwuugbrwwuwgruwwurw
rrbwggggurwrbwrrwubbrrurwwgbbrwuuwrruuwbrwb
ugwwwrbrbugbgrbuwbubwuggbwwugbgwrrwurrrwrrbgwrub
gbwgguuguuuugwgbuubggwuwbgrrbrbgwwbgugguruwrwggwwrwgwgu
wuubbbugwgrugububgrbgwugrurruwbwrbggwbgbbgurgrgbw
gwugwbbrwbwgwrwbrgurbwuwuugrrrbwwrburubgwrwwbbg
wwrgrrbubbuuwwbuwgrrwrrgggguwrrubbugrgwwbbug
gwubbruruuuwbbgrugbbbgbgwurwgwgwbwbwugggugbwuburwb
grgwgwrugugbgbwwbwubgwgbrgwguuwrrwwwugbgwgbgwruwwrwgwwrwb
rwrggugrwbbwgbubuwuwrrrgguguwrggbwbbwrrwb
rbgbwuwbwrbbwbbgugwgbbbwbrrrugwbrbubgruburwgwrrwb
wrrgbbbbwwuwgrgrrrbgurugbuwuubrgbgrbbbrrwb
ggrbwgwgrugrbrrwgugwguuwubuwwrugbbwwbbwuwggwuu
rwuuwwbugruwrruubuwuruuwubrugwrrwgruwrwrubbruruuwwg
rwrwuwbuwugbubgbbrguwgubuubbuwbwbgurubggbgubgwu
ugrrrruuwruuguwggubguwwwgrwuuwrwugwruwgrrbbw
ggwgwgurwrggrrwgwruuguwrugubrbuurwwruwbgrgrwb
rwbrrwuwbbbgbrrbwburwbbgbggwbbggwggugggrrrwbugg
ugbruwrruwgrbwuggrwwbruwwubrurrggbubgubugbgruugrrwb
wwwuubbwubwrubgubwrugrurbugguurburrrrwgguwwuggugurguwurwr
bwwbrruwbugbwguubbgggbrwbbrurgwbrwgggbgugbbgrbww
brgbwwubgubguwugwwuruubggwwuuwgwgwggbbwwbubbbggu
rbbrbbrurbuwwwguggguwgwggburbggubuwwbrbbubruuwwbgbru
rwuuugbwgwuugurbwrrwwbugbggbuururrbgwbwuuurggrurbgwbgggrrwb
bbgrgwwugwbwugggbugbgubgbgwbbuwrruurbwurwrgwurwb
bgwgguuwggrbbugbgwwwrwurrrbugrgguugrbgwbgwgwggruwwggwwgrwb
urrwggrubuwgbwggbbuwwbwbbwwrrgwrwbgurwurru
uwwbugruuuwggrrrrrbrrrbrurgwrrwwrrwbwbruwbbbuggwuu
wrururubbrugbggubggrbruuuubuubwuggggwwwubbwbbwbgbgbbgurwb
ubrubrbrgugurbuwrwuuwgbgwwrrwrrbbgwgbwruwrrrggggr
rbwguruwbgbgbbbbubbrrrugrruggurwwgrrrbrwb
rurgwubwbwgubwrbgguugrruururgwgbuwwurgugww
bwugrgruugguguwbgrbbbwuuwrrgwrrwrrubgrbrgbrggbww
rrgwbrwggbbgrggugurwgrgbrgwgbwrruwgwggwgrwuwrwbburwwbu
uurbwggwubwgwwguwbbgwwggugrrruggbgwbrrgwrr
grwbwbwrgrwrrubbbgwgrbbwrbgrurwrguwwwwggrbwbrwubbwrggr
gbuwbugrgubbrrbwwrbgwuwrwrbrbrwwbwbwrwuurrruurwb
ubrwurrrwwrbgwwgguubuwwgwbguwggurwbbgrugwbbrubug
rbugbwbguwggwwrwbbgwwuuruwwbrububbrurbubrgwwrbugugwbubggru
uuguruubgwwrrrwwugwurbgwbubrgrurrgwuuuuuggwbgrwbugu
gwwbugrrburuuwbwwbbugguubuuwwbuwbuwgubuwbruuugrgurgbuuubbw
ugwwgubwubbrubbrugbbbrurwgrgubgubugururgwgwwburgr
uggrgbruwrrbwrwgrruurwgguguwrwrwgbrggububgwrbguwbugwwguw
gruruurbgwrggggbrrugrbrgubrurrgugbbgrbgrwwugbrubw
ruggggwgbubuuubbgbburuwwgbbugrwubbrubgbrgbggrgubrb
wrguwbuwbrrbbbwbwrbgrrubwggbuwrrrgugbbrwbrguugrbrwgbrgg
rrgrwbgurgbbrgrbgugwrgrruruuugrgrrbbrrrwb
uuggrwugruuggrurbwggwgrwbwrgrbbbgbwbubugwg
rwwwrwrrbgrrgrgrwrgururgwrwburubwgrguwbuwwrrugugbbrwb
bbgguuwwuwbbuuwgwgurrwrwgbbrgurwgbrrbwrwbrwrbuggbwwrwrbuw
wrwwbgwgwruwrubbwrrwurwubgrrwrggbbgbbbgwwbgwggrbbwbrbbgbg
wgggrbrbwuwgubrguubgrguwrwuuuwbwwubuuwgbgrgbruubb
uggrwrwwbguwurbbburrgwgwururgwrgruwbwuubugubrurbuubrwrbuurwb
wrugguwugrgbuuwrbugrubrggggwwrbuwuurbuwruwwuww
wugwrwbbbrbbbrggrwbuwrwgwwbbrbwwgbruwugwruggggbw
uguurbwgwbbuuguwrwguubuugwurbgwrrbgbrrguwuwug
uwwuubgrrwgwrbbrgwwwbwugbbggbuuuurgubgwugrbgurbbwug
gwuwgwrrwgrwbwggugrbrggubbuburbbbgugrbuwrurrwbrwgggr
wwgrugrwuguwbruwugguurguwrugubwubrbgwwbrwbrwgbwrgwrruwurbr
gwgburrgwuurwburubuuwwwwgbbwbggwwgwuugrgwrbwrrw
rbgwgbbruuwwugugugrubbuugggwgubrguwwgrwgrrrgwbggbuguwu
rwwrrbrggruuubgruburgwubrrguwbwwgrgbwggruggwg
burgwuwugwbbbgrwgrubguuwugrbrbguubwwwrbbrwbrrugubuwwguuurw
gburugwwrwrrugugbbubrwrburrugrubbrurbrwwgrbbww
wuubbrbubbrbuubuwuwwgbuubugbrrgrugwrgwgwwwwwwwuurb
wuwgrrgwbbgrurbrgrrurbbgwuggggbgwuurwggurrwb
grbbggbgrugwbuubruwrgbwrbbwuugwrrugwrggbrurbwrrurbrwb
uuubbgrbwrurbwbuggbbgrwuguuwubrwgbgrrwurubbrwgggwbggrwb
urgwrgbbuwwrbrrrbbrwgwugwwrgrugwbgbbgrwb
wgbrwggguwwruuwwggwwrwbbbugbruwugbbbuuuwwgurrrbwwbubbwgburwb
buggbbgbgbbwwwurwrwrwbruwgwbbgrruwwgruubgwwwuggur
rbgbwubgbbgrurwwguwubrwubbuuggrugurubwuwgrwgubgugwguugrgw
urbbgurbubwwgbbwburrrbgrbwwubggwugbrrbugwrbgubrb
wbrurrrbgrgbgbwwwrwurrwbuuwrwwgrburwrrbgruggubgrguwgbwur
uuururbwrrwgwbwwrwwgwgruwurrbugwrgburgwrwrbrbw
rrwrurbrgubuguwurwgururugbgrbgubrgrgggurggugurgrbbuwgw
rrwuwrugwwbbubbrbrwrbwbwubgubgwwgrbugwgrugbgb
grwgbggwwwgwrwgruggbbgwrgwubgwrwguwgrguuuuuwgbbubgguugg
rbuurugruurwuwgburwgwgugrwgwwgwwgbrrugguwruw
urubgguwggurwbgrwwbubguwggbbbgrugwgrbgbrwgwrrbrbbrguub
wrbrurgwbubbwbbrwbbrugwgbubrwbgrgwguwuugbgugrgbg
rwuruwurgugggrgrrrugrurgggrrubguurbububugugbwurwuwwug
uubwuwrwwgrbbwgrrgubwgguggbrrwuruuwuubgrwuggbgruggbrr
uurbbgrgbrgbbgrgrbwwugbrrubgubgurrbbrrrbubr
guguggbgggwbbwrwrbwbgggrurburgurgbbwwgruru
wbrrbbuurwruuuwugrgubwuuurbrwurwurbwwbwububwbbbrwb
ubbrwgggwrwbwwwrbgbrrrbrubwrgurgbbgbuuuuugbwgwgrwuwwbuu
bwrbggbgrbbgubbwrrrubgwburgrgrrruurwuuggbguwbwwurrwrwb
gwuguuwbruwuuggrbrrbuwurbggbbwguwwgwwbgrurrwb
rrggbbgurwbbbgurbgbggubgrruuwbrbwgbrguwubbggguwbgruwwrwb
uwugbwwwrbbruubwbrgbuuubbgrubururrbrrgwwbgrwgbrwruwrwb
bwurruruwuguwrbuuggbwbrubbrwuwurbgwwbrgurgwuggr
ruuuwugrrurbwrgrbgurbrwbrbubbwwuuwwuwwuugugbbgrbggwr
uugrgwgwwgrbrubbugbgbrguwbbwwgrubbbgbgbruwugrrwb
brbgbwwwbbuuugrwrugbwurrgggbwwuubwruuburrbrr
wrwrgwwrwrugrwrrurbuuwgurgbrgbrwwbwrggwbrbbuugrbbwugrwb
rugbbggbuggwgwwuruwrwbggwgburuubuwugbggbrbgubrwgr
ubrrwuwguwwrbgwbbbrrgrggrgrgwgbrugubuwwwwuwguuurwb
ruguguwuruubbwwwgwgrrrwrwwuuuruuuwuwgwubwwrwu
brggrwrbrwwwuwwbwrgwbwurbuwwrbrgrrugbwugrbguuwb
gwuugwuuuggrgurbbwggrubbwuurruuwrggrggurgrrwrrgbrb
ugwggbgbbrrwgwrbuggurrbuugbwrurbbuggubwbgwgwuwgwrrrwubuwurwb
wwuugrrggrbrrgwuuugbwbwrurrbuwwwubwrbrggubbubbgrrr
ggwuubgurubrurbwgrwwuggururbrgruwgruugugrbwgrbubrbrb
rwggguwwubburgwwuurrurrrgwgbrgbbbrruguwbwugguuurr
rrbwbrrwbuwwbwrrbbbwwubuwgurrguwugguwrbuwuubbwuwrbggbuu
grgrbggrburrbgwbwbuugugbburbrwrrrguuwbugggugrrrgrwrwb
buubrrggburbggwgwgrbgurwbwwwubbwbgbwwuwbwwrwb
wguuurrggwguurburgugugbrwrgbwrrwbgrugwuugbwgbbuubggrugbub
wbwgruuugggrrubbwrwwubugguguwwguubwurwgwwrbgubwrgbbubrwb
ruwrggugbbbbgurwggruuggwwggrwwrwbbbrwguuuuug
bggwwuwgwbuguwggrgurbwugbbbuurwgwuggubgrwbwwwbwgrrbuug
rrgwugbuwugubuuggbrwwguurwuwugwuuuubgrwrrwrbgrgwbuggwr
grguwrrurgbwbwrgwwwrggrwbwgbuwbbbwbggrbrwbbrwb
uubgbrgrwbbgwrbrwwgbgburbuurbubbguuwbgbuuwburbubggguug
gwbgwrbwwwubuwwrwbbwrrrgwuwbrubwbgggubugbwwgggburrbugrgu
bwgwguugggbrrbuggwggwgbrbugurbwwuuwwwugbbubbrwb
rwgwbgbwwuwrbgbgwbrwuwruuubbrbwwuruwbwrbrwrwrgru
wwrbwwwurggbgggugwuggubbbwgrrwrbwwuugwrbubwgrbgrrr
ubrubggrgguugburwgbbrwurbrburuuwwrrbrrwwbgwbgggwugurugwwrwb
gbggrubrgubgubbwwwwuwrbburrgrwbrgrwbrwguuwwuwrgguwrwb
bbwgbrwggwrbwugbgubugwwuwwggbgubwubgggwwrbgrwrwwgb
uubrbgbbguugrruurbrwbbuuuubbwwuruuuwbbgwbgrbwrrrgb
bbbwugurwrwurgbuuugrrruubrwrgwguwubrurgburbgrrwrr
gggwwgwubwwwrrbubuuuggrgrgburugbgbuurbgrugrwrgwgruu
burugbguwbuwgubugubbburrgrrwuruubbrbrwwbwrburubwubbb
wrwbwrbggggbgbruwwwubuurwbgwgrrgrwubwrrbbggrgbwbwbbbuwbbrwb
uuurggrbbwubuwbwbwrgrbbwgrgugbrruguuugrgrubb
buuugbwbbgwrgruuwrbwbgwbbrgwbrgrwruwwwgwruggrb
rgwrrguwuugbgrbubgbuburgrbuuwwgbbwgurrwwubrgwguw
ruuwwurgwurgbuwurruurbbbbugrubrrgwrgurgubbgbbwgugrwb
urrwrwgugrrbbrgggrgubwbrwwgbgururbwruguwwrgburg
rugrggruuubgguuwwwbgbgbbgugrwgurrruubrgburgrrwb
ubwwrugbguwrrrbwuwggrwrwrububurbgruwbgwrbbbgrrrgggwr
wuggwbgwbbbwugrbbwwubgrbwrgrgrrgwuuwgrwgwwurug
bgwwbbbwrrwugwgwwrruggrbwuwbwwgrwrgrrguwgrurwgurgggrrwb
guwrwubwrwwwgugguuwwurbgugbuwrrbwrguuwgbwbbgbgurrgwbbu
gwugguubwruguubuguguugbuuugrrwrrrurrbwgrbwgwugburuu
brwgwrbbgwurgrugggrrbbwruugrgburrwggwguwuuwrrbw
bwbugwurgbgurwwrugurgbbgbuurugggwugubrwb
bbbuuubggggggwrbrgbbwruwuuwugurbubgwgrrguugbwuggrubrwbwgr
wgrrrurugrbgwbgbbrrgurrgwrurrwwwbgrguuggrgurwww
gubbrbwurgwwbbggurwgbgrwrwbrugrwrburgrrugb
uubuubgguwwbrrwwwwubgwbbwbwwwwugguguwburgbrbbbg
ubgrwugugrruwuurrwguggwuwbrwbwrugruuuwrugwwuwrubuugbrwrrrwb
wrgwguugruurububuurwurrwuggrrubbrrrgugwuugwurgrg
bwubggubrrburbrbwggrurwrbwbgbbgwggubggbubrububrwb
urugwwbubbrrwwwrbrwuwbwurwgrurbwbrurbrwrgrruburwb
rruubgwwwgrwrggubgubwrbbgwgbguruwwgrgburgwrg
rgugrgrbbrgwbguwgguguwrrubgwwgwgwuwubwbwrggbwuuuwrrbwgwu
gwuwbwuwwbwwggbbgrgwugwrgugruuubgwguwwgbbrwb
bbwuguwwwuguuuuurrbbububurbwruuubugbgrbuwgrururwb
bbbugrrrbrgburgwuuruwrbwgwrgwgrugbrgububrbwwgrbrgbuwbgguu
bubwuuwwuwbggrwwubruwbubbwwgwrubuguwbuuwugwrbbugr
uwrgubbrrgguggubuuwrrrwrrurbuubrgbbbwgrwub
wbbguubbbbguwuwbwrgwwubwrurgwurbrrwurrbgrbbburw
rgbwugbubggbrbwgbuuubrwgbrruwggbbggbbuggwg
rgrugbgrwbwgwuwrbggrwuburrbguwguguuugwgubrgruwwbw
uuuruwuurbwubrwgwuuwbugrrwggbwwubbugwgubbrwgwwwugbwwrwb
brgbguwuwggbbwrbggggbrbubbwbrwbbgwuubbbbgwrgwgbbwu
uggrgrubuuuwruuurbuwwugbwwgwwguubuggubwwugrrwbggwrgubrbwrw
wbburbgbbrbbggrgrrurwwgurbubwuurwwgwbwrgbguuuwrubwwubuu
buwbgbrwgbubbrbrgwuwbgbrwburgbbrwgguwwbwgbwbgbww
gurwggwurgwbbubbgbgruggbrbubuwbruwwrwguggrbbbrggwgbrgbgu
wbwwwbbbwgruuuwubbrrgbbggwbrgwwbgurbbwgwgwgrbggwrugrugggbrwb
bbgrwgruggrwwurwwrggbruugbbrgwggrrugrwuuugbrrwb
wwbugbwuguwgbrwrwgrrbuwgwuwgwrbbbubwwgbrguwuw
ugwbgbwrrgbwrrrbrwwguggruwugwwurwrrbgwubbwrggugbruuw
bbbruuwuwwurrwbuwbuguuggurgbgbruruwurgbgbgrrwb
bggwgrggrrugwwbuwgbrbbgwbbuwwuwbrgbwbggwbbgggugwggrwbbur
uuurruuuuugrbuwwgrbwwuuwbruggggbgrbuuggbuuuwgrrb
gbgrgubggbgrgguuwbwbrwbggwurgbwwwbrubwgwrggrbwurggrwrrr
ggbrbrbguwguuugubruggbgwbbuwwrbuuugbuuwgww
wurrbururbgrbrgwggwggrgrgrgbgrrgbbwwgbrgwururwb
uubugrgbrubuggrggrbwbbbruwbrrwugugrurwbgwwwbubgrggr
rgwwbwgbwugugrwrrwubrwbgwuwuruggbguubbwbugururu
wbuwrbggrrwbgbrbwwwbbgwbwrrggubrubbwbubrgwrwburbgb
gbwuruuwuwwwbggurugrwgwubbgbwwwurgwbruwgbgrbwrgurwb
gwururwwugrrubbruwbuwrbgwrbruugbuuugggwbubwubb
wgrgrrgwwruugbrrrbwwrwrrgbguwwgwrbgwuuwbgwuwrugg
ugurwrbgrbubwbbgrwgrwrbgwbwuwubgrbuwwrubrggwuguwbgbu
ugrrburuwwrrwgrugbruwgwbbubrbuwbwwruuurgbuwwgwgbwwbuburwb
wurugurbrbubbbbburuubrbrrbwubguwggwubbrbrbrgurrbwwwuggwg
bwrburggbggbbgbuguwbgwwbbbubugwguwbbgbgwbg
gbwrbgbgbrugbbguruuwgurwwruggggbuburbgwwrwb
rubrgwubrrrrrwbwbrurbwwggrrburrugrrubwbbguwbbgrwwrbburrwbr
wgbuurbrrbgrugwgubuwbgurrwwuwgrbrgrbgwrwwbrururuuwrrrwb
grwuuggwugwgrbggggbwbgwububwrgwgburrugurbugurrrwrwrububrwb
bbggugurwurrgggrrbbrurubbwbuwbbwwbrwgrrrubrgur
gwwwugwuguubuuwgbgruruwguugrbbwgbbwwgrgrwwrrrrrbuwbbwburwb

10
day19/sample1.in 100644
View File

@ -0,0 +1,10 @@
r, wr, b, g, bwu, rb, gb, br
brwrr
bggr
gbbr
rrbgbr
ubwu
bwurrg
brgr
bbrgwb

8
day19/sol.sh 100755
View File

@ -0,0 +1,8 @@
#!/bin/bash
file="$1"
designs=$(sed -n '1s/, /|/gp' <"$file")
echo $designs
sed -e '1,2d' <"$file" | grep -E "^($designs)*$" | wc -l

31
day19/sol2.py 100644
View File

@ -0,0 +1,31 @@
from functools import cache
def solve(file):
designs = file.readline().strip().split(", ")
assert file.readline() == '\n'
ds = set(designs)
@cache
def ways(x):
n = 0
if x in ds:
n += 1
if len(x) > 1:
for i in range(1,len(x)):
if x[:i] in ds:
n += ways(x[i:])
#print("ways(%s) = %s"%(x,n))
return n
t = 0
for line in file:
towel = line.strip()
w = ways(towel)
#print(w, towel)
t += w
print(t)
solve(open('sample1.in'))
solve(open('input'))