Catching Up On Old Business
Looking back at my previous posts, I decided to revisit a few with the perspective of some time gone by.
Back in February, I compared and contrasted the eMusic and Urge music services. eMusic came out ahead and after another 2 months of use, I am still really happy with it. I've discovered a couple of great new bands and the website continues to impress me with its usability.
I just encountered my first issue yesterday when I went to use my latest batch of downloads. The previous month I had downloaded Bloc Party's latest album and wanted to get the previous one. However, these albums were now no longer available to download. A victim of their own success? I sent an email to eMusic to find out what's going on, so we'll see if then can top Urge's painfully slow response rate.
Earlier this month, I referenced the FizzBuzz test, used in interviews to quickly assess a candidate's basic level of programming skill. With a rare comment posted asking for more, here's the description and a solution:
Description:
Write a 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".
Possible Solution (in a Python interpreter):
def FizzBuzzFunc(x):
if (x % 5 == 0 and x % 3 == 0):
print "FizzBuzz"
elif (x % 5 == 0):
print "Buzz"
elif (x % 3 == 0):
print "Fizz"
else:
print x
[FizzBuzzFunc(x) for x in range(1,101)]
This is probably not the cleanest / most Pythonic way to do it, but it seems to work.
The first part is just a function definition, the form of which should look pretty familiar even if you don't know any Python.
The second part is a list comprehension, which translated into pseudo code says:
For every value "x" in the range defined from 1 to 101 (not including 101), execute the function FizzBuzzFunc with "x" as an argument,
If you've been following my blog at all, you know that I have previously mentioned some fiddling around I've done with Ruby. Well that never really took off, so next on the list was Python. The reasons for ditching Ruby and going to Python are too long to include in this post, but perhaps sometime in the future.