Thursday, August 9, 2018

Solving A Magic Square

You've probably heard of this puzzle. I read about it in a book and it's quite challenging. The goal is to fill a tic tac toe square with number 1-9 in a way that every row, column and diagonal add up to 15. if you think this is a piece of cake you are probably mistaken. I thought it would be fun to solve it, but it would be more fun to have a computer solve it for me.

At first I experimented with Apple code which is very easy to work with, but it wasn't really designed for this sort of operation. I started learning Python on a web sight called solo learn(it's not that hard, it's still english). I chose python mainly because it sounded like the coolest programing language.

My Dad and I discussed for a while and I couldn't find any systematic ways for rearranging the places in a way that would be sure to find all combinations except this method.

You change the places in the square to a list so that the computer can deal with it. We created 18 checks for the list to make sure it was a working combination and then it is added to the list of answers.

The program started at [0,0,0,0,0,0,0,0,0] adding one every time until it reached [9,9,9,9,9,9,9,9,9]. You can quickly notice that this can be shortened to [1,2,3,4,5,6,7,8,9] to [9,8,7,6,5,4,3,2,1].

One snag we encountered was the append statement in python. This adds something onto the end of a list but what we didn't know is that is was, in a way, smart. If you append say, n to a list and then change n's value the list's value will then be changed as well. We did not know this so when the script spit out answerlist=[[9,8,7,6,5,4,3,2,1],[9,8,7,6,5,4,3,2,1],[9,8,7,6,5,4,3,2,1],[9,8,7,6,5,4,3,2,1],[9,8,7,6,5,4,3,2,1],[9,8,7,6,5,4,3,2,1],[9,8,7,6,5,4,3,2,1],[9,8,7,6,5,4,3,2,1],[9,8,7,6,5,4,3,2,1]] we didn't understand. However what it was doing was appending all nine answers in their current state which was the end of the script state [9,8,7,6,5,4,3,2,1]. This was an easy fix and the hole thing after about a month came together.

This was the end result:
All Done!
 Your answerlist was:['[2, 7, 6, 9, 5, 1, 4, 3, 8]', '[2, 9, 4, 7, 5, 3, 6, 1, 8]', '[4, 3, 8, 9, 5, 1, 2, 7, 6]', '[4, 9, 2, 3, 5, 7, 8, 1, 6]', '[6, 1, 8, 7, 5, 3, 2, 9, 4]', '[6, 7, 2, 1, 5, 9, 8, 3, 4]', '[8, 1, 6, 3, 5, 7, 4, 9, 2]', '[8, 3, 4, 1, 5, 9, 6, 7, 2]']
 Your final x was:[9, 8, 7, 6, 5, 4, 3, 2, 1]
 and your try count was:375313600
Exit status: 0
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.


[Process completed]


The Ultimate Tactical Helmet

This morning an idea of certain geeky importance seized me and captured my interest with a wondrous grip. It seems to have ocurred to me before, but this particular time it was irresistible. I mused upon a Helmet of numerous utility. Headgear so finally tuned that you could listen to tunes in surround sound and have infrared vision. I so far call it the Ultimate Tack Helmet! However I'd be open to suggestions. Please comment on what you think it should be called.


  • Floodlights
    • I thought there could be twelve, and you could turn them on in pairs to create six light levels.
  • Night Vision
    • I probably know the least about this feature, but the plan is to have infrared LEDs in the helmet and have some kind of drop-down/slide-out display so you can see the infrared light you are creating.
  • Sunglasses
    • No more "Ah the sun's in my eyes" excuses for you.
  • Video Camera
    • A great way of having a photographic memory "You did say that! Here I'll pull it up."
  • Inner Cooling
    • Not air conditioning as in air blown over a cold pipe; just a fan. Setting a thermostat would be easy.
  • Microphone
    • Would allow you to take calls from your helmet and record your conversations with yourself, the people you interogate, and maybe the milk man if he stands close by.
  • Surround Sound
    • Surround sound is so much easier in a helmet. You just have to have it!
  • Retractable Rearview Mirrors
    • No one can sneak up on this smart helmet wearer! And if they are too dorky for you, they're retractable!
  • Color Scheme
    • For some reason I always picture the helmet silver with a double racing stripe, but definitely comment on what color you would want your Tack Helmet in.
  • Materials
    • Plastic, Styrofoam, and Aluminum, it's cheap and light. I don't think this would be a great helmet for protection. But hey! Maybe floodlights and video cameras absorb shock better than you think.




I'm interested to see anyone's feedback. © Walters 2018 all rights reserved. The first to send me 5000 bars of Lindt's Swiss Dark chocolate will be the receiver of an exclusive production contract for the Ultimate Tack Helmet.