Solve the no connection puzzle: Difference between revisions

Content added Content deleted
m (→‎{{header|Haskell}}: Tidying, and pruned out one import.)
Line 1,580: Line 1,580:


=={{header|Haskell}}==
=={{header|Haskell}}==
<lang haskell>import Data.List (intercalate, permutations)
<lang haskell>import Data.List (permutations)


solution :: [Int]
solution :: [Int]
Line 1,596: Line 1,596:
main =
main =
(putStrLn . unlines) $
(putStrLn . unlines) $
unlines (zipWith (\x y -> x : (" = " ++ show y)) ['A' .. 'H'] solution) :
let rightShift s
(rightShift . unwords . fmap show <$> [[], [a, b], [c, d, e, f], [g, h]])
| length s > 3 = s
where
| otherwise = " " ++ s
rightShift s
in intercalate
"\n"
| length s > 3 = s
(zipWith (\x y -> x : (" = " ++ show y)) ['A' .. 'H'] solution) :
| otherwise = " " ++ s</lang>
((rightShift . unwords . fmap show) <$> [[], [a, b], [c, d, e, f], [g, h]])</lang>
{{Out}}
{{Out}}
<pre style="font-size:80%">A = 3
<pre style="font-size:80%">A = 3