Fantomas format

This commit is contained in:
Smaug123
2021-12-06 19:40:35 +00:00
parent 5afea832f1
commit 9d3e7259ec
4 changed files with 20 additions and 19 deletions

View File

@@ -11,7 +11,7 @@ module Day1 =
|> Seq.pairwise
|> Seq.filter (fun (a, b) -> a < b)
|> Seq.length
let part2 () =
Utils.readResource "Day1.txt"
|> Seq.map int

View File

@@ -7,6 +7,6 @@ module Program =
| "1" ->
printfn $"{Day1.part1 ()}"
printfn $"{Day1.part2 ()}"
| s ->
failwithf $"Unexpected argument: %s{s}"
| s -> failwithf $"Unexpected argument: %s{s}"
0

View File

@@ -5,13 +5,9 @@ open Xunit
open FsUnitTyped
module TestDay1 =
[<Fact>]
let ``Part 1`` () =
Day1.part1 ()
|> shouldEqual 1766
[<Fact>]
let ``Part 2`` () =
Day1.part2 ()
|> shouldEqual 1797
let ``Part 1`` () = Day1.part1 () |> shouldEqual 1766
[<Fact>]
let ``Part 2`` () = Day1.part2 () |> shouldEqual 1797

View File

@@ -5,15 +5,20 @@ open System.Reflection
[<RequireQualifiedAccess>]
module Utils =
type private Dummy = class end
type private Dummy =
class
end
let readResource' (name : string) : string array =
let asm = Assembly.GetAssembly typeof<Dummy>
use stream = asm.GetManifestResourceStream (sprintf "AdventOfCode2021.Inputs.%s" name)
let s =
use reader = new StreamReader(stream)
reader.ReadToEnd()
s.Split('\r', '\n')
let inline readResource (name : string) : string list =
readResource' name |> List.ofArray
use stream =
asm.GetManifestResourceStream (sprintf "AdventOfCode2021.Inputs.%s" name)
let s =
use reader = new StreamReader (stream)
reader.ReadToEnd ()
s.Split ('\r', '\n')
let inline readResource (name : string) : string list = readResource' name |> List.ofArray