Compare commits
5 Commits
8c244330b7
...
minimal
Author | SHA1 | Date | |
---|---|---|---|
|
337d11e0e6 | ||
|
a401d8cf5c | ||
|
61f15726a1 | ||
|
d50618676f | ||
|
ad28718b3e |
@@ -3,16 +3,9 @@ steps:
|
||||
image: nixos/nix
|
||||
commands:
|
||||
- echo 'experimental-features = flakes nix-command' >> /etc/nix/nix.conf
|
||||
# Lint
|
||||
- "nix flake check"
|
||||
# Test
|
||||
- nix develop --command dotnet test AdventOfCode2023.FSharp
|
||||
- nix develop --command dotnet test AdventOfCode2023.FSharp --configuration Release
|
||||
- nix develop --command dotnet --info
|
||||
- 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 .
|
||||
- nix develop --command dotnet tool restore
|
||||
- nix develop --command dotnet fantomas --check .
|
||||
|
||||
when:
|
||||
- event: "push"
|
||||
|
@@ -1,28 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<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>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.fs"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AdventOfCode2023.FSharp.Lib\AdventOfCode2023.FSharp.Lib.fsproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@@ -1,95 +1,7 @@
|
||||
namespace AdventOfCode2023
|
||||
|
||||
#if DEBUG
|
||||
#else
|
||||
#nowarn "9"
|
||||
#endif
|
||||
|
||||
open System
|
||||
open System.Diagnostics
|
||||
open System.IO
|
||||
namespace AdventOfCode2023
|
||||
|
||||
module Program =
|
||||
|
||||
let inline toUs (ticks : int64) =
|
||||
1_000_000.0 * float ticks / float Stopwatch.Frequency
|
||||
|
||||
[<EntryPoint>]
|
||||
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
|
||||
|
Reference in New Issue
Block a user