Tackled problem 1625
[cses-programming-tasks.git] / app / cses2165.hs
1 data Move = Move Int Int
2 -- deriving (Show)
3
4 instance Show Move where
5 show (Move a b) = show a ++ " " ++ show b
6
7 main :: IO ()
8 main = do
9 line1 <- getLine
10 let nDisks = read line1 :: Int
11 let moves = solve nDisks 1 2 3
12 print $ length moves
13 putStrLn $ unlines $ map show moves
14
15 solve :: Int -> Int -> Int -> Int -> [Move]
16 solve 0 _ _ _ = []
17 solve n a b c = solve (n-1) a c b ++ [Move a c] ++ solve (n-1) b a c