Have you been asked a ‘FizzBuzz’ question in a technical interview?

This question popped up in my daily email digest from Quora:

Are there really programmers with computer science degrees who cannot pass the FizzBuzz test?

Ok. I’ve been a professional software developer for 22 years (not including hobbyist coding before graduating and starting work) and I have a Computer Science degree. What is this FizzBuzz test? Now I’m curious. I admit it’s been a while since I’ve been for a job interview, but I’m aware of the current trend to ask interview questions to determine a candidate’s ability to solve problems. ‘FizzBuzz’ refers to a school game where you as a group you take turns in counting, but replace ‘Fizz’ if the current number is divisible by 3, ‘Buzz’ if divisible by ‘5’, or ‘FizzBuzz’ if divisible by both (or something similar, along those lines).

So the interview question is: write code that counts from 1 to 100, and outputs the number, or Fizz, Buzz, or FizzBuzz according to these rules.

The point of the question is not to write the most elegant, or brilliantly clever solution to the problem, the point of the question is to establish whether the interview candidate can write code demonstrating elementary software development concepts such as iteration and boolean logic conditions. If you’ve ever conducted technical interviews before then you won’t be surprised that you will come across candidates who say they have x years of experience in coding in language XYZ, but it’s pretty obvious that they can’t code anything at all. Jeff Atwood commented on this in a post here.

My first attempt at writing this straight up with little thinking, I wrote this:

Once I’d written this, it concerned me that I had the mod 5 test twice, so I tried to optimize the logic to not repeat this test, and my second attempt resulted in code that didn’t write out the correct expected results. I think this is the second part of the point of this question – it’s a puzzle where it appears there should be an elegant solution, but there really isn’t. Gayle McDowell’s answer to this question on Quroa calls this the ‘Smart Person’s Mirage’ – it seems like there should be a smart answer to the question, but there really isn’t.

Other than being lured in to try and answer this question myself since I’d never heard of this before, I guess the lesson here is that it’s not really the answer that counts, it’s how you approach the problem, and the process you take to solve the problem.

mdm crashing after upgrade from Mint 17.3 to Mint 18 (and solution)

I recently upgraded my Mint 17.3 to Mint 18 using mintupgrade and following the instructions here, and unluckily had a powercut while in the middle of the upgrade. When I rebooted, some things had changed, like the logon screen had new background images, and the grub menu now said ‘Mint 18’, but as soon as I logged on, mdm crashed and there was a dialog saying that XWindows had crashed within seconds of starting. The popup dialog said to check ~/.xsession-errors, which contained this error:

initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
syndaemon: no process found

A quick Google found this question with the same error message, and following the suggestion to run ‘sudo apt-get install cinnamon’ fixed my issues. I restarted mdm with ‘sudo service mdm restart’, logged on and eveything was good.

I’m not entirely sure how much of the upgrade completed, so re-running ‘mintupgrade upgrade’ again still prompted for a number of packages to be deleted or upgraded. Completed the upgrade, rebooted, and now everything looks good.

This could have been a lot worse, but luckily was able to recover with no noticeable issues so far. And Mint 18 looks great! (I like the new window animations!)

Docker Swarm node set up with Docker 1.12 RC on Raspberry Pi

I’ve been following through the steps in this article to set up a Docker swarm cluster on a pair of Raspberry Pis. Most of the steps work as-is from Mac OS, but for a few steps there’s a couple of variations.

This is most likely going to be part 1 of a few posts as I work through and get this working.

For example, to copy your ssh key to the Pis, instead of:

ssh-copy-id pirate@pi3.local

… you can do (from tip here):

cat ~/.ssh/id_rsa.pub | ssh user@machine "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys"

To switch between remote hosts:

eval $(docker-machine env pi1)

where pi1 is the name of the remote host.

To switch back to the localhost (not entirely obvious but found the answer here):

eval "$(docker-machine env -u)"

After ‘swarm init’ and adding the other nodes to the cluster, ‘docker swarm ls’ lists the nodes in the cluster:

More to come in part 2:-)

Installing kernel headers for Oracle Linux 6 on VirtualBox

The usual reason for Guest Additions failing to install on a Linux guest on Virtual Box is that the kernel headers are missing. How you install these or where they come from varies from distro to distro, although they’re usually available via the package manager on that distro.

I had an Oracle Linux 6 guest installed, Guest Additions (for video drivers, shared folder, clipboard sharing) was all working, and then at some point I started it up again and it was no longer working and wouldn’t re-install either. Seems like I’d picked up an update, and I needed to update the kernel headers too.

This post covers the steps needed. On OE6 before installing the Guest Additions, just run ‘yum install kernel-uek-devel’ and you should be good to go (assuming you’re booting with the ‘unbreakable kernel’ and not the RHEL compatible kernel)