Magic squares of doubly even order: Difference between revisions
Magic squares of doubly even order (view source)
Revision as of 15:52, 10 December 2016
, 7 years ago→JS ES6: (Adjusted the point at which the truth series starts – simplifies the indexing expressions)
m (→{{header|Haskell}}: (Tweaked the point at which the 'magic series' starts, for more natural indexing) |
m (→JS ES6: (Adjusted the point at which the truth series starts – simplifies the indexing expressions)) |
||
Line 427:
// truthSeries :: Int -> [Int]
const truthSeries = n => {
if (n <= 1) return [true, false];
const xs = truthSeries(n - 1);
return xs.concat(xs.map(x => !x));
Line 435:
scale = curry(replicate)(n / 4),
power = Math.log2(sqr),
sequence = isInt(power) ? truthSeries(power
flatten(
splitEvery(4, truthSeries(4))
.map(scale)
)
)
);
Line 532 ⟶ 536:
// TEST -----------------------------------------------------------------
return [4, 8, 12]▼
//return doubleEvenMagicSquare(8)
.map(n => {
const lines = doubleEvenMagicSquare(n);
|