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 - Gene - 09-08-2020 01:40 PM (09-08-2020 12:04 AM)Dwight Sturrock Wrote: HP42S, 5 steps: 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. RE: Challenge: Generate 24 in the X register / display - Valentin Albillo - 09-08-2020 03:09 PM . 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. RE: Challenge: Generate 24 in the X register / display - pinkman - 09-08-2020 03:38 PM 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:
Now I can’t wait to see the answers for 9 and 0! RE: Challenge: Generate 24 in the X register / display - pinkman - 09-08-2020 04:00 PM 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). RE: Challenge: Generate 24 in the X register / display - Gene - 09-08-2020 04:21 PM 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. RE: Challenge: Generate 24 in the X register / display - Didier Lachieze - 09-08-2020 04:56 PM A solution for 7, on the 42S, in 6 steps: Code: 7 (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 . RE: Challenge: Generate 24 in the X register / display - Dwight Sturrock - 09-08-2020 06:01 PM (09-08-2020 01:40 PM)Gene Wrote:(09-08-2020 12:04 AM)Dwight Sturrock Wrote: HP42S, 5 steps: Oops, think I was sidetracked by the exception for PI. HP42S, 6 steps using 4 three times: OCT 4 ENTER ENTER X + RE: Challenge: Generate 24 in the X register / display - pinkman - 09-08-2020 08:32 PM Found new ideas 1) 5 steps Code:
2) 3 steps Code:
3) 4 steps Code:
4) 6 steps Code:
5) 7 steps Code:
6) 5 steps Code:
7) 8 steps Code:
8) 5 steps Code:
9) 7 steps Code:
10) 10 steps Code:
RE: Challenge: Generate 24 in the X register / display - Werner - 09-09-2020 06:39 AM (41, 42) generic solution for d=1..9, shamelessly borrowing pinkman's idea: Code: dd RE: Challenge: Generate 24 in the X register / display - pinkman - 09-09-2020 04:29 PM Excellent! This uses dd/d=11, thus (dd+d)/d=12 The same for 15c and others without STO X function: Code:
RE: Challenge: Generate 24 in the X register / display - Hlib - 09-09-2020 08:14 PM (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 || |