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.)
 Process but obviously not a solution. Comment 2 of 2 |

My initial program had some issues with run-time, I had PRINT statements to allow me to monitor progress; the calling on the CPU to provide SCREEN display is very taxing taking much longer than 12 hours (didn't finish as a security process shut the program down!).

My original program did not allow for long integers.
By removing PRINT calls and allowing long integers the run-time was 44 minutes.

The program sought only to offer the final high and low closest values to the targets which are shown:
ONE 1.002992021276596
.8  (due to H/L values for the ratio, never below 1,  this was
never going to change)
TWO 2.002313284864508
1.99933708982433
PHI 1.61803894772805
1.618025751072961

In checking Charlie's solution he has reach each ratios for ONE and TWO.  I did arrive at the same value for PHI.

At this point I haven't investigated the program.  I offer my comment more for any interest in the evaluation of rows, columns, the ratios and the narrowing process to arrive at the limit.

DEFDBL A-Z

DIM g(15)
DIM sumr(15)
DIM sumc(15)
DIM b(15)
DIM row(20)
DIM used(15)
A\$ = TIME\$
one = 1: oneh = 1.2: onel = 0.8
two = 2: twoh = 2.2: twol = 1.8
phi = (1 + SQR(5)) / 2: phih = 1.7: phil = 1.5

FOR a = 0 TO 11
IF used(a) = 0 THEN
used(a) = 1
FOR b = 0 TO 11
IF used(b) = 0 THEN
used(b) = 1
FOR c = 0 TO 11
IF used(c) = 0 THEN
used(c) = 1
FOR d = 0 TO 11
IF used(d) = 0 THEN
used(d) = 1
FOR e = 0 TO 11
IF used(e) = 0 THEN
used(e) = 1
FOR f = 0 TO 11
IF used(f) = 0 THEN
used(f) = 1
FOR g = 0 TO 11
IF used(g) = 0 THEN
used(g) = 1
FOR h = 0 TO 11
IF used(h) = 0 THEN
used(h) = 1
FOR i = 0 TO 11
IF used(i) = 0 THEN
used(i) = 1
FOR j = 0 TO 11
IF used(j) = 0 THEN
used(j) = 1
FOR k = 0 TO 11
IF used(k) = 0 THEN
used(k) = 1
FOR l = 0 TO 11
IF used(l) = 0 THEN
used(l) = 1
g(12) = a: g(11) = b: g(10) = c: g(9) = d: g(8) = e: g(7) = f: g(6) = g: g(5) = h: g(4) = i: g(3) = j: g(2) = k: g(1) = l
'     FOR ga = 1 TO 12
'      IF g(ga) = 10 OR g(ga) = 11 THEN g(ga) = 10
'     PRINT g(ga);
'     IF ga = 4 OR ga = 8 THEN PRINT
'     NEXT: PRINT
'evaluate rows
mm = 1: ex = 0: sumr(mm) = 0
FOR rr = 12 TO 1 STEP -1
IF g(rr) <> 10 THEN
sumr(mm) = sumr(mm) + g(rr) * 10 ^ ex
ex = ex + 1
IF rr = 5 OR rr = 9 THEN
ex = 0: mm = mm + 1: sumr(mm) = 0
END IF
ELSE
ex = 0: mm = mm + 1: sumr(mm) = 0
END IF
NEXT
zz = mm: rowsum = 0
FOR ww = 1 TO zz

rowsum = rowsum + sumr(ww)
NEXT
' PRINT "row"; rowsum

'evaluate columns
mm = 1: ex = 0: sumc(mm) = 0
FOR qq = 0 TO 3
FOR rr = 12 - qq TO 1 STEP -4
IF g(rr) <> 10 THEN
sumc(mm) = sumc(mm) + g(rr) * 10 ^ ex
ex = ex + 1
IF rr = 4 OR rr = 3 OR rr = 2 THEN
ex = 0: mm = mm + 1: sumc(mm) = 0
END IF
ELSE
ex = 0: mm = mm + 1: sumc(mm) = 0
END IF
NEXT
NEXT
dd = mm: colsum = 0
FOR hh = 1 TO dd

colsum = colsum + sumc(hh)
NEXT
'  PRINT "col"; colsum

'evaluate ratios
IF (rowsum / colsum) > (colsum / rowsum) THEN
rat = rowsum / colsum
ELSE
rat = colsum / rowsum
END IF
'  PRINT "RAT"; rat
'ONE
IF rat > one AND rat < oneh THEN
oneh = rat
ra1 = a: ra2 = b: ra3 = c: ra4 = d: ra5 = e: ra6 = f: ra7 = g: ra8 = h: ra9 = i: ra10 = j: ra11 = k: ral2 = l
ELSE
IF rat > onel AND rat < one THEN
onel = rat
ra1 = a: ra2 = b: ra3 = c: ra4 = d: ra5 = e: ra6 = f: ra7 = g: ra8 = h: ra9 = i: ra10 = j: ra11 = k: ral2 = l
END IF
END IF
'     PRINT "ONE"; rat; oneh; onel
'TWO
IF rat > two AND rat < twoh THEN
twoh = rat
rba1 = a: rba2 = b: rba3 = c: rba4 = d: rba5 = e: rba6 = f: rba7 = g: rba8 = h: rba9 = i: rba10 = j: rba11 = k: rbal2 = l
ELSE
IF rat > twol AND rat < two THEN
twol = rat
rba1 = a: rba2 = b: rba3 = c: rba4 = d: rba5 = e: rba6 = f: rba7 = g: rba8 = h: rba9 = i: rba10 = j: rba11 = k: rbal2 = l
END IF
END IF
'    PRINT "TWO"; rat; twoh; twol
'PHI
IF rat > phi AND rat < phih THEN
phih = rat
rpa1 = a: rpa2 = b: rpa3 = c: rpa4 = d: rpa5 = e: rpa6 = f: rpa7 = g: rpa8 = h: rpa9 = i: rpa10 = j: rpa11 = k: rpal2 = l
ELSE
IF rat > phil AND rat < phi THEN
phil = rat
rpa1 = a: rpa2 = b: rpa3 = c: rpa4 = d: rpa5 = e: rpa6 = f: rpa7 = g: rpa8 = h: rpa9 = i: rpa10 = j: rpa11 = k: rpal2 = l
END IF
END IF
'    PRINT A\$
'     PRINT "PHI"; rat; phih; phil
'     PRINT ra1; ra2; ra3; ra4; ra5; ra6; ra7; ra8; ra9; ra10; ra11; ral2
'     PRINT rba1; rba2; rba3; rba4; rba5; rba6; rba7; rba8; rba9; rba10; rba11; rbal2
'     PRINT rpa1; rpa2; rpa3; rpa4; rpa5; rpa6; rpa7; rpa8; rpa9; rpa10; rpa11; rpal2

'    DO
'    LOOP WHILE INKEY\$ <> CHR\$(32)
'      PRINT: PRINT
used(l) = 0: END IF: NEXT
used(k) = 0: END IF: NEXT
used(j) = 0: END IF: NEXT
used(i) = 0: END IF: NEXT
used(h) = 0: END IF: NEXT
used(g) = 0: END IF: NEXT
used(f) = 0: END IF: NEXT
used(e) = 0: END IF: NEXT
used(d) = 0: END IF: NEXT
used(c) = 0: END IF: NEXT
used(b) = 0: END IF: NEXT
used(a) = 0: END IF: NEXT
'Final results
PRINT TIME\$, A\$
PRINT "ONE"; oneh; onel; "TWO"; twoh; twol; "PHI"; phih; phil
PRINT ra1; ra2; ra3; ra4; ra5; ra6; ra7; ra8; ra9; ra10; ra11; ral2
PRINT rba1; rba2; rba3; rba4; rba5; rba6; rba7; rba8; rba9; rba10; rba11; rbal2
PRINT rpa1; rpa2; rpa3; rpa4; rpa5; rpa6; rpa7; rpa8; rpa9; rpa10; rpa11; rpal2

FOR ga = 1 TO 12
IF g(ga) = 10 OR g(ga) = 11 THEN g(ga) = 10
PRINT g(ga);
IF ga = 4 OR ga = 8 THEN PRINT
NEXT: PRINT

Edited on July 2, 2012, 4:10 am
 Posted by brianjn on 2012-07-02 01:52:15

 Search: Search body:
Forums (0)