Intel's Ronler Acres Plant

Silicon Forest
If the type is too small, Ctrl+ is your friend

Sunday, July 11, 2021

Stack Smashing

This is what passes for excitement a mi casa:

stack smashing detected

Dennis gave me a puzzle for my birthday. It consists of the ten digits laid out like old seven-segment computer display numbers. The problem comes with trying to fit them back into the frame they came in where they were all interlocked and fit nicely. I worked on it for a bit, but then I realized this is a whole lot like that cube puzzle he gave me a while back, it should be easy enough to write a program to figure this out. I've done it before, I should be able to do it again.

The first problem I ran into was figuring out how to encode the shapes. If they were all perfectly made of simple, identical segments, it would be easy, just use 7 bits to indicate they are present or not. Each bit corresponds to a position in the display. Turning that bit on means that segment is shown. 

But the pieces in this puzzle are not perfect. Some of the segments are missing the little point on one end of the segment, sometimes there's an extra little point stuck in. So I decided to make each segment three characters, one for the point on one end, one for the body, and one for the point on the other end.

I'm not sure this will work, but I'm confident enough to write some code to try it out. So I did. Wrote it, ran it through the compiler, fixed about a dozen minor errors, and ran it. This is just a test program to see if I know how to hold my keyboard. All it does it print the digit to the terminal window, rotate it, and print it again. First got the result you see above. You can see the upside down 9  along the left side of image. It looks like the rotation did not go as planned, which is why you have all that other nonsense on the screen. But it got all the way through 9, so not bad for a first run.

Upside down and backwards.


xoxoxoBruce said...

I do't see any upside down 9s.
Is writing a program to have a computer solve the puzzle ethical?
Or is it just a tool like pencil & paper.
I don't know, it strikes me like the king telling the pissboy to solve it and taking the credit.

Chuck Pergiel said...

There are several 9s near the left hand edge arranged to make a crude representation of a larger 9. There is a bunch of garbage on the screen as well, so it's not obvious what's going on. Solving puzzles is a form of entertainment. Writing programs to solve puzzles in another form of entertainment, plus it allows me to stay in practice. Some people like to cut their lawns with scissors, other people like to use lawn mowers.

xoxoxoBruce said...

Ha ha ha, Touché Sir.