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

 Getting closer to three targets (Posted on 2012-07-01)
STEP1 : Arrange 10 distinct digits and 2 blank spaces into 3x4 matrix.

Example:
 1 2 sp 8 4 5 6 7 3 sp 0 9

STEP2 : Now sum up the numbers row by row (in our example SumRows=12+8+4567+3+9=4599).

STEP3 : Next sum up the numbers column by column (in our example SumCols=143+25+60+879=1107).

STEP4 : Evaluate the ratio R= (bigger sum)/ (smaller sum). In our example 4599/1107=4.14543

You are requested to arrange the 12 symbols so that the value of R will be as close as possible to:
a) 1.000
b) 2.000
c) Phi (the golden ratio =1.618034)

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

QB64 enabled this to run in under 1/2 hour:

DECLARE FUNCTION total# (x\$)
DEFDBL A-Z
DECLARE SUB permute (a\$)
OPEN "closer3.txt" FOR OUTPUT AS #2
CLS
a\$ = "0123456789  ": h\$ = a\$
best1diff = .01: best2diff = .01: bestphidiff = .01
phi = (1 + SQR(5)) / 2
DO
b\$ = MID\$(a\$, 1, 1) + MID\$(a\$, 5, 1) + MID\$(a\$, 9, 1) + " "
b\$ = b\$ + MID\$(a\$, 2, 1) + MID\$(a\$, 6, 1) + MID\$(a\$, 10, 1) + " "
b\$ = b\$ + MID\$(a\$, 3, 1) + MID\$(a\$, 7, 1) + MID\$(a\$, 11, 1) + " "
b\$ = b\$ + MID\$(a\$, 4, 1) + MID\$(a\$, 8, 1) + MID\$(a\$, 12, 1) + " "
a2\$ = MID\$(a\$, 1, 4) + " " + MID\$(a\$, 5, 4) + " " + MID\$(a\$, 9, 4) + " "

tot1 = total(a2\$)
tot2 = total(b\$)
rat = tot1 / tot2: IF rat < 1 THEN rat = 1 / rat
diff1 = ABS(1 - rat): diff2 = ABS(2 - rat): diffphi = ABS(phi - rat)

IF diff1 <= best1diff OR diff2 <= best2diff OR diffphi <= bestphidiff THEN
IF diff1 < best1diff THEN best1diff = diff1: PRINT rat, diff1
IF diff2 < best2diff THEN best2diff = diff2: PRINT rat, diff2
IF diffphi < bestphidiff THEN bestphidiff = diffphi: PRINT rat, diffphi
PRINT #2, a\$; "; "; rat
END IF
prv\$ = MID\$(a\$, 1, 1)
permute a\$
IF MID\$(a\$, 1, 1) <> prv\$ THEN PRINT a\$
LOOP UNTIL a\$ = h\$
CLOSE 2

DEFDBL A-Z
FUNCTION total (x\$)
x2\$ = x\$
t = 0
DO
ix = INSTR(x2\$, " ")
t = t + VAL(MID\$(x2\$, 1, ix - 1))
x2\$ = LTRIM\$(MID\$(x2\$, ix))
LOOP UNTIL x2\$ = ""
total = t
END FUNCTION

Out of the 12!/2 (= 239,500,800) permutations of the digits and spaces, there are many, many ways of getting exactly 1 or 2 (149,516 and 208,600 ways, respectively), such as

`For 1:`
`134 9 870526`
` 2784 691350 `
`70 93 421586`
`For 2:`
`1 69 3502784`
` 2784 693051 `
`859 024 3671`

The 116 ways of getting 1.618025751072961, the closest possible to phi (~= 1.618033988749895) are:

`1857 602 934`
`2397 586 410`
`2397 856 140`
`2479 053 861`
`2497 035 861`
`2586 397 410`
`2586 793 014`
`2793 586 014`
`2856 397 140`
`2965 341 087`
`32795 680 41`
`32795 681 40`
`32798 650 41`
`32798 651 40`
`32975 861 04`
`32975 864 01`
`32976 851 04`
`32976 854 01`
`397 586 2410`
`397 856 2140`
`4 9732051 86`
`4 9732056 81`
`479 053 2861`
`479 2061853 `
`479 2063851 `
`497 035 2861`
`497 2061835 `
`497 2065831 `
`497 2510386 `
`497 2516380 `
`5 6832790 41`
`5 6832791 40`
`5 690 713248`
`5 691 703248`
`5 6932410 78`
`5 6932418 70`
`5 7832140 96`
`5 7832146 90`
`5 7832410 69`
`5 7832419 60`
`5 8632971 04`
`5 8632974 01`
`5 961 073284`
`5 9632140 78`
`5 9632148 70`
`5 967 013284`
`586 397 2410`
`586 793 2014`
`6 5932410 87`
`6 5932417 80`
`6 8532971 04`
`6 8532974 01`
`6 951 073284`
`6 9532140 78`
`6 9532148 70`
`6 957 013284`
`65 970 13248`
`65 971 03248`
`69 570 13248`
`69 571 03248`
`7 4932501 86`
`7 4932506 81`
`7 9432051 86`
`7 9432056 81`
`749 2061583 `
`749 2063581 `
`793 586 2014`
`794 2061538 `
`794 2068531 `
`794 2513086 `
`794 2516083 `
`8 6532790 41`
`8 6532791 40`
`8 7532140 96`
`8 7532146 90`
`8 7532410 69`
`8 7532419 60`
`856 397 2140`
`857 602 1934`
`9 4732501 86`
`9 4732506 81`
`9 5632410 87`
`9 5632417 80`
`9 650 713248`
`9 651 703248`
`9 6532410 78`
`9 6532418 70`
`947 2061385 `
`947 2065381 `
`95 601 73284`
`95 607 13284`
`96 501 73284`
`96 507 13284`
`965 341 2087`
`974 2061358 `
`974 2068351 `
` 397 5862410`
` 397 8562140`
` 3972586 410`
` 3972856 140`
` 479 0532861`
` 4792053 861`
` 497 0352861`
` 4972035 861`
` 586 3972410`
` 586 7932014`
` 5862397 410`
` 5862793 014`
` 793 5862014`
` 7932586 014`
` 856 3972140`
` 8562397 140`
` 857 6021934`
` 8571602 934`
` 965 3412087`
` 9652341 087`

 Posted by Charlie on 2012-07-01 18:36:12

 Search: Search body:
Forums (0)