# Nim

Standard

Nim is a very old game with precise mathematical theory, and one player can always force a win.

The game is Nim is played as follows: Any number of matches/pebbles are arranged in heaps, the number of heaps and the number matches/pebbles in each heap, being arbitrary.  There are two players, A and B. The first player A takes any number of matches/pebbles from a heap, he/she may take only one or any number up to the whole of the heap, but he/she must touch one heap only. B then makes a move conditioned similarly, and the players continue to take alternate turns of picking matches/pebbles. The player who takes the last match/pebble wins the game.

We define a winning position as a position such that if one player P (A or B) can secure it by his/her move, leaving his/her opponent Q (B or A) to move next, then, whatever Q may do, P can play so as to win the game. Any other position we call a losing position.

Next, we express the number of matches in each heap in the binary scale and form a figure by writing down one under the other. Then we add up the columns. For example, consider the following position:

Then, (1,3,5,7) position gives the following figure:

001
011
101
111

224

If the sum of each column is even (which is the case above), then the position is correct. An incorrect position is one which is not correct, thus (1,3,4) is incorrect.

Then we have the following result:

A position in Nim is a winning position if and only if it is correct.

For the proof/discussion/variations of rules, see § 9.8, of G. H. Hardy and E. M. Wright’s An Introduction to the Theory of Numbers.

But designing an elaborate winning strategy, i.e. ensuring that you always stay in winning position, is not so easy (though we know it exists!). For example, watch this video by Matt Parker:

# Packing Problems

Standard

Easy to state and hard to solve problems make mathematics interesting. Packing problems are one such type. In fact there is a very nice Wikipedia article on this topic:

Packing problems involve attempting to pack objects together into containers. The goal is to either pack a single container as densely as possible or pack all objects using as few containers as possible.

I came across this problem a couple of years ago, while watching the following TED Talk by Eduardo Sáenz de Cabezón:

In this talk, the object of attraction is the Weaire-Phelan structure made from six 14-hedrons and two dodechedrons. This object is believed to be the solution of Kelvin’s problem:

How you can chop 3d space into cells of equal volume with the minimum surface area per cell?

The packing problem for higher dimensions was in news last year, since a problem about “Densest Packing Problem in Dimensions 8 and 24” was solved by a young mathematician (Maryna Viazovska). The mathematics involved in the solution is very advanced but we can start gaining knowledge from this book:

A classic reference in this field by two well known geniuses.

Recently, while reading Matt Parker’s book, I discovered a wonderful website called Packomania by Eckard Specht (Otto-von-Guericke-Universität Magdeburg) containing data about packing problems in 2D and 3D. (also checkout his Math4u.de website, it’s a good reference for elementary triangle geometry and inequalities problems.)

Screen-shot of Dr. Eckard Specht’s homepage, his online problem collection (with solutions; each problem in GIF, PS and PDF formats) and Packomania.

Computers also have a role to play in solving such optimization problems For example, in 2015 Thomas Hales formally proved Kepler’s Conjecture about 3D packing:

No arrangement of equally sized spheres filling space has a greater average density than that of the cubic close packing (face-centered cubic) and hexagonal close packing arrangements.

using HOL Light proof assistant.

The proof was a huge collaboration and was called Flyspeck Project. The details about this proof are available in this book:

NOTE: You can construct your own Truncated octahedron and Weaire-Phelan polyhedra by printing the nets available at Matt Parker’s website.

# Popular-Lonely primes understood

Standard

While reading standup mathematician Matt Parker‘s book Things to Make and do in Fourth Dimension, I found answer (on pp. 146) to the question I raised 7 months ago.

When the grid happens to be a multiple of 6 wide, suddenly all primes snap into dead-straight lines. All primes (except 2 and 3) are one more or less than a multiple of 6. (© Matt Parker, 2014)

He also proves the following surprising theorem:

The square of every prime number greater than 3 is one more than a multiple of 24.

Let $p$ be an odd prime not equal to 3. Now we subtract one from the square of this prime number. Therefore, we wish to prove that $p^2-1=(p-1)(p+1)$ is a multiple of 24.

Note that, $p^2-1$ is a product of two even numbers. In particular, one of these two even numbers must be a multiple of 4, as they are consecutive even numbers and every other even number is divisible by 4. Hence we conclude that $p^2-1$ is divisible by 8.

Observe that exactly one of three consecutive numbers, $p-1,p,p+1$ must be divisible by 3. Since $p$ is an odd prime different from 3, one of $p-1$ or $p+1$ must be divisible by 3. Hence we conclude that $p^2-1$ is divisible by 3.

Combining both the conclusions made above, we complete proof of our statement (since 2 and 3 are coprime).

Edit[19 April 2017]: Today I discovered that this theorem is exercise 68 in “The USSR Olympiad Problem Book“.