# Advent of Ada Submissions

**URL:** https://forum.ada-lang.io/t/advent-of-ada-submissions/129
**Category:** Advent of Code
**Created:** [November 24, 2022, 12:47pm UTC](https://forum.ada-lang.io/t/advent-of-ada-submissions/129 "2022-11-24T12:47:13Z")
**Posts on this page:** 20
**Page:** 2

<div class="post-metadata">

### Author: ![cantanima](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/cantanima/32/121_2.png) [@cantanima](https://forum.ada-lang.io/u/cantanima)
#### Post date: [December 2, 2022, 2:30am UTC](https://forum.ada-lang.io/t/advent-of-ada-submissions/129/21 "2022-12-02T02:30:19Z")

</div>

[cantanima][1][Ada][Calorie Counting](https://github.com/johnperry-math/AoC2022/tree/master/Day1)

---

<div class="post-metadata">

### Author: ![smionean](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/smionean/32/88_2.png) [@smionean](https://forum.ada-lang.io/u/smionean)
#### Post date: [December 2, 2022, 5:16am UTC](https://forum.ada-lang.io/t/advent-of-ada-submissions/129/22 "2022-12-02T05:16:13Z")

</div>

[smionean][1][Ada][https://github.com/smionean/AdventOfCode/tree/master/2022/day01](https://github.com/smionean/AdventOfCode/tree/master/2022/day01)

---

<div class="post-metadata">

### Author: ![analogrelay](https://forum.ada-lang.io/letter_avatar_proxy/v4/letter/a/8e8cbc/32.png) [@analogrelay](https://forum.ada-lang.io/u/analogrelay)
#### Post date: [December 2, 2022, 5:18am UTC](https://forum.ada-lang.io/t/advent-of-ada-submissions/129/23 "2022-12-02T05:18:43Z")

</div>

[analogrelay][1][Ada] [aoc2022/day\_01.adb at 1870db114d7e9555364e8d4a1445cc295552e627 · analogrelay/aoc2022 · GitHub](https://github.com/analogrelay/aoc2022/blob/1870db114d7e9555364e8d4a1445cc295552e627/src/day_01.adb)

---

<div class="post-metadata">

### Author: ![JeremyGrosser](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/jeremygrosser/32/3_2.png) [@JeremyGrosser](https://forum.ada-lang.io/u/JeremyGrosser)
#### Post date: [December 2, 2022, 5:24am UTC](https://forum.ada-lang.io/t/advent-of-ada-submissions/129/24 "2022-12-02T05:24:44Z")

</div>

[JeremyGrosser][2][Ada][[advent/day2\_2.adb at 3fdc3b70869b12840f96afe5a2c9ecb7c66de300 · JeremyGrosser/advent · GitHub](https://github.com/JeremyGrosser/advent/blob/3fdc3b70869b12840f96afe5a2c9ecb7c66de300/2022/src/day2_2.adb)]

---

<div class="post-metadata">

### Author: ![zertovitch](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/zertovitch/32/90_2.png) [@zertovitch](https://forum.ada-lang.io/u/zertovitch)
#### Post date: [December 2, 2022, 6:05am UTC](https://forum.ada-lang.io/t/advent-of-ada-submissions/129/25 "2022-12-02T06:05:58Z")

</div>

[Zertovitch][2][Ada][hac/aoc\_2022\_02.adb at 93ad0ab88a063470721cbe5b02b5630fdf91ca88 · zertovitch/hac · GitHub](https://github.com/zertovitch/hac/blob/93ad0ab88a063470721cbe5b02b5630fdf91ca88/exm/aoc/2022/aoc_2022_02.adb)

---

<div class="post-metadata">

### Author: ![cantanima](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/cantanima/32/121_2.png) [@cantanima](https://forum.ada-lang.io/u/cantanima)
#### Post date: [December 2, 2022, 6:49am UTC](https://forum.ada-lang.io/t/advent-of-ada-submissions/129/26 "2022-12-02T06:49:52Z")

</div>

[cantanima][2][Ada][[AoC2022/Day2 at master · johnperry-math/AoC2022 · GitHub](https://github.com/johnperry-math/AoC2022/tree/master/Day2)]

---

<div class="post-metadata">

### Author: ![ebriot](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/ebriot/32/156_2.png) [@ebriot](https://forum.ada-lang.io/u/ebriot)
#### Post date: [December 2, 2022, 8:09am UTC](https://forum.ada-lang.io/t/advent-of-ada-submissions/129/27 "2022-12-02T08:09:51Z")

</div>

[ebriot][1][Ada] [advent\_of\_code/2022/day1 at master · briot/advent\_of\_code · GitHub](https://github.com/briot/advent_of_code/tree/master/2022/day1)  
[ebriot][2][Ada] [advent\_of\_code/2022/day2 at master · briot/advent\_of\_code · GitHub](https://github.com/briot/advent_of_code/tree/master/2022/day2)

---

<div class="post-metadata">

### Author: ![rommudoh](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/rommudoh/32/101_2.png) [@rommudoh](https://forum.ada-lang.io/u/rommudoh)
#### Post date: [December 2, 2022, 8:27am UTC](https://forum.ada-lang.io/t/advent-of-ada-submissions/129/28 "2022-12-02T08:27:04Z")

</div>

[rommudoh][1][Ada] [aoc2022-Ada/day01.adb at main - aoc2022-Ada - Codeberg.org](https://codeberg.org/rommudoh/aoc2022-Ada/src/branch/main/src/day01.adb)  
[rommudoh][2][Ada] [aoc2022-Ada/day02.adb at main - aoc2022-Ada - Codeberg.org](https://codeberg.org/rommudoh/aoc2022-Ada/src/branch/main/src/day02.adb)

---

<div class="post-metadata">

### Author: ![rocher](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/rocher/32/89_2.png) [@rocher](https://forum.ada-lang.io/u/rocher)
#### Post date: [December 2, 2022, 9:26am UTC](https://forum.ada-lang.io/t/advent-of-ada-submissions/129/29 "2022-12-02T09:26:54Z")

</div>

[rocher][2][Ada] L’ets play Rock, Paper Scissors … _literally_!

Part one here:

```ada
  pragma Ada_2022;

  with Ada.Text_IO; use Ada.Text_IO;

  procedure Day02_P1 is

     Type Rock_Paper_Scissors is ('🪨', '🧻', '✀');
     for Rock_Paper_Scissors use ('🪨' => 1, '🧻' => 2, '✀' => 3);

     Type Result is ('😖', '🤝', '🏆');
     for Result use ('😖' => 0, '🤝' => 3, '🏆' => 6);

     Result_Table : array (Rock_Paper_Scissors, Rock_Paper_Scissors) of Result :=
       ('🪨' => (
                '🪨' => '🤝',
                '🧻' => '🏆',
                '✀' => '😖'),
        '🧻' => (
                '🪨' => '😖',
                '🧻' => '🤝',
                '✀' => '🏆'),
        '✀' => (
                '🪨' => '🏆',
                '🧻' => '😖',
                '✀' => '🤝'));
     -- Result table for players given as (Opponent, Player);

     function Round (Opponent, Player: Rock_Paper_Scissors) return Natural is
        Score : Natural := 0;
     begin
        Score := Result'Enum_Rep (Result_Table (Opponent, Player));
        Score := @ + Rock_Paper_Scissors'Enum_Rep (Player);
        return Score;
     end;

     Subtype Opponent_Char is Character range 'A' .. 'C';
     Opponent_Strategy : array (Opponent_Char) of Rock_Paper_Scissors :=
       ('A' => '🪨', 'B' => '🧻', 'C' => '✀');

     Subtype Player_Char is Character range 'X' .. 'Z';
     Player_Strategy : array (Player_Char) of Rock_Paper_Scissors :=
       ('X' => '🪨', 'Y' => '🧻', 'Z' => '✀');

     Opponent : Character;
     Player : Character;
     Score : Natural := 0;

     Space : Character;
     Input : File_Type;

  begin

     Open (Input, In_File, "input.txt");
     loop
        Get (Input, Opponent);
        Get (Input, Space);
        Get (Input, Player);
        Score := @ + Round (Opponent_Strategy (Opponent), Player_Strategy (PLayer));
        exit when End_Of_File (Input);
     end loop;
     Close (Input);

     Put_Line ("Answer:" & Score'Image);
  end Day02_P1;

```

---

<div class="post-metadata">

### Author: ![zetah11](https://forum.ada-lang.io/letter_avatar_proxy/v4/letter/z/58f4c7/32.png) [@zetah11](https://forum.ada-lang.io/u/zetah11)
#### Post date: [December 2, 2022, 11:13am UTC](https://forum.ada-lang.io/t/advent-of-ada-submissions/129/30 "2022-12-02T11:13:42Z")

</div>

My day 1 is in a message above. It’s pretty fun getting used to SPARK this way!

[zetah11][2][SPARK][[aoc2022/day2.adb at 3d253bff347ad66db3c17ae1b48191dfc9de2ffa · zetah11/aoc2022 · GitHub](https://github.com/zetah11/aoc2022/blob/3d253bff347ad66db3c17ae1b48191dfc9de2ffa/day2/src/day2.adb)]

---

<div class="post-metadata">

### Author: ![jklmnn](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/jklmnn/32/108_2.png) [@jklmnn](https://forum.ada-lang.io/u/jklmnn)
#### Post date: [December 2, 2022, 11:32am UTC](https://forum.ada-lang.io/t/advent-of-ada-submissions/129/31 "2022-12-02T11:32:12Z")

</div>

[jklmnn][2][SPARK][aoc/day\_2022\_2.adb at 8d67cb10e4528210a9219d7f20b7689c33308938 · jklmnn/aoc · GitHub](https://github.com/jklmnn/aoc/blob/8d67cb10e4528210a9219d7f20b7689c33308938/Ada/src/day_2022_2.adb)

---

<div class="post-metadata">

### Author: ![captain-haddock17](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/captain-haddock17/32/186_2.png) [@captain-haddock17](https://forum.ada-lang.io/u/captain-haddock17)
#### Post date: [December 2, 2022, 12:50pm UTC](https://forum.ada-lang.io/t/advent-of-ada-submissions/129/32 "2022-12-02T12:50:33Z")

</div>

[William-Franck][2][Ada][Release Day-02 · captain-haddock17/Advent\_of\_Code\_2022 · GitHub](https://github.com/captain-haddock17/Advent_of_Code_2022/releases/tag/Day-02)

---

<div class="post-metadata">

### Author: ![rocher](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/rocher/32/89_2.png) [@rocher](https://forum.ada-lang.io/u/rocher)
#### Post date: [December 2, 2022, 1:31pm UTC](https://forum.ada-lang.io/t/advent-of-ada-submissions/129/33 "2022-12-02T13:31:02Z")

</div>

[rocher][2][Ada] And here part 2:

```ada
  pragma Ada_2022;

  with Ada.Text_IO; use Ada.Text_IO;

  procedure Day02_P2 is

     Type Rock_Paper_Scissors is ('🪨', '🧻', '✀');
     for Rock_Paper_Scissors use ('🪨' => 1, '🧻' => 2, '✀' => 3);

     Type Result is ('😖', '🤝', '🏆');
     for Result use ('😖' => 0, '🤝' => 3, '🏆' => 6);

     Result_Table : array (Rock_Paper_Scissors, Rock_Paper_Scissors) of Result :=
       ('🪨' => (
                '🪨' => '🤝',
                '🧻' => '🏆',
                '✀' => '😖'),
        '🧻' => (
                '🪨' => '😖',
                '🧻' => '🤝',
                '✀' => '🏆'),
        '✀' => (
                '🪨' => '🏆',
                '🧻' => '😖',
                '✀' => '🤝'));
     -- Result table for players given as (Opponent, Player);

     function Round (Opponent, Player: Rock_Paper_Scissors) return Natural is
        Score : Natural := 0;
     begin
        Score := Result'Enum_Rep (Result_Table (Opponent, Player));
        Score := @ + Rock_Paper_Scissors'Enum_Rep (Player);
        return Score;
     end;

     Subtype Opponent_Char is Character range 'A' .. 'C';
     Opponent_Strategy : array (Opponent_Char) of Rock_Paper_Scissors :=
       ('A' => '🪨', 'B' => '🧻', 'C' => '✀');

     Subtype Player_Char is Character range 'X' .. 'Z';
     Player_Strategy : array (Player_Char) of Result :=
       ('X' => '😖', 'Y' => '🤝', 'Z' => '🏆');

     function Choose_Shape (Opponent: Rock_Paper_Scissors; R : Result)
                           return Rock_Paper_Scissors
     is
        Player : Rock_Paper_Scissors;
     begin
        for P in Rock_Paper_Scissors'Range loop
           if Result_Table (Opponent, P) = R then
              Player := P;
           end if;
        end loop;
        return Player;
     end;

     Opponent : Character;
     Player : Character;
     Score : Natural := 0;

     Space : Character;
     Input : File_Type;

  begin

     Open (Input, In_File, " __Current_Path__" & "input.txt");
     loop
        Get (Input, Opponent);
        Get (Input, Space);
        Get (Input, Player);
        Score := @ + Round (Opponent_Strategy (Opponent),
                            Choose_Shape (Opponent_Strategy (Opponent),
                                          Player_Strategy (PLayer)));
        exit when End_Of_File (Input);
     end loop;
     Close (Input);

     Put_Line ("Answer:" & Score'Image);
  end Day02_P2;

```

---

<div class="post-metadata">

### Author: ![smionean](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/smionean/32/88_2.png) [@smionean](https://forum.ada-lang.io/u/smionean)
#### Post date: [December 2, 2022, 3:38pm UTC](https://forum.ada-lang.io/t/advent-of-ada-submissions/129/34 "2022-12-02T15:38:29Z")

</div>

[smionean][2][Ada][day02.adb](https://github.com/smionean/AdventOfCode/blob/1e58d583898edc7dc071f4586d2682c75b07f67b/2022/day02/src/day02.adb)

---

<div class="post-metadata">

### Author: ![Max](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/max/32/21_2.png) [@Max](https://forum.ada-lang.io/u/Max)
#### Post date: [December 2, 2022, 4:39pm UTC](https://forum.ada-lang.io/t/advent-of-ada-submissions/129/35 "2022-12-02T16:39:13Z")

</div>

[max][2][SPARK] [source/day\_02.adb](https://github.com/reznikmm/advent-of-ada/blob/2022/source/day_02.adb)  
[max][3][SPARK] [source/day\_03.adb](https://github.com/reznikmm/advent-of-ada/blob/2022/source/day_03.adb)  
[max][4][SPARK] [source/day\_04.adb](https://github.com/reznikmm/advent-of-ada/blob/2022/source/day_04.adb)  
[max][5][Ada] [source/day\_05.adb](https://github.com/reznikmm/advent-of-ada/blob/2022/source/day_05.adb)  
[max][6][SPARK] [source/day\_06.adb](https://github.com/reznikmm/advent-of-ada/blob/2022/source/day_06.adb)  
[max][7][SPARK] [source/day\_07.adb](https://github.com/reznikmm/advent-of-ada/blob/2022/source/day_07.adb)  
[max][8][Ada] [source/day\_08.adb](https://github.com/reznikmm/advent-of-ada/blob/2022/source/day_08.adb)  
[max][9][SPARK] [source/day\_09.adb](https://github.com/reznikmm/advent-of-ada/blob/2022/source/day_09.adb)  
[max][10][SPARK] [source/day\_10.adb](https://github.com/reznikmm/advent-of-ada/blob/2022/source/day_10.adb)  
[max][11][Ada] [source/day\_11.adb](https://github.com/reznikmm/advent-of-ada/blob/2022/source/day_11.adb)  
[max][12][Ada] [source/day\_12.adb](https://github.com/reznikmm/advent-of-ada/blob/2022/source/day_12.adb)  
[max][13][Ada] [source/day\_13.adb](https://github.com/reznikmm/advent-of-ada/blob/2022/source/day_13.adb)  
[max][14][Ada] [source/day\_14.adb](https://github.com/reznikmm/advent-of-ada/blob/2022/source/day_14.adb)  
[max][15][Ada] [source/day\_15.adb](https://github.com/reznikmm/advent-of-ada/blob/2022/source/day_15.adb)  
[max][16][Ada] [source/day\_16.adb](https://github.com/reznikmm/advent-of-ada/blob/2022/source/day_16.adb)  
[max][17][Ada] [source/day\_17.adb](https://github.com/reznikmm/advent-of-ada/blob/2022/source/day_17.adb)  
[max][18][Ada] [source/day\_18.adb](https://github.com/reznikmm/advent-of-ada/blob/2022/source/day_18.adb)  
[max][19][Ada] [source/day\_19.adb](https://github.com/reznikmm/advent-of-ada/blob/2022/source/day_19.adb)  
[max][20][Ada] [source/day\_20.adb](https://github.com/reznikmm/advent-of-ada/blob/2022/source/day_20.adb)  
[max][21][Ada] [source/day\_21.adb](https://github.com/reznikmm/advent-of-ada/blob/2022/source/day_21.adb)  
[max][22][Ada] [source/day\_22.adb](https://github.com/reznikmm/advent-of-ada/blob/2022/source/day_22.adb)  
[max][23][Ada] [source/day\_23.adb](https://github.com/reznikmm/advent-of-ada/blob/2022/source/day_23.adb)  
[max][24][Ada] [source/day\_24.adb](https://github.com/reznikmm/advent-of-ada/blob/2022/source/day_24.adb)  
[max][25][Ada] [source/day\_25.adb](https://github.com/reznikmm/advent-of-ada/blob/2022/source/day_25.adb)

---

<div class="post-metadata">

### Author: ![yannickmoy](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/yannickmoy/32/54_2.png) [@yannickmoy](https://forum.ada-lang.io/u/yannickmoy)
#### Post date: [December 2, 2022, 7:08pm UTC](https://forum.ada-lang.io/t/advent-of-ada-submissions/129/36 "2022-12-02T19:08:10Z")

</div>

[yannickmoy][1][SPARK] [advent\_of\_code\_2022/spark/day1 at main · yannickmoy/advent\_of\_code\_2022 · GitHub](https://github.com/yannickmoy/advent_of_code_2022/tree/main/spark/day1)

---

<div class="post-metadata">

### Author: ![Alex](https://forum.ada-lang.io/letter_avatar_proxy/v4/letter/a/db5fbb/32.png) [@Alex](https://forum.ada-lang.io/u/Alex)
#### Post date: [December 2, 2022, 7:13pm UTC](https://forum.ada-lang.io/t/advent-of-ada-submissions/129/37 "2022-12-02T19:13:44Z")

</div>

[Neoxas][1][SPARK] [GitHub - Neoxas/aoc\_2022\_ada: AOC 2022 solutions written in SPARK ADA!](https://github.com/Neoxas/aoc_2022_ada)  
[Neoxas][2][SPARK] [GitHub - Neoxas/aoc\_2022\_ada: AOC 2022 solutions written in SPARK ADA!](https://github.com/Neoxas/aoc_2022_ada)

---

<div class="post-metadata">

### Author: ![wutka](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/wutka/32/854_2.png) [@wutka](https://forum.ada-lang.io/u/wutka)
#### Post date: [December 2, 2022, 7:38pm UTC](https://forum.ada-lang.io/t/advent-of-ada-submissions/129/38 "2022-12-02T19:38:02Z")

</div>

Haha! Nice use of Unicode!

---

<div class="post-metadata">

### Author: ![Max](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/max/32/21_2.png) [@Max](https://forum.ada-lang.io/u/Max)
#### Post date: [December 2, 2022, 8:51pm UTC](https://forum.ada-lang.io/t/advent-of-ada-submissions/129/39 "2022-12-02T20:51:06Z")

</div>

```ada
Group.Append (Calories'Value (Line (Line'First .. Last)));

```

How did you make `gnatprove` eat this without [Fabian’s powerful technique](https://github.com/Fabien-Chouteau/adventofcode-ada/blob/459fc82b5ea3a32ce964bc7ba6c3bbf8ac28e687/2022/src/day_01.adb#L167)? The `Line` could contain any garbage and `'Value` will raise exception, no? 🤔

---

<div class="post-metadata">

### Author: ![rocher](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/rocher/32/89_2.png) [@rocher](https://forum.ada-lang.io/u/rocher)
#### Post date: [December 2, 2022, 9:03pm UTC](https://forum.ada-lang.io/t/advent-of-ada-submissions/129/40 "2022-12-02T21:03:17Z")

</div>

Kind reminder: Join us in the AOC leaderboard!

Please feel free to add yourself to the AOC leaderboard shared in this post.  
Visit [Leaderboard - Advent of Code 2022](https://adventofcode.com/2022/leaderboard/private) and use the code `1708445-6a8f7730` to join.

[Previous page](https://forum.ada-lang.io/t/advent-of-ada-submissions/129.md?page=1)

[Next page](https://forum.ada-lang.io/t/advent-of-ada-submissions/129.md?page=3)
