Solve the no connection puzzle: Difference between revisions

→‎{{header|Haskell}}: Slight tidying
(→‎{{header|Haskell}}: Slight tidying)
Line 793:
 
=={{header|Haskell}}==
<lang haskell>import Data.List (permutationsintercalate, intercalatepermutations)
 
solution :: [Int]
Line 800:
isSolution :: [Int] -> Bool
isSolution (a:b:c:d:e:f:g:h:_) =
all ((> 1) . abs) $
((> 1) . abs)zipWith
[ a (- d)
[a, c, -g, e, a, c, g, e, b, d, h, f, b, d, h, f]
[d, d, d, d, c, g, -e, a, e, e, e, e, d, h, f, b]
, e - d
, a - c
, c - g
, g - e
, e - a
, b - e
, d - e
, h - e
, f - e
, b - d
, d - h
, h - f
, f - b
]
 
main :: IO ()
main =
mapM_ (putStrLn . unlines) $
let rightShift s
| length s > 3 = s
Line 828 ⟶ 814:
in intercalate
"\n"
(zipWith (\x y -> (.:) x ((" = " ++) . show)) . (:y)) ['A' .. 'H'] solution) :
((rightShift . unwords . (showfmap <$>)show) <$> [[], [a, b], [c, d, e, f], [g, h]])</lang>
{{Out}}
<pre style="font-size:80%">A = 3
9,655

edits