mirror of
https://github.com/Smaug123/AdventOfCode2021
synced 2025-10-06 08:18: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.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
|
||||||
|
@@ -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
|
||||||
|
@@ -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
|
||||||
|
21
Utils.fs
21
Utils.fs
@@ -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
|
||||||
|
Reference in New Issue
Block a user