projects
/
advent_of_code_2017.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
bec09f2
)
Simplify the spin part
author
Ummon
<greg.burri@gmail.com>
Mon, 18 Dec 2017 07:31:42 +0000
(08:31 +0100)
committer
Ummon
<greg.burri@gmail.com>
Mon, 18 Dec 2017 07:31:42 +0000
(08:31 +0100)
AdventOfCode2017/Day16.fs
patch
|
blob
|
history
diff --git
a/AdventOfCode2017/Day16.fs
b/AdventOfCode2017/Day16.fs
index
1a124d7
..
fbe7ee7
100644
(file)
--- 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) ->