mirror of
https://github.com/Smaug123/AdventOfCode2021
synced 2025-10-05 07:48:41 +00:00
Fantomas format
This commit is contained in:
2
Day1.fs
2
Day1.fs
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
21
Utils.fs
21
Utils.fs
@@ -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
|
||||
|
Reference in New Issue
Block a user