All Bring Your Own Code

13 Jul 2011

Turning the Lights Out

by Alex Papadimoulis in Bring Your Own Code on 2011-07-13

Despite the eighty-hour weeks, the relatively low pay, and the constant threat of being whipped if you don’t code fast enough, there’s something appealing about developing videogames professionally. After all, if videogames are superfun, then being immersed in them fourteen hours a day is basically heaven.

Of course, I never had a real desire to find out and ended up sticking with “normal” programming throughout my career. While I could always code whatever I wanted to do on the side, I never thought I’d ever get paid to write a videogame. That is, until I got paid to write this:

153 Comments - Last Comment @ 19:07
14 Mar 2011

The Disgruntled Bomb

by Alex Papadimoulis in Bring Your Own Code on 2011-03-14

It's been quite a while since the last Bring Your Own Code. It's mostly because I haven't thought of any coding quandaries that fit in the "totally fun and doable over a quick break" difficulty; everything has been either hello world easy or graduate-level comp sci homework hard. If you've got any ideas, please do send them to me.

That said, today's BYOC is a little bit different than the previous ones. It was inspired by a submission from Mårten Rånge, who wrote "rumor has it that a disgruntled employee once left #define true false in a random header file in the codebase. Given our codebase, that would be a lot harder to debug than one might think."

305 Comments - Last Comment @ 19:07
05 May 2010

Krypto and 24

by Alex Papadimoulis in Bring Your Own Code on 2010-05-05

As a kid, I was never a fan gambling away my hard-earned allowance. Heck, even playing poker with M&M’s meant that maybe — just maybe — I’ll walk away with less chocolate than I came to the table with, and that was an anxiety worth not experiencing. Fortunately, I’ve since come to my senses, but I’ll never forget the game my risk-averse friends and I would play when we came across a deck of playing cards.

While most kids reached in their pockets for coins to ante up, we’d pulled the face and joker cards out of the deck, shuffle the rest, and deal out six cards, face-up, in the middle of the table with one of the cards a few inches from the rest.

115 Comments - Last Comment @ 19:07
31 Mar 2010

The Key Lock Box

by Alex Papadimoulis in Bring Your Own Code on 2010-03-31

Nearly two years ago, I set out on the quest for a new house. Well, not new by any stretch of the word "new", but more foreclosed and dilapidated. It was 2008 and the market was flooded with homes, especially those of the not quite livable variety. As I explored house after house after house, I became intimately familiar with a device known as a key lock box. Generally used by realtors, key lock boxes are a convenient, low-tech way to provide combination code access to a lock that would otherwise require a physical key for access.

This was actually the first time I had ever seen a key lock box. Essentially, they're small steel boxes that contain a key and are often affixed near a keyhole (eg., the door handle). Some feature a set of dials that must be aligned with the right code, while others (such as the one pictured) use a pushbutton system to enter the combination.

258 Comments - Last Comment @ 19:07
20 Jan 2010

Avoiding the Splice

by Alex Papadimoulis in Bring Your Own Code on 2010-01-20

One mistake that rookie carpenters will often make is to measure for trim molding – baseboard, casing, crown, etc – by the linear foot. Take the casing on a 7’ door, for example. Each leg of the door requires 84” of trim and the header needs 32”. If your house has 16 doors, and each side of the door needs 200” of trim, then that adds up to 533’ 4” (16 x 2 x 200”). And since you can get casing in 16’ boards, you’d need to order 34 boards to get the job done, right?

Not quite. You’d actually need 38 of those 16’ boards. Although each 16’ board can easily fit two 7’ door legs, the remaining 24” should be scrapped, as a splice in a header casing is about as professional as modHmm. And while door casings are relatively easy to measure for, baseboard and crown molding can get trickier.

178 Comments - Last Comment @ 19:07
16 Sep 2009

Kirkman's Ladies

by Alex Papadimoulis in Bring Your Own Code on 2009-09-16

