[Jeff Carter][14][Ada]AoA_22/day14_1.adb at c4b91064af456922c88ed26aa9a86788da96cef7 · jrcarter/AoA_22 · GitHub
[Zertovitch][15][Ada]hac/aoc_2022_15.adb at 06759b59d1888ab74447036b6105e4636731ae31 · zertovitch/hac · GitHub
[lhumphrey][1][SPARK] https://github.com/lhumphrey/AoC-2022-In-Ada/blob/c3b207e54e6d78e4bb9e2ba531ae64b38f739203/Day_01/src/main.adb
[lhumphrey][2][SPARK] https://github.com/lhumphrey/AoC-2022-In-Ada/blob/c3b207e54e6d78e4bb9e2ba531ae64b38f739203/Day_02/src/main.adb
[lhumphrey][3][SPARK] https://github.com/lhumphrey/AoC-2022-In-Ada/blob/c3b207e54e6d78e4bb9e2ba531ae64b38f739203/Day_03/src/main.adb
[lhumphrey][4][SPARK] https://github.com/lhumphrey/AoC-2022-In-Ada/blob/ba6b8410fef894789b4e3e4f95231d40415b9a09/Day_04/src/main.adb
[lhumphrey][5][SPARK] https://github.com/lhumphrey/AoC-2022-In-Ada/blob/c10a46dceef69c801a1232fdfb70d89ca691d999/Day_05/src/main.adb
[lhumphrey][6][SPARK] https://github.com/lhumphrey/AoC-2022-In-Ada/blob/e709d8d71aa2c2f2d6b9839c6d9c782ecc04ab43/Day_06/src/main.adb
[lhumphrey][8][SPARK] https://github.com/lhumphrey/AoC-2022-In-Ada/blob/91e03aa433868dbe27ded2ff4466d073e24d032e/Day_08/src/main.adb
[lhumphrey][9][SPARK] https://github.com/lhumphrey/AoC-2022-In-Ada/blob/9265cc226a3a74cbf6df6bf3a686d165128938ba/Day_09/src/main.adb
[lhumphrey][10][SPARK] https://github.com/lhumphrey/AoC-2022-In-Ada/blob/6bf2e80cf61587978e0f027425d83bcbc34fb12d/Day_10/src/main.adb
[rommudoh][16][Ada] aoc2022-Ada/day16.adb at main - aoc2022-Ada - Codeberg.org (only Part 1 yet)
[wutka][16][SPARK] advent-of-code-2022-spark/day16.adb at 657a8a896a0e12edf474cf7309bfc4dbfad1e1a4 · wutka/advent-of-code-2022-spark · GitHub
[wutka][17][SPARK] advent-of-code-2022-spark/day17.adb at 70b61eba098ff106b67b6d930f109d8c4e2c4255 · wutka/advent-of-code-2022-spark · GitHub
For day 17 I had to use --level=2 on gnatprove to get it to check a long integer multiply
[anuj-seth][7][Ada]Day 7
[rocher][12][Ada]
Part 1:
pragma Ada_2022;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Containers.Functional_Sets; use Ada.Containers;
procedure Day12_P1 is
subtype Row_Range is Natural range 1 .. 41;
subtype Col_Range is Natural range 1 .. 179;
type Position is record
Row : Row_Range;
Col : Col_Range;
end record;
type Node is record
Pos : Position;
Label : Character;
Steps : Natural := Natural'Last;
Visited : Boolean := False;
end record;
type Node_Acc is access all Node;
package Node_Package is new Functional_Sets (Node_Acc);
use Node_Package;
subtype Node_Set is Node_Package.Set;
Map : array (Row_Range, Col_Range) of aliased Node;
Start_Pos : Position;
End_Pos : Position;
procedure Add_Neighbor
(Set : in out Node_Set; P : Position; Δr, Δc : Integer)
is
begin
if P.Row + Δr in Row_Range and P.Col + Δc in Col_Range then
declare
Q : Position := (P.Row + Δr, P.Col + Δc);
begin
if not Map (Q.Row, Q.Col).Visited and
(Map (Q.Row, Q.Col).Label'Enum_Rep -
Map (P.Row, P.Col).Label'Enum_Rep <=
1)
then
Set := Add (Set, Map (Q.Row, Q.Col)'Access);
end if;
end;
end if;
end Add_Neighbor;
function Get_Neighbors (N : Node_Acc) return Node_Set is
P : Position := (N.Pos.Row, N.Pos.Col);
S : Node_Set;
begin
Add_Neighbor (S, P, 1, 0);
Add_Neighbor (S, P, 0, 1);
Add_Neighbor (S, P, -1, 0);
Add_Neighbor (S, P, 0, -1);
return S;
end Get_Neighbors;
begin
declare
Row : Natural := Map'First (1);
Input : File_Type;
Line : String (Col_Range);
begin
Open (Input, In_File, "input.txt");
for Row in Row_Range loop
Get (Input, Line);
for Col in Col_Range loop
Map (Row, Col).Label := Line (Col);
Map (Row, Col).Pos := (Row, Col);
if Map (Row, Col).Label = 'S' then
Map (Row, Col).Label := 'a';
Start_Pos := (Row, Col);
elsif Map (Row, Col).Label = 'E' then
Map (Row, Col).Label := 'z';
End_Pos := (Row, Col);
end if;
end loop;
end loop;
Close (Input);
end;
declare
Node : Node_Acc := Map (Start_Pos.Row, Start_Pos.Col)'Access;
To_Visit : Node_Set;
Neighbors : Node_Set;
begin
Node.Steps := 0;
To_Visit := Add (To_Visit, Node);
loop
Node := Iter_Element (To_Visit, Iter_First (To_Visit));
To_Visit := Remove (To_Visit, Node);
Node.Visited := True;
Neighbors := Get_Neighbors (Node);
for N of Neighbors loop
N.Steps := Natural'Min (@, Node.Steps + 1);
end loop;
To_Visit := Union (To_Visit, Neighbors);
exit when Is_Empty (To_Visit);
end loop;
end;
Put_Line ("Answer:" & Map (End_Pos.Row, End_Pos.Col).Steps'Image);
end Day12_P1;
Part 2:
pragma Ada_2022;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Containers.Functional_Sets; use Ada.Containers;
procedure Day12_P2 is
subtype Row_Range is Natural range 1 .. 41;
subtype Col_Range is Natural range 1 .. 179;
type Position is record
Row : Row_Range;
Col : Col_Range;
end record;
type Node is record
Pos : Position;
Label : Character;
Steps : Natural := Natural'Last;
Visited : Boolean := False;
end record;
type Node_Acc is access all Node;
package Node_Package is new Functional_Sets (Node_Acc);
use Node_Package;
subtype Node_Set is Node_Package.Set;
Map : array (Row_Range, Col_Range) of aliased Node;
Start_Pos : Position;
End_Pos : Position;
procedure Add_Neighbor
(Set : in out Node_Set; P : Position; Δr, Δc : Integer)
is
begin
if P.Row + Δr in Row_Range and P.Col + Δc in Col_Range then
declare
Q : Position := (P.Row + Δr, P.Col + Δc);
begin
if not Map (Q.Row, Q.Col).Visited and
(Map (Q.Row, Q.Col).Label'Enum_Rep -
Map (P.Row, P.Col).Label'Enum_Rep >=
-1)
then
Set := Add (Set, Map (Q.Row, Q.Col)'Access);
end if;
end;
end if;
end Add_Neighbor;
function Get_Neighbors (N : Node_Acc) return Node_Set is
P : Position := (N.Pos.Row, N.Pos.Col);
S : Node_Set;
begin
Add_Neighbor (S, P, 1, 0);
Add_Neighbor (S, P, 0, 1);
Add_Neighbor (S, P, -1, 0);
Add_Neighbor (S, P, 0, -1);
return S;
end Get_Neighbors;
begin
declare
Row : Natural := Map'First (1);
Input : File_Type;
Line : String (Col_Range);
begin
Open (Input, In_File, "input.txt");
for Row in Row_Range loop
Get (Input, Line);
for Col in Col_Range loop
Map (Row, Col).Label := Line (Col);
Map (Row, Col).Pos := (Row, Col);
if Map (Row, Col).Label = 'S' then
Map (Row, Col).Label := 'a';
Start_Pos := (Row, Col);
elsif Map (Row, Col).Label = 'E' then
Map (Row, Col).Label := 'z';
End_Pos := (Row, Col);
end if;
end loop;
end loop;
Close (Input);
end;
declare
Node : Node_Acc := Map (End_Pos.Row, End_Pos.Col)'Access;
To_Visit : Node_Set;
Neighbors : Node_Set;
Found : Boolean := False;
begin
Node.Steps := 0;
To_Visit := Add (To_Visit, Node);
loop
Node := Iter_Element (To_Visit, Iter_First (To_Visit));
To_Visit := Remove (To_Visit, Node);
Node.Visited := True;
Neighbors := Get_Neighbors (Node);
for N of Neighbors loop
N.Steps := Natural'Min (@, Node.Steps + 1);
if N.Label = 'a' then
Found := True;
if N.Steps < Map (Start_Pos.Row, Start_Pos.Col).Steps then
Start_Pos := N.Pos;
end if;
end if;
end loop;
To_Visit := Union (To_Visit, Neighbors);
exit when Found;
end loop;
end;
Put_Line ("Answer:" & Map (Start_Pos.Row, Start_Pos.Col).Steps'Image);
end Day12_P2;
[cantanima][17][Ada]Pyroclastic Flow
Still working on Day 16. More accurately, still waiting for my horrible solution to complete.
[rommudoh][17][Ada] rommudoh/aoc2022-Ada - aoc2022-Ada - Codeberg.org (only part 1 working - does this only count as half?)
[cantanima][16][Ada]Proboscidea Volcanium
Finally!
[mhatzl][1][Ada] AoC2022/aoc2022_p1 at main · mhatzl/AoC2022 · GitHub
[anuj-seth][8][Ada]Day 8
[rommudoh][18][Ada] aoc2022-Ada/day18.adb at main - aoc2022-Ada - Codeberg.org (this time again both parts)
[rvlad13][8][Ada] GitHub - rvl13/Advent_of_code_2022_Ada
[rvlad13][10][Ada] same repo
[wutka][18][SPARK] advent-of-code-2022-spark/day18.adb at e29d913926bf31d49788c36ac503003fea3a11d4 · wutka/advent-of-code-2022-spark · GitHub
[cantanima][18][Ada]Boiling boulders
Wrong link? It links to day 17…