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.pairwise
|> Seq.filter (fun (a, b) -> a < b) |> Seq.filter (fun (a, b) -> a < b)
|> Seq.length |> Seq.length
let part2 () = let part2 () =
Utils.readResource "Day1.txt" Utils.readResource "Day1.txt"
|> Seq.map int |> Seq.map int

View File

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

View File

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

View File

@@ -5,15 +5,20 @@ open System.Reflection
[<RequireQualifiedAccess>] [<RequireQualifiedAccess>]
module Utils = module Utils =
type private Dummy = class end type private Dummy =
class
end
let readResource' (name : string) : string array = let readResource' (name : string) : string array =
let asm = Assembly.GetAssembly typeof<Dummy> 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 = use stream =
readResource' name |> List.ofArray 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