Well over 150 years ago, the Reverend Thomas Kirkman posed an interesting problem in The Ladies' and Gentlemen's Diary for 1850. The curiously-named publication was in fact a mathematical journal and, as such, Kirkman's problem was mathematical in nature.

Fifteen young ladies in a school walk out three abreast for seven days in succession: it is required to arrange them daily so that no two shall walk twice abreast.

72 Comments - Last Comment @ 19:07
02 Sep 2009

Sliding Around

by Alex Papadimoulis in Bring Your Own Code on 2009-09-02

Andy Hertzfeld is a bona fide Software Wizard. I'm not kidding: it was his official job title, codified on his business card. And not just any old business card, but one from Apple Computer. You see, not only was Andy a key player on the Macintosh team, but he also had a knack for doing the impossible. One his feats was described in the September 1995 issue of Byte Magazine.

Besides everything else he did to help get the first Macintosh out the door, Andy Hertzfeld wrote all the first desk accessories. Most of these were written in assembly. However, to show that desk accessories could also be written in higher-level languages, Hertzfeld wrote a demonstration puzzle games desk accessory in Pascal. Like its plastic counterparts, users moved squares around until the numbers 1 to 9 were in order. As time began to get short, the decision was made that the puzzle, at 7KB [7KB = 7168 bytes], was too big (and too game-like) to ship with the first Macintosh. In a single weekend, Hertzfeld rewrote the program to take up only 800 bytes. The puzzle shipped with the Mac.

That's pretty impressive, especially considering that simply telling the story took a little under 800 bytes. Fortunately, Andy did have one thing going for him: sliding puzzles — especially of the 32 variety — are pretty simple. There are nine squares and eight pieces, and a piece can slide into the empty square.

1 2 3
4 5 6
7 8  

197 Comments - Last Comment @ 19:07
19 Aug 2009

Knocking Me Off The Perch

by Alex Papadimoulis in Bring Your Own Code on 2009-08-19

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?

253 Comments - Last Comment @ 19:07
12 Aug 2009

Automating the Knight’s Tour

by Alex Papadimoulis in Bring Your Own Code on 2009-08-12

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.

137 Comments - Last Comment @ 19:07
05 Aug 2009

Nerds, Jocks, and Lockers

by Jake Vinson in Bring Your Own Code on 2009-08-05

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.

435 Comments - Last Comment @ 19:07
29 Jul 2009

Josephus' Circle

by Alex Papadimoulis in Bring Your Own Code on 2009-07-29

With nearly 750 responses, and solutions written in everything from ABAP to MUMPS to XSLT, I’d say that last week’s Programming Praxis (Russian Peasant Multiplication) was certainly a success. The comments are most certainly worth a read, if nothing else but to see things like the circuit diagram solution, something done entirely using regular expressions, and some obscure childrens' language called Baltie 3. That said, I'm excited to present this next Programming Praxis.

Titus Flavius Josephus was an important first-century historian. Having survived the siege and destruction of Jerusalem in 70 AD, he authored several works on Jewish history, including The Jewish War and Antiquities of the Jews. Not only have his writings given valuable insight into first century Judaism, they provide an extra-Biblical account of early Christianity. But aside from the books, and the writings, and all of his other invaluable contributions to history, Josephus also told the story of how he had escaped death by quickly standing in the "safe spot" of what is now called Josephus’ Circle.

379 Comments - Last Comment @ 19:07
22 Jul 2009

Russian Peasant Multiplication

by Alex Papadimoulis in Bring Your Own Code on 2009-07-22

Ever since the first OMGWTF Programming Contest, I've always wanted to bring back some element of "coding challenges" to the site. Ideally, this would be in the form of a second contest... but considering that contests require a ton of work, and the fact that interns around town have come to learn that interning at Inedo basically mean means shipping mugs, mailing stickers, testing contest entries, and acting as human ottomans, we'll have to go with something a bit scaled back. And that's where Programming Praxis will come in.

The goal of Programming Praxis 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. There is no “right” answer and no perfect solution, but some will certainly be better than others. The best of these will get a TDWTF sticker.

775 Comments - Last Comment @ 19:07