続々・0〜9の数字を使って、掛け算して、Go!解けた。
改行が余分に出るのはナゼだろう、、
は、unlinesでリストの各要素に改行が付けられて、さらにputStrLnで改行が付いたためだったらしい。
main = 直後のputStrLnをprintにしてみると分かる。
"402 x 39 = 15678\n483 x 12 = 05796\n495 x 36 = 17820\n"
というわけで、putStrLn → putStrに変更。
ついでに、nlistToStringのconcat $ map → concatMapにしてみる。(特に意味はない)
修正後のソースはこう。
import List main = putStr $ unlines $ map format $ filter test $ perm [0,1,2,3,5,6,7,8,9] perm [] = [[]] perm xs = concat [map (x:) $ perm (delete x xs) | x <- xs] test [a,b,c,d,e,f,g,h,i] = if (400 + a*10 + b) * (c*10 + d) == (e*10000 + f*1000 + g*100 + h*10 + i) then True else False format [a,b,c,d,e,f,g,h,i] = nlistToString [4,a,b] ++ " x " ++ nlistToString[c,d ] ++ " = " ++ nlistToString [e,f,g,h,i] nlistToString nl = concatMap show nl
余分な改行も出なくなっていい感じです。