HP Forums

Full Version: Challenge: Generate 24 in the X register / display
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Challenge: Using a single digit repeated 3 and only 3 times, produce the number 24 in the X register.

Details - read them carefully... not trying to be picky, but to lay things out.

You cannot assume any default state of the calculator or the stack. You may not reset the calculator either. :-) Open to any ** HP ** RPN model or RPL model or the 71B with no extensions / plug ins added. No alpha functions allowed either. Stay numeric.

Please STATE which model your solution is for. This should provide a number of possible solutions, so just because someone posts a 2 step solution, please try it yourself.

Note: Solutions are sought for the numbers 0 – 9. Can you use 0 up to three times and generate 24 in the display? Can you use 1 up to three times and generate 24 in the display? Etc.

Embargo on solutions posted until Monday evening 5pm Central Time USA – roughly 24 hours from this post.


Example: A solution for the number 8 (most obviously) could be five steps: 8 ENTER ENTER + + which leaves 24 in the X register. Another solution would be six steps: 8 ENTER 8 + 8 + but that is longer.


Suggested layout of the solutions:

Solution for up to three 1’s. Model HP-25:

1
ENTER

Etc.

Remember to have fun.
Gene
Edit 1: there was a difference between what was written and what I understood, all my solutions are invalid. Arrggg.
Edit 2: ok 2nd try ...
a) With value 3 → 5 steps on most HP RPN scientific calculators and several RPN financial calculators.
b) With value 5 → 6 steps on most HP RPN scientific calculators and several RPN financial calculators.
I get 6 steps on an HP41C!

Namir
For which one Namir ? :-) Remember, please state which numeral you are using up to three times to get 24.

Did you use 0, 1, 2, 3... ?
Is it allowed to use:
1) some digit less than up to 3 times
2) built-in constants and procedures (HP-50g)
3) SQ or x^2 ?
Edited original instructions.

Use the same single digit 3 and only 3 times.

No built in constants (don't think the 50g has 24 built in but ... ?)

and things like X^2 etc are fine.
(09-07-2020 12:42 AM)Gene Wrote: [ -> ]Use the same single digit 3 and only 3 times.

Hlib question still remains: can we use a digit less than 3 times, or should it be exactly 3 times ?

Also, do you consider Pi a built-in constant ? Because in the HP-71B it is a function.

V.
Use a single digit repeated 3 and only 3 times and a required total of 3 times. All solutions should incorporate the use of a single digit - the same digit - three times.


PI on the HP-71B is allowed. I suspect it to be a "constant" elsewhere, but I won't worry too much about PI. Use it if you wish, but you must include three instances of 0 or 1 or 2...whichever solution you are providing. Just covering my bases should a 24 be included as some sort of constant for some reason! :-)
41C:

0: 11 (14 keystrokes)
1: 8 (9 keystrokes)
2: 5
3: 6 (7 keystrokes)
4: 6 (7 keystrokes)
5: 7 (8 keystrokes)
6: 6 (7 keystrokes)
7: 11
8: 6
9: 8

But I am rusty at this... and I assumed no other digits were allowed, just the selected digit 3 times. All these counts include the three keystrokes for the number.
5 steps using 5 on any 41/42 and some other programmable RPN machines

Edit: Cut a step, 6 -> 5
(09-07-2020 01:26 AM)Gene Wrote: [ -> ]Use a single digit repeated 3 and only 3 times and a required total of 3 times. All solutions should incorporate the use of a single digit - the same digit - three times.

Understood.

However, unless you forbid it explicitly, to use a number just 2 times, say, and still be within your current rules, you simply enter the first instance, ignore it altogether, then use just the second and third instances,.

Thus, I'd suggest allowing solutions with up to 3 instances of the digit. Or else explicitly forbid entering an instance and doing nothing whatsoever with it. Smile

V.
(09-07-2020 02:26 AM)Valentin Albillo Wrote: [ -> ]However, unless you forbid it explicitly, to use a number just 2 times, say, and still be within your current rules, you simply enter the first instance, ignore it altogether, then use just the second and third instances,.

Thus, I'd suggest allowing solutions with up to 3 instances of the digit. Or else explicitly forbid entering an instance and doing nothing whatsoever with it. Smile

Shhh.....
Monte said: "and I assumed no other digits were allowed, just the selected digit 3 times."

Gene: This is correct.
I also found a solution that requires NO digits!!!

:-)

Namir
Gene...

I think the first sentence in this challenge should say "single digit number repeated 3 and only 3 times", not "single digit repeated 3 and only 3 times". The challenge as written could just as well mean 000, 111, 222, etc., although the rest of the challenge statement indicates otherwise.

Using my DM42, I made a generic solution that can solve this challenge for three 0s, three 1s, three 2s, all the way to up to three 9s. The program totals 16 steps, including label and END. I took the approach that the program would accept a single digit number (0-9) in the x-register, then ENTER twice to get all three numbers required for the challenge into X, Y, and Z (this is two steps of the program). I then used all three of these numbers and no digit keys whatsoever. If I enter all three numbers into the stack first, then the program shrinks to 14 steps.

I'm sure a better generic solution exists and I will keep plugging away at it.

// EDIT: Now down to 12 steps, including the two ENTERs at the beginning. //

Fred
(09-07-2020 03:30 AM)Namir Wrote: [ -> ]I also found a solution that requires NO digits!!!

How many steps/bytes/keystrokes/functions? CEIL(e^pi) springs to mind immediately.

I've a 5 operation / 6 keystroke version for '4' that works on all scientifics apart from the 35 and 21. It also works on business models from the SPICE series onwards.

Pauli
Namir...

I also found a solution that doesn't require any digits. It's currently at 8 steps on the DM42.

Fred
> Remember to have fun.

Great advice! Nice challenge too.
HP-50g, RPN mode:
Universal algorithm: 8 7 steps by 8 7 keystrokes
for any digit except zero. Only arithmetic
operations are used and all the rules of the challenge are met.
EDIT:
#9 || 7 steps(clicks)
#8 || 5 steps(clicks)
#7 || 7 ...
#6 || 6 ...
#5 || 6 ...
#4 || 6 ...
#3 || 5 ...
#2 || 7 ...
#1 || 7 ...
#0 || 10 ... steps(clicks)
Reminder to ttw and others... please do not post solutions until after the deadline.
Pages: 1 2 3
Reference URL's