Home > Numbers
six and thirteen (Posted on 2018-03-15) |
|
Part one:
Compose number 6 with each digit using the digit only three times (Ex: 6=2+2+2)
Allowed basic operations (+,-,*,/), sqrt and factorial (no others).
Part two:
Get number 13 using only number 2 three times. Allowed basic and not-basic operations.
No Solution Yet
|
Submitted by armando
|
No Rating
|
|
computer solution
|
| Comment 2 of 9 |
|
Again repurposing code from three fours:
Translating manually from RPN to algebraic notation, the best for 6 are
(0!+0!+0!)! (1+1+1)! 2+2+2 2*2+2 to give one not in the example sqrt(33+3) 4+4-sqrt(4) 5+5/5 6+6-6 7-7/7 8-sqrt(sqrt(8+8)) (this one required a higher length limit in RPN) (sqrt(8+8/8))! (another interesting one for 8's) (9-9/sqrt(9))
111 1,1+,1+! 1,1,1++! 222 2,2+,2+ 2,2*,2+ 2,2/,2+! 2,2,2++ 2,2,2*+ 2,2,2/+! 333 33,3+v 3,33+v 3,3+,3-! 3,3-,3+! 3,3-,3!+ 3,3*,3- 3,3*,3/! 3,3*v,3+ 3,3/,3*! 3,3/,3!* 3,3,3-+! 3,3,3--! 3,3,3*v+ 3,3,3/*! 3,3,3//! 3,3,3!-- 3,3,3!// 3,3!+,3- 3,3!*,3/ 3,3!,3-+ 3,3!,3/* 3!,3+,3- 3!,3-,3+ 3!,3*,3/ 3!,3/,3* 3!,3,3-+ 3!,3,3-- 3!,3,3/* 3!,3,3// 444 4,4+,4v- 4,4,4/-! 4,4,4v-+ 4,4,4v/+ 4,4v-,4+ 4,4v/,4+ 4,4v,4-- 555 5,5-!,5+ 5,5/,5+ 5,5/v,5+ 5,5,5-!+ 5,5,5/+ 5,5,5/v+ 666 6,6+,6- 6,6-,6+ 6,6-!,6* 6,6-v,6+ 6,6*,6/ 6,6/,6* 6,6/v,6* 6,6,6-+ 6,6,6-- 6,6,6-!* 6,6,6-!/ 6,6,6-v+ 6,6,6-v- 6,6,6/* 6,6,6// 6,6,6/v* 6,6,6/v/ 777 7,7,7-!- 7,7,7/- 7,7,7/v- 888 8,8+v!,8/! 8,8-!,8+v! 8,8/,8+v! 8,8/v,8+v! 8,8,8+vv- 8,8,8-!+v! 8,8,8/+v! 8,8,8/v+v! 999 9,9+,9v/ 9,9,9v/-
Part 2
A version of the program seeking 13 was unsuccessful, but F(7) = 13, where F(n) is the nth Fibonacci number. We can form 7 via
2,2+s,2- 2,2*s,2- 2,2^s,2- 2,2,9//,2-
The first three involve subfactorials, but the last is 2/.2. - 2, where .2. represents .2 with a bar over the 2. So for 13 we use F(2/.2. - 2).
DefDbl A-Z Dim crlf$, stack(10), concatable(4), fact(15), dfact(-1 To 25), solCt(1000), shortest(1000) As String Dim stackPtr, wh, pz As String, expstr As String, lvl, subfact As Variant
Private Sub Form_Load() Form1.Visible = True Text1.Text = "" crlf = Chr$(13) + Chr$(10)
f = 1: fact(0) = f For i = 1 To 15 f = f * i fact(i) = f Text1.Text = Text1.Text & f & crlf Next dfact(-1) = 1: dfact(0) = 1 For i = 1 To 25 f = 1 If i Mod 2 = 1 Then For j = 1 To i Step 2: f = f * j: Next Else For j = 2 To i Step 2: f = f * j: Next End If dfact(i) = f Text1.Text = Text1.Text & i & Str(f) & crlf Next subfact = Array(1, 0, 1, 2, 9, 44, 265, 1854, 14833, 133496)
For onlydig = 1 To 9 pz0 = String$(3, LTrim(Str(onlydig))) pz = pz0 Text1.Text = Text1.Text & pz & crlf h$ = pz ' Do stackPtr = 1 stack(1) = Val(Left(pz, 1)): concatable(1) = 1 expstr = LTrim(Str(stack(1))) wh = 2 addOn ' permute pz ' Loop Until pz = h ' For i = 1 To 1000 ' Text1.Text = Text1.Text & i & " " & shortest(i) & crlf ' If shortest(i) = "" Then missct = missct + 1 ' If missct > 2 Then Exit For ' Next Next onlydig
Text1.Text = Text1.Text & crlf & " done" End Sub
Sub addOn() ReDim sstack(4) ReDim sconcatable(4) DoEvents For typ = 0 To 8 sstackPtr = stackPtr sexpstr$ = expstr For i = 1 To stackPtr sstack(i) = stack(i) sconcatable(i) = concatable(i) swh = wh Next good = 1 Select Case typ Case 0 ' concatenate If concatable(stackPtr) And wh < 4 Then stack(stackPtr) = 10 * stack(stackPtr) + Val(Mid(pz, wh, 1)) expstr = expstr + Mid(pz, wh, 1) wh = wh + 1 Else good = 0 End If Case 1 ' add (+) If stackPtr > 1 Then stackPtr = stackPtr - 1 stack(stackPtr) = stack(stackPtr) + stack(stackPtr + 1) expstr = expstr + "+" concatable(stackPtr) = 0 Else good = 0 End If Case 2 ' subtract (-) If stackPtr > 1 Then stackPtr = stackPtr - 1 stack(stackPtr) = stack(stackPtr) - stack(stackPtr + 1) expstr = expstr + "-" concatable(stackPtr) = 0 Else good = 0 End If Case 3 ' multiply (*) If stackPtr > 1 Then stackPtr = stackPtr - 1 stack(stackPtr) = stack(stackPtr) * stack(stackPtr + 1) expstr = expstr + "*" concatable(stackPtr) = 0 Else good = 0 End If Case 4 ' divide (/) If stackPtr > 1 And stack(stackPtr) <> 0 Then stackPtr = stackPtr - 1 stack(stackPtr) = stack(stackPtr) / stack(stackPtr + 1) expstr = expstr + "/" concatable(stackPtr) = 0 Else good = 0 End If Case 5 ' comma If wh < 4 Then stackPtr = stackPtr + 1 stack(stackPtr) = Val(Mid(pz, wh, 1)) concatable(stackPtr) = 1 expstr = expstr + "," + Mid(pz, wh, 1) wh = wh + 1 Else good = 0 End If Case 6 ' power (^) good = 0 ' If stackPtr > 1 Then ' If stack(stackPtr - 1) <> 0 And stack(stackPtr - 1) < 1000 And stack(stackPtr) >= 0 And stack(stackPtr) < 10 And (stack(stackPtr - 1) > 0 Or stack(stackPtr) = Int(stack(stackPtr))) Then ' stackPtr = stackPtr - 1 ' stack(stackPtr) = stack(stackPtr) ^ stack(stackPtr + 1) ' expstr = expstr + "^" ' concatable(stackPtr) = 0 ' Else ' good = 0 ' End If ' Else ' good = 0 ' End If Case 7 ' factorial If stack(stackPtr) = Int(stack(stackPtr)) And stack(stackPtr) <= 15 And stack(stackPtr) >= 0 And stack(stackPtr) <> 1 And stack(stackPtr) <> 2 Then stack(stackPtr) = fact(stack(stackPtr)) expstr = expstr + "!" concatable(stackPtr) = 0 Else good = 0 End If Case 8 ' radical If stack(stackPtr) >= 0 And Right(expstr, 2) <> "vv" Then stack(stackPtr) = Sqr(stack(stackPtr)) expstr = expstr + "v" concatable(stackPtr) = 0 Else good = 0 End If Case 9 ' double factorial If stack(stackPtr) = Int(stack(stackPtr)) And stack(stackPtr) <= 25 And stack(stackPtr) >= 4 Then stack(stackPtr) = dfact(stack(stackPtr)) expstr = expstr + "(!!)" concatable(stackPtr) = 0 Else good = 0 End If Case 10 ' 4/9 If wh < 4 Then stackPtr = stackPtr + 1 stack(stackPtr) = 4 / 9 concatable(stackPtr) = 0 expstr = expstr + ",4,9/" wh = wh + 1 Else good = 0 End If Case 11 ' subfactorial If stack(stackPtr) = Int(stack(stackPtr)) And stack(stackPtr) <= 9 And stack(stackPtr) >= 4 Then stack(stackPtr) = subfact(stack(stackPtr)) expstr = expstr + "s" concatable(stackPtr) = 0 Else good = 0 End If End Select If good Then If stackPtr = 1 And wh = 4 And stack(1) = 6 Then If stack(stackPtr) <= 1000 And stack(stackPtr) > 0 And Abs(stack(stackPtr) - Int(stack(stackPtr) + 0.5)) < 0.000000001 Then ' solCt(stack(stackPtr)) = solCt(stack(stackPtr)) + 1 ' If Len(expstr$) < Len(shortest(stack(stackPtr))) Or Len(shortest(stack(stackPtr))) = 0 Then ' Text1.Text = Text1.Text & mform(stack(stackPtr), "##0") & " " & expstr & crlf shortest(stack(stackPtr)) = expstr Text1.Text = Text1.Text & expstr & crlf ' End If End If End If If Len(expstr) < 10 Then addOn End If End If wh = swh expstr = sexpstr stackPtr = sstackPtr For i = 1 To stackPtr stack(i) = sstack(i) concatable(i) = sconcatable(i) Next Next typ
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
|
Posted by Charlie
on 2018-03-15 11:55:36 |
|
|
Please log in:
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:
|