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:
89a7dc6
)
Simplify a bit
author
Ummon
<greg.burri@gmail.com>
Mon, 18 Dec 2017 07:53:33 +0000
(08:53 +0100)
committer
Ummon
<greg.burri@gmail.com>
Mon, 18 Dec 2017 07:53:33 +0000
(08:53 +0100)
AdventOfCode2017/Day16.fs
patch
|
blob
|
history
diff --git
a/AdventOfCode2017/Day16.fs
b/AdventOfCode2017/Day16.fs
index
bc52286
..
d032c45
100644
(file)
--- a/
AdventOfCode2017/Day16.fs
+++ b/
AdventOfCode2017/Day16.fs
@@
-43,13
+43,14
@@
let dance (size : int) (nb : int) (moves : DanceMove list) : string =
swap (find a) (find b)
let cycle =
- (
(0, initialState)
, Seq.initInfinite id)
+ (
initialState
, Seq.initInfinite id)
||> Seq.scan (
- fun
(_, previous) i
->
+ fun
previous _
->
let current = previous.[*]
applyMoves current
-
i + 1,
current
+ current
)
+ |> Seq.indexed
|> Seq.takeWhile (fun (i, state) -> i = 0 || i <= nb && not (state |=| initialState))
|> Seq.map snd
|> Array.ofSeq