From b24e01d58c07066e4da4d1549e2db9c290c8020d Mon Sep 17 00:00:00 2001 From: Ummon Date: Mon, 18 Dec 2017 08:31:42 +0100 Subject: [PATCH] Simplify the spin part --- AdventOfCode2017/Day16.fs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/AdventOfCode2017/Day16.fs b/AdventOfCode2017/Day16.fs index 1a124d7..fbe7ee7 100644 --- a/AdventOfCode2017/Day16.fs +++ b/AdventOfCode2017/Day16.fs @@ -34,11 +34,9 @@ let dance (size : int) (nb : int) (moves : DanceMove list) : string = for move in moves do match move with | Spin s -> - for i = 1 to s do - let last = danceFloor.[size - 1] - for j in size - 1 .. -1 .. 1 do - danceFloor.[j] <- danceFloor.[j - 1] - danceFloor.[0] <- last + let last = danceFloor.[size - s ..] |> Array.rev + Array.Copy (danceFloor, 0, danceFloor, s, size - s) + Array.Copy (last, danceFloor, s) | Exchange (p1, p2) -> swap p1 p2 | Partner (a, b) -> -- 2.45.2