Friday, October 24, 2008

Tineecee Tim's tiny-c Mollykewels Juz Gotz Larger

c:\tc>tinyc.exe

tiny-c/PC Interpreter Version PC-01-05
Copyright (c) 1984 by Scott B. Guthery
Last revised on 2/17/2008 - Lee Bradley, Ed Davis

tiny-c Shell - 3/4/2008

tc>.r mollykew.tc
524
0 24 524 11476
tc>.mollykew

mollykew.tc - lrb - 10/24/2008

1 3 - 10 6 - 11 5 - 12 4 - 14 2 - 16 9 - 17 8 - 18 7 - count = 8
1 8 - 10 6 - 11 5 - 12 4 - 13 3 - 14 2 - 16 9 - 18 7 - count = 8
1 15 - 10 6 - 11 5 - 12 4 - 13 3 - 14 2 - 16 9 - 17 8 - 18 7 - count = 9

c:\tc>

Never miss an opportunity to roll that die one more time. Despite the fact that DiDi / Toby / Amy's post is still wet behind the ears (and a reminder that Barack himself is on a bit of a roll), I can't resist telling all those thousands of tiny-c programmers out there that that dancing partner puzzle finally met its match and was solved this morning, by computer. Not unlike that palindromic odometer puzzle (also from Car Talk), after both Amy and I solved it I began to realize there *had* to be a way to automate the brute force algorithm via a computer program.

It's always a good idea to refresh your skill at *anything* you once knew but have not tried for a while so I started typing away in tiny-c last night only to finally crash with a mental note that I was either going to drop the project or hit it again this morning. I had to get out the book, recall all sorts of details about the syntax and semantics etc. etc. and then beat my head against the wall on the true nature of the problem at hand before I finally nailed it.

(I know there will probably be at most 3 people out there there will read this drivel and even they will probably have little clue what the listing below means. How the general / non-technical remarks above finally crystallized into the victory below is hard to explain.)

A "screen scrape" of the final run is up top. Here's the listing:

/* mollykew.tc - tct - 10/23,24/2008

mollykew [
int j,cnt,k,m
pl "";ps "mollykew.tc - lrb - 10/24/2008";pl "";pl ""
for (j=2;j<16;++j) [
if ((1+j==4)+(1+j==9)+(1+j==16)) [
pn 1;pn j;ps " -"
cnt=1
for (k=10;k<19;++k) [
for (m=2;m<10;++m) [
if (
(k!=m)*(k!=j)*(m!=j)*
((k+m==4)+(k+m==9)+(k+m==16)+(k+m==25))
) [
++cnt
pn k;pn m;ps " -";break
] /* if
] /* m loop
] /* k loop
ps " count =";pn cnt;pl ""
] /* if
if (cnt==9) exit
] /* j loop
]

No comments: