Compare commits
4 Commits
ad28718b3e
...
minimal
Author | SHA1 | Date | |
---|---|---|---|
|
337d11e0e6 | ||
|
a401d8cf5c | ||
|
61f15726a1 | ||
|
d50618676f |
@@ -3,14 +3,7 @@ steps:
|
|||||||
image: nixos/nix
|
image: nixos/nix
|
||||||
commands:
|
commands:
|
||||||
- echo 'experimental-features = flakes nix-command' >> /etc/nix/nix.conf
|
- echo 'experimental-features = flakes nix-command' >> /etc/nix/nix.conf
|
||||||
# Lint
|
- nix develop --command dotnet --info
|
||||||
- "nix flake check"
|
|
||||||
# Test
|
|
||||||
- nix develop --command dotnet test AdventOfCode2023.FSharp
|
|
||||||
- nix develop --command dotnet test AdventOfCode2023.FSharp --configuration Release
|
|
||||||
- nix develop --command alejandra --check .
|
|
||||||
- nix develop --command dotnet tool restore
|
|
||||||
- nix develop --command dotnet fantomas --check .
|
|
||||||
- nix develop --command dotnet publish AdventOfCode2023.FSharp/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.fsproj --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 sh -c "$(find . -type f -name AdventOfCode2023.FSharp | grep Release | grep publish) AdventOfCode2023.FSharp/Test/samples"
|
||||||
|
|
||||||
|
@@ -1,28 +1,12 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<PublishAot>true</PublishAot>
|
<PublishAot>true</PublishAot>
|
||||||
<InvariantGlobalization>true</InvariantGlobalization>
|
|
||||||
<UseSystemResourceKeys>true</UseSystemResourceKeys>
|
|
||||||
|
|
||||||
<IlcOptimizationPreference>Speed</IlcOptimizationPreference>
|
|
||||||
<IlcGenerateStackTraceData>false</IlcGenerateStackTraceData>
|
|
||||||
|
|
||||||
<DebuggerSupport>false</DebuggerSupport>
|
|
||||||
<EnableUnsafeBinaryFormatterSerialization>false</EnableUnsafeBinaryFormatterSerialization>
|
|
||||||
<EventSourceSupport>false</EventSourceSupport>
|
|
||||||
<HttpActivityPropagationSupport>false</HttpActivityPropagationSupport>
|
|
||||||
<MetadataUpdaterSupport>false</MetadataUpdaterSupport>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Program.fs"/>
|
<Compile Include="Program.fs"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\AdventOfCode2023.FSharp.Lib\AdventOfCode2023.FSharp.Lib.fsproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@@ -1,95 +1,7 @@
|
|||||||
namespace AdventOfCode2023
|
namespace AdventOfCode2023
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
#else
|
|
||||||
#nowarn "9"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
open System
|
|
||||||
open System.Diagnostics
|
|
||||||
open System.IO
|
|
||||||
|
|
||||||
module Program =
|
module Program =
|
||||||
|
|
||||||
let inline toUs (ticks : int64) =
|
|
||||||
1_000_000.0 * float ticks / float Stopwatch.Frequency
|
|
||||||
|
|
||||||
[<EntryPoint>]
|
[<EntryPoint>]
|
||||||
let main argv =
|
let main argv =
|
||||||
let endToEnd = Stopwatch.StartNew ()
|
|
||||||
endToEnd.Restart ()
|
|
||||||
|
|
||||||
let dir = DirectoryInfo argv.[0]
|
|
||||||
|
|
||||||
let sw = Stopwatch.StartNew ()
|
|
||||||
|
|
||||||
do
|
|
||||||
sw.Restart ()
|
|
||||||
let input = Path.Combine (dir.FullName, "day1.txt") |> File.ReadAllText
|
|
||||||
let part1 = Day1.part1 input
|
|
||||||
sw.Stop ()
|
|
||||||
Console.WriteLine (part1.ToString ())
|
|
||||||
Console.Error.WriteLine ((1_000.0 * float sw.ElapsedTicks / float Stopwatch.Frequency).ToString () + "ms")
|
|
||||||
sw.Restart ()
|
|
||||||
let part2 = Day1.part2 input
|
|
||||||
sw.Stop ()
|
|
||||||
Console.WriteLine (part2.ToString ())
|
|
||||||
Console.Error.WriteLine ((1_000.0 * float sw.ElapsedTicks / float Stopwatch.Frequency).ToString () + "ms")
|
|
||||||
|
|
||||||
do
|
|
||||||
let input = Path.Combine (dir.FullName, "day2.txt") |> File.ReadAllText
|
|
||||||
sw.Restart ()
|
|
||||||
let part1 = Day2.part1 input
|
|
||||||
sw.Stop ()
|
|
||||||
Console.WriteLine (part1.ToString ())
|
|
||||||
Console.Error.WriteLine ((1_000.0 * float sw.ElapsedTicks / float Stopwatch.Frequency).ToString () + "ms")
|
|
||||||
sw.Restart ()
|
|
||||||
let part2 = Day2.part2 input
|
|
||||||
sw.Stop ()
|
|
||||||
Console.WriteLine (part2.ToString ())
|
|
||||||
Console.Error.WriteLine ((1_000.0 * float sw.ElapsedTicks / float Stopwatch.Frequency).ToString () + "ms")
|
|
||||||
|
|
||||||
do
|
|
||||||
let input = Path.Combine (dir.FullName, "day3.txt") |> File.ReadAllBytes
|
|
||||||
|
|
||||||
sw.Restart ()
|
|
||||||
let resultArr, len, lineCount = Day3.parse input
|
|
||||||
sw.Stop ()
|
|
||||||
|
|
||||||
Console.Error.WriteLine (
|
|
||||||
(1_000.0 * float sw.ElapsedTicks / float Stopwatch.Frequency).ToString ()
|
|
||||||
+ "ms parse"
|
|
||||||
)
|
|
||||||
#if DEBUG
|
|
||||||
let contents =
|
|
||||||
{
|
|
||||||
Elements = Array.take len resultArr
|
|
||||||
Width = len / lineCount
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
use ptr = fixed resultArr
|
|
||||||
|
|
||||||
let contents =
|
|
||||||
{
|
|
||||||
Elements = ptr
|
|
||||||
Length = len
|
|
||||||
Width = len / lineCount
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
let part1 = Day3.part1 contents
|
|
||||||
sw.Stop ()
|
|
||||||
Console.WriteLine (part1.ToString ())
|
|
||||||
Console.Error.WriteLine ((1_000.0 * float sw.ElapsedTicks / float Stopwatch.Frequency).ToString () + "ms")
|
|
||||||
sw.Restart ()
|
|
||||||
let part2 = Day3.part2 contents
|
|
||||||
Console.WriteLine (part2.ToString ())
|
|
||||||
Console.Error.WriteLine ((1_000.0 * float sw.ElapsedTicks / float Stopwatch.Frequency).ToString () + "ms")
|
|
||||||
|
|
||||||
endToEnd.Stop ()
|
|
||||||
|
|
||||||
Console.Error.WriteLine (
|
|
||||||
(1_000.0 * float endToEnd.ElapsedTicks / float Stopwatch.Frequency).ToString ()
|
|
||||||
+ "ms total"
|
|
||||||
)
|
|
||||||
|
|
||||||
0
|
0
|
||||||
|
Reference in New Issue
Block a user