mirror of
https://github.com/plasmaofthedawn/2023adventofcode.git
synced 2024-10-18 10:06:24 -05:00
Compare commits
2 Commits
79b3d84920
...
dfa1997824
Author | SHA1 | Date | |
---|---|---|---|
dfa1997824 | |||
77250a2568 |
22
Makefile
22
Makefile
@ -154,5 +154,27 @@ day15part2:
|
||||
@echo
|
||||
./build/day15part2
|
||||
|
||||
day16part1:
|
||||
fpc src/day16/part1.pas -obuild/day16part1
|
||||
@echo
|
||||
./build/day16part1
|
||||
|
||||
day16part2:
|
||||
fpc src/day16/part2.pas -obuild/day16part2
|
||||
@echo
|
||||
./build/day16part2
|
||||
|
||||
|
||||
day17part1:
|
||||
fpc src/day17/part1.pas -obuild/day17part1
|
||||
@echo
|
||||
./build/day17part1
|
||||
|
||||
day17part2:
|
||||
fpc src/day17/part2.pas -obuild/day17part2
|
||||
@echo
|
||||
./build/day17part2
|
||||
|
||||
|
||||
clean:
|
||||
rm build/*
|
19
pythonsrc/day7/part1.py
Normal file
19
pythonsrc/day7/part1.py
Normal file
@ -0,0 +1,19 @@
|
||||
print(
|
||||
sum([a * (c + 1) for c, (_, a) in enumerate(sorted( # sort by hand value and payout bets according to rank
|
||||
[(sum([ # total hand value
|
||||
[max(
|
||||
13**5 * 6 if 5 in d else 0, # five of a kind
|
||||
13**5 * 5 if 4 in d else 0, # four of a kind
|
||||
13**5 * 4 if 3 in d and 2 in d else 0, # full house
|
||||
13**5 * 3 if 3 in d else 0, # three of a kind
|
||||
13**5 * 2 if list(d).count(2) == 2 else 0, # two pair
|
||||
13**5 if 2 in d else 0 # pair
|
||||
) for d in [{k: b.count(k) for k in b}.values()]][0], # total type value (value from the type of hand)
|
||||
sum([13**(4 - e) * '23456789TJQKA'.index(a) for e, a in enumerate(b)]) # total card value (value from the type of card)
|
||||
]), int(v)) # makes an array of form (total hand value, bet)
|
||||
for b, v in [x.split(' ') for x in open('resources/day7.txt').read().split("\n")] # reads file split on \n
|
||||
]
|
||||
))])
|
||||
)
|
||||
|
||||
#sum([a * (c + 1) for c, (_, a) in enumerate(sorted([(sum([[max(13**5 * 6 if 5 in d else 0, 13**5 * 5 if 4 in d else 0, 13**5 * 4 if 3 in d and 2 in d else 0, 13**5 * 3 if 3 in d else 0, 13**5 * 2 if list(d).count(2) == 2 else 0, 13**5 if 2 in d else 0) for d in [{k: b.count(k) for k in b}.values()]][0], sum([13**(4 - e) * '23456789TJQKA'.index(a) for e, a in enumerate(b)])]), int(v)) for b, v in [x.split(' ') for x in open('resources/day7.txt').read().split("\n")]]))])
|
@ -39,4 +39,7 @@ it uses zasm to compile and z80sim from [z80pack](https://www.autometer.de/unix4
|
||||
i edited z80sim to not print out that giant logo at the beginning but otherwise it's just the newest one built.
|
||||
the binary is included though lol.
|
||||
|
||||
make day13part1z80 i think is the make for it.
|
||||
output is in the hl register.
|
||||
|
||||
|
||||
|
110
resources/day16.txt
Normal file
110
resources/day16.txt
Normal file
@ -0,0 +1,110 @@
|
||||
\.........|......./...|........................................................|............|-...\...-/.......
|
||||
.....................\.......\........./...|...............|...\................................-...|.......\.
|
||||
.......................................-....-./............/.......-.............\..|.......|......//.........
|
||||
...../..../.....\.........-.........-./..-.......\./..\.............-.....\..........|-..................|....
|
||||
...........\..\...............-.............|.......-.\......\...\..........\.......-.....|..................\
|
||||
................|.........|........|............--........./\....|-.....................................-.....
|
||||
........./...........\................../...................\././........./...-...-.\.-.........-.............
|
||||
......|.....|............-............./...|...................-...|........./............/......./...........
|
||||
......./........../..|.....-...........\|.................................................\.........|..../....
|
||||
........................|..................|.......|.................-..\...........-/.\.................\.|..
|
||||
.......|...|./....................................-...\........\.......|............................|...|.....
|
||||
\..-................................\.......\........../....|.....................|........\../.........../..\
|
||||
....-|...............................\....|..............\.....................|.....\......\............../..
|
||||
.....\......-.........-.\.|..........|...............-.................|..........-............../............
|
||||
.........-...................-.............................................-.........../...................|.-
|
||||
....................\..\........|-.\...............-............/....|..................../...................
|
||||
.\.........-........................|..-.......|.......-...........-.-...................\/...\....|....\.....
|
||||
.-........-./.....-.....\.......-..........\..-........\..-.....................................\..../...|....
|
||||
....-.........................|..\.....................................\./...............-............/.......
|
||||
..........|..\....-........./..............................|........................-.......|./|........\.....
|
||||
..\.........|..|..-|........\...-................|/..\......../.......-|..................||.-./..............
|
||||
.--..-.......-........./.................\....../.................-............................--.........-...
|
||||
.......|.........../......./........../..\.........\...\../..\..././.......-..................................
|
||||
.........-/...............|..\|.................\...........|............../............\.....................
|
||||
..........-.........\.-................|-..................../......../...|/...\..-....|-........-.......-....
|
||||
.--|.\|.......|.....-............................|.-....-...|...................|........../..................
|
||||
.....-......./..../.|...................|\..-.........../...|.............................\/../........../....
|
||||
......./........|.\......-../...........\........................./..........\.........-...\................|.
|
||||
./.......................\........-......|...|............................/............\....-.....|..../...\..
|
||||
....................-..............-..-.............../..\...../.\.........\................../.....\.....-...
|
||||
...................../......-....-.......|....|......../..|-...............\..\../.-.....././..........|......
|
||||
..\.....|...\............................./.../...../..../......../...........................................
|
||||
./.../................................../.....-.........|.....|..........-...............................-....
|
||||
...............|..\...-................................\.........................|....\...............-.-.....
|
||||
/........|.......|.....-.......-..-..-.\.................................-.\...-.......\.............-..\.....
|
||||
./......|../......|................................/.........||.-....................|..\.........-....|../...
|
||||
|..................................................\......|...-............................../.......-........
|
||||
....../...............-....-..................\....-../................................./.\.................-.
|
||||
......-...........-...../.....-......|..........\.\...-......../......\................--..............-......
|
||||
.............\/........|...../...........-.......\...|........................................................
|
||||
...\\........\..........|...\............/........-..../....-.....................-......................../..
|
||||
.......-......../......./..........-....|....-..\.........................\.............../..........-.....-..
|
||||
.....|\/..../.........|.........../|.....\.......-........-............../..././.............|................
|
||||
.........|....|....\..-....../............/.....\/....|.............\........................|.........-......
|
||||
.\\..........................//......................\....\...........................-.|/....................
|
||||
...................|...................-.|........................................../..........\..............
|
||||
......\..|....../...........\.-.........-.......-..|../........../.............................../.......-...|
|
||||
..........|................/|.....-.....\................||........./.............|.........../..-..|./.......
|
||||
............../../|.......\...............-..../|..../-..|................................../......-....|..|..
|
||||
............\...............\.........................\....-.............-..|/.....--...................-...-.
|
||||
.....|\......\...........................-.................-.......\...............|............|........../..
|
||||
.....\...-.............|............\........\...../.-...........|.-.................\.........|..............
|
||||
......./......\..-............|..-...\......................\..........|....../..........|........./.......\.-
|
||||
..-.....|........./|............./.....................|...|.\....-.......-..........|...\.\|-........\....|..
|
||||
......................../............-...........|...................../............-.......\.........-.......
|
||||
......../..............-./...................................--........................\....-.......-..//.....
|
||||
........|.....-....................|...../..............-..........-......|..\................................
|
||||
.......-..//.............../.....-......................./..|........./...........-..../..|.........-.........
|
||||
.-...............-...........................\.......\...........-..................-.|...\..\.....\..\.....\.
|
||||
.........-../............|......|.|.........................\.......-......\...\..............-../.../-\......
|
||||
.-...........-..|.....\/........-.|...................../.|........-...........\..........\.....\/|..../...\.\
|
||||
.-..........\.\-..\....-\/................./.\.......|.........................-............./....\........./.
|
||||
.............\.........|............/...........\\................./..-..........................|//.......\..
|
||||
..../-........-.........................-\...........|................./..........|.............|.\..|........
|
||||
...-..|.....\..-..\.................\-.................|...../.-..........|........|/...-.-.\.................
|
||||
.-.-............................|.....\..-..........|/|.........|....\............\.....\..-...........|/...|.
|
||||
......................../...............|..-............................-.........|........../.-....../.......
|
||||
.........|-...................|.....................-...........|.../..............................|....-...-.
|
||||
..............|....................................................|.....|.......--.....\...\.............../.
|
||||
..-...............|........|..................-............|.........../.....\................................
|
||||
........................|.........|............-....-..\../..................\..|......\.........\../.../.....
|
||||
.|............................./..............-....-.......--....-.../..........|.....\.........-/.....|-./...
|
||||
....-..............|...-.....\.....\/.-........................................-.\.............|...../|/......
|
||||
........./..-................/........./..............-............................................-....-.....
|
||||
...........-........./...................../.........-........-................./.|...........................
|
||||
............................................................-.............-..-......|..........-.\............
|
||||
....\/........................-../.../.................................\............/..........|./-......-...\
|
||||
....-............../..-.\.......|......-...|...|.........../......|../...........|..-.\.................../...
|
||||
...-......../....-........................|...-............-.........................|/.....|.........|......-
|
||||
...|........-.......-.......|...|\.......\............-...-...................................-|........-.....
|
||||
....\/..-.....-.....-..--./-..-............../................|............\.............../.......|..........
|
||||
.........-.\.......-......|........-.............|..../..............\-.....\..........-..../.................
|
||||
.................-......\|.--..../../.-......-.......-........\....-...../....................../.............
|
||||
...../..../....../.............-......\..........|..........\..\........-.-...................................
|
||||
..............................|........./........-..................|.............-.../.................\..-..
|
||||
.....|./......-........\...\.................|....-........|..............|...................................
|
||||
\...|............................-..|.............../..............|.../......-......-.........../....../.....
|
||||
..../.............................-..........\.....\-..................................-........../...........
|
||||
..........................\....................-...-/.|....................../................................
|
||||
\.......|.........-............\\...............-...-...................../...................................
|
||||
..\...................................-................................................../.......\.|..........
|
||||
...............................-................/........\....\.......|...................-.../.....|.........
|
||||
...-..-............-.||..../././..........-\\............||...............-.\.........../...\........|...\...|
|
||||
....\./.|./...................\..-.-./..-.....||............../............|.......\.|...../..................
|
||||
......-.......\.\.........\......|..\...\.-|.\..............|...|......\......./...\........................-.
|
||||
........./.-......../....|..............................|...|...\........//./.................................
|
||||
.........................|...........\...........|.....................\........//..-.................\-/.....
|
||||
.\....................\..-.-..-..........|/.\..........\././.....................|............\....|...|/.....
|
||||
......./.................../...-.................\.........../.........\................|....................|
|
||||
......-..\....|..................\............\........|......|....../........................................
|
||||
.........\/..............|.............\.........-............-...........\.\..\./....../.....//..............
|
||||
.........../...\.......-.../.-.............\../....\|./............/...-..\........|..|/.....\......\\........
|
||||
..|............/..............................................-./...-.|..........-......../...................
|
||||
...............-..|.......\.............\..../.....................|..........\...................\.....\./\..
|
||||
.|..........\..\...|......................\...........-.......--........................-.....................
|
||||
...................../................\.|..........-..|................-................................-.....
|
||||
...../.........|-............|.\.|.../\.....|../........\../..................................................
|
||||
................/........\../.....................\./..../...........-............\-......../../..\.|.........
|
||||
..............|.........-......|/......././.....|..../.|...........-.....................|./.-.....\...|......
|
||||
.......|..-.......\..........|................................................/..\.....-..........-...........
|
10
resources/day16sample.txt
Normal file
10
resources/day16sample.txt
Normal file
@ -0,0 +1,10 @@
|
||||
.|...\....
|
||||
|.-.\.....
|
||||
.....|-...
|
||||
........|.
|
||||
..........
|
||||
.........\
|
||||
..../.\\..
|
||||
.-.-/..|..
|
||||
.|....-|.\
|
||||
..//.|....
|
146
src/day16/part1.pas
Normal file
146
src/day16/part1.pas
Normal file
@ -0,0 +1,146 @@
|
||||
{$mode objfpc}
|
||||
{$RANGECHECKS ON}
|
||||
|
||||
program day16part1;
|
||||
uses sysutils;
|
||||
|
||||
type
|
||||
Tdirection = (Left, Up, Right, Down, NA);
|
||||
|
||||
var
|
||||
map: array[1..1000] of string;
|
||||
illuminated: array[1..1000, 1..1000] of boolean;
|
||||
splitted: array[1..1000, 1..1000] of boolean;
|
||||
height, width: int32;
|
||||
|
||||
procedure print_illuminated();
|
||||
var
|
||||
i, j: int32;
|
||||
begin
|
||||
for i := 1 to height do
|
||||
begin
|
||||
for j := 1 to width do
|
||||
case illuminated[i, j] of
|
||||
true: write('#');
|
||||
false: write('.');
|
||||
end;
|
||||
writeln();
|
||||
end;
|
||||
end;
|
||||
|
||||
function sum_illuminated(): int32;
|
||||
var
|
||||
i, j: int32;
|
||||
begin
|
||||
|
||||
sum_illuminated := 0;
|
||||
|
||||
for i := 1 to height do
|
||||
for j := 1 to width do
|
||||
if illuminated[i, j] then
|
||||
sum_illuminated := sum_illuminated + 1;
|
||||
end;
|
||||
|
||||
procedure step_illumination(x, y: int32; dir: Tdirection);
|
||||
begin
|
||||
|
||||
{ range check }
|
||||
if (x < 1) or (x > width) or (y < 1) or (y > height) then
|
||||
exit;
|
||||
|
||||
writeln('(', x, ',', y, ')');
|
||||
|
||||
illuminated[y, x] := true;
|
||||
|
||||
{ nested case my beloved }
|
||||
case map[y, x] of
|
||||
'.':
|
||||
begin
|
||||
{ continue same direction }
|
||||
case dir of
|
||||
Up: step_illumination(x, y - 1, Up);
|
||||
Left: step_illumination(x - 1, y, Left);
|
||||
Down: step_illumination(x, y + 1, Down);
|
||||
Right: step_illumination(x + 1, y, Right);
|
||||
end;
|
||||
end;
|
||||
'/':
|
||||
begin
|
||||
{ reflect direction }
|
||||
case dir of
|
||||
Up: step_illumination(x + 1, y, Right);
|
||||
Left: step_illumination(x, y + 1, Down);
|
||||
Down: step_illumination(x - 1, y, Left);
|
||||
Right: step_illumination(x, y - 1, Up);
|
||||
end;
|
||||
end;
|
||||
'\':
|
||||
begin
|
||||
{ reflect direction but in the other way}
|
||||
case dir of
|
||||
Up: step_illumination(x - 1, y, Left);
|
||||
Left: step_illumination(x, y - 1, Up);
|
||||
Down: step_illumination(x + 1, y, Right);
|
||||
Right: step_illumination(x, y + 1, Down);
|
||||
end;
|
||||
end;
|
||||
'|':
|
||||
begin
|
||||
{ up down passthrough, left right split }
|
||||
case dir of
|
||||
Up: step_illumination(x, y - 1, Up);
|
||||
Down: step_illumination(x, y + 1, Down);
|
||||
Left, Right:
|
||||
begin
|
||||
if not splitted[y, x] then // so we don't split forever in a loop
|
||||
begin
|
||||
splitted[y, x] := true;
|
||||
step_illumination(x, y - 1, Up);
|
||||
step_illumination(x, y + 1, Down);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
'-':
|
||||
begin
|
||||
{ lr passthrough, ud split }
|
||||
case dir of
|
||||
Left: step_illumination(x - 1, y, Left);
|
||||
Right: step_illumination(x + 1, y, Right);
|
||||
Up, Down:
|
||||
begin
|
||||
if not splitted[y, x] then // so we don't split forever in a loop
|
||||
begin
|
||||
splitted[y, x] := true;
|
||||
step_illumination(x - 1, y, Left);
|
||||
step_illumination(x + 1, y, Right);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
var
|
||||
|
||||
file_: text;
|
||||
|
||||
begin
|
||||
|
||||
assign(file_, 'resources/day16.txt');
|
||||
reset(file_);
|
||||
|
||||
height := 0;
|
||||
|
||||
while not eof(file_) do
|
||||
begin
|
||||
height := height + 1;
|
||||
readln(file_, map[height]);
|
||||
end;
|
||||
width := length(map[1]);
|
||||
|
||||
step_illumination(1, 1, Right);
|
||||
print_illuminated();
|
||||
writeln('Total illuminated is ', sum_illuminated());
|
||||
|
||||
end.
|
219
src/day16/part2.pas
Normal file
219
src/day16/part2.pas
Normal file
@ -0,0 +1,219 @@
|
||||
{$mode objfpc}
|
||||
{$RANGECHECKS ON}
|
||||
|
||||
program day16part1;
|
||||
uses sysutils;
|
||||
|
||||
type
|
||||
Tdirection = (Left, Up, Right, Down, NA);
|
||||
|
||||
var
|
||||
map: array[1..1000] of string;
|
||||
illuminated: array[1..1000, 1..1000] of boolean;
|
||||
splitted: array[1..1000, 1..1000] of boolean;
|
||||
height, width: int32;
|
||||
|
||||
procedure print_illuminated();
|
||||
var
|
||||
i, j: int32;
|
||||
begin
|
||||
for i := 1 to height do
|
||||
begin
|
||||
for j := 1 to width do
|
||||
case illuminated[i, j] of
|
||||
true: write('#');
|
||||
false: write('.');
|
||||
end;
|
||||
writeln();
|
||||
end;
|
||||
end;
|
||||
|
||||
function sum_illuminated(): int32;
|
||||
var
|
||||
i, j: int32;
|
||||
begin
|
||||
|
||||
sum_illuminated := 0;
|
||||
|
||||
for i := 1 to height do
|
||||
for j := 1 to width do
|
||||
if illuminated[i, j] then
|
||||
sum_illuminated := sum_illuminated + 1;
|
||||
end;
|
||||
|
||||
procedure reset_illuminated_splitted();
|
||||
var
|
||||
i, j: int32;
|
||||
begin
|
||||
for i := 1 to height do
|
||||
for j := 1 to width do
|
||||
begin
|
||||
illuminated[j, i] := false;
|
||||
splitted[j, i] := false;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure step_illumination(x, y: int32; dir: Tdirection);
|
||||
begin
|
||||
|
||||
{ range check }
|
||||
if (x < 1) or (x > width) or (y < 1) or (y > height) then
|
||||
exit;
|
||||
|
||||
illuminated[y, x] := true;
|
||||
|
||||
{ nested case my beloved }
|
||||
case map[y, x] of
|
||||
'.':
|
||||
begin
|
||||
{ continue same direction }
|
||||
case dir of
|
||||
Up: step_illumination(x, y - 1, Up);
|
||||
Left: step_illumination(x - 1, y, Left);
|
||||
Down: step_illumination(x, y + 1, Down);
|
||||
Right: step_illumination(x + 1, y, Right);
|
||||
end;
|
||||
end;
|
||||
'/':
|
||||
begin
|
||||
{ reflect direction }
|
||||
case dir of
|
||||
Up: step_illumination(x + 1, y, Right);
|
||||
Left: step_illumination(x, y + 1, Down);
|
||||
Down: step_illumination(x - 1, y, Left);
|
||||
Right: step_illumination(x, y - 1, Up);
|
||||
end;
|
||||
end;
|
||||
'\':
|
||||
begin
|
||||
{ reflect direction but in the other way}
|
||||
case dir of
|
||||
Up: step_illumination(x - 1, y, Left);
|
||||
Left: step_illumination(x, y - 1, Up);
|
||||
Down: step_illumination(x + 1, y, Right);
|
||||
Right: step_illumination(x, y + 1, Down);
|
||||
end;
|
||||
end;
|
||||
'|':
|
||||
begin
|
||||
{ up down passthrough, left right split }
|
||||
case dir of
|
||||
Up: step_illumination(x, y - 1, Up);
|
||||
Down: step_illumination(x, y + 1, Down);
|
||||
Left, Right:
|
||||
begin
|
||||
if not splitted[y, x] then // so we don't split forever in a loop
|
||||
begin
|
||||
splitted[y, x] := true;
|
||||
step_illumination(x, y - 1, Up);
|
||||
step_illumination(x, y + 1, Down);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
'-':
|
||||
begin
|
||||
{ lr passthrough, ud split }
|
||||
case dir of
|
||||
Left: step_illumination(x - 1, y, Left);
|
||||
Right: step_illumination(x + 1, y, Right);
|
||||
Up, Down:
|
||||
begin
|
||||
if not splitted[y, x] then // so we don't split forever in a loop
|
||||
begin
|
||||
splitted[y, x] := true;
|
||||
step_illumination(x - 1, y, Left);
|
||||
step_illumination(x + 1, y, Right);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
var
|
||||
|
||||
file_: text;
|
||||
|
||||
max: int32;
|
||||
i, t: int32;
|
||||
|
||||
// for pretty printing
|
||||
max_dir: Tdirection;
|
||||
max_idx: int32;
|
||||
|
||||
begin
|
||||
|
||||
assign(file_, 'resources/day16.txt');
|
||||
reset(file_);
|
||||
|
||||
height := 0;
|
||||
|
||||
while not eof(file_) do
|
||||
begin
|
||||
height := height + 1;
|
||||
readln(file_, map[height]);
|
||||
end;
|
||||
width := length(map[1]);
|
||||
|
||||
max := -1;
|
||||
max_dir := NA;
|
||||
max_idx := -1;
|
||||
|
||||
{ check up + down }
|
||||
for i := 1 to width do
|
||||
begin
|
||||
step_illumination(i, 1, Down);
|
||||
t := sum_illuminated();
|
||||
reset_illuminated_splitted();
|
||||
|
||||
if t > max then
|
||||
begin
|
||||
max := t;
|
||||
max_dir := Down;
|
||||
max_idx := i;
|
||||
end;
|
||||
|
||||
step_illumination(i, height, Up);
|
||||
t := sum_illuminated();
|
||||
reset_illuminated_splitted();
|
||||
|
||||
if t > max then
|
||||
begin
|
||||
max := t;
|
||||
max_dir := Up;
|
||||
max_idx := i;
|
||||
end;
|
||||
end;
|
||||
|
||||
{ check left + right }
|
||||
for i := 1 to height do
|
||||
begin
|
||||
step_illumination(1, i, Right);
|
||||
t := sum_illuminated();
|
||||
reset_illuminated_splitted();
|
||||
|
||||
if t > max then
|
||||
begin
|
||||
max := t;
|
||||
max_dir := Right;
|
||||
max_idx := i;
|
||||
end;
|
||||
|
||||
step_illumination(width, i, Left);
|
||||
t := sum_illuminated();
|
||||
reset_illuminated_splitted();
|
||||
|
||||
if t > max then
|
||||
begin
|
||||
max := t;
|
||||
max_dir := Left;
|
||||
max_idx := i;
|
||||
end;
|
||||
end;
|
||||
|
||||
writeln('The best configuration is going ', max_dir, ' at index ', max_idx);
|
||||
writeln('The max illumination is ', max);
|
||||
|
||||
|
||||
end.
|
14
src/day17/part1.pas
Normal file
14
src/day17/part1.pas
Normal file
@ -0,0 +1,14 @@
|
||||
{$mode objfpc}
|
||||
{$RANGECHECKS ON}
|
||||
|
||||
program day17part1;
|
||||
uses sysutils;
|
||||
|
||||
type
|
||||
Tnode = record
|
||||
x, y: int32;
|
||||
end;
|
||||
|
||||
begin
|
||||
|
||||
end.
|
23
src/day17/queue.pas
Normal file
23
src/day17/queue.pas
Normal file
@ -0,0 +1,23 @@
|
||||
// i wrote this but i didn't use it
|
||||
// might be useful for the future;
|
||||
|
||||
var
|
||||
queue: array[0..1000] of Tnode;
|
||||
queue_start, queue_length: int32;
|
||||
|
||||
procedure enqueue(node: Tnode);
|
||||
begin
|
||||
queue[queue_start + queue_length] := node;
|
||||
inc(queue_length);
|
||||
end;
|
||||
|
||||
function dequeue(): Tnode;
|
||||
begin
|
||||
dequeue := queue[queue_start];
|
||||
inc(queue_start);
|
||||
dec(queue_length);
|
||||
end;
|
||||
|
||||
var
|
||||
|
||||
a, b: Tnode;
|
Loading…
Reference in New Issue
Block a user