From e4ab85dedd210282b90969fb22a8f27e46feb18e Mon Sep 17 00:00:00 2001 From: Ummon Date: Fri, 22 Dec 2017 10:13:35 +0100 Subject: [PATCH] Beginning of day 22 --- AdventOfCode2017/AdventOfCode2017.fsproj | 2 ++ AdventOfCode2017/Day20.fs | 2 +- AdventOfCode2017/Day22.fs | 19 ++++++++++++++ Tests/Day20 tests.fs | 20 +++------------ Tests/Day22 tests.fs | 32 ++++++++++++++++++++++++ Tests/Tests.fsproj | 1 + 6 files changed, 58 insertions(+), 18 deletions(-) create mode 100644 AdventOfCode2017/Day22.fs create mode 100644 Tests/Day22 tests.fs diff --git a/AdventOfCode2017/AdventOfCode2017.fsproj b/AdventOfCode2017/AdventOfCode2017.fsproj index 4cc42dc..257e1c6 100644 --- a/AdventOfCode2017/AdventOfCode2017.fsproj +++ b/AdventOfCode2017/AdventOfCode2017.fsproj @@ -79,6 +79,7 @@ + @@ -141,6 +142,7 @@ PreserveNewest + diff --git a/AdventOfCode2017/Day20.fs b/AdventOfCode2017/Day20.fs index 031fadd..218e095 100644 --- a/AdventOfCode2017/Day20.fs +++ b/AdventOfCode2017/Day20.fs @@ -5,7 +5,7 @@ open System type Vec = { X : float; Y : float; Z : float } with - member this.ManhattanNorm = abs this.X + abs this.Y + abs this.Z + member this.ManhattanNorm = abs this.X + abs this.Y + abs this.Z type Particule = { Pos : Vec; V : Vec; A : Vec } diff --git a/AdventOfCode2017/Day22.fs b/AdventOfCode2017/Day22.fs new file mode 100644 index 0000000..a651517 --- /dev/null +++ b/AdventOfCode2017/Day22.fs @@ -0,0 +1,19 @@ +module AdventOfCode2017.Day22 + +type M = Set + +let parseInput (lines : string[]) : M = + for i = 0 to lines.Length do + for + + +let infection (m : M) : int = + + let rec burst (i, j) (di, dj) n m = + if n = 0 then + () + else + burst (i, j) (di, dj) (n - 1) m + + 23 + diff --git a/Tests/Day20 tests.fs b/Tests/Day20 tests.fs index 27cc33f..ce41f5f 100644 --- a/Tests/Day20 tests.fs +++ b/Tests/Day20 tests.fs @@ -7,26 +7,12 @@ open Swensen.Unquote open AdventOfCode2017 -type ``Day20 tests`` (output : ITestOutputHelper) = +type ``Day22 tests`` (output : ITestOutputHelper) = [] let ``(Part1) From web page`` () = - let input = - [| - "p=< 3,0,0>, v=< 2,0,0>, a=<-1,0,0>" - "p=< 4,0,0>, v=< 0,0,0>, a=<-2,0,0>" - |] |> Day20.parseInput - - Day20.nearestZero input =! 0 + () [] let ``(Part2) From web page`` () = - let input = - [| - "p=<-6,0,0>, v=< 3,0,0>, a=< 0,0,0>" - "p=<-4,0,0>, v=< 2,0,0>, a=< 0,0,0>" - "p=<-2,0,0>, v=< 1,0,0>, a=< 0,0,0>" - "p=< 3,0,0>, v=<-1,0,0>, a=< 0,0,0>" - |] |> Day20.parseInput - - Day20.nbAlive input =! 1 \ No newline at end of file + () \ No newline at end of file diff --git a/Tests/Day22 tests.fs b/Tests/Day22 tests.fs new file mode 100644 index 0000000..27cc33f --- /dev/null +++ b/Tests/Day22 tests.fs @@ -0,0 +1,32 @@ +namespace AdventOfCode2017.Tests + +open System +open Xunit +open Xunit.Abstractions +open Swensen.Unquote + +open AdventOfCode2017 + +type ``Day20 tests`` (output : ITestOutputHelper) = + + [] + let ``(Part1) From web page`` () = + let input = + [| + "p=< 3,0,0>, v=< 2,0,0>, a=<-1,0,0>" + "p=< 4,0,0>, v=< 0,0,0>, a=<-2,0,0>" + |] |> Day20.parseInput + + Day20.nearestZero input =! 0 + + [] + let ``(Part2) From web page`` () = + let input = + [| + "p=<-6,0,0>, v=< 3,0,0>, a=< 0,0,0>" + "p=<-4,0,0>, v=< 2,0,0>, a=< 0,0,0>" + "p=<-2,0,0>, v=< 1,0,0>, a=< 0,0,0>" + "p=< 3,0,0>, v=<-1,0,0>, a=< 0,0,0>" + |] |> Day20.parseInput + + Day20.nbAlive input =! 1 \ No newline at end of file diff --git a/Tests/Tests.fsproj b/Tests/Tests.fsproj index 1987918..228586e 100644 --- a/Tests/Tests.fsproj +++ b/Tests/Tests.fsproj @@ -75,6 +75,7 @@ + -- 2.45.2