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

Home > General
Magic trick (Posted on 2007-05-11) Difficulty: 3 of 5
Two magicians A and B perform the following trick:

A leaves the room and B chooses 4 members from the audience at random. Each member chooses a card numbered from 1 to 100 (each chooses a different card) and after B has seen their cards he chooses a card from the remaining deck of cards. The 5 chosen cards are shuffled by an audience member and handed to A who just returned to the room. Prove that A is able to figure out which cards each member picked. Consider that the chosen members form a row and e.g. the leftmost member picks the first card and the rightmost member (B) picks the last card.

No Solution Yet Submitted by atheron    
Rating: 4.1667 (6 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
re(3): please read | Comment 23 of 51 |
(In reply to re(2): please read by Ken Haley)

I ran the following program to try random selections of 4 cards, and in each case print on the first line the four numbers, in order, and the computed Z value. On the second line for each are the ak and Z values followed by the ak and Z values that the decoder, A, would deduce. In those instances where these differ from what B intended, the second line is also marked with an X.

Program:

match$ = "1234,1243,1324,1342,1423,1432,2134,2143,2314,2341,2413,2431,"
match$ = match$ + "3124,3142,3214,3241,3412,3421,4123,4132,4213,4231,4312,4321"

CLS
DO
  REDIM taken(100)
  FOR i = 1 TO 4
   DO
    n = INT(RND(1) * 100 + 1)
    IF taken(n) = 0 THEN cd(i) = n: orig(i) = n: taken(n) = 1: EXIT DO
   LOOP
  NEXT

  j = 0
  FOR i = 1 TO 100
    IF taken(i) THEN
      j = j + 1
      cd(j) = i
    END IF
  NEXT

  seq$ = ""
  FOR i = 1 TO 4
    FOR j = 1 TO 4
      IF orig(i) = cd(j) THEN seq$ = seq$ + LTRIM$(STR$(j))
    NEXT
  NEXT

  Z = (INSTR(match$, seq$) + 4) / 5
  FOR i = 1 TO 4
    PRINT orig(i);
  NEXT
  PRINT Z

  cd(5) = cd(1) + 100
  FOR i = 1 TO 4
   IF cd(i + 1) - cd(i) > 24 THEN ak = cd(i): EXIT FOR
  NEXT
  newNumb = ak + Z

  s = 1
  FOR r = 1 TO 5
   IF newNumb < cd(s) THEN
     recd(r) = newNumb
     newNumb = 99999
   ELSE
     recd(r) = cd(s)
     s = s + 1
   END IF
  NEXT

  recd(6) = recd(1) + 100: recd(7) = recd(2) + 100
  FOR i = 2 TO 6
    diff = recd(i + 1) - recd(i - 1)
    IF diff >= 25 THEN ak2 = recd(i - 1): Z2 = recd(i) - ak2: EXIT FOR
  NEXT
  PRINT ak; Z, ak2; Z2;
  IF ak = ak2 AND Z = Z2 THEN PRINT :  ELSE PRINT " X"
  REM
LOOP

Results:

71  54  58  29  22
29  22        29  22
31  78  2  77  11
2  11         2  11
82  71  5  42  23
5  23         5  23
87  80  38  97  15
38  15        38  15
88  6  95  37  14
6  14         6  14
53  77  6  60  11
6  11         6  11
47  30  63  65  7
65  7         30  17  X
27  28  83  59  2
28  2         28  2
99  92  23  70  23
23  23        23  23
99  25  54  11  22
25  22        11  14  X
100  68  2  58  23
2  23         2  23
11  80  29  5  12
29  12        11  18  X
30  39  31  95  3
39  3         39  3
98  41  28  17  24
41  24        28  13  X
17  65  42  72  3
17  3         17  3
33  64  21  19  18
33  18        21  12  X
59  9  46  91  13
9  13         9  13
27  79  38  29  6
38  6         38  6
92  64  63  43  24
64  24        63  1  X
10  57  70  92  1
10  1         10  1
84  3  55  92  13
3  13         3  13
44  68  51  52  5
68  5         68  5
47  36  41  27  22
47  22        41  6  X

To take one of the X'ed examples, if the audience choices were

C  D  E  F 
47 30 63 65

Rearranged this is

30 47 63 65
D  C  E  F    for Z=7
30  47  63  65 130 shows ak=65
                     z+ak = 72

A then sees 30  47  63  65  72
and appends 130 and 147:

30  47  63  65  72  130  147

The difference 63-30 shows up immediately as >= 25, so A perceives ak = 30 and Z=17  for ak+Z=47, and so reconstructs

30 47 63 65 72
E  B  F  C  D

Is this mistaken decoding? No.  Let's start out with

C  D  E  F
65 72 30 63
30 63 65 72
E F C D Z=17
30 63 65 72 130  ak=30; Z+ak = 47

Present to A: 30 47 63 65 72; just as in the first problem where the audience chosen numbers were different. Both 47 30 63 65 and 65 72 30 63 resulted in the same coded value, 30 47 63 65 72. It was inevitable that different audience-chosen sets of 4 cards, in order, must share encoded sets of cards as there are only 75,287,520 of the latter and 94,109,400 of the former.

Out of the 23 computer-generated random sets of 4 cards, in 7 cases, the result of the decoding disagreed with the set being encoded.

Did Finland really use just 100 cards in the statement of the problem?


  Posted by Charlie on 2007-05-13 03:09:48
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (22)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information