Over the weekend, I was writing some code in Ruby — cracking some programming puzzles to keep my brain working. One puzzle was to write to a program that displays LCD style numbers at adjustable sizes.
Sunday morning, it took me about an hour and a half to write a solution and it was 1469 bytes. Then I read that somebody had done this under 300 bytes !!
Suddenly, the challenge got to me — it bit me hard. Pretty much , rest of the day, I toiled over this problem. Tried every trick I could think of to eat away at the bytes. Kind of an obsessive thing — I even went to the shoe-store with my wife shopping for (her) shoes and me sitting in the middle of the shop with a laptop trying to squeeze out bytes.
Its 1:52 AM now, and I have cracked the challenge ! My code is 299 bytes.
The situation at home being a bit tense. I just got a phone call from my wife who is supposed to be sleeping in the other room. It was a terse “Wont you sleep?”
Anyway, I am a happy guy. As I maintain, there are only a handful of other pleasures that can equal the end of a hard day getting a piece of code to work.
The code is in Ruby and is heavily golfed (obfuscated). 299 bytes. 5 lines, each less than 80 characters. This is perfectly legal Ruby code. Reminds me of a favourite excuse of lazy-me avoiding code comments, “If it was hard to write, it should be hard to read”.
Can your favourite programming language do this under 300 bytes ?