Skip to content

Instantly share code, notes, and snippets.

@UnkindPartition
Created October 12, 2014 09:30
Show Gist options
  • Save UnkindPartition/066d480394aa5351844f to your computer and use it in GitHub Desktop.
Save UnkindPartition/066d480394aa5351844f to your computer and use it in GitHub Desktop.
-- http://haskell98.blogspot.com/2014/10/blog-post_10.html
import Control.Monad
rotate n (x,y) = (n+1-y, x)
rotations n = take 4 $ iterate (rotate n .) id
solutions n =
let half = [ 1 .. n `div` 2 ]
quarter = liftM2 (,) half half
in mapM (\p -> rotations n `ap` [p]) quarter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment