Sha256: 017a346eb2dc34342c2cf9d1af3b1b806d8c5ae369829bd23eeca68417cef19e
Contents?: true
Size: 665 Bytes
Versions: 396
Compression:
Stored size: 665 Bytes
Contents
module Queens (boardString, canAttack) where type Position = (Int, Int) boardString :: Maybe Position -> Maybe Position -> String boardString w b = concatMap rowString [0..7] where rowString row = concatMap (tileString row) [0..7] tileString row col = [tileChar (row, col), tileSep col] tileSep 7 = '\n' tileSep _ = ' ' tileChar pos | w == Just pos = 'W' | b == Just pos = 'B' | otherwise = '_' canAttack :: Position -> Position -> Bool canAttack (wr, wc) (br, bc) = sameRow || sameCol || diagonal where dr = wr - br dc = wc - bc sameRow = dr == 0 sameCol = dc == 0 diagonal = abs dr == abs dc
Version data entries
396 entries across 396 versions & 1 rubygems