The following warnings occurred:
Warning [2] Undefined array key 177232 - 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 177232 - 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





Re: a challenge related to the 15 puzzle



#2

Well, the HP-32sii version takes a while to run because it has to decode registers A-D in which 4 numbers are stored in each register. I did that to avoid using so many registers. This version stores a single cell value in each register A-P. While it uses many more registers than the other version, it runs much quicker (about 7 seconds versus 40 seconds).

Life (and programming) is all about trade-offs!

Program to determine solvability of 15 puzzle for 32s.
This one is faster than the one that stores 4 numbers in each register A-D.

Register usage:

A-P - 16 cell values, entered after XEQ A
Q - number of inversions, including row number of empty cell
R - current outer loop cell value
i - indirect addressing and inner loop index
T - outer loop index

Usage:
XEQ A
enter 16 cell values (0 for empty cell) R/S after each
program displays number of inversions; if even, puzzle is solvable

Code:

lbl a entry point
1.016 loop to get cell values
sto i
lbl b
r/s enter each of 16 values
sto (i) stores in A-P
x<>0 if 0 calc row#
goto c
3
rcl+i
4
/
ip
sto q inversion count starts with row# of empty cell
lbl c
isg i
goto b
1.015 outer loop goes from 1 to 15
sto t outer loop index
lbl d
rcl t get current outer loop cell value
sto i and store in R
rcl (i)
sto r
rcl t
ip
1.016
+ inner loop goes from t+1 to 16
sto i inner loop index
lbl e
rcl (i)
x=0 if inner loop cell value is 0, ignore
goto f
rcl r current outer loop cell value
x<y
goto f
1
sto + q increment inversion counter
lbl f
isg i
goto e iterate inner loop
isg t
goto d iterate outer loop
rcl q display inversion counter, even means puzzle is solvable
rtn


Edited: 19 Jan 2011, 10:23 a.m.


Possibly Related Threads…
Thread Author Replies Views Last Post
  Good puzzle for kids to solve on 35s? snaggs 11 3,284 09-18-2013, 10:40 PM
Last Post: David Hayden
  Second Batch of HP-15 LE calculators Namir 6 2,324 07-02-2013, 12:27 PM
Last Post: Kimberly Thompson
  HP-15 LE Key repair question Namir 2 1,407 06-10-2013, 10:42 PM
Last Post: Namir
  Party Puzzle: for your amusement hugh steers 2 1,239 05-28-2013, 03:00 PM
Last Post: hugh steers
  HP 41 Mcode related Questions Michael Fehlhammer 4 1,913 05-10-2013, 07:09 PM
Last Post: Michael Fehlhammer
  The answer to the second semi-mathematical puzzle Mike Reed 3 1,405 02-18-2013, 02:40 AM
Last Post: Derek Walker (UK)
  Answer to Mathematical Puzzle Mike Reed 2 1,196 02-08-2013, 12:11 AM
Last Post: LHH
  OT: a semi mathmatical puzzle 4 u Mike Reed 6 1,981 02-05-2013, 07:50 PM
Last Post: Mike Reed
  Calculator O.T., instead HP related. Luiz C. Vieira (Brazil) 1 1,132 08-17-2012, 06:57 AM
Last Post: Frank Boehm (Germany)
  A new firmware beyond 2.15 for 50g ever? mr-scorpio 3 1,585 07-24-2012, 07:25 AM
Last Post: Keith Midson

Forum Jump: