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

Home > Numbers
Two SPECIAL PARTITIONS (Posted on 2017-10-28) Difficulty: 3 of 5
Find a number N that can be presented in 2 distinct ways
as a sum of 3 squares, say N= a12+b12+c12=a22+b22+c22
while a1+b1+c1=a2+b2+c2

No Solution Yet Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
oh, and the program... Comment 4 of 4 |
DefDbl A-Z
Dim crlf$


Private Sub cmd1_Click()
 Text1.Text = ""

 
 Open "two special partitions.txt" For Output As #2
 For tot = 1 To 50
   For a = 1 To tot / 3
   For b = a To (tot - a) / 2
     c = tot - a - b
     For a2 = a To tot / 3
     For b2 = a2 To (tot - a2) / 2
       If a2 <> a Or b2 <> b Then
         c2 = tot - a2 - b2
         If a * a + b * b + c * c = a2 * a2 + b2 * b2 + c2 * c2 Then
            Text1.Text = Text1.Text & mform(a * a + b * b + c * c, "################0") & "  "
            Text1.Text = Text1.Text & Str(a) & Str(b) & Str(c) & "    "
            Text1.Text = Text1.Text & Str(a2) & Str(b2) & Str(c2) & crlf
            Print #2, mform(a * a + b * b + c * c, "################0"); "  ";
            Print #2, Str(a) & Str(b) & Str(c); "    ";
            Print #2, Str(a2) & Str(b2) & Str(c2)
         End If
       End If
       DoEvents
     Next
     Next
   Next
   Next
 Next
 Close 2
 
 Text1.Text = Text1.Text & crlf & " done"

End Sub

Private Sub cmd2_Click()
 Open "two special partitions.txt" For Input As #1
 Text1.Text = ""
  l$ = "                                    "
  Do
    p$ = l
    Line Input #1, l$
    If Left(l, 17) = Left(p, 17) Then
      ct = ct + 1
      If ct = 2 Then Text1.Text = Text1.Text & p & crlf
      Text1.Text = Text1.Text & l & crlf
    Else
      ct = 1
    End If
    DoEvents
  Loop Until EOF(1)
 
 
 Close 1
End Sub

Private Sub Form_Load()
 Form1.Visible = True
  crlf = Chr$(13) + Chr$(10)
 

  
End Sub

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


The second part is invoked after sorting the output from the first part.

  Posted by Charlie on 2017-10-28 11:22:23
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (0)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information