I am a sophomore in high school and my math teacher did a very short lesson on infinity, here's how it went: (Try to solve each part yourself the first two are easy)

Part 1

You have an inf. number of boxes each labeled like so


and that there is a person in each one of these boxes. But you have another set of five boxes like so


You want to only have one set of boxes what do you do? You must be able to tell each person what box they should goto next.


Each person is told to move down five boxes. Or n+5 is you new box, and the five people from the other boxes are able to move into the first five boxes or just n+0.

Part 2

Well you actually have two of these inf. box sets, but you really only want one. What now? (same rules apply)

Each person from set one is told to go to box 2n and each person from set two is told to box 2n-1

Part 3

Now you have an inf. number of these inf. box sets arranged like so

1: [1][2][3][4][5]...
2: [1][2][3][4][5]...
3: [1][2][3][4][5]...
4: [1][2][3][4][5]...
5: [1][2][3][4][5]...

and you want to fit them all into one inf. box set, how do you do it. She refused to tell us the answer and no one in my class figured it out, but I think I just did (correct me if I'm wrong, I'm also looking for alternate solutions).

How I went about solving this problem

Step 1

I assumed that there had to be some sort of pattern so I tried a few

Step 2

I picked the following patter.
1: [1][3][6][10][15]...
2: [2][5][9][14][]...
3: [4][8][13][][]...
4: [7][12][][][]...
5: [11][][][][]...
The numbers in the box represent the new box of each person

Step 3

I started to create a formula for the people to find there new room based of there current room number and box set number. I found the following sequence in for people in the first row, 1 3 6 10 15. Or +2 +3 +4 +5. Which told me that it was quadratic so the equation had to be ax^2 + bx + c = new room number

Step 4

I found three equation by plugging in room numbers and their correct new room numbers to find these three equations:
(1^2)a + 1b + c = 1 or a + b + c = 1
(2^2)a + 2b + c = 3 or 4a + 2b + c = 3
(3^2)a + 3b + c = 6 or 9a + 3b + c = 6

Step 5

After solving this system I got the following equation 1/2x^2 + 1/2x + 0 = new room number where x = current room number. This of course only tell the people in the boxes on the bottom where to go. Now I needed to find how to place the rest of the people. The first thing I noticed was that people on the same diagonal as seen bellow were very much related to each other when you look at the rooms they will end up in.

The solution

Working this knowledge into my equation was fairly easy (I was able to do it while going for a run so I won't explain how I got my equation). The equation is:
(1/2(r+c-1)^2 + 1/2(r+c-1) + 0)-r+1 = new room number | r = row | c = column

Now my question to all of you is

  1. Is my equation correct?
  2. Are there any alternate solutions to this problem?
  3. How could you fit a 3D array of boxes (inf boxes of people in all direction) into a 1D line of boxes?
  4. Can you find a way to fit a n dimensional array of boxes into a 1D line of boxes?

For any of you into JAVA here's a a short snippet of code I made to prove my answer

    package main;

public class Main {

     * @param args
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        int f = 2;
        int r = 1;
        int c = 1;
            double x = (.5*(r+c-1)*(r+c-1) + .5*(r+c-1) + 0)-r+1;
            System.out.print(x +", ");
            if(r < 1){
                r = f;
                c = 1;
  • 4
    $\begingroup$ Part 2 is known as Hilbert's paradox. $\endgroup$ – oldrinb May 11 '13 at 21:47
  • $\begingroup$ Nice question. One random thought: the formula isn't really the point. The point is that there exists a way to fit two-dimensional array into a $1$-dimensional one, and it rarely matters how precisely you do it. At Step 2, you really had all that you needed. (Of course, asking for a possible formula is also interesting. But existence itself is, in my humble opinion, orders of magnitude more important than anything else) $\endgroup$ – Jakub Konieczny May 12 '13 at 10:36

There are various ways to do this. Here's one: $$ \begin{array}{rrrrrrrrrrrrrrrr} 1 & \rightarrow & 2 & & 6 & \rightarrow & 7 & & 15 & \rightarrow & 16 \\ & \swarrow & & \nearrow & & \swarrow & & \nearrow & & \swarrow \\ 3 & & 5 & & 8 & & 14 \\ \downarrow & \nearrow & & \swarrow & & \nearrow \\ 4 & & 9 & & 13 \\ & \swarrow & & \nearrow \\ 10 & & 12 \\ \downarrow & \nearrow \\ 11 \end{array} $$

Here's another: $$ \begin{array}{rrrrrrrrrrrrrrr} 1 & \rightarrow & 2 & & 9 & \rightarrow & 10 & & 25 & \rightarrow \\ & & \downarrow & & \uparrow & & \downarrow & & \uparrow \\ 4 & \leftarrow & 3 & & 8 & & 11 & & 24 \\ \downarrow & & & & \uparrow & & \downarrow & & \uparrow \\ 5 & \rightarrow & 6 & \rightarrow & 7 & & 12 & & 23 \\ & & & & & & \downarrow & & \uparrow \\ 16 & \leftarrow & 15 & \leftarrow & 14 & \leftarrow & 13 & & 22 \\ \downarrow & & & & & & & & \uparrow \\ 17 & \rightarrow & 18 & \rightarrow & 19 & \rightarrow & 20 & \rightarrow & 21 \end{array} $$


A simpler formula to problem 3 is to move row $r$, column $c$ to box $2^{r-1}(2c-1)$. For three dimensions you can move row $r$, column $c$, layer $l$ to box $2^{l-1}(2^{r}(2c-1)-1)$. Do you see why these work and how to generalize to $n$ dimensions?

  • $\begingroup$ shouldn't it be 2^l-1(2^r-1(2c-1)-1)? $\endgroup$ – java May 11 '13 at 22:29
  • $\begingroup$ And I still can't see how you would make a generalized formula with n. For example if n was a million it would be a very long equation with you just went with the pattern and what if n was infinity? $\endgroup$ – java May 11 '13 at 22:31

Let me comment on your solution and some of those proposed in the other answers. First of all, both of Michael Hardy's pictures will lead to formulas more complicated than yours, because he goes back and forth rather than always going in the same direction as you did. In particular, his first picture is just the back-and-forth version of yours except that you tabulated numbers instead of drawing a picture. (For related non-mathematical amusement,you might look up "boustrophedron".) Hagen von Eitzen, on the other hand, has a really simple formula, and it actually admits a rather nice description in terms of moving people from infinitely many rows of boxes to a single row; I'll call that single row the "target" row. I haven't checked whether the following gives exactly Hagen's formula, but it'll be close. Tell the people in the first row of boxes to occupy every second box in the single target row, just as you did when you stated with two rows of boxes. They occupy target boxes $0,2,4,\dots$, leaving infinitely many empty boxes in the target row, namely $1,3,5,\dots$. Now tell the people in the second of your original rows to occupy every second one of those still-empty boxes, namely $1,5,9,\dots$, again leaving infinitely many boxes empty, namely $3,7,11,\dots$. Continue in the same way with each successive row, putting its occupants into every second one of whatever target boxes remain empty; that leaves infinitely many target boxes empty, so you can continue to the next row.

  • $\begingroup$ Would this be the formula? 2^r * c - 1 $\endgroup$ – java May 12 '13 at 1:51
  • $\begingroup$ 2^(2^w * l - 1) * l - 1 for 3d? $\endgroup$ – java May 12 '13 at 1:59
  • $\begingroup$ 2^(n * l - 1) = n-1 so can i use a stigma here to get them all? $\endgroup$ – java May 12 '13 at 2:24

The following answer is not yet complete solution, but I think it might be an idea how to approach the problem yourself.
I recall the Collatz-problem in the "syracuse"-statement and look at the inverse transformation which allows to construct an infinite tree with infinitely many infinitely long "boxes" where each odd natural number occurs exactly one time (well, whether all odd natural numbers occur at least once is really open, but it would not spoil the resulting infinite indexing-system).
The "syracuse"-statement of the Collatz-transformation is with an odd a and b and a natural $A \ge 1$ is $$ b = {3a+1 \over 2^A} $$ where the value of A and that of b are of course uniquely determined by the value of a. But there are a lot (actually infinitely many) of different a which lead to the same b, so if we invert the transformation, $$ b = {a 2^A - 1 \over 3} $$ we have for each a by infinitely many A's infinitely many different b, so we could write infinitely many indexed b as $$ b_{A} = {a 2^A - 1 \over 3} $$ and now each of the infinitely many $b_A$ can be treated similarly to get $$c_{A,B} = {b_A 2^B - 1 \over 3} $$ This scheme implements an infinite long index (the infinite number of boxes) and each box is of infinite length. One need now to show, that the occuring values are unique, which I think is not too difficult (it is not solving Collatz, because that (unsolved) conjecture is that the values are not only unique but also including all odd positive natural numbers which makes it so difficult).

(I have also another statement from the same problem for the infinitude of infinite bins, maybe I can reproduce it here later as an even easier-to-see representation, I'm short of time at the moment, sorry)


First, kudos to you for solving this!

As to your question about possible generalizations to $n$ dimension. Well, I suppose you could repeat the work you did for $n=3,4,\ldots$. There is, however, a simpler way. Take a step back and look at what you have achieved. Your function $$ f(r,c) = \frac{1}{2}(r+c-1)^2 + \frac{1}{2}(r+c-1)-r+1 $$ takes a pair of numbers (positive integers, to be precise) and maps them to just a single positive integer. And, and that's the point, it does so in a reversive way. After all, when rearranging your boxes according to your function, you don't add or lose any box. Thus, given an positive integer $n$, there's only one pair $(r,c)$ for which $f(r,c)=n$.

Now, say you want to combine pairs of three integers into one, which corresponds to turning an infinite cube of boxes into a straight line. You can simply start with two of the three integers, and map them to a single integer, using your function. Then, you take that value and the last of the original integers, and invoke your function again, ending up with only a single integer. You thus get a function $$ g(r,c,l) = f(f(r,c),l) \text{.} $$ And that function is again reversible. Starting from an $n$ you can first figure out $f(r,c)$ and $l$, and then proceed to figure out $r$ and $c$.

So by solving the problem for two dimensions, you have actually solved it for all finite dimensions!

Now image the following situation. You're faced with all the finite-dimensional cases together. In other words, there's a line of boxes, a 2-dimensional array of boxes, a 3-dimensional cube of boxes, a 4-dimensional um, well, whatever of boxes, and so on. In the language of sequences of numbers, you're faced with all single numbers, all pairs, all triples, all quadruples, ... Can you map all of those to a single number in a reversible way? To solve that, remember that you've already solved this separately for each of the cases. Thus, each thing that you want to map already falls into one of the solved cases. You can re-use the solution for that case, you just have to make sure that when undoing the mapping, you have a way to figure out which case that was. Luckily, the case itself is handily represented by a positive integer itself...

If you have solved that, it's again time to step back and reflect. Have you then solved things for the infinite dimensional case? (i.e., have you managed to map arbitrary sequences of numbers to a single number?). Consider for example the sequence of numbers $1,2,3,\ldots$. Have you mapped that to a single number? For that to be true, the sequence $1,2,3,\ldots$ would have to fall into one of the cases single number, pair, tripple, ... Does it?

The answer is no! You have succeeded in mapping all finite sequences of numbers to a single number, i.e. all sequences with stop at some point. They may be arbitrarily long, but not infinitely long - that's the crucial difference.

Now lets assume for a moment that you have solved things for the infinite-dimensional case, i.e. you've managed to map arbitrary sequences of numbers to a single numbers, reversibly. You can then make a list, each row containing an infinite sequence and the number its mapped to. Your list will then be complete in the sense that every target number and every sequence appears in the list exactly once. Your list might like this $$ \begin{array}{l|l} \textrm{target}& \textrm{sequence} \\ \hline \\ 1& (1,2,3,4,\ldots) \\ 2& (2,3,4,5,\ldots) \\ 3& (1) \\ 4& (100, 101) \\ \ldots&\ldots \end{array} $$

You can imagine such a list to be a function $g(n,i)$ which gives you the $i$-th entry in the infinite sequence mapped to the positive integer $n$. This makes it possible to define the following infinite sequence of positive numbers $$ g(1,1)+1,\,g(2,2)+2,\,g(3,3)+3,\,\ldots $$ Can you see a problem with that?

Try to find this sequence in your original table. If you table is complete, i.e. really reversibly maps infinite sequences to integers and back, it has to be there somewhere. Yet the sequence cannot be the first sequence in your list (i.e., the one mapped to the number 1), because their first element differs - the first sequence in your list has $g(1,1)$ as its first element, and the sequence we just defined has $g(1,1)+1$. But the same argument applied to the second sequence.. and the third... So, it seems that the table cannot have been complete! So, it turns out, the infinite dimensional case has no solution. You cannot map all finite and infinite sequences of positive integers to a single positive integers!

You can also try something different. Try mapping finite and infinite sequences of positive integers to real numbers. Can you find a way which does that reversibly, and hits each real number exactly once?

  • $\begingroup$ Thanks, I figured out how to solve for finite amounts but still can't think of how to make an equation for an inf. number of dimensions... I'll keep working on it $\endgroup$ – java May 12 '13 at 2:06
  • $\begingroup$ @java You have to distinguish between mapping all finite-dimensional cases at once, and between the actual infinite-dimensional case. I've expended my answer to point that out more clearly. I've also added part discussing the infinite-dimensional case - they're a few surprises there... $\endgroup$ – fgp May 12 '13 at 10:07

You have a great mathematical future!! Do you have a geometric way of coming up with your counting principle, rather than algebraic?

The answers to 3. and 4. are, indeed, YES. Get to work!!

Then: 5. What about an infinite sequence of such arrays (i.e., one for each positive integer)?

  • 1
    $\begingroup$ The problem with my high school is that they value speed over everything else, I like to think about problems and figure out why we're using an equation and why the equation works verus just thoughtlessly plugging in numbers $\endgroup$ – java May 11 '13 at 21:58
  • 3
    $\begingroup$ Straight out of my chem SAT subject prep book "We will teach you what is really important, how to raise your test scores, without waisting your time explaining why something is true" Are test scores really more important than knowledge? $\endgroup$ – java May 11 '13 at 22:03
  • $\begingroup$ @java If one wants to pass a test, then yes. If teaching is merely based on passing a test, however, I think that invalidates the test. And thus invalidates the teaching. $\endgroup$ – Hagen von Eitzen May 11 '13 at 22:21
  • $\begingroup$ Stick to your thinking guns, java! $\endgroup$ – Ted Shifrin May 12 '13 at 0:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.