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

Home > Numbers
Ascending order (Posted on 2018-05-26) Difficulty: 4 of 5
1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 = 10
Replace the 'x' by '+', '-', '*', '/'.
No operator occurs more than twice.
Evaluation is left to right, no brackets, e.g. 1+2*3-4= 3*3-4=5

Source: Zeit Magazin, Nr 13, 22. Mar. 96

See The Solution Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution (spoiler) Comment 1 of 1
The two solutions are shown below. Each is followed by the set of successive intermediate results; for example 1-2=-1, then -1+3=2, and 2/4=0.5, etc.

1-2+3/4*5*6-7/8+9
-1
2
0.5
2.5
15
8
1
10

1/2*3-4+5*6-7/8+9
0.5
1.5
-2.5
2.5
15
8
1
10




DefDbl A-Z
Dim crlf$, ct(4), s$, v, h(9)


Private Sub Form_Load()
 Form1.Visible = True
 Text1.Text = ""
 crlf = Chr(13) + Chr(10)
 
 s$ = "1": v = 1
 addOn 2
 
 Text1.Text = Text1.Text & crlf & " done"
  
End Sub

Sub addOn(wh)
  Dim ctsave(4)
  For i = 1 To 4
    vsave = v: ssave$ = s
    For j = 1 To 4
      ctsave(j) = ct(j)
    Next
    Select Case i
      Case 1
         v = v + wh
         s = s + "+"
         ct(1) = ct(1) + 1
      Case 2
         v = v - wh
         s = s + "-"
         ct(2) = ct(2) + 1
      Case 3
         v = v * wh
         s = s + "*"
         ct(3) = ct(3) + 1
      Case 4
         v = v / wh
         s = s + "/"
         ct(4) = ct(4) + 1
    End Select
    h(wh) = v
    s = s + LTrim(Str(wh))
    If ct(i) <= 2 Then
        If wh = 9 Then
          If Abs(v - 10) < 0.000000001 Then
             Text1.Text = Text1.Text & s & crlf
          For j = 2 To 9
            Text1.Text = Text1.Text & h(j) & crlf
          Next
          Text1.Text = Text1.Text & crlf
          End If
        Else
          addOn wh + 1
        End If
    End If
    s = ssave: v = vsave
    For j = 1 To 4
      ct(j) = ctsave(j)
    Next
  Next
End Sub


  Posted by Charlie on 2018-05-26 13:00:57
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