HP Forums
Challenge: Generate 24 in the X register / display - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: Challenge: Generate 24 in the X register / display (/thread-15553.html)

Pages: 1 2 3


Challenge: Generate 24 in the X register / display - Gene - 09-06-2020 09:58 PM

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


RE: Challenge: Generate 24 in the X register / display - Sylvain Cote - 09-06-2020 10:25 PM

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.


RE: Challenge: Generate 24 in the X register / display - Namir - 09-06-2020 10:53 PM

I get 6 steps on an HP41C!

Namir


RE: Challenge: Generate 24 in the X register / display - Gene - 09-07-2020 12:03 AM

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... ?


RE: Challenge: Generate 24 in the X register / display - Hlib - 09-07-2020 12:39 AM

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 ?


RE: Challenge: Generate 24 in the X register / display - Gene - 09-07-2020 12:42 AM

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.


RE: Challenge: Generate 24 in the X register / display - Valentin Albillo - 09-07-2020 01:13 AM

(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.


RE: Challenge: Generate 24 in the X register / display - Gene - 09-07-2020 01:26 AM

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! :-)


RE: Challenge: Generate 24 in the X register / display - Monte Dalrymple - 09-07-2020 01:49 AM

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.


RE: Challenge: Generate 24 in the X register / display - rprosperi - 09-07-2020 02:24 AM

5 steps using 5 on any 41/42 and some other programmable RPN machines

Edit: Cut a step, 6 -> 5


RE: Challenge: Generate 24 in the X register / display - Valentin Albillo - 09-07-2020 02:26 AM

(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.


RE: Challenge: Generate 24 in the X register / display - rprosperi - 09-07-2020 02:42 AM

(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.....


RE: Challenge: Generate 24 in the X register / display - Gene - 09-07-2020 03:26 AM

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

Gene: This is correct.


RE: Challenge: Generate 24 in the X register / display - Namir - 09-07-2020 03:30 AM

I also found a solution that requires NO digits!!!

:-)

Namir


RE: Challenge: Generate 24 in the X register / display - Fred Lusk - 09-07-2020 05:25 AM

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


RE: Challenge: Generate 24 in the X register / display - Paul Dale - 09-07-2020 05:26 AM

(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


RE: Challenge: Generate 24 in the X register / display - Fred Lusk - 09-07-2020 05:38 AM

Namir...

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

Fred


RE: Challenge: Generate 24 in the X register / display - EdS2 - 09-07-2020 08:17 AM

> Remember to have fun.

Great advice! Nice challenge too.


RE: Challenge: Generate 24 in the X register / display - Hlib - 09-07-2020 09:23 AM

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)


RE: Challenge: Generate 24 in the X register / display - Gene - 09-07-2020 12:16 PM

Reminder to ttw and others... please do not post solutions until after the deadline.