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

Home > Just Math
Pandigital Ponder II (Posted on 2014-08-19) Difficulty: 3 of 5
Each of P, Q, R and S together uses the base ten digits from 1 to 9 exactly once.

What are the respective minimum and maximum value of P*Q*R*S?

No Solution Yet Submitted by K Sengupta    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution Comment 3 of 3 |
DefDbl A-Z
Dim crlf$, s As String

Private Sub Form_Load()
 ChDir "C:\Program Files (x86)\DevStudio\VB\projects\flooble"
 Text1.Text = ""
 crlf$ = Chr(13) + Chr(10)
 Form1.Visible = True
 DoEvents
 
 s = "123456789": h$ = s
 minval = 999999999
 Do
  a = Left(s, 1)
  b = Mid(s, 2, 1): c = Mid(s, 3, 1): d = Mid(s, 4, 6)
  GoSub evaluate
  b = Mid(s, 2, 1): c = Mid(s, 3, 2): d = Mid(s, 5, 5)
  GoSub evaluate
  b = Mid(s, 2, 1): c = Mid(s, 3, 3): d = Mid(s, 6, 4)
  GoSub evaluate
  b = Mid(s, 2, 2): c = Mid(s, 4, 2): d = Mid(s, 6, 4)
  GoSub evaluate
  b = Mid(s, 2, 2): c = Mid(s, 4, 3): d = Mid(s, 7, 3)
  GoSub evaluate
  a = Left(s, 2): b = Mid(s, 3, 2): c = Mid(s, 5, 2): d = Mid(s, 7, 3)
  GoSub evaluate
  permute s
 Loop Until s = h$
 
 Text1.Text = Text1.Text & maxval & " =" & Str(maxa) & " *" & Str(maxb) & " *" & Str(maxc) & " *" & Str(maxd) & crlf
 Text1.Text = Text1.Text & minval & " =" & Str(mina) & " *" & Str(minb) & " *" & Str(minc) & " *" & Str(mind) & crlf
 
 
 Text1.Text = Text1.Text & crlf & " done"
 Exit Sub
 
evaluate:
  prod = a * b * c * d
  If prod > maxval Then maxval = prod: maxa = a: maxb = b: maxc = c: maxd = d
  If prod < minval Then minval = prod: mina = a: minb = b: minc = c: mind = d
 Return
End Sub


finds

367856664 = 74 * 83 * 92 * 651
2740734 = 1 * 2 * 3 * 456789

  Posted by Charlie on 2014-08-19 18:18:00
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 (7)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

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