Friday, March 09, 2007

FizzBuzz Problem

This has been on digg recently and there was some talk about it recently at work.

If you are interviewing someone and need a programming question to ask, this is a good one. Any competent programmer should be able to give you a solution.
This puzzle is typically given to all levels of programming candidates (newbie to senior) during their interview. According to numerous people, only about 10% of the programmers can pass it (even the seniors). Can you? (hint… its actually not that hard if you figure out the key).

Problem:

Write a (substitute language here) program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.
The problem is actually simple and has a simple strait forward solution, which is what makes it such a good question to ask.

A simple solution would be to setup a loop from 1 through 100, checking for numbers that are divisible by 3, 5, or both and printing the correct output.

Since taking the simple solution is boring, here's a python solution that I came up with that is only one line long.

print "\n".join([((num % 3 == 0) and (num % 5 == 0)) and 'FizzBuzz' or (num % 3 == 0) and 'Fizz' or (num % 5 == 0) and 'Buzz' or str(num) for num in range(1, 101)])

Anyway, if you think you have a cool solution post it here.

Dan

Friday, January 19, 2007

CodeMash 2007 Follow Up

Here's my wrap up on CodeMash 2007.

First, let me just say, props to the individuals (organizers, event staff, and presenters) who took part in the event. Also thanks to the sponsors who paid the bulk of the money that made the event happen. I had a blast and learned a ton.

In case you couldn't go, I was able to record the presentations that I went to. The quality isn't great, but you can hear what is being said without too much difficulty.

Here are the links.

Day 1

  1. Keynote - Domain-Specific Languages and Their Roles in the Evolution of the Programming Paradigm presented by Neal Ford.

  2. Maximum Velocity with MySQL presented by Jay Pipes

  3. The End of Tier-Based Architecture presented by Owen Taylor

  4. KeyNote - The World is Dynamic presented by Bruce Eckel



Day 2

  1. SOA: Next Wave of Enterprise Development or Return of the Son of CORBA? presented by Neal Ford

  2. Selenium Radically Simplified Testing Websites presented by Eric Pugh

  3. The Productive Programmer presented by Neal Ford

  4. Improve Your Testing with Open Source Testing Tools presented by Jim Holmes.



I would highly recommend listening to "The Productive Programmer", I found it very informative.

Also, If anyone has or knows where to get recordings of the other presentations, please let me know. There were too many good presentations to attend all of them.

Lastly, I'm posting the recording on my own, and am assuming that the presenters will not mind. If you, the presenter, do not want them posted here please contact me and I will remove them.

Enjoy,

Dan

Monday, January 08, 2007

CodeMash

CodeMash – I'll be there!

CodeMash is on January 18-19, 2007 at the Kalahari resort in Sandusky, Ohio. I would encourage anyone who can, to attend the event. There will be a wealth of programming knowledge available on topics including SOA, Java, EJB3, .NET, Python, PHP, and Ruby on Rails, and many other things. In addition, the Kalahari resort is an incredibly fun place to stay.

I'm planning to attend these sessions. Perhaps I will see you there.

Day 1

- Maximum Velocity with MySQL
- End of Tier-Based Architecture
- Building Enterprise Smart Clients using a Services Oriented Architecture
- Simplified Data Access With Spring

Day 2

- SOA: Son of CORBA
- Selenium radically simplifies testing Websites!
- The Productive Programmer
- Improve your testing with Open Source Testing Tools

Sunday, August 27, 2006

Ubuntu on Dell 1950

When it comes to putting together a kick-ass Linux box, I usually prefer building my own box. It generally works out better, I get to pick the hardware so I know it's quality and I know that the support in Linux is very good.

However, there are sometimes when building your own box isn't practical. I recently found myself in this situation, and I had to purchase some pre-built rack mountable machines from a vendor. Here's what I wanted minimally in each machine.

- 1U rack mountable
- Dual Core processor
- 64-Bit processor
- DDR2 memory
- 10K RPM SATA Hard Drive
- Dual Giga-Bit Ethernet

And I need them to be inexpensive because I was working on a small budget.

The machine I ended up selecting was the Dell 1950, which at the time was a brand new offering. Technically the machine more than met my prerequisites including the low cost. However my biggest concern was that the support for Linux would be poor.

Upon receiving the machines, I began to experimenting with two different distributions of Linux (Ubuntu Dapper Drake, and Suse 10.1). Here is what I found out.

Ubuntu (6.06) "Dapper Drake" Server
I chose the Server version from Ubuntu for the following reasons, it's absolutely free, it is only one CD to download, it takes less than 10 minutes to completely install, and it installs a very minimal set of tools which are perfect for creating a server to do just about anything. My favorite thing about Ubuntu Server is that is comes with NO servers pre-installed.

If you are going to install Ubuntu on a Dell 1950, make sure that you download the 64-bit version of Ubuntu. If you try to install the 32-bit version, the install will not complain. It will install normally, but you will not get any of the benefits of the 64-bit processors in the system.

My biggest concern was that the installer would not be able to find some of the hardware. The Ubuntu Server installer was able to find all of the hardware in the system, except the network cards (Broadcom® NetXtreme IITM 5708). At first this seemed like a major problem, however I was able to continue through the installer by telling it to ignore the fact that it couldn't find my Ethernet. Everything else installed fine. However, when the installer went to reboot the system, the screen locked up completely. Yikes! So I held in the power button, the system turned off. I powered up the system and was happily greeted by the login prompt.

After logging in, it was my first priority to try to get the Ethernet working. Upon closer examination, I found that Ubuntu had already loaded the driver I needed, and all I had to do was configure my devices. So I opened up the /etc/network/interfaces file and add records for each Ethernet device, and restart the network (sudo /etc/init.d/networking restart). Sure enough I had two fully functioning Ethernet devices.

After a little bit of poking around, it seems that the kernel on the installer CD doesn't have the driver that is needed for this network card, but that the kernel that is installed does have the correct driver. The driver that worked for me was called 'bnx2'.

In addition to my good fortune with the network cards, I found that when I rebooted the system, it no longer froze. So other than these two small gotchas I was able to get the system working perfectly, with a very minimal amount of work.

OpenSuse 10.1
I'm going to start by saying I had a major problem with the Suse installer, so I didn't pursue working with it for very long. The problem I had was that the installer wouldn't recognize the hard drive. I'm not exactly sure what the problem was because it seemed to load the drivers for the SAS controller without any problems. But something wasn't right because it couldn't find the hard drive at all.

I would imagine that if you were using Suse Enterprise edition, this problem wouldn't exist as Dell ships a CD with a special installer program that is used to give the Dell drivers to the Suse installer. Unfortunately this software would not work with OpenSuse.

Summary
If you are looking for a reasonably priced server with great performance I would recommend the Dell 1950. In addition, if you are looking to run Linux on it, I would recommend using Ubuntu Server. It is easy to setup on this hardware, and is a very solid distribution overall.