Friday, April 30, 2010

Riverworld

Depressing for two reasons. First, because I thought it was a movie when it turned out to be a pilot for a series on Sci-Fi. Quality was low. Second, because no additional episodes were ordered. The food tasted bad and the portions were too small.

What is a Memristor?

The fourth quadrant of Resistor, Capacitor, and Inductor. Insert jokes about the Three Musketeers here. I have a lot to learn, I'm just saying.

There's plenty of room at the bottom



Richard Feynman's talk at the 1959 meeting of the American Physical Society at Caltech, describing nanotechnology as an important field for future.

Yes, these are record grooves. It's what people used to listen to music before 8-track players came along.

Question of the day

This one is mine. I wonder whether people will look back on the huge oil spill in the Gulf Coast and say that it was one of the best things that ever happened to the environmental lobby, because it forestalled or cancelled all of the offshore drilling that Obama had tentatively authorized in the recent energy bill.

That hasn't happened yet, but there was a bit on NPR this morning talking about how the Oil lobby for drilling has put the permission to drill off the coast on the back burner for a while.

How to be a programmer

An article I will read again and again. The applications go beyond programming.

Steve Jobs Letter about Flash

Lots of people are talking/writing about it, but Charlie Stross I think has a good take here. Short version -- no one knows what will happen in the PC market in the next few years, but the future is mobile and the winners will be those who go all in.

Wednesday, April 28, 2010

Prob 10

Question: What is the sum of all prime numbers below 2 million? Compiled correctly and gave the right answer the first time. Booyah.

Unpublished Dilbert Cartoon


Topical. Click on cartoon to see the whole thing.

Clarke's Laws

Arthur C. Clarke formulated the following three "laws" of prediction:

1. When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.

2. The only way of discovering the limits of the possible is to venture a little way past them into the impossible.

3. Any sufficiently advanced technology is indistinguishable from magic.

Star Wars Review

A multi-part review of the Star Wars series of movies. Very funny.

Multiply digits in 1000 digit number

Interesting errors in problem #8 were arrayOutOfBounds and remembering the syntax for string class operators. Slowly the concept of object oriented programming is coming back to me, but it's not coming that quickly.

Tuesday, April 27, 2010

Off by 1

Done with problem #7. Lots of off-by-one errors around my loops to find the nth prime number. Also, a little bit of a problem with the edge case of 2 being prime, but I just manhandled it into the answer. Not pretty, but I'm tired.

New York City from staples



Gotta like this if you like New York.

Monday, April 26, 2010

5 & 6 down, 293 to go

Prob 5: Very cool problem, because the short solution (9 lines) was fast up to about first 10 integers (find lcm), then it became much slower. The long solution was not measurably slower for first 30 integers than for the first 10. If the problem had been first 30 integers, I would have had to have used the longer algorithm, but the short one gets the job done for n = 20.

Big insight on this problem was actually something that would have been a cooler solution for prob 3 -- start with 2 and just divide if you can, then change the target divisor to n/2 and repeat until you can't anymore, then move to 3 and then 4. What's cool about this is that it will pick up all the factors of 2, thus knocking out all the composite even numbers. Repeat until the number you're dividing by equals the number you've reduced your target to. Not only are you done, but (by the Sieve of Aristophanes), the last divisor is the largest prime.

Not much interesting in Prob 6. Not sure why it came after 4 & 5.

4 down

Finished problem #4, which required finding the largest six-digit palindrome number with three digit divisors. The interesting shortcuts for me on this one were that if a number has six digits, then the square root of that number will have three digits (since one million is 1000^2 and 100,000 is roughly 316^2. This made me realize that I could just check divisors starting at 999 and decrementing the potential divisor by one until I reached the square root. This dramatically cut down on the number of divisions to make each time.

It’s not a very generalizable program, unlike some of the others – finding largest prime factor of a number, find the sum of a certain number of values of a sequence – which could be used for other parameters by changing the values of some of the initial conditions. The solution program for this problem was really specifically designed to solve this problem, and it’s not really useful for other (5 digit, 7 digit, etc.) numbers. The structure is basically the same, but it would require more rewriting of the function that generates the palindrome numbers.

A more general solution would involve generating palindromes between the values of x and y and then finding the largest one that is a perfect square or something like that.

Looking at the answers, I was actually a little surprised how much I overthought it. It turns out you can just brute force all the products of 3-digit numbers and then check to see if its a palindrome and you get an answer that way, too. I'm already starting to think about the balance between code that is easy to read (i.e., a simple algorithm) versus code the runs quickly.

Saturday, April 24, 2010

IBM etches small map




"IBM researchers have developed a manufacturing technique capable of etching 1,000 three-dimensional world maps on materials the size of a grain of salt." -- article here from Slashdot.

3 down, 286 to go.

Ok, that one was hard: find the largest prime factor of a 12 digit number. Problems I ran into -- inefficient algorithms, and trouble entering in the number, since 12 digits is bigger than the largest int primitive in Java, and I needed to enter it as a long. However, I couldn't just enter it directly, because the Java compiler tried to read the number as an int, so I had to bring it in as a string, then use the Long.parseLong(string x) method in the Long class to get it into the variable before I could even get started on the algorithm.

This is as much to get me refamiliarized with Java as it is solving the problems. Long way to go . . . .

Standards



Aaron Altman: What do you think the Devil is going to look like if he's around? Nobody is going to be taken in if he has a long, red, pointy tail. No. I'm semi-serious here. He will look attractive and he will be nice and helpful and he will get a job where he influences a great God-fearing nation and he will never do an evil thing... he will just bit by little bit lower standards where they are important. Just coax along flash over substance... Just a tiny bit. And he will talk about all of us really being salesmen. And he'll get all the great women. -- Broadcast News

Nixie Tube Wrist Watch


Very cool. Not just because Woz has one, but partly . . . . Can't spend $400 on it, though.