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) |
RE: Challenge: Generate 24 in the X register / display - rprosperi - 09-07-2020 01:26 PM Sometimes, it feels like there are more lawyers in here than calculator fans... RE: Challenge: Generate 24 in the X register / display - Valentin Albillo - 09-07-2020 02:30 PM (09-07-2020 01:26 PM)rprosperi Wrote: Sometimes, it feels like there are more lawyers in here than calculator fans... Math fans, scientists and engineers, all of them tend to value precision, exactness and accuracy and abhor ambiguity. Lawyers, not so much. Regards. V. RE: Challenge: Generate 24 in the X register / display - ndzied1 - 09-07-2020 02:36 PM On a 41c used 3 and 6 keystrokes. RE: Challenge: Generate 24 in the X register / display - HP67 - 09-07-2020 02:42 PM 6 keystrokes on HP 48. Still waiting for Namir's no-key 41 solution RE: Challenge: Generate 24 in the X register / display - Gene - 09-07-2020 03:02 PM HP67... remember, six keys for a solution using which number from 0 - 9 ? There are 10 scenarios to be solved here. What is a solution using the number 1 three and exactly three times? Same for 0. Same for 7, etc. I suspect Namir's solution is using no digits at all. That's fine, but does not remove the scenarios above... :-) RE: Challenge: Generate 24 in the X register / display - ndzied1 - 09-07-2020 03:34 PM 50g no digits, 3 steps RE: Challenge: Generate 24 in the X register / display - HP67 - 09-07-2020 06:39 PM (09-07-2020 03:02 PM)Gene Wrote: HP67... remember, six keys for a solution using which number from 0 - 9 ? Oh well I should have known. Any time I think I understand a problem in math of any kind it means I didn't understand it RE: Challenge: Generate 24 in the X register / display - Paul Dale - 09-07-2020 09:01 PM My no digits solution is three steps: Code: 01 pi Without CEIL, it's four steps (on a 41): Code: 01 pi This provides a limit on solutions because the digits can be entered first and ignored: Code: 01 0 I.e. there is a digit independent way of getting the result in six bytes/steps assuming all the used functionality is available on the device in question. Okay, pi isn't permitted since it is a constant but that leads onto: For digits 1 - 9, there is an eight step solution.
Assume the digit is d: Code: 01 d Since we're aiming for the fewest steps, having this limit sets a bar -- not necessarily a very low bar but a bar. This doesn't mean that longer solutions aren't interesting. There is also an eight step solution for the digit 0. On the other end of the scale, we must use each digit thrice and doing so cannot get the answer of 24. Therefore, the minimal program must be 4 or more steps/bytes. I suspect it has to be more than 4 in all cases (but no doubt will be proven wrong). RE: Challenge: Generate 24 in the X register / display - rprosperi - 09-07-2020 09:01 PM Embargo - lifted. For the 41/42 and select other RPN models. 5 ENTER ENTER * DSE X 5 steps , 8 bytes 16 bytes with 1-char global label and an END RE: Challenge: Generate 24 in the X register / display - Sylvain Cote - 09-07-2020 09:20 PM (09-07-2020 09:01 PM)rprosperi Wrote: Embargo - lifted.Actually not yet, it is 5PM CENTRAL TIME USA RE: Challenge: Generate 24 in the X register / display - rprosperi - 09-07-2020 09:47 PM (09-07-2020 09:20 PM)Sylvain Cote Wrote: Actually not yet, it is 5PM CENTRAL TIME USA Dang. Gene, when are you going to move to the East coast? Anyhow, I'll be on a family monthly zoom then, plus I suspect this is not such an insightful solution that it will ruin anyone's day... RE: Challenge: Generate 24 in the X register / display - Hlib - 09-07-2020 10:51 PM HP-50g, RPN mode. To ensure the least number of keystrokes I`ve made a custom soft menu for four functions: DUP, SQ(x^2), !(factorial), NOT. { DUP SQ ! NOT } `CST` STO [LS] [MODE] Thus number of steps in the solution match the keystrokes. The universal chain N DUP + N ÷ SQ ! (seven clicks) comes up to every number except zero. But in some particular cases, this can be made more shorter. #9 24=√9×9–√9 || 9 √ 9 × 9 √ – || 7 steps(clicks) #8 24=8+8+8 || 8 DUP + 8 + || 5 steps(clicks) #7 24=(((7+7)÷7)^2)! || 7 DUP + 7 ÷ SQ ! || 7 #6 24=6^2–6–6 || 6 SQ 6 – 6 – || 6 #5 24=5^2–5÷5 || 5 SQ 5 DUP ÷ – || 6 #4 24=4^2+4+4 || 4 SQ 4 + 4 + || 6 #3 24=3^3–3 || 3 DUP y^x 3 – || 5 #2 24=(((2+2)÷2)^2)! || 2 DUP + 2 ÷ SQ ! || 7 #1 24=(((1+1)÷1)^2)! || 1 DUP + 1 ÷ SQ ! || 7 #0 24=... || 0 NOT 0 NOT + 0 NOT ÷ SQ ! || 10 RE: Challenge: Generate 24 in the X register / display - Dwight Sturrock - 09-08-2020 12:04 AM HP42S, 5 steps: 4.9 ENTER ENTER X IP RE: Challenge: Generate 24 in the X register / display - Fred Lusk - 09-08-2020 12:18 AM I shortened my generic DM-42 program again. Now it is 10 steps. This program takes any single-digit number sitting in the X-register (or any number, positive, negative, or zero, for that matter), makes three copies in the stack (putting the number in X into Y and Z also), then uses all three numbers to create the number 24. 01 LBL "T4" 02 ENTER 03 ENTER 04 + 05 + 06 SIGN 07 RCL+ ST X 08 RCLx ST X 09 N! 10 END If you preload the stack with the same number in X, Y, and Z, then delete steps 02 and 03, which leaves an 8-step program. The following program will take ANY number in the X-register and convert it to 24. It works like the previous program, but it's simpler because it only has to deal with one number. 01 LBL "TF" 02 SIGN 03 RCL+ ST X 04 RCLx ST X 05 N! 06 END ...Fred RE: Challenge: Generate 24 in the X register / display - Paul Dale - 09-08-2020 12:33 AM My solution for 4 is: Code: 4 4 ENTER 4 n! The first two 4's and the command after doing nothing. For zero (8 steps): Code: 0 0 COS 0 n! + x^2 n! Pauli RE: Challenge: Generate 24 in the X register / display - Sylvain Cote - 09-08-2020 02:49 AM My solution for value 3 is: (HP-41 → 5 operations, 7 keystrokes, no unused data is left on the stack, Z & T are preserved) Code: 3 My solution for value 4 is: (HP-41 → 6 operations, lots of keystrokes, no unused data is left on the stack, Z & T are preserved) Code: 4 My solution for value 5 is: (HP-41 → 6 operations, 8 keystrokes, no unused data is left on the stack, T is preserved) Code: 5 Sylvain Edit: typos RE: Challenge: Generate 24 in the X register / display - Sylvain Cote - 09-08-2020 03:01 AM (09-08-2020 12:18 AM)Fred Lusk Wrote: I shortened my generic DM-42 program again. ...Brilliant! Here is an adapted version for the HP-41 and which also now preserve Z & T . Code: 01 LBL "T4" Sylvain RE: Challenge: Generate 24 in the X register / display - Namir - 09-08-2020 04:04 AM Using 1 only once =========== Code: 1 Using NO Digit ========= Code: CLX RE: Challenge: Generate 24 in the X register / display - Didier Lachieze - 09-08-2020 05:22 AM My solution for 2 on the 42S in 6 steps : Code: 2 RE: Challenge: Generate 24 in the X register / display - ndzied1 - 09-08-2020 10:51 AM 42S, digit 4, 7 steps, roundabout way. 4! 2 steps. Code: 4 |