diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..ef94d8a3 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,96 @@ +name: Advent of Code Tests + +on: [push, pull_request] + +jobs: + rust_tests: + runs-on: ubuntu-latest + strategy: + matrix: + project: + - 2015 + - 2018 + - 2019/aoc_rust + - 2020/01 + - 2021/_1 + - 2021/_2 + - 2021/_3 + - 2021/_4 + - 2021/_5 + - 2021/_6 + - 2021/_7 + - 2022 + steps: + - uses: actions/checkout@v4 + - name: Install Rust Stable + uses: dtolnay/rust-toolchain@stable + if: ${{ matrix.project != '2021/_4' }} + - name: Install Rust Nightly for 2021/_4 + uses: dtolnay/rust-toolchain@nightly + if: ${{ matrix.project == '2021/_4' }} + - name: Set up cargo-nextest + uses: taiki-e/install-action@nextest + - name: Build 2015 binary + if: ${{ matrix.project == '2015' }} + run: cargo build --release + working-directory: ${{ matrix.project }} + - name: Run Rust tests in 2015 with cargo-nextest + if: ${{ matrix.project == '2015' }} + run: cargo nextest run + working-directory: ${{ matrix.project }} + - name: Run Rust tests in ${{ matrix.project }} + if: ${{ matrix.project != '2015' }} + run: cargo test + working-directory: ${{ matrix.project }} + + go_tests: + runs-on: ubuntu-latest + strategy: + matrix: + project: + - 2017 + - 2019/go + - 2020/02 + - 2024/golang + steps: + - uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '^1.18' + - name: Run Go tests in 2017 + if: ${{ matrix.project == '2017' }} + run: go test ./... + working-directory: 2017 + - name: Run Go tests in 2019/go + if: ${{ matrix.project == '2019/go' }} + run: go test ./cmd/... + working-directory: 2019/go + - name: Run Go tests in 2020/02 + if: ${{ matrix.project == '2020/02' }} + run: go test ./... + working-directory: 2020/02 + - name: Run Go tests in 2024/golang + if: ${{ matrix.project == '2024/golang' }} + run: go test ./cmd/... + working-directory: 2024/golang + + csharp_tests: + runs-on: ubuntu-latest + strategy: + matrix: + project: + - 2021/cs/1 + - 2021/cs/2 + steps: + - uses: actions/checkout@v4 + - name: Set up .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '6.0.x' + - name: Restore dependencies for ${{ matrix.project }} + run: dotnet restore + working-directory: ${{ matrix.project }} + - name: Run C# tests in ${{ matrix.project }} + run: dotnet test + working-directory: ${{ matrix.project }} diff --git a/2015/src/first.rs b/2015/src/day01.rs similarity index 100% rename from 2015/src/first.rs rename to 2015/src/day01.rs diff --git a/2015/src/second.rs b/2015/src/day02.rs similarity index 100% rename from 2015/src/second.rs rename to 2015/src/day02.rs diff --git a/2015/src/trird.rs b/2015/src/day03.rs similarity index 100% rename from 2015/src/trird.rs rename to 2015/src/day03.rs diff --git a/2015/src/fourth.rs b/2015/src/day04.rs similarity index 100% rename from 2015/src/fourth.rs rename to 2015/src/day04.rs diff --git a/2015/src/fifth.rs b/2015/src/day05.rs similarity index 100% rename from 2015/src/fifth.rs rename to 2015/src/day05.rs diff --git a/2015/src/sixth.rs b/2015/src/day06.rs similarity index 100% rename from 2015/src/sixth.rs rename to 2015/src/day06.rs diff --git a/2015/src/seventh.rs b/2015/src/day07.rs similarity index 100% rename from 2015/src/seventh.rs rename to 2015/src/day07.rs diff --git a/2015/src/eigth.rs b/2015/src/day08.rs similarity index 100% rename from 2015/src/eigth.rs rename to 2015/src/day08.rs diff --git a/2015/src/ninth.rs b/2015/src/day09.rs similarity index 100% rename from 2015/src/ninth.rs rename to 2015/src/day09.rs diff --git a/2015/src/tenth.rs b/2015/src/day10.rs similarity index 100% rename from 2015/src/tenth.rs rename to 2015/src/day10.rs diff --git a/2015/src/eleventh.rs b/2015/src/day11.rs similarity index 100% rename from 2015/src/eleventh.rs rename to 2015/src/day11.rs diff --git a/2015/src/twelfth.rs b/2015/src/day12.rs similarity index 100% rename from 2015/src/twelfth.rs rename to 2015/src/day12.rs diff --git a/2015/src/thirteenth.rs b/2015/src/day13.rs similarity index 100% rename from 2015/src/thirteenth.rs rename to 2015/src/day13.rs diff --git a/2015/src/fourteenth.rs b/2015/src/day14.rs similarity index 100% rename from 2015/src/fourteenth.rs rename to 2015/src/day14.rs diff --git a/2015/src/fifteenth.rs b/2015/src/day15.rs similarity index 100% rename from 2015/src/fifteenth.rs rename to 2015/src/day15.rs diff --git a/2015/src/sixteenth.rs b/2015/src/day16.rs similarity index 100% rename from 2015/src/sixteenth.rs rename to 2015/src/day16.rs diff --git a/2015/src/seventeenth.rs b/2015/src/day17.rs similarity index 100% rename from 2015/src/seventeenth.rs rename to 2015/src/day17.rs diff --git a/2015/src/eighteenth.rs b/2015/src/day18.rs similarity index 100% rename from 2015/src/eighteenth.rs rename to 2015/src/day18.rs diff --git a/2015/src/nineteenth.rs b/2015/src/day19.rs similarity index 100% rename from 2015/src/nineteenth.rs rename to 2015/src/day19.rs diff --git a/2015/src/twentieth.rs b/2015/src/day20.rs similarity index 100% rename from 2015/src/twentieth.rs rename to 2015/src/day20.rs diff --git a/2015/src/twentyfirst.rs b/2015/src/day21.rs similarity index 100% rename from 2015/src/twentyfirst.rs rename to 2015/src/day21.rs diff --git a/2015/src/twentysecond.rs b/2015/src/day22.rs similarity index 100% rename from 2015/src/twentysecond.rs rename to 2015/src/day22.rs diff --git a/2015/src/twentythird.rs b/2015/src/day23.rs similarity index 100% rename from 2015/src/twentythird.rs rename to 2015/src/day23.rs diff --git a/2015/src/twentyfourth.rs b/2015/src/day24.rs similarity index 100% rename from 2015/src/twentyfourth.rs rename to 2015/src/day24.rs diff --git a/2015/src/twentyfifth.rs b/2015/src/day25.rs similarity index 100% rename from 2015/src/twentyfifth.rs rename to 2015/src/day25.rs diff --git a/2015/src/day26.rs b/2015/src/day26.rs new file mode 100644 index 00000000..9db4d0b0 --- /dev/null +++ b/2015/src/day26.rs @@ -0,0 +1,42 @@ +pub fn first(content: String) -> i32 { + // Solution for part 1 of Day 26 + 0 +} + +pub fn solve_first(is_prod: bool) -> i32 { + let content = if is_prod { + include_str!("./inputs/26_prod.txt") + } else { + include_str!("./inputs/26_test.txt") + }; + first(content.to_string()) +} + +pub fn second(content: String) -> i32 { + // Solution for part 2 of Day 26 + 0 +} + +pub fn solve_second(is_prod: bool) -> i32 { + let content = if is_prod { + include_str!("./inputs/26_prod.txt") + } else { + include_str!("./inputs/26_test.txt") + }; + second(content.to_string()) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_26_first() { + assert_eq!(solve_first(false), 0); + } + + #[test] + fn test_26_second() { + assert_eq!(solve_second(false), 0); + } +} \ No newline at end of file diff --git a/2015/src/10_prod.txt b/2015/src/inputs/10_prod.txt similarity index 100% rename from 2015/src/10_prod.txt rename to 2015/src/inputs/10_prod.txt diff --git a/2015/src/10_test.txt b/2015/src/inputs/10_test.txt similarity index 100% rename from 2015/src/10_test.txt rename to 2015/src/inputs/10_test.txt diff --git a/2015/src/11_prod.txt b/2015/src/inputs/11_prod.txt similarity index 100% rename from 2015/src/11_prod.txt rename to 2015/src/inputs/11_prod.txt diff --git a/2015/src/11_test.txt b/2015/src/inputs/11_test.txt similarity index 100% rename from 2015/src/11_test.txt rename to 2015/src/inputs/11_test.txt diff --git a/2015/src/12_prod.txt b/2015/src/inputs/12_prod.txt similarity index 100% rename from 2015/src/12_prod.txt rename to 2015/src/inputs/12_prod.txt diff --git a/2015/src/12_test.txt b/2015/src/inputs/12_test.txt similarity index 100% rename from 2015/src/12_test.txt rename to 2015/src/inputs/12_test.txt diff --git a/2015/src/13_prod.txt b/2015/src/inputs/13_prod.txt similarity index 100% rename from 2015/src/13_prod.txt rename to 2015/src/inputs/13_prod.txt diff --git a/2015/src/13_test.txt b/2015/src/inputs/13_test.txt similarity index 100% rename from 2015/src/13_test.txt rename to 2015/src/inputs/13_test.txt diff --git a/2015/src/14_prod.txt b/2015/src/inputs/14_prod.txt similarity index 100% rename from 2015/src/14_prod.txt rename to 2015/src/inputs/14_prod.txt diff --git a/2015/src/14_test.txt b/2015/src/inputs/14_test.txt similarity index 100% rename from 2015/src/14_test.txt rename to 2015/src/inputs/14_test.txt diff --git a/2015/src/15_prod.txt b/2015/src/inputs/15_prod.txt similarity index 100% rename from 2015/src/15_prod.txt rename to 2015/src/inputs/15_prod.txt diff --git a/2015/src/15_test.txt b/2015/src/inputs/15_test.txt similarity index 100% rename from 2015/src/15_test.txt rename to 2015/src/inputs/15_test.txt diff --git a/2015/src/16_prod.txt b/2015/src/inputs/16_prod.txt similarity index 100% rename from 2015/src/16_prod.txt rename to 2015/src/inputs/16_prod.txt diff --git a/2015/src/16_test.txt b/2015/src/inputs/16_test.txt similarity index 100% rename from 2015/src/16_test.txt rename to 2015/src/inputs/16_test.txt diff --git a/2015/src/17_prod.txt b/2015/src/inputs/17_prod.txt similarity index 100% rename from 2015/src/17_prod.txt rename to 2015/src/inputs/17_prod.txt diff --git a/2015/src/17_test.txt b/2015/src/inputs/17_test.txt similarity index 100% rename from 2015/src/17_test.txt rename to 2015/src/inputs/17_test.txt diff --git a/2015/src/18_prod.txt b/2015/src/inputs/18_prod.txt similarity index 100% rename from 2015/src/18_prod.txt rename to 2015/src/inputs/18_prod.txt diff --git a/2015/src/18_test.txt b/2015/src/inputs/18_test.txt similarity index 100% rename from 2015/src/18_test.txt rename to 2015/src/inputs/18_test.txt diff --git a/2015/src/19_prod.txt b/2015/src/inputs/19_prod.txt similarity index 100% rename from 2015/src/19_prod.txt rename to 2015/src/inputs/19_prod.txt diff --git a/2015/src/19_test.txt b/2015/src/inputs/19_test.txt similarity index 100% rename from 2015/src/19_test.txt rename to 2015/src/inputs/19_test.txt diff --git a/2015/src/1_prod.txt b/2015/src/inputs/1_prod.txt similarity index 100% rename from 2015/src/1_prod.txt rename to 2015/src/inputs/1_prod.txt diff --git a/2015/src/1_test.txt b/2015/src/inputs/1_test.txt similarity index 100% rename from 2015/src/1_test.txt rename to 2015/src/inputs/1_test.txt diff --git a/2015/src/21_prod.txt b/2015/src/inputs/21_prod.txt similarity index 100% rename from 2015/src/21_prod.txt rename to 2015/src/inputs/21_prod.txt diff --git a/2015/src/21_test.txt b/2015/src/inputs/21_test.txt similarity index 100% rename from 2015/src/21_test.txt rename to 2015/src/inputs/21_test.txt diff --git a/2015/src/22_prod.txt b/2015/src/inputs/22_prod.txt similarity index 100% rename from 2015/src/22_prod.txt rename to 2015/src/inputs/22_prod.txt diff --git a/2015/src/22_test.txt b/2015/src/inputs/22_test.txt similarity index 100% rename from 2015/src/22_test.txt rename to 2015/src/inputs/22_test.txt diff --git a/2015/src/23_prod.txt b/2015/src/inputs/23_prod.txt similarity index 100% rename from 2015/src/23_prod.txt rename to 2015/src/inputs/23_prod.txt diff --git a/2015/src/23_test.txt b/2015/src/inputs/23_test.txt similarity index 100% rename from 2015/src/23_test.txt rename to 2015/src/inputs/23_test.txt diff --git a/2015/src/24_prod.txt b/2015/src/inputs/24_prod.txt similarity index 100% rename from 2015/src/24_prod.txt rename to 2015/src/inputs/24_prod.txt diff --git a/2015/src/25_prod.txt b/2015/src/inputs/25_prod.txt similarity index 100% rename from 2015/src/25_prod.txt rename to 2015/src/inputs/25_prod.txt diff --git a/2015/src/inputs/26_prod.txt b/2015/src/inputs/26_prod.txt new file mode 100644 index 00000000..6f081017 --- /dev/null +++ b/2015/src/inputs/26_prod.txt @@ -0,0 +1 @@ +26_prod_data \ No newline at end of file diff --git a/2015/src/inputs/26_test.txt b/2015/src/inputs/26_test.txt new file mode 100644 index 00000000..013fe8ba --- /dev/null +++ b/2015/src/inputs/26_test.txt @@ -0,0 +1 @@ +26_test_data \ No newline at end of file diff --git a/2015/src/2_prod.txt b/2015/src/inputs/2_prod.txt similarity index 100% rename from 2015/src/2_prod.txt rename to 2015/src/inputs/2_prod.txt diff --git a/2015/src/2_test.txt b/2015/src/inputs/2_test.txt similarity index 100% rename from 2015/src/2_test.txt rename to 2015/src/inputs/2_test.txt diff --git a/2015/src/3_prod.txt b/2015/src/inputs/3_prod.txt similarity index 100% rename from 2015/src/3_prod.txt rename to 2015/src/inputs/3_prod.txt diff --git a/2015/src/3_test.txt b/2015/src/inputs/3_test.txt similarity index 100% rename from 2015/src/3_test.txt rename to 2015/src/inputs/3_test.txt diff --git a/2015/src/4_prod.txt b/2015/src/inputs/4_prod.txt similarity index 100% rename from 2015/src/4_prod.txt rename to 2015/src/inputs/4_prod.txt diff --git a/2015/src/4_test.txt b/2015/src/inputs/4_test.txt similarity index 100% rename from 2015/src/4_test.txt rename to 2015/src/inputs/4_test.txt diff --git a/2015/src/5_prod.txt b/2015/src/inputs/5_prod.txt similarity index 100% rename from 2015/src/5_prod.txt rename to 2015/src/inputs/5_prod.txt diff --git a/2015/src/5_test.txt b/2015/src/inputs/5_test.txt similarity index 100% rename from 2015/src/5_test.txt rename to 2015/src/inputs/5_test.txt diff --git a/2015/src/6_prod.txt b/2015/src/inputs/6_prod.txt similarity index 100% rename from 2015/src/6_prod.txt rename to 2015/src/inputs/6_prod.txt diff --git a/2015/src/6_test.txt b/2015/src/inputs/6_test.txt similarity index 100% rename from 2015/src/6_test.txt rename to 2015/src/inputs/6_test.txt diff --git a/2015/src/7_prod.txt b/2015/src/inputs/7_prod.txt similarity index 100% rename from 2015/src/7_prod.txt rename to 2015/src/inputs/7_prod.txt diff --git a/2015/src/7_test.txt b/2015/src/inputs/7_test.txt similarity index 100% rename from 2015/src/7_test.txt rename to 2015/src/inputs/7_test.txt diff --git a/2015/src/8_prod.txt b/2015/src/inputs/8_prod.txt similarity index 100% rename from 2015/src/8_prod.txt rename to 2015/src/inputs/8_prod.txt diff --git a/2015/src/8_test.txt b/2015/src/inputs/8_test.txt similarity index 100% rename from 2015/src/8_test.txt rename to 2015/src/inputs/8_test.txt diff --git a/2015/src/9_prod.txt b/2015/src/inputs/9_prod.txt similarity index 100% rename from 2015/src/9_prod.txt rename to 2015/src/inputs/9_prod.txt diff --git a/2015/src/9_test.txt b/2015/src/inputs/9_test.txt similarity index 100% rename from 2015/src/9_test.txt rename to 2015/src/inputs/9_test.txt diff --git a/2015/src/lib.rs b/2015/src/lib.rs index 488dab0b..78501a00 100644 --- a/2015/src/lib.rs +++ b/2015/src/lib.rs @@ -1,28 +1,29 @@ -pub mod eighteenth; -pub mod eigth; -pub mod eleventh; -pub mod fifteenth; -pub mod fifth; -pub mod first; -pub mod fourteenth; -pub mod fourth; -pub mod nineteenth; -pub mod ninth; -pub mod second; -pub mod seventeenth; -pub mod seventh; -pub mod sixteenth; -pub mod sixth; -pub mod tenth; -pub mod thirteenth; -pub mod trird; -pub mod twelfth; -pub mod twentieth; -pub mod twentyfifth; -pub mod twentyfirst; -pub mod twentyfourth; -pub mod twentysecond; -pub mod twentythird; +pub mod day18; +pub mod day08; +pub mod day11; +pub mod day15; +pub mod day05; +pub mod day01; +pub mod day14; +pub mod day04; +pub mod day19; +pub mod day09; +pub mod day02; +pub mod day17; +pub mod day07; +pub mod day16; +pub mod day06; +pub mod day10; +pub mod day13; +pub mod day03; +pub mod day12; +pub mod day20; +pub mod day25; +pub mod day21; +pub mod day24; +pub mod day22; +pub mod day23; +pub mod day26; struct Excercise { content: String, diff --git a/CRUSH.md b/CRUSH.md index f60374e5..17ba5f06 100644 --- a/CRUSH.md +++ b/CRUSH.md @@ -24,7 +24,8 @@ Due to the polyglot nature of this repository, build and test commands are speci ### Rust Projects -For Rust projects (identified by `Cargo.toml`): +For Rust projects (identified by `Cargo.toml`), you might need `libclang` development headers installed on your system for some dependencies. + - **Build**: `cargo build` - **Run**: `cargo run` - **Test**: `cargo test`