Skip to content

Instantly share code, notes, and snippets.

@scoiatael
Created January 23, 2018 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scoiatael/994b673c77f2c12662dba19415cbb9e2 to your computer and use it in GitHub Desktop.
Save scoiatael/994b673c77f2c12662dba19415cbb9e2 to your computer and use it in GitHub Desktop.
let exchange (a : int, b : int) : Move =
let toKV arr = Map.ofArray (Array.indexed arr) in
let ofKV map = Array.map snd (Array.sortBy fst (Map.toArray map)) in
fun circle ->
ofKV (Map.add b circle.[a] (Map.add a circle.[b] (toKV circle)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment