You are currently browsing the coffee corner blog archives for December, 2005


Where’s a coder when you need one?

Again, I wish I knew a bit more about coding than I actually do. Jason brought home a math brain teaser the other day that he and his grandmother got stumped on:

Arrange the numbers from 1 to 16 in a four by four square so that each row and each column and the two main diagonals add up to 34.

(note: as I type this, I have the brainflash to feed that quote into Google. I think I just found the answer there – would’ve saved me a few hours today. I’m not going to be able to sleep if I don’t figure this out for myself, though.) I spent some time with Excel this afternoon, setting up a grid that showed the row, column, and diagonal sums and then started arranging the numbers. I’ve managed to fit everything but the diagonals, and I’m getting a feel for the rules of movement to switch numbers around without breaking what I’ve got so far.

Part of me wants to make this a linear programming problem, set up a matrix of coefficients, and solve it. That was one of the coolest things I learned in my Materials & Energy Balance class, the first course in chemical engineering. By setting this up as a system of equations, if you have enough (non-redundant) equations to satisfy the degree of freedom, there is a matrix manipulation algorithm that will nicely resolve all the equations into the solution. I’ve been trying, but I can’t come up with enough equations. I have sixteen variables (one for each grid square), so I need sixteen equations, but I can’t pick them out to get a solvable matrix.

I moved on a little while ago to think about a computational brute-force. Let the computer churn overnight on all the 20,922,789,888,000 variations on this square and check them while I blissfully sleep. My problem with that, and the reason I wish I had more of a computer science background, is that I’m not sure how to represent the matrix in a sensible form. The ugly way would be a nest of sixteen for i = 1 to 16: loops, with checks at each level of the nest to ensure that no number was used twice. This would be hideous to write and, I suspect, extremely inefficient.

Rather than represent this as a matrix, what it really looks like is a sorting problem. Instead of a matrix, treat the grid as a sixteen-element array. Let the first row be positions 1 through 4, the next row positions 5 through 8, and so on. Based on what I tried with the linear programming above, I can write a function to evaluate the matrix by adding up the values at certain positions and make sure they add up to 34. Problem is, I don’t know nearly enough about sorting algorithms to readily apply them here. Essentially, a sorting function would be able to evaluate two items in the list and see if they are in the proper place (the first is “higher” than the second) or if they should be swapped around (the second is “higher” than the first) and swap them. Unfortunately, in the evaluation function for this problem, I don’t know how to determine which is a better fit and which is not, so which elements should I swap?

See, this is what keeps me up at 1:17 in the morning. Welcome to my world.

UPDATE: Answer is in the comments. Thanks, Dad!

So much to say….

Today has been Christmas day. Rather, Christmas lights day. I spent the afternoon outside untangling strands of lights, hanging strands, rehanging (%$#^ plug end goes on the OTHER side of the yard…) the strands, re-rehanging the strands (whadya mean I hung them too low?), and searching for the burnt out bulbs among far too many sections of lights. The back yard is now cozily lit (if dim in a couple of spots), and if the front yard looks like it came down with mange, well, I did my best. We’ll have it fixed by Christmas.

In other news:

  • Teachef, from Adagio Teas, is a community site dedicated to cooking with teas. Each month, they offer up samples of a particular variety of tea, and whomever gets to spend the rest of the month coming up with the best recipe to showcase that tea. I’ve just signed up to work with Lapsang Souchong in January, so this should be quite interesting to follow.
  • NIST Dictionary of Algorithms and Data Structures – put this one in the “Gee, wish I’d studied computer science” category. Lots of concepts here that I wish I knew more about, and if I read between the lines enough I might get to learn them. If anybody has a recommendation like Graph Theory For Dummies or Dick And Jane Learn Stasticial Modelling, please pass it along.
  • The wood-fired oven idea is not dead. I’ve requested a copy of Denzer’s book (linked a few posts below) from the local public library, so I can see it before I decide if this is beyond my skill or not. It’s been suggested that if I want to spend time building an outdoor oven, I should probably also look at screening in our back porch. If anybody has a recommendation like Building Wood Frames For Dummies or Dick And Jane Use A Nail Gun….
  • Dating an Apple Developer. Something that should be required reading if you ever find yourself in a relationship with a code monkey. Fortunately, Christine is quite understanding.
  • An interview with the Hairy Bikers. If anybody out there in blogland UK can record this for me, I’d be extremely grateful. Food television that sounds like it should not be missed. (Tip of the hat to Geoff)
  • Transferring MPEG2 files back to the TiVo; more of a mental note to myself than anything else.

That about covers it. Work has been extremely busy, not the usual end-of-year slowdown, mainly because I’m covering for two roles that each want 75% of my time. I am still cooking when I can – I make a pretty mean buttermilk scone, and I enjoyed my crepes last week, not to mention a fabulous roast chicken – and getting into the holiday spirit. For everybody who has asked, I do have a skeleton of a Christmas list if it’s still needed – send me an email and I’ll send it out.

Lazyweb: NUMB3RS and whiteboard markers

Lazyweb, I’d like to know what dry erase markers are used in NBC’s hit drama “NUMB3RS”. Despite my best TiVo-rewind efforts, I can’t make out the brand and type of markers used. Most often they are a bright yellow ink that shows up very clearly on clear glass as opposed to traditional white boards. What are they, and can I get them?

Bonus points: Can anybody confirm the pen used by the Architect in Matrix: Reloaded? I believe it was by Lamy, but I want to be sure.