AOJ try!(2)
ttp://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0501
の問題。
toTouple :: [String]-> (String,String) toTouple (a:b:_) =(a,b) trans :: Int -> String -> Char -> String trans n cs c = case lookup [c] (maketable n cs) of Just a -> a Nothing-> [c] maketable :: Int -> String -> [(String,String)] maketable n = map toTouple.take n.map words.lines getOrigin :: Int -> String -> [Char] getOrigin n cs= let input = drop n $ lines cs in map head.take (read $ head input) $ tail input main = do n <- getLine cs <- getContents print.concat.map (trans (read n) cs) $ getOrigin (read n) cs
入力が2段階であるので、どうにも面倒だな.....
汚くなってしまった。
更に関数を分けたりすれば読みやすくはなるけど。
Haskellは入力処理がネックだな
Pythonでもやりたいけど、ちょっと残りの時間は真剣にネタ繰りしよ