Lambdia

Arithmetic series

2 articles

5050 Minus the Total, in One Pass

Sorting the list finds the gap and is merely wasteful, which is why the article says so rather than striking it out. The subtraction works because 5050 is a closed form available before the list is read, and the two conditions carrying it are distinctness and a known range. The article adds the duplicate-hunting mirror image, the sum-of-squares route when two values are absent, and the exclusive-or accumulator for when the total would overflow.

0

A Board of Stacks That Folds Into a Cube

Stack i + j - 1 cubes on every square of a 20 by 20 board and the total is 8000, which is 20 cubed. Folding the board across the squares that are exactly 20 deep pairs every stack with a mirror stack, and each pair adds to 40, so the average depth is 20. The double sum gets the same answer and is merely slow, and the main diagonal is the fold that proves nothing.

0