Magic squares of doubly even order: Difference between revisions
Content deleted Content added
→{{header|Haskell}}: dropped splitEvery for chunksOf, updated output |
→{{header|Haskell}}: Made the test more direct |
||
Line 645:
| otherwise =
chunksOf n $
zipWith
(\x i ->
Line 658 ⟶ 656:
limit = sqr + 1
series
| isPowerOf 2 n = magicSeries $ floor (logBase 2 (fromIntegral sqr))
| otherwise =
concat . concat . concat . scale $ scale <$> chunksOf 4 (magicSeries 4)
Line 677 ⟶ 671:
diagonals = fmap (flip (zipWith (!!)) [0 ..]) . ((:) <*> (return . reverse))
checked :: [[Int]] -> (Int, Bool)
checked
where
h:t =
sum <$>
Line 689 ⟶ 682:
main :: IO ()
main = do
mapM_ print square
putStrLn ""
print $ checked
{{Out}}
<pre>[1,63,62,4,60,6,7,57]
|