Denote the respective length, breadth, width and the space diagonal of a
rectangular cuboid as L, B, W and D.
Determine the total number of triplets (L, B, W) such that each of L,B,W and D is a positive integer with L+B+W = 29.
*** Order does not matter. For example (1,5,7) and (7,5,1) would be considered as different triplets.
L B W D
4 5 20 21
4 20 5 21
5 4 20 21
5 20 4 21
6 6 17 19
6 17 6 19
8 9 12 17
8 12 9 17
9 8 12 17
9 12 8 17
12 8 9 17
12 9 8 17
17 6 6 19
20 4 5 21
20 5 4 21
There are only three basic solutions, with diagonals 17, 19 and 21. But since permutations are to be counted separately (I would describe that as "order does matter"), there are 15 such triplets, as two of the basic solutions have all different dimensions and thus 6 permutations, and one solution has a duplicated dimension and so has only 3 permutations.
DefDbl A-Z
Dim crlf$
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
Private Sub Form_Load()
Text1.Text = ""
crlf$ = Chr(13) + Chr(10)
Form1.Visible = True
DoEvents
tot = 29
For l = 1 To 27
For b = 1 To 29 - l - 1
w = 29 - l - b
dsq = l * l + b * b + w * w
sr = Int(Sqr(dsq) + 0.5)
If sr * sr = dsq Then
Text1.Text = Text1.Text & l & Str(b) & Str(w) & Str(sr) & crlf
End If
Next
Next
Text1.Text = Text1.Text & " done"
End Sub
|
Posted by Charlie
on 2015-02-09 14:40:57 |