 All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars  perplexus dot info  Arithmetic Grid II (Posted on 2014-06-12) In the following grid:

(1) The numbers in each column form an increasing arithmetic sequence
(2) The numbers in each row form an increasing arithmetic sequence
(3) The X's in each spot indicate how many digits are in the number
(4) A is at least 1200
(5) B is at least 2900

```+---+---+----+----+----+----+----+----+
|  0| XX|  XX|  XX|  XX|  XX|  XX| XXX|
+---+---+----+----+----+----+----+----+
| XX|XXX| XXX| XXX| XXX| XXX| XXX| XXX|
+---+---+----+----+----+----+----+----+
|XXX|XXX| XXX| XXX| XXX| XXX| XXX| XXX|
+---+---+----+----+----+----+----+----+
|XXX|XXX| XXX| XXX| XXX| XXX|XXXX|XXXX|
+---+---+----+----+----+----+----+----+
|XXX|XXX| XXX| XXX|XXXX|XXXX|XXXX|XXXX|
+---+---+----+----+----+----+----+----+
|XXX|XXX| XXX|XXXX|XXXX|XXXX|XXXX|XXXX|
+---+---+----+----+----+----+----+----+
|XXX|XXX|XXXX|XXXX|XXXX|XXXX|XXXX|XXXX|
+---+---+----+----+----+----+----+----+
|XXX|XXX|   A|XXXX|XXXX|XXXX|XXXX|   B|
+---+---+----+----+----+----+----+----+
```
Reconstruct the grid.
An analytic solution is preferred.

 No Solution Yet Submitted by Jer No Rating Comments: ( Back to comment list | You must be logged in to post comments.) The program method Comment 2 of 2 | DefDbl A-Z
Dim crlf\$, grid(8, 8)

Function mform\$(x, t\$)
a\$ = Format\$(x, t\$)
If Len(a\$) < Len(t\$) Then a\$ = Space\$(Len(t\$) - Len(a\$)) & a\$
mform\$ = a\$
End Function

Text1.Text = ""
crlf\$ = Chr(13) + Chr(10)
Form1.Visible = True
DoEvents

grid(1, 1) = 0
For b = 2900 To 20000
grid(8, 8) = b
For a = 1200 To 1897
grid(8, 3) = a
row8incr = (b - a) / 5
If row8incr = Int(row8incr) Then
If a - row8incr < 1000 And a - 2 * row8incr > 99 And a + row8incr > 999 And b - row8incr < 10000 Then
For i = 1 To 7
grid(8, i) = a + row8incr * (i - 3)
Next
For ur = 100 To 999
row1incr = ur / 7
col8incr = (b - ur) / 7
If row1incr = Int(row1incr) And col8incr = Int(col8incr) Then
If ur + 2 * col8incr < 1000 And ur + 3 * col8incr > 999 And ur - row1incr < 100 Then
For i = 1 To 7
grid(i, 8) = ur + (i - 1) * col8incr
Next
If grid(8, 1) Mod 7 = 0 Then
col1incr = grid(8, 1) / 7
If col1incr > 10 And col1incr < 100 Then
If 2 * col1incr > 99 Then
For i = 2 To 7
grid(i, 1) = (i - 1) * col1incr
Next
good = 1
For row = 2 To 7
Select Case row
Case 2, 3
last3 = 8
Case 4
last3 = 6
Case 5
last3 = 4
Case 6
last3 = 3
Case 7
last3 = 2
End Select
rowincr = (grid(row, 8) - grid(row, 1)) / 7
If rowincr <> Int(rowincr) Then
good = 0: Exit For
End If
If grid(row, 1) + rowincr < 100 Or grid(row, 1) + (last3 - 1) * rowincr > 999 Then
good = 0: Exit For
End If
If row > 3 Then
If grid(row, 1) + rowincr * last3 < 1000 Then
good = 0: Exit For
End If
End If
For cl = 2 To 7
grid(row, cl) = grid(row, 1) + (cl - 1) * rowincr
Next
Next row
If good Then
For cl = 2 To 7
grid(1, cl) = (cl - 1) * row1incr
Next
GoSub showit
End If
End If
End If
End If
End If
End If
Next ur
End If
End If
Next a
Next b
Text1.Text = Text1.Text & "done"
Exit Sub
showit:
Text1.Text = Text1.Text & mform(a, "#####0") & mform(b, "#####0") & crlf
For rw = 1 To 8
For cl = 1 To 8
Text1.Text = Text1.Text & mform(grid(rw, cl), "####0")
Next: Text1.Text = Text1.Text & crlf
Next: Text1.Text = Text1.Text & crlf
DoEvents
sctr = sctr + 1: If sctr > 10 Then Exit Sub
Return
End Sub

finds

`  1220  2905    0   15   30   45   60   75   90  105   78  139  200  261  322  383  444  505  156  263  370  477  584  691  798  905  234  387  540  693  846  999 1152 1305  312  511  710  909 1108 1307 1506 1705  390  635  880 1125 1370 1615 1860 2105  468  759 1050 1341 1632 1923 2214 2505  546  883 1220 1557 1894 2231 2568 2905`

the first line showing A and B.  After that is the whole grid.

The program did not have to check the vertical columns (other that the first and last) for being in arithmetic progression; that came about automatically from the horizontal considerations together with the beginning and end column.

 Posted by Charlie on 2014-06-12 23:44:27 Please log in:

 Search: Search body:
Forums (0)