All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 2000 cards (Posted on 2009-01-04)
There are cards labeled from 1 to 2000. The cards are arranged and placed in a pile.

The top card is placed on the table, then the next card at the bottom of the pile.

Then the next card is placed on the table to the right of the first card, and the next card is placed at the bottom of the pile.

This process is continued until all the cards are on the table.

The final order (from left to right) is 1, 2, 3, ... , 2000.

In the original pile, how many cards were above card labeled 1999?

 See The Solution Submitted by pcbouhid No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
 computer solution (spoiler) | Comment 1 of 9

Initially I thought representation as binary might help (and indeed it might if understood in enough depth), but the fact that 2000 is not a power of 2 complicates the situation.

DEFINT A-Z
DIM used(2000)
DIM table(2000)

DO
DO
upto = upto + 1
IF upto > 2000 THEN upto = 1
IF used(upto) = 0 THEN EXIT DO
LOOP
place = place + 1
table(place) = upto
used(upto) = 1
IF place = 2000 THEN EXIT DO
DO
upto = upto + 1
IF upto > 2000 THEN upto = 1
IF used(upto) = 0 THEN EXIT DO
LOOP
LOOP

FOR i = 1 TO 2000
PRINT USING "#### "; table(i);
b\$ = ""
n = table(i)
FOR j = 1 TO 11
b\$ = LTRIM\$(STR\$(n MOD 2)) + b\$
n = n \ 2
NEXT
PRINT b\$

IF i MOD 40 = 0 OR table(i) = 2000 THEN DO: LOOP UNTIL INKEY\$ > ""
NEXT

I show the positions of the last several numbers placed on the table, with binary representation also:

`1152 100100000001216 100110000001280 101000000001344 101010000001408 101100000001472 101110000001536 110000000001600 110010000001664 110100000001728 110110000001792 111000000001856 111010000001920 111100000001984 11111000000  96 00001100000 224 00011100000 352 00101100000 480 00111100000 608 01001100000 736 01011100000 864 01101100000 992 011111000001120 100011000001248 100111000001376 101011000001504 101111000001632 110011000001760 110111000001888 11101100000  32 00000100000 288 00100100000 544 01000100000 800 011001000001056 100001000001312 101001000001568 110001000001824 11100100000 160 00010100000 672 010101000001184 100101000001696 11010100000 416 001101000001440 10110100000 928 011101000001952 11110100000`

so the 1999, the next to last placed, was originally the 928th card from the top, with 927 cards above it.

The sequence of deck positions of numbers placed on the table starts at 1 with increments of 2, then starting again at 2 with increments of 4, then starting with 4 with increments of 8, then starting with 8 with increments of 16 and then starting with 16 with increments of 32. But then the next one starts with 64 with increments of 64, followed by 96 with increments of 128 and then 32 with increments of 256, etc.

The break with regularity occurred just as the last card in the original deck was placed.

 Posted by Charlie on 2009-01-04 15:04:56

 Search: Search body:
Forums (0)