While going about my usual business, I stumbled across an old forum thread about Chocolate Rain. There were some new posts at the end of the thread, which I found rather strange, I thought the whole phase had blown over by now. Evidently Tay Zonday is far more popular than I was to believe. He has made a song and video for Dr. Pepper’s Cherry Chocolate Cola. This is starting to remind William Hung. People who aren’t really that great singers becoming famous. I have no issue with people trying, we’re not all great. However, doesn’t it seem a little cruel to raise people to such high levels when they probably wouldn’t have been well known without people ridiculing them. On the other hand, I guess Tay Zonday has shown that possibly good things can come out of 4chan…
Archive for November, 2007
Wow, did not expect this
November 30, 2007Puzzling Myself
November 29, 2007I have been trying to think lately of an efficient way to loop over every possibility for putting a series of numbers into set positions, using each number once. For example if you had to put the numbers 1 to 10 in a line, everyone knows the total number of possibilities is 10!. However, I have no idea how I could efficiently program this. The only thing I could like of would be to use 10 for loops, each going from 1 to 10, checking the number has not already been used. This is horrible however, it requires 10^10 loops and a hideous amount of checks in each one. Any suggestions?
I’m Back Baby!
November 28, 2007Well, it’s been a while since I attempted to blog. Yes, it failed. Maybe this time it will go ahead, we’ll see! Most the time my need to blog is brought on by a sudden interest in a new thing and I guess this time is no difference. Recently I have decided to teach myself Python. I guess it came about from a combination of “Hey, I would really like to expose myself to more programming languages and get good at a few” after my experiences with learning Java and C at uni this year. I’ve always wanted to learn to program but was never motivated to go out and teach myself. Now that I have the “basics” of programming down in Java and C I should be able to teach myself Python and other languages. Python was first on the list as a lot of UCC members use and love Python.
So far I haven’t looked that deeply at the language, only looking at the first few parts of the tutorial. I was successfully able to solve a problem introduced to me by one of my friends, shmookey, that was to find a “7 digit phone number” that has the property that exactly half the numbers before it contain the number 6. For those who care I shall put it below (assume correct indentation occurs…):
#! /usr/bin/python
#Count up from 10
c = 1
for i in range(10, 9999999):
n = i
while n > 0:
if n%10 == 6:
c += 1
break
n = n/10
if 2*c == i:
print ‘The phone number is: ‘ + i
break
Not a very difficult problem to solve but at least gave me a bit of an introduction to using Python. The first thing I noticed was that I had to remove all of my semicolons and braces, I think this will take a while to get used to. Once I had it all working I noticed that Python was much slower than I expected. While I did not expect it to have a blinding speed I still thought it would run much faster. I guess for simple number crunches like this I will just revert back to C. I wont give up on Python however, while I was disappointed with the speed at which it ran, I am surprised about how simple the majority of the syntax is.