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

 Arrange The Disks (Posted on 2006-07-04)
A set of 47 disks are consecutively numbered 1 to 47 and placed in a row as follows: 1, 2, 3, 4, ... 45, 46, 47.

Rearrange the disks so for any two given disks A and B, the disk equal to their arithmetic mean doesn't lie between them. For example, Disk 4 cannot lie between Disk 1 and Disk 7 since the arithmetic mean of 1 and 7 is 4. However, since 7 is not equal to the arithmetic mean of 1 and 4, Disk 7 may lie between Disk 1 and Disk 4.

 See The Solution Submitted by K Sengupta Rating: 3.6667 (3 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 re: A sampling of the trillions of solutions. | Comment 12 of 14 |
(In reply to A sampling of the trillions of solutions. by Charlie)

For producing the 300 random trials:

RANDOMIZE TIMER
nb = 47
DIM n(nb)

DIM n\$(nb)

OPEN "arrgdisk.txt" FOR OUTPUT AS #2

FOR trial = 1 TO 300
FOR i = 1 TO nb
n\$ = ""
n = i
FOR j = 1 TO 6
r = n MOD 2
n = n \ 2
n\$ = LTRIM\$(STR\$(r)) + n\$
NEXT
n\$(i) = n\$
n(i) = i
NEXT

FOR check = 1 TO 6
checkP = check - 1
IF checkP = 0 THEN
a0 = 1: b0 = nb
ELSE
a0 = 1: b0 = 1
DO
IF b0 > nb THEN b0 = b0 - 1: EXIT DO
IF RIGHT\$(n\$(b0), checkP) <> RIGHT\$(n\$(a0), checkP) THEN
b0 = b0 - 1
EXIT DO
ELSE
b0 = b0 + 1
END IF
LOOP
END IF
DO
a = a0: b = b0
IF RND(1) > .5 THEN
low\$ = "0": high\$ = "1"
ELSE
low\$ = "1": high\$ = "0"
END IF
DO
DO WHILE MID\$(n\$(a), 7 - check, 1) = low\$ AND a < b
a = a + 1
LOOP
DO WHILE MID\$(n\$(b), 7 - check, 1) = high\$ AND a < b
b = b - 1
LOOP
IF a < b THEN SWAP n\$(a), n\$(b): SWAP n(a), n(b)
LOOP WHILE a < b
IF b0 < nb THEN
a0 = b0 + 1: b0 = a0
DO
IF b0 > nb THEN b0 = b0 - 1: EXIT DO
IF RIGHT\$(n\$(b0), checkP) <> RIGHT\$(n\$(a0), checkP) THEN
b0 = b0 - 1
EXIT DO
ELSE
b0 = b0 + 1
END IF
LOOP
ELSE
EXIT DO
END IF
LOOP
NEXT

FOR a = 1 TO nb - 2
FOR c = a + 2 TO nb
avg = (n(a) + n(c)) / 2
IF avg = INT(avg) THEN
FOR i = a + 1 TO c - 1
IF n(i) = avg THEN
ct = ct + 1
LOCATE ct MOD 40 + 1, (ct \ 40) * 20 + 1
PRINT n(a); n(i); n(c);
END IF
NEXT
END IF
NEXT
NEXT

FOR i = 1 TO nb
PRINT #2, STR\$(n(i));
IF i <> nb THEN PRINT #2, ",";
NEXT
PRINT #2,
PRINT #2,

LOCATE 40, 1

FOR a = 1 TO nb - 2
FOR c = a + 2 TO nb
avg = (n(a) + n(c)) / 2
IF avg = INT(avg) THEN
FOR i = a + 1 TO c - 1
IF n(i) = avg THEN
ct = ct + 1
PRINT n(a); n(i); n(c)
END IF
NEXT
END IF
NEXT
NEXT

NEXT trial

 Posted by Charlie on 2006-07-06 09:09:24

 Search: Search body:
Forums (0)