The following warnings occurred:
Warning [2] Undefined array key 74055 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $thread - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $fid - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 74055 - Line: 331 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 331 errorHandler->error_callback
/inc/plugins/threaded_mode.php 304 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $theme - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $theme - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $lang - Line: 5 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 5 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Attempt to read property "messages_in_thread" on null - Line: 5 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 5 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks





S&SMC#9: Optimized 42S (and 41C) RPN solution



#2

Hi,

The RPN solution I gave for the 42S yesterday was an
unoptimized, direct translation of my original solution for the 71B, and would run only on a 42S because it used more subroutine levels than the 41C would allow.

On the other and, this optimized translation, despite still using the exact same logic as the 71B version, does include the following improvements over the first one:

  • Appreciably shorter (80 steps, 149 bytes vs. 92 steps, 167 bytes) and faster.

  • Doesn't use subroutine levels in a recursive manner, so its maximum depth is 1, and thus will run on the HP-41C essentially unchanged.
The only modification necessary to make it run in the HP-41C is to expand the RCL arithmetic at steps 44 (RCL+ IND 01) and 53 (RCLx IND 03) into two separate steps each (RCL, + and RCL, x, respectively), thus the 41C version will be 82 steps long.

01*LBL "SR" 21 STO IND 02 41 FS? IND ST X 61 3
02 0.009 22 CF 15 42 GTO 03 62 XEQ 06
03 STO 04 23 X=Y? 43 INT 63 RUP
04*LBL 05 24 SF 15 44 RCL+ IND 01 64 GTO 00
05 CF IND ST X 25 3 45 STO IND 03 65*LBL 04
06 ISG ST X 26 FC? 15 46 RCL 00 66 RCL IND 02
07 GT0 05 27 STO- IND 02 47 MOD 67 CF IND ST X
08 1 28 1E5 48 X#0? 68*LBL 03
09 STO 00 29 STO/ IND 02 49 GTO 03 69 ISG IND 02
10 5 30 RCL 04 50 RCL IND 02 70 GTO 01
11 STO 01 31 STO+ IND 02 51 SF IND ST X 71 -3
12 6 32 4 52 10 72 XEQ 06
13 STO 02 33 FS? 15 53 RCLx IND 03 73 GTO 04
14 7 34 STO+ IND 02 54 9 74*LBL 06
15 STO 03 35 RCL 00 55 RCL 00 75 STO+ 01
16 0 36 2 56 X<Y? 76 STO+ 02
17*LBL 00 37 MOD 57 GTO 02 77 STO+ 03
18 STO IND 01 38 STO+ IND 02 58 VIEW ST Z 78 SIGN
19 RCL 00 39*LBL 01 59 GTO 04 79 STO+ 00
20 5 40 RCL IND 02 60*LBL 02 80 END

To run it, simply:
    SIZE 32
SF 21
XEQ "SR" -> ST Z=3,816,547,290 (in the HP42S)
-> 3,816,547,290 (in the HP-41C)
after a few seconds in the 42S or a few minutes in the 41C. No other solutions do exist, but you can make certain by
continuing the search by pressing [R/S]. After a while it will signal that further solutions are nonexistent by displaying "Nonexistent" (42S) or "NONEXISTENT" (41C),
which is achieved by forcing that error message when the search is over, thus saving the steps required to display an alpha prompt.

This same program would also run in an HP-15C (despite the effects of using system flags 8 and 9) with a small change to cater for the fact that you can't use the X-register for indirect addressing (simply X<>I, indirect operation using I, X<>I) and also bringing the solution to the X-register before pausing/stopping for the user to see it (the 42S/41C version above displays the solution using a VIEW Z, because it is in the Z-register at that time).

Best regards from V.


Possibly Related Threads…
Thread Author Replies Views Last Post
  [HP-PIRME] BUG Pretty Print, Solution: abs => |...|, ABS => ||...|| CompSystems 2 2,075 12-13-2013, 09:36 AM
Last Post: CompSystems
  Converting Great Circle Navigation from 41C to 42S Bill Triplett 11 3,378 11-13-2013, 07:24 AM
Last Post: Kimberly Thompson
  [PRIME] RPN: another attempt at returning more than one value to the RPN stack Marcus von Cube, Germany 5 2,382 11-05-2013, 02:44 AM
Last Post: Marcus von Cube, Germany
  [HP-Prime xCAS] Arrays: Programming Commands (solution to the ambiguity) CompSystems 6 2,494 08-30-2013, 06:32 PM
Last Post: CompSystems
  HP-Prime: Solution to ambiguity with [ ... ] & another BUGs CompSystems 12 3,565 08-28-2013, 08:48 AM
Last Post: CompSystems
  Advanced User's Manual and solution to the ambiguity of data types [HP-Prime xCAS] CompSystems 15 5,402 08-20-2013, 03:37 PM
Last Post: Thomas Klemm
  HHC 2012 RPN Programming Contest - 10-Step Way-After-Nashville Solution Jeff O. 32 6,661 10-12-2012, 01:41 AM
Last Post: Paul Dale
  41CL: Linux/Mac connection solution (soon) Geir Isene 28 6,324 06-10-2012, 01:21 PM
Last Post: Ángel Martin
  Re: RPN Programming exercise (HP-42S) Gerson W. Barbosa 1 1,013 02-27-2012, 05:51 PM
Last Post: Marcus von Cube, Germany
  RPN Programming exercise (HP-42S) Gerson W. Barbosa 71 13,185 02-26-2012, 11:48 AM
Last Post: Valentin Albillo

Forum Jump: