Recent Bring Your Own Code

The goal of BYOC is simple: provide an outlet for you, the enquiring software developer, to sharpen your programming skills on a problem a bit more interesting than the normal, boring stuff. That, and to put your code where you mouth is, so to say.

Aug 2009

Knocking Me Off The Perch

by in Bring Your Own Code on

Photo Credit: discopalace @ flickrNot too long ago, I went up to Windsor, Ontario with my lawyer, Mr. Van Dress. Like my netbook, I never like to leave town without legal representation. Since there are really only three things to do in Windsor – drink, gamble, and buy Cuban cigars – we picked up some stogies, drank until we were confident we’d win, and headed over to the casino.

Before long, I had blown through far too much money on blackjack, and Mr. Van Dress had “invested” just as much on craps. Checking our pockets, I had $2 in chips remaining and he had $8, so we walked towards the roulette tables to place one last bet. Which table? and Black or Red? were the burning questions, and the answer seemed obvious: Table #3 and Red. After all, the table’s counter showed that black had just come up four times previously, so that meant red would have to come up next. Right?


Automating the Knight’s Tour

by in Bring Your Own Code on

Long before the advent of software, computers, or even electricity, Wolfgang von Kempelen debuted one of the world’s most spectacular technological marvels ever invented, even by today’s standards. Inspired by the then-famous illusionist François Pelletier, Kempelen wanted to build something so incredible that it would top Pelletier’s – and all others’ – illusions, and that he did. The year was 1770 and the machine was a chess-playing automaton known as The Turk.

The brains behind The Turk were springs, spindles, cogs, and gears, and they were all powered by a few turns of a large key. Some of the clockwork computed the moves while others controlled the automaton’s arm. Yes, there was actually a human-like (Turkish, in fact) torso attached to the cabinet that would physically move the chess pieces.


Nerds, Jocks, and Lockers

by in Bring Your Own Code on

Mr. Zargas was the zany math teacher at Cliffmont High that everyone seemed to love. Whether you were a nerd or a jock, he made mathematics interesting, challenging, and fun to learn. That, in and of itself, was impressive enough, but Mr. Zargus took it one step further. When it came time for his frequent "Mathematical Battle of Wits," he would let the jocks use their brawn instead of their brains. The nerds never stood a chance, especially when it came to his "locker challenge."

The rules of Mr. Zargas' locker challenge were simple. Corridor G was a long-since abandoned section of Cliffmont High that a row of 100 unused, empty lockers. If you "toggled" the state of each locker (i.e. opening it if its closed, closing it if its open) in the following manner, which lockers would remain open?

  1. Every single locker is toggled (since all lockers start closed, this means each one is opened).
  2. Every other locker is toggled (in this case, closed), starting with the second.
  3. Every third locker is toggled, starting with the third.
  4. Every fourth locker is toggled, starting with the forth.
  5. ...
  6. The hundredth locker is toggled.