6 Commits

Author SHA1 Message Date
Smaug123
aa2ace9bf9 Add test
Some checks failed
ci/woodpecker/push/all-checks-complete Pipeline is pending
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/pr/build Pipeline failed
ci/woodpecker/pr/all-checks-complete unknown status
2023-12-03 19:15:52 +00:00
Smaug123
e64b9f7cf2 Fix
Some checks failed
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/pr/build Pipeline failed
ci/woodpecker/push/all-checks-complete Pipeline was successful
ci/woodpecker/pr/all-checks-complete unknown status
2023-12-03 17:50:30 +00:00
Smaug123
4efbddd9d2 And try a publish
Some checks failed
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/pr/build Pipeline failed
ci/woodpecker/push/all-checks-complete Pipeline was successful
ci/woodpecker/pr/all-checks-complete unknown status
2023-12-03 17:44:53 +00:00
Smaug123
56d0b0c44e Merge branch 'main' into woodpecker
Some checks failed
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/all-checks-complete Pipeline was successful
ci/woodpecker/pr/build Pipeline failed
ci/woodpecker/pr/all-checks-complete unknown status
2023-12-03 17:42:49 +00:00
Smaug123
331092ff44 Try this
All checks were successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/all-checks-complete Pipeline was successful
2023-12-03 17:42:08 +00:00
Smaug123
89958b0fa0 Woodpecker
All checks were successful
ci/woodpecker/manual/build Pipeline was successful
ci/woodpecker/manual/all-checks-complete Pipeline was successful
2023-12-03 17:25:37 +00:00
12 changed files with 125 additions and 65 deletions

View File

@@ -6,8 +6,11 @@ steps:
# Lint # Lint
- "nix flake check" - "nix flake check"
# Test # Test
- nix develop --command dotnet test - nix develop --command dotnet test AdventOfCode2023.FSharp
- nix develop --command dotnet test --configuration Release - nix develop --command dotnet test AdventOfCode2023.FSharp --configuration Release
- nix develop --command dotnet publish AdventOfCode2023.FSharp/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.fsproj --configuration Release
- nix develop --command sh -c "$(find . -type f -name AdventOfCode2023.FSharp | grep Release | grep publish) AdventOfCode2023.FSharp/Test/samples"
- nix develop --command alejandra --check .
when: when:
- event: "push" - event: "push"

View File

@@ -86,6 +86,10 @@ module Program =
Console.Error.WriteLine ((1_000.0 * float sw.ElapsedTicks / float Stopwatch.Frequency).ToString () + "ms") Console.Error.WriteLine ((1_000.0 * float sw.ElapsedTicks / float Stopwatch.Frequency).ToString () + "ms")
endToEnd.Stop () endToEnd.Stop ()
Console.Error.WriteLine ((1_000.0 * float endToEnd.ElapsedTicks / float Stopwatch.Frequency).ToString () + "ms total")
Console.Error.WriteLine (
(1_000.0 * float endToEnd.ElapsedTicks / float Stopwatch.Frequency).ToString ()
+ "ms total"
)
0 0

View File

@@ -8,9 +8,14 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Util.fs" />
<Compile Include="TestDay1.fs" /> <Compile Include="TestDay1.fs" />
<Compile Include="TestDay2.fs" /> <Compile Include="TestDay2.fs" />
<Compile Include="TestDay3.fs" /> <Compile Include="TestDay3.fs" />
<EmbeddedResource Include="samples\day1.txt" />
<EmbeddedResource Include="samples\day1part1.txt" />
<EmbeddedResource Include="samples\day2.txt" />
<EmbeddedResource Include="samples\day3.txt" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -8,26 +8,13 @@ open System.IO
[<TestFixture>] [<TestFixture>]
module TestDay1 = module TestDay1 =
let sample1 = let sample1 = Assembly.getEmbeddedResource typeof<Dummy>.Assembly "day1part1.txt"
"""1abc2
pqr3stu8vwx
a1b2c3d4e5f
treb7uchet
"""
[<Test>] [<Test>]
let part1Sample () = let part1Sample () =
sample1 |> Day1.part1 |> shouldEqual 142 sample1 |> Day1.part1 |> shouldEqual 142
let sample2 = let sample2 = Assembly.getEmbeddedResource typeof<Dummy>.Assembly "day1.txt"
"""two1nine
eightwothree
abcone2threexyz
xtwone3four
4nineeightseven2
zoneight234
7pqrstsixteen
"""
[<Test>] [<Test>]
let part2Sample () = let part2Sample () =
@@ -38,7 +25,9 @@ zoneight234
let s = let s =
try try
File.ReadAllText (Path.Combine (__SOURCE_DIRECTORY__, "../../inputs/day1.txt")) File.ReadAllText (Path.Combine (__SOURCE_DIRECTORY__, "../../inputs/day1.txt"))
with :? FileNotFoundException -> with
| :? DirectoryNotFoundException
| :? FileNotFoundException ->
Assert.Inconclusive () Assert.Inconclusive ()
failwith "unreachable" failwith "unreachable"
@@ -49,7 +38,9 @@ zoneight234
let s = let s =
try try
File.ReadAllText (Path.Combine (__SOURCE_DIRECTORY__, "../../inputs/day1.txt")) File.ReadAllText (Path.Combine (__SOURCE_DIRECTORY__, "../../inputs/day1.txt"))
with :? FileNotFoundException -> with
| :? DirectoryNotFoundException
| :? FileNotFoundException ->
Assert.Inconclusive () Assert.Inconclusive ()
failwith "unreachable" failwith "unreachable"

View File

@@ -8,13 +8,7 @@ open System.IO
[<TestFixture>] [<TestFixture>]
module TestDay2 = module TestDay2 =
let sample = let sample = Assembly.getEmbeddedResource typeof<Dummy>.Assembly "day2.txt"
"""Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green
Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue
Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red
Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red
Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green
"""
[<Test>] [<Test>]
let part1Sample () = sample |> Day2.part1 |> shouldEqual 8 let part1Sample () = sample |> Day2.part1 |> shouldEqual 8
@@ -28,7 +22,9 @@ Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green
let s = let s =
try try
File.ReadAllText (Path.Combine (__SOURCE_DIRECTORY__, "../../inputs/day2.txt")) File.ReadAllText (Path.Combine (__SOURCE_DIRECTORY__, "../../inputs/day2.txt"))
with :? FileNotFoundException -> with
| :? DirectoryNotFoundException
| :? FileNotFoundException ->
Assert.Inconclusive () Assert.Inconclusive ()
failwith "unreachable" failwith "unreachable"
@@ -39,7 +35,9 @@ Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green
let s = let s =
try try
File.ReadAllText (Path.Combine (__SOURCE_DIRECTORY__, "../../inputs/day2.txt")) File.ReadAllText (Path.Combine (__SOURCE_DIRECTORY__, "../../inputs/day2.txt"))
with :? FileNotFoundException -> with
| :? DirectoryNotFoundException
| :? FileNotFoundException ->
Assert.Inconclusive () Assert.Inconclusive ()
failwith "unreachable" failwith "unreachable"

View File

@@ -13,18 +13,7 @@ open System.IO
[<TestFixture>] [<TestFixture>]
module TestDay3 = module TestDay3 =
let sample = let sample = Assembly.getEmbeddedResource typeof<Dummy>.Assembly "day3.txt"
"""467..114..
...*......
..35..633.
......#...
617*......
.....+.58.
..592.....
......755.
...$.*....
.664.598..
"""
[<Test>] [<Test>]
let part1Sample () = let part1Sample () =
@@ -77,7 +66,9 @@ module TestDay3 =
let bytes = let bytes =
try try
File.ReadAllBytes (Path.Combine (__SOURCE_DIRECTORY__, "../../inputs/day3.txt")) File.ReadAllBytes (Path.Combine (__SOURCE_DIRECTORY__, "../../inputs/day3.txt"))
with :? FileNotFoundException -> with
| :? DirectoryNotFoundException
| :? FileNotFoundException ->
Assert.Inconclusive () Assert.Inconclusive ()
failwith "unreachable" failwith "unreachable"
@@ -107,7 +98,9 @@ module TestDay3 =
let bytes = let bytes =
try try
File.ReadAllBytes (Path.Combine (__SOURCE_DIRECTORY__, "../../inputs/day3.txt")) File.ReadAllBytes (Path.Combine (__SOURCE_DIRECTORY__, "../../inputs/day3.txt"))
with :? FileNotFoundException -> with
| :? DirectoryNotFoundException
| :? FileNotFoundException ->
Assert.Inconclusive () Assert.Inconclusive ()
failwith "unreachable" failwith "unreachable"

View File

@@ -0,0 +1,21 @@
namespace AdventOfCode2023.Test
open System.IO
open System.Reflection
type Dummy = class end
[<RequireQualifiedAccess>]
module Assembly =
let getEmbeddedResource (assembly : Assembly) (name : string) : string =
let names = assembly.GetManifestResourceNames ()
let names = names |> Seq.filter (fun s -> s.EndsWith name)
use s =
names
|> Seq.exactlyOne
|> assembly.GetManifestResourceStream
|> fun s -> new StreamReader (s)
s.ReadToEnd ()

View File

@@ -0,0 +1,7 @@
two1nine
eightwothree
abcone2threexyz
xtwone3four
4nineeightseven2
zoneight234
7pqrstsixteen

View File

@@ -0,0 +1,4 @@
1abc2
pqr3stu8vwx
a1b2c3d4e5f
treb7uchet

View File

@@ -0,0 +1,5 @@
Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green
Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue
Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red
Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red
Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green

View File

@@ -0,0 +1,10 @@
467..114..
...*......
..35..633.
......#...
617*......
.....+.58.
..592.....
......755.
...$.*....
.664.598..

View File

@@ -1,26 +1,45 @@
{ {
description = "Advent of Code 2023"; description = "Advent of Code 2023";
inputs = { inputs = {
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
}; };
outputs = { outputs = {
self, self,
nixpkgs, nixpkgs,
flake-utils, flake-utils,
}: flake-utils.lib.eachDefaultSystem (system: }:
let pkgs = nixpkgs.legacyPackages.${system}; in flake-utils.lib.eachDefaultSystem (
{ system: let
devShells = { default = pkgs.mkShell { pkgs = nixpkgs.legacyPackages.${system};
buildInputs = with pkgs; [ in
(with dotnetCorePackages; # Conditionally include Swift and Apple SDK for Darwin systems
combinePackages [ let
dotnet-sdk_8 darwinDeps =
dotnetPackages.Nuget if system == "x86_64-darwin" || system == "aarch64-darwin"
]) then [
] ++ [pkgs.swift darwin.apple_sdk.frameworks.Foundation darwin.apple_sdk.frameworks.CryptoKit darwin.apple_sdk.frameworks.GSS pkgs.zlib pkgs.zlib.dev pkgs.openssl pkgs.icu]; pkgs.swift
};}; pkgs.darwin.apple_sdk.frameworks.Foundation
} pkgs.darwin.apple_sdk.frameworks.CryptoKit
pkgs.darwin.apple_sdk.frameworks.GSS
]
else [];
in {
devShells = {
default = pkgs.mkShell {
buildInputs = with pkgs;
[
(with dotnetCorePackages;
combinePackages [
dotnet-sdk_8
dotnetPackages.Nuget
])
]
++ darwinDeps
++ [pkgs.zlib pkgs.zlib.dev pkgs.openssl pkgs.icu pkgs.alejandra];
};
};
}
); );
} }