Friday, August 28, 2009

Fun with typing

-Another nerdy post

Yesterday all the groups under my group's director (my boss's boss) met for an annual meeting to discuss statistics, politics, arbitrary administrative tasks, and a small bit of what I quaintly refer to as "real work". Like all such meetings, it started off with a "safety tip". This is where people with no medical, structural engineering, or injury prevention training give you unsolicited advice on how to behave both at work and at home, as though they were some sort of authority.

The tip this time was about hand injury prevention, and, although I find the whole "safety tip" phenomenon lame at best (dangerous at worst), this one was pretty sensible. Use the right tool - a crescent wrench is a bad hammer, for example. Most injuries occur to your off hand, e.g., you hammer the hand holding the nail. And lastly, the reflection-inducing question: How much of your job could you do if you lost a finger? A thumb? A hand? As in, we type for money, we dial phones, we take notes, we draw on whiteboards, we sometimes wear shirts with buttons. Hands and fingers are pretty useful for all these tasks. This got me reflecting on some fun keyboard related things I've done over they years.

CompuServe

As members of CompuServe's tech support group, my ex-wife and I (we were engaged at the time) did a lot of case note entries. This is where you summarize what a caller's problem was, what you did to try to fix it, and where the problem stands now. In some cases, a caller has only one phone line, and can't connect to the service while talking to you, and after the call ends, you must take the next call in queue rather than call back later to check on them. Although this is a rule I broke frequently, most tech support people gave the customer the boot happily, and hoped that the customer would get another CSR when they called back saying the problem still wasn't fixed. "Here, try this init string..." flush! "Sometimes that goes away if you reboot..." flush! That sort of thing.

Wednesday, August 19, 2009

In defense of play

- In which Curtis samples a new board game

"Don't capitalize on an opponent's mistake, play better Go." - Aphorism on the "Go" board game.

This year I first heard the term "German-style board game", referring to the fantastic game "Settlers of Catan". I was looking for board games for the house, as the missus is fond of them, and spent some time perusing websites in search of one that was just right. Settlers was pretty highly rated, and I liked the description of it on Wikipedia and Amazon, so I bought it.

It turns out that the game has a large following, including a couple of my Facebook friends. The premise is basically city building. Different areas in the land you're settling produce different resources. If you collect enough brick, wood, what have you, you can build roads and settlements. Liberty and I played a game and enjoyed it, and some time later a friend and his wife brought over their copy for another game. Big fun.

A couple months later, the aforementioned man and wife, Herr and Frau Barrett, brought over Eurorails, which I had never heard of. It's a train game based on the Empire Builder rules, where you lay tracks and make deliveries of goods to cities based on cards you are dealt. You have goals such as building lines into so many major cities, and being the first to make so much money.

Wednesday, August 12, 2009

And with a perky grin, she said, "I'm a Mathematician"

Background
The high school I went to was a magnet school of what was then just "Worthington High School", but is now either Thomas Worthington, or Worthington Kilbourne, or perhaps it is a magnet of both. I don't really care enough about the current zoning of Worthington schools to fact check that. It was called the Linworth Alternative Program, and unlike other "alternative" schools, its function was not to house the ruffians who couldn't be managed by meek schoolmarms, it housed instead the hippies, punks, budding activists, and artists that couldn't be managed by closed-minded state employees who made their cheddar parroting textbooks and catering to sports enthusiasts and young Republicans.

There were roughly 200 kids at the AP. Teachers dressed casually and were referred to by their first names. Class schedules were determined with a sort of voting process: teachers put available times for classes and how many students could be in each on a bulletin board, and interested students wrote their names by the classes they wanted to be in. Classes included the standards: history, math, english, sciences, but also classes with social/political themes: "Current Events", "Science and Society", and "World Trade", and differing points of view classes such as Canadian History. Phys Ed was free-form; you just had to log 40 hours of athletic stuff you had done on a piece of paper and hand it in - the main effect of this was to encourage students to play pick-up soccer games after school and marathon hacky-sack sessions during free periods.

Free periods were free, neither study hall nor lunch; you could listen to your Walkman, take a nap, read, whatever. There was no cafeteria, so when you wanted lunch, you went to the office and signed your name on the "sign-out" sheet, and wrote down where you were going, and went there. Most lockers did not have locks on them, and in my 4 years at the AP there were only 2 reports of theft, one of which was resolved (catty girls playing out some Kabuki theater drama).

Friday, August 07, 2009

The Invisible, Undocumented Hack Which Was Nearly My Undoing

- In which Curtis reverse-engineers the good intentions of someone very familiar
"The best underlings will skim a little. If they're not taking a little, they're taking a lot. And if they're not taking a lot, they've got an angle, and they're dangerous." - Mob saying

I am not the type to take psychological baggage from work home with me, but a particular project has been my bane now for a couple of months, and I have taken to rambling about it at home. I have been fretting about it so much lately, that my dear wife has taken to asking me how work was, which she was never previously inclined to do. The problem? A well-meaning programmer at a vendor put a few undocumented hacks into some code to help us a few years ago, and then left his company.

With names changed to protect the innocent, we'll say that I am the translator, the messaggero, if you will, between internal mafia bosses, and external contract killers. It's a dirty world we live in, friends. A dirty world. The mob system keeps its books in an internal database that we'll call "Corleone". The contract killers keep track of their info in a system we'll call "assassi-net".

When somebody doesn't pay up, or insults a boss, Corleone sends me an xml message with who to clip, where they are located, and a unique identifier for the request that, for lack of a better term, we'll call a "ticket number". I, in turn, take the request and reformat it to data that assassi-net can read, and then I open a "ticket" with assassi-net, and give the return info to Corleone, including their ticket number, and which hitman is assigned.

Saturday, August 01, 2009

kNN, Finding the k nearest neighbors of points on a Cartesian plane

So I'm obsessed with yet another Facebook engineering puzzle. After solving Gattaca before my last blog post, I worked on User Bin Crash (where you have to calculate the best selection of items to toss out of an airplane to keep it from crashing), which I solved a couple weeks ago with little fanfare. The current puzzle is "Small World", whose problem statement begins thusly:

As a popular engineer, you know many people in your home city. While traveling around town, visiting your friends, you realize it would be really handy to have a program that tells you which of your friends are closest based upon which friend you are currently visiting.


The problem translates to a "nearest neighbor" problem variant known as "kNN", or k Nearest Neighbors. There is a host of wikipedia and scholarpedia articles related to this, however I never found a source with a good plain-English problem description that didn't also claim one search method or other as "The kNN algorithm", rather than acknowledging more than one good approach. Here's a bad approach:

The naive approach

For each point, find the distance to each other point, remembering the best 3 distances along the way. I was able to whip up something without much trouble (in perl, naturally) that does just that. Discounting the routine that parses the file into variables, and the one that summarizes all the results, the rest of the code looks like this: