(09-08-2020 12:04 AM)Dwight Sturrock Wrote: [ -> ]HP42S, 5 steps:
4.9
ENTER
ENTER
X
IP
Gene: That does indeed generate 24, but does not satisfy the basic rule on the initial post.
"Using a single digit repeated 3 and only 3 times..."
4.9 is not a single digit between 0 and 9.
.
Hi,
Gene & all:
Quote:Challenge: Using a single digit repeated 3 and only 3 times, produce the number 24 in the X register
As no one has submitted a solution for the
HP-71B (as if !), here's a generic one I've created for it:
DISP USING "^,DD";(digit+digit)/digit,FACT(RES+RES)
24
Simple as it is, notice the following:
- it meets all requirements but as the
HP-71B doesn't have an
"X register" it simply puts
24 in the display
- it works in any
FIX,
SCI or whatever mode so it puts in the display
24, not
2.4000E1 or
24.00
- it doesn't use any other
numbers at all, nor
any variables
- as per the requirements, it works for
digit =
1,
2,
3,...,
9, but also you can replace
digit by
most any number, be it
Pi,
Sqrt(5),
e^Pi^Pi, ...-, except
digit =
0
- for
digit =
0, substitute
digit above by, say,
EXP(digit) or
COS(digit), and there you are.
- also,
RES+RES could be instead
RES*RES,
RES^RES, and other variants.
This solution can be adapted easily to most
RPN models, for instance:
digit, ENTER, digit, +, digit, / , x^2, FACT
Thanks for the challenge and best regards.
V.
My apologies for this answer: I did not have the time to participate, and before reading the above answers I post mine. Sorry if I’m repeating answers or giving some already found (and I guess I’m far from the best answers).
Tested on HP42s but did not want to use STO+X to make it work on 15c or other classic RPN.
That said, here are my attempts:
Code:
1 10^x 1 + 1 + ENTER +
2 10^x 2 / 2 / DSE
3 3 x^y 3 -
4 4 + 4 x^2 +
5 5 5 * DSE
6 6 6 + ENTER +
7 7 * 7 SQRT IP / IP
8 8 + 8 +
9 9 + LASTX + 9 SQRT -
0 0 10^x 10^x 0 e^x e^x * LASTX - IP
Now I can’t wait to see the answers for 9 and 0!
And now I’ve read the above messages and noticed that the rules, apparently clear and simple, were not.
Was it asked to find a solution for each digit from 0 to 9 as I did, or the best solution using 1 of the digits?
I also understand that each digit had to be used 3 and only 3 times, and I respected the rule with a few cheating, letting the unused digits on the stack (ie. 5).
The goal was to use each digit exactly 3 times, no more and no less.
Ideally 10 solutions, one for 0 through 9.
A general solution is possible - get a number 4 showing in the display and use FACT or n! (if available on the model) to get to 24, but that may be more steps than another solution.
A solution for 7, on the 42S, in 6 steps:
Code:
7
x^2
7
RCLx ST L
%
IP
(09-08-2020 04:21 PM)Gene Wrote: [ -> ]The goal was to use each digit exactly 3 times, no more and no less.
So I assume that the RCLx ST L above is counting as the third use of the digit 7 .
(09-08-2020 01:40 PM)Gene Wrote: [ -> ] (09-08-2020 12:04 AM)Dwight Sturrock Wrote: [ -> ]HP42S, 5 steps:
4.9
ENTER
ENTER
X
IP
Gene: That does indeed generate 24, but does not satisfy the basic rule on the initial post.
"Using a single digit repeated 3 and only 3 times..."
4.9 is not a single digit between 0 and 9.
Oops, think I was sidetracked by the exception for PI.
HP42S, 6 steps using 4 three times:
OCT
4
ENTER
ENTER
X
+
(41, 42) generic solution for d=1..9, shamelessly borrowing pinkman's idea:
Cheers, Werner
Excellent! This uses dd/d=11, thus (dd+d)/d=12
The same for 15c and others without STO X function:
Code:
dd
d
+
LASTX
/
ENTER
+
(hp-50)
#1 || 1 10^x EULER 1 %T 1 – ||
#2 || 2 DUP DUP ➝LIST ΣLIST ! ||
And a general solution for any three equal numbers
(including zero) placed on the stack:
|| N DUP DUP MAX SAME 10^x EULER ! ||
or
|| N DUP DUP MAX SAME 10^x √ e^x CEIL ||