module Homework.Ch01.Hanoi where import qualified Data.HashMap.Strict as HashMap newtype Peg = Peg () data Move = Move {moveFrom :: String, moveTo :: String} deriving (Eq, Show) data Disc = Disc {discSize :: Int} hanoi :: Int -> String -> String -> String -> Either String [Move] hanoi numDisks pegLabelA pegLabelB pegLabelC = let _pegs = HashMap.fromList [ (pegLabelA, fillPegWithDiscs), (pegLabelB, []), (pegLabelC, []) ] in Right [ Move "a" "c", Move "a" "b", Move "c" "b" ] where fillPegWithDiscs :: [Disc] fillPegWithDiscs = Disc <$> [1 .. numDisks] -- start here: make sure this is initialized correctly