From: Ummon Date: Mon, 18 Dec 2017 07:31:42 +0000 (+0100) Subject: Simplify the spin part X-Git-Url: https://git.euphorik.ch/?a=commitdiff_plain;h=b24e01d58c07066e4da4d1549e2db9c290c8020d;p=advent_of_code_2017.git Simplify the spin part --- 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) ->