In the 1974 MAA Annual High School Mathematics Examination (Problem #9), students solved this grid pattern riddle:
"The integers greater than one are arranged in five columns as follows:
Col 1 Col 2 Col 3 Col 4 Col 5
Row 1: 2 3 4 5
Row 2: 9 8 7 6
Row 3: 10 11 12 13
Row 4: 17 16 15 14
Four consecutive integers appear in each row. In the odd-numbered rows, the integers appear in the last four columns and increase from left to right. In the even-numbered rows, the integers appear in the first four columns and increase from right to left.
In which column will the number 1,000 fall? (A) 1 (B) 2 (C) 3 (D) 4 (E) 5."
Let's examine the periodicity of the grid:
Row 1 contains $4$ numbers ($2, 3, 4, 5$).
Row 2 contains $4$ numbers ($6, 7, 8, 9$).
Together, every pair of rows contains $4 + 4 = 8$ numbers. Therefore, the pattern repeats every 8 numbers!
Let's see where numbers land based on their remainder modulo 8:
$2 \pmod 8 = 2 \implies \text{Column 2}$
$3 \pmod 8 = 3 \implies \text{Column 3}$
$4 \pmod 8 = 4 \implies \text{Column 4}$
$5 \pmod 8 = 5 \implies \text{Column 5}$
$6 \pmod 8 = 6 \implies \text{Column 4}$
$7 \pmod 8 = 7 \implies \text{Column 3}$
$8 \pmod 8 = 0 \implies \text{Column 2}$
$9 \pmod 8 = 1 \implies \text{Column 1}$
For the number $1,000$:
$$1000 \div 8 = 125 \text{ remainder } 0$$
Since $1000 \equiv 0 \pmod 8$, it shares the same column as $8$, which is Column 2!
In this lesson, we write a simulation loop in Lua to populate the serpentine rows and locate the column of 1,000!
Now you try. Replace ???? with 1000 and run the code to verify that 1000 lands in Column 2.
Type your code here:
See your results here:
Share your code
Show a friend, family member, or teacher what you've done!
Here is a share link to your code:
Need a hint?
💡 What now?
The code has ???? for the target number. Replace ???? with 1000 and click Run Code to find which column holds 1,000!