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

Home > Numbers
Make it true (Posted on 2016-05-09) Difficulty: 3 of 5
2 ? 3 ? 4 ? 5 ? 6 = 10

To make the above equation valid replace each of the four ? marks by any operator of the set (+, -, /, *) and unlimited quantity of brackets.

Rem1: No other operators/signs allowed.
Rem2: Analytical solution preferred.

See The Solution Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution via computer | Comment 3 of 5 |
A modification of the code for the puzzle "80" (thus explaining the extraneous code):

DefDbl A-Z
Dim crlf$, puzz(13) As String, stack(6), concatable(6), stackPtr
Dim expstr As String, pz As String

Private Sub Form_Load()
 Form1.Visible = True
 
 puzz(1) = "23456"

 
 Text1.Text = ""
 crlf = Chr$(13) + Chr$(10)
 
 For pNo = 1 To 1
   pz$ = puzz(pNo)
   Text1.Text = Text1.Text & pz & crlf
   h$ = pz
   Do
     stackPtr = 1
     stack(1) = Val(Left(pz, 1)): concatable(1) = 0
     expstr = Left(pz, 1)
     addOn (2)
    
     
    ' permute pz
   Loop Until pz = h
 Next
 

 Text1.Text = Text1.Text & crlf & " done"
  
End Sub

Sub addOn(wh)
 ReDim sstack(6)
 ReDim sconcatable(6)
 DoEvents
        For typ = 1 To 5
   sstackPtr = stackPtr
   sexpstr$ = expstr
   For i = 1 To stackPtr
     sstack(i) = stack(i)
     sconcatable(i) = concatable(i)
   Next
          good = 1
          Select Case typ
        '    Case 0
        '      If concatable(stackPtr) Then
        '        stack(stackPtr) = 10 * stack(stackPtr) + Val(Mid(pz, wh, 1))
        '        If Right(expstr, 1) = "," Then expstr = Left(expstr, Len(expstr) - 1)
        '        expstr = expstr + Mid(pz, wh, 1)
        '      Else
        '        good = 0
        '      End If
            Case 1
              stack(stackPtr) = stack(stackPtr) + Val(Mid(pz, wh, 1))
              expstr = expstr + Mid(pz, wh, 1) + "+"
              concatable(stackPtr) = 0
            Case 2
              stack(stackPtr) = stack(stackPtr) - Val(Mid(pz, wh, 1))
              expstr = expstr + Mid(pz, wh, 1) + "-"
              concatable(stackPtr) = 0
            Case 3
              stack(stackPtr) = stack(stackPtr) * Val(Mid(pz, wh, 1))
              expstr = expstr + Mid(pz, wh, 1) + "*"
              concatable(stackPtr) = 0
            Case 4
              If Val(Mid(pz, wh, 1)) > 0 Then
                stack(stackPtr) = stack(stackPtr) / Val(Mid(pz, wh, 1))
                expstr = expstr + Mid(pz, wh, 1) + "/"
                concatable(stackPtr) = 0
              Else
                good = 0
              End If
            Case 5   ' comma
              stackPtr = stackPtr + 1
              stack(stackPtr) = Val(Mid(pz, wh, 1))
              concatable(stackPtr) = 1
              expstr = expstr + "," + Mid(pz, wh, 1)
            Case 6
              If stack(stackPtr) < 1000 Then
                stack(stackPtr) = stack(stackPtr) ^ Val(Mid(pz, wh, 1))
                expstr = expstr + Mid(pz, wh, 1) + "^"
                concatable(stackPtr) = 0
              Else
                good = 0
              End If
         End Select
          If good Then
            If stackPtr = 1 Then
              If stack(stackPtr) = 10 And Len(expstr) = 9 Then
                Text1.Text = Text1.Text & "    " & expstr & crlf
              End If
            End If
            If wh < 6 Then addOn wh + 1
          End If
   expstr = sexpstr
   stackPtr = sstackPtr
   For i = 1 To stackPtr
     stack(i) = sstack(i)
     concatable(i) = sconcatable(i)
   Next
   
     
        Next

End Sub




finds the RPN:

    23+4+5-6+
    23+4*5/6+
    23/4-5+6*
    
which translates to:

2+3+4-5+6
(2+3)*4/5+6
(2/3-4+5)*6

  Posted by Charlie on 2016-05-09 15:45:58
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 (3)
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