Scaffolding
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
<Compile Include="Day3.fs" />
|
<Compile Include="Day3.fs" />
|
||||||
<Compile Include="Day4.fs" />
|
<Compile Include="Day4.fs" />
|
||||||
<Compile Include="Day5.fs" />
|
<Compile Include="Day5.fs" />
|
||||||
|
<Compile Include="Day6.fs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
14
AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Lib/Day6.fs
Normal file
14
AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Lib/Day6.fs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
namespace AdventOfCode2023
|
||||||
|
|
||||||
|
open System
|
||||||
|
|
||||||
|
[<RequireQualifiedAccess>]
|
||||||
|
module Day6 =
|
||||||
|
|
||||||
|
let part1 (s : string) =
|
||||||
|
use mutable lines = StringSplitEnumerator.make '\n' s
|
||||||
|
-1
|
||||||
|
|
||||||
|
let part2 (s : string) =
|
||||||
|
use mutable lines = StringSplitEnumerator.make '\n' s
|
||||||
|
-1
|
@@ -121,6 +121,21 @@ module Program =
|
|||||||
Console.WriteLine (part2.ToString ())
|
Console.WriteLine (part2.ToString ())
|
||||||
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")
|
||||||
|
|
||||||
|
printfn "=====Day 6====="
|
||||||
|
|
||||||
|
do
|
||||||
|
let input = Path.Combine (dir.FullName, "day6.txt") |> File.ReadAllText
|
||||||
|
sw.Restart ()
|
||||||
|
let part1 = Day6.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 = Day6.part2 input
|
||||||
|
sw.Stop ()
|
||||||
|
Console.WriteLine (part2.ToString ())
|
||||||
|
Console.Error.WriteLine ((1_000.0 * float sw.ElapsedTicks / float Stopwatch.Frequency).ToString () + "ms")
|
||||||
|
|
||||||
endToEnd.Stop ()
|
endToEnd.Stop ()
|
||||||
|
|
||||||
Console.Error.WriteLine (
|
Console.Error.WriteLine (
|
||||||
|
@@ -14,12 +14,14 @@
|
|||||||
<Compile Include="TestDay3.fs" />
|
<Compile Include="TestDay3.fs" />
|
||||||
<Compile Include="TestDay4.fs" />
|
<Compile Include="TestDay4.fs" />
|
||||||
<Compile Include="TestDay5.fs" />
|
<Compile Include="TestDay5.fs" />
|
||||||
|
<Compile Include="TestDay6.fs" />
|
||||||
<EmbeddedResource Include="samples\day1.txt" />
|
<EmbeddedResource Include="samples\day1.txt" />
|
||||||
<EmbeddedResource Include="samples\day1part1.txt" />
|
<EmbeddedResource Include="samples\day1part1.txt" />
|
||||||
<EmbeddedResource Include="samples\day2.txt" />
|
<EmbeddedResource Include="samples\day2.txt" />
|
||||||
<EmbeddedResource Include="samples\day3.txt" />
|
<EmbeddedResource Include="samples\day3.txt" />
|
||||||
<EmbeddedResource Include="samples\day4.txt" />
|
<EmbeddedResource Include="samples\day4.txt" />
|
||||||
<EmbeddedResource Include="samples\day5.txt" />
|
<EmbeddedResource Include="samples\day5.txt" />
|
||||||
|
<EmbeddedResource Include="samples\day6.txt" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
46
AdventOfCode2023.FSharp/Test/TestDay6.fs
Normal file
46
AdventOfCode2023.FSharp/Test/TestDay6.fs
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
namespace AdventOfCode2023.Test
|
||||||
|
|
||||||
|
open System
|
||||||
|
open AdventOfCode2023
|
||||||
|
open NUnit.Framework
|
||||||
|
open FsUnitTyped
|
||||||
|
open System.IO
|
||||||
|
|
||||||
|
[<TestFixture>]
|
||||||
|
module TestDay6 =
|
||||||
|
|
||||||
|
let sample = Assembly.getEmbeddedResource typeof<Dummy>.Assembly "day6.txt"
|
||||||
|
|
||||||
|
[<Test>]
|
||||||
|
let part1Sample () =
|
||||||
|
sample |> Day6.part1 |> shouldEqual 0
|
||||||
|
|
||||||
|
[<Test>]
|
||||||
|
let part2Sample () =
|
||||||
|
sample |> Day6.part2 |> shouldEqual 0
|
||||||
|
|
||||||
|
[<Test>]
|
||||||
|
let part1Actual () =
|
||||||
|
let s =
|
||||||
|
try
|
||||||
|
File.ReadAllText (Path.Combine (__SOURCE_DIRECTORY__, "../../inputs/day6.txt"))
|
||||||
|
with
|
||||||
|
| :? DirectoryNotFoundException
|
||||||
|
| :? FileNotFoundException ->
|
||||||
|
Assert.Inconclusive ()
|
||||||
|
failwith "unreachable"
|
||||||
|
|
||||||
|
Day6.part1 s |> shouldEqual 0
|
||||||
|
|
||||||
|
[<Test>]
|
||||||
|
let part2Actual () =
|
||||||
|
let s =
|
||||||
|
try
|
||||||
|
File.ReadAllText (Path.Combine (__SOURCE_DIRECTORY__, "../../inputs/day6.txt"))
|
||||||
|
with
|
||||||
|
| :? DirectoryNotFoundException
|
||||||
|
| :? FileNotFoundException ->
|
||||||
|
Assert.Inconclusive ()
|
||||||
|
failwith "unreachable"
|
||||||
|
|
||||||
|
Day6.part2 s |> shouldEqual 0
|
33
AdventOfCode2023.FSharp/Test/samples/day6.txt
Normal file
33
AdventOfCode2023.FSharp/Test/samples/day6.txt
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
seeds: 79 14 55 13
|
||||||
|
|
||||||
|
seed-to-soil map:
|
||||||
|
50 98 2
|
||||||
|
52 50 48
|
||||||
|
|
||||||
|
soil-to-fertilizer map:
|
||||||
|
0 15 37
|
||||||
|
37 52 2
|
||||||
|
39 0 15
|
||||||
|
|
||||||
|
fertilizer-to-water map:
|
||||||
|
49 53 8
|
||||||
|
0 11 42
|
||||||
|
42 0 7
|
||||||
|
57 7 4
|
||||||
|
|
||||||
|
water-to-light map:
|
||||||
|
88 18 7
|
||||||
|
18 25 70
|
||||||
|
|
||||||
|
light-to-temperature map:
|
||||||
|
45 77 23
|
||||||
|
81 45 19
|
||||||
|
68 64 13
|
||||||
|
|
||||||
|
temperature-to-humidity map:
|
||||||
|
0 69 1
|
||||||
|
1 0 69
|
||||||
|
|
||||||
|
humidity-to-location map:
|
||||||
|
60 56 37
|
||||||
|
56 93 4
|
Reference in New Issue
Block a user