module Zurg where import Search import List( (\\), delete, sort) data Toy = Buzz | Hamm | Rex | Woody deriving (Eq,Ord,Show) data Pos = L | R deriving (Eq,Show) type Group = [Toy] type BridgePos = (Pos,Group) type Move = Either Toy Group toys :: [Toy] toys = [Buzz,Hamm,Rex,Woody] time :: Toy -> Int time Buzz = 5 time Woody = 10 time Rex = 20 time Hamm = 25 duration :: [Move] -> Int duration = sum . map (either time (maximum . map time)) backw :: Group -> [(Move,BridgePos)] backw xs = [(Left x,(L,sort (x:(toys \\ xs)))) | x <- xs] forw :: Group -> [(Move,BridgePos)] forw xs = [(Right [x,y],(R,delete y ys)) | x <- xs,let ys=delete x xs, y <- ys, x