Knight's tour: Difference between revisions

m
Line 3,220:
knightMoves :: Square -> [Square]
knightMoves (x, y) =
let[(1, onBoard2), =(1, -2), (&&-1, 2), .(-1, -2), (02, <1), <*>(2, -1), (9-2, >1), (-2, -1)] >>=
in (=<<\(i, j) ->
let (\(i,a j)= ->x + i
let ab = xy + ij
in bool [] [(a, b)] (onBoard a && onBoard b = y + j))
 
in bool [] [(a, b)] (onBoard a && onBoard b))
onBoard :: Int -> Bool
[(1, 2), (1, -2), (-1, 2), (-1, -2), (2, 1), (2, -1), (-2, 1), (-2, -1)]
onBoard = (&&) . (0 <) <*> (9 >)
 
-- TEST ---------------------------------------------------
9,659

edits