Skip to content

Instantly share code, notes, and snippets.

@Duta
Created November 5, 2014 14:44
Show Gist options
  • Save Duta/db470cc02ea73e3a44cf to your computer and use it in GitHub Desktop.
Save Duta/db470cc02ea73e3a44cf to your computer and use it in GitHub Desktop.
english :: BoardSpec
english = [ ((x, y), not $ all (==3) [x,y])
| x <- [0..6]
, y <- [0..6]
, (x,y) `notElem` [ (x',y')
| let xs = [0,1,5,6]
, x' <- xs
, y' <- xs
]
]
european :: BoardSpec
european = [ ((x, y), not $ all (==3) [x,y])
| x <- [0..6]
, y <- [0..6]
, (x,y) `notElem` [ (0,0),(0,1),(1,0)
, (6,6),(5,6),(6,5)
, (0,5),(0,6),(1,6)
, (5,0),(6,0),(6,1)
]
]
@JordanBell
Copy link

Very nice! Actually taught me a bit just by looking at this. Here's what you were probably looking for in that last one.

european :: BoardSpec
european = [ ((x, y), not $ all (==3) [x,y])
           | x <- [0..6]
           , y <- [0..6]
           , (x,y) `notElem` [ (x',y')
                            | let xs = [0,1,5,6]
                            , x' <- xs
                            , y' <- xs
                            , not . null $ [x', y'] `intersect` [6, 0] -- Either x or y are 6 or 0
                            ]
           ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment