DefDbl A-Z
Dim crlf$, grid(3, 7), used(2 To 3, 9), solct
Private Sub Form_Load()
Text1.Text = "": Text2.Text = ""
crlf$ = Chr(13) + Chr(10)
Form1.Visible = True
DoEvents
For i = 1 To 7
grid(1, i) = Val(Mid("2461357", i, 1))
Next
fillcol 1
Text1.Text = Text1.Text & solct
End Sub
Sub fillcol(col)
For b = 1 To 7
For sr = 2 To 5
sq = sr * sr
a = grid(1, col)
c = sq - b - a
If c < 8 And c > 0 And (c >= b Or col > 1) Then
If used(2, b) = 0 And used(3, c) = 0 Then
used(2, b) = 1: used(3, c) = 1
grid(2, col) = b: grid(3, col) = c
If col = 7 Then
row2 = 0
For i = 1 To 7
row2 = 10 * row2 + grid(2, i)
Next i
row3 = 0
For i = 1 To 7
row3 = 10 * row3 + grid(3, i)
Next i
If row3 >= row2 Then
Text1.Text = Text1.Text & "2461357" & crlf
For rw = 2 To 3
For cl = 1 To 7
Text1.Text = Text1.Text & grid(rw, cl)
Next: Text1.Text = Text1.Text & crlf
Next: Text1.Text = Text1.Text & crlf
DoEvents
solct = solct + 1
End If
Else
fillcol col + 1
End If
used(2, b) = 0: used(3, c) = 0
End If
End If
Next sr
Next b
End Sub
We have 67 basic (B <= C) solutions:
2461357
1234567
6374152
2461357
1236574
6372145
2461357
1237465
6371254
2461357
1254637
6354712
2461357
1263547
6345172
2461357
1325674
6213745
2461357
1357246
6251473
2461357
1374562
6234157
2461357
1435267
6173452
2461357
1456372
6152347
2461357
1473625
6135724
2461357
1523476
6715243
2461357
1524367
6714352
2461357
1526374
6712345
2461357
1567324
6741325
2461357
1576234
6732415
2461357
1726345
6512374
2461357
1734526
6574123
2461357
1765432
6543217
2461357
2137456
5471263
2461357
2145637
5463712
2461357
2176543
5432176
2461357
2341576
5267143
2461357
2345671
5263741
2461357
2347615
5261734
2461357
2365741
5243671
2461357
2374651
5234761
2461357
2415673
5123746
2461357
2436715
5172634
2461357
2461357
5147362
2461357
2514736
5724613
2461357
2546371
5762341
2461357
2567413
5741236
2461357
2617345
5621374
2461357
2634517
5674132
2461357
2635471
5673241
2461357
2637415
5671234
2461357
2671435
5637214
2461357
3217654
4321765
2461357
3241567
4367152
2461357
3256741
4352671
2461357
3415762
4123657
2461357
3451726
4157623
2461357
3452617
4156732
2461357
3456712
4152637
2461357
3476152
4132567
2461357
3526714
4712635
2461357
3547126
4761523
2461357
3572461
4736251
2461357
3625147
4613572
2461357
3657412
4651237
2461357
3671524
4637125
2461357
3712546
4526173
2461357
3721456
4517263
2461357
3741526
4567123
2461357
3745621
4563721
2461357
3746512
4562137
2461357
7123456
7415263
2461357
7125463
7413256
2461357
7126354
7412365
2461357
7143526
7465123
2461357
7152436
7456213
2461357
7214563
7324156
2461357
7246135
7362514
2461357
7263451
7345261
2461357
7615234
7623415
2461357
7654321
7654321
This last solution has B equal to C, and the digits are in descending order.
If we require that no two digits in the same column be equal, we're reduced to six basic solutions:
2461357
1236574
6372145
2461357
1325674
6213745
2461357
1523476
6715243
2461357
1576234
6732415
2461357
3526714
4712635
2461357
3712546
4526173
|
Posted by Charlie
on 2014-07-02 12:33:17 |