PS
SUDOKU SOLVER
10 lines of Haskell that solve anything
Solver.hs
1module Solver where23class (Eq c, Show c) => Config c where4 successors :: c -> [c]56solveAll :: (Config c) => (c -> Bool) -> c -> [c]7solveAll isGoal c =8 let rest = concat [solveAll isGoal c' | c' <- successors c]9 in if isGoal c then c:rest else rest1011solve :: (Config c) => (c -> Bool) -> c -> Maybe c12solve isGoal c = case solveAll isGoal c of13 [] -> Nothing14 x:_ -> Just x
click a demo to start
solver@psajnani.com:~$
10 lines. Any problem. Type 'help' or click a demo.
speedslow