>sliding-tile puzzle of a lizard. There were 8 pieces on a little 3x3
>
>That night, the cat got up in my lap, arranged itself across my
>forearms, so I decided to "solve" the 3x3 8-piece sliding tile puzzle.

>Now, this would have been an ideal time to try out Ruby, but with a
>purring cat trapping my arms, that wasn't really practical.

Just once, I wanna see c/cat/wife

>Same with perl or TCL... I'd need a reference book at hand, and that
>wasn't going to happen unless I dumped the cat.  And it's just wrong
>to dump a purring cat, so I fell back on that old standby we call C.

So, you're still able to operate.  Books aren't really required; with the
Web you have all the reference material available.  Admittedly, some are
better than others.  PHP shines here.

>Just for fun. It's just 'noodling'... futzing around, really, until
>I got a reasonable answer. Then I went to bed.

Just as I expected.  Stewart coughs, and out comes runnable code.

>There's lots of stuff to criticize. Have fun.
>-----------------------------------------------------------------------------
> * $Id: sliding_nine.c,v 1.2 2007/12/24 19:55:58 stremler Exp $

Aren't we supposed to embed this in the object somehow ( :)  ...troll )

I let the machine do the criticizing.  Who am I to judge?

$ gcc sliding_nine.c -o sli -Wall
sliding_nine.c: In function `make_deque':
sliding_nine.c:74: warning: control reaches end of non-void function
sliding_nine.c: In function `new':
sliding_nine.c:206: warning: unused variable `a'
sliding_nine.c:206: warning: unused variable `b'
sliding_nine.c: In function `fill_children':
sliding_nine.c:246: warning: unused variable `p'
sliding_nine.c:247: warning: unused variable `temp'

Okay, but the premise is that it /runs/

$ ./sli.exe
Usage: ./sli start end
        start = 9 character board configuration
        end   = 9 character board configuration
        (Note that a blank is REQUIRED!)

$ ./sli.exe 246813579 123456789
Starting with '246813579' and trying for '123456789'
start: 0x9700f8          end: 0x970120
Bad board configuration: '246813579' in sliding_nine.c at 259
Segmentation fault (core dumped)

Hmm...OK, there should only be 8 tiles of the 9.  "Note that a blank is
REQUIRED!"

$ ./sli.exe 2468135 7 1234567 8
Usage: ./sli start end
        start = 9 character board configuration
        end   = 9 character board configuration
        (Note that a blank is REQUIRED!)

Umm...blank as delimiter, blank as...oh, I did learn something about shells:

$ ./sli.exe "2468135 7" "12345678 "
Starting with '2468135 7' and trying for '12345678 '
start: 0x9700f8          end: 0x970120

(now it's thinking)...

 [2]  [4]  [6]
 [8]  [1]  [3]
 [5]  [ ]  [7]

 [2]  [4]  [6]
 [8]  [ ]  [3]
 [5]  [1]  [7]

 and so on, until

 [1]  [2]  [3]
 [4]  [5]  [6]
 [7]  [8]  [ ]



Okay, I learned this, too:

$ time ./sli.exe "2468135 7" "12345678 " > sli.txp

real    0m37.930s
user    0m0.000s
sys     0m0.000s

...on a screamin' 533MHz Pentium, in cygwin, under Windows 98. 
...uphill, both ways.

(Okay peanut gallery, this is where you post /your/ time...)

Barry


-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to