Cube
I can solve a Rubick's Cube without looking at instructions. Some of the moves I “get”; some of them I don't, but now that they are memorized I can watch them carefully and am beginning to understand them. Cool.
Movie
I watched
The Professional. Wow. Awesome. In that, I noticed an actor I hadn't noticed before:
Gary Oldman who plays the maniacal villain, not unlike his role in
Fifth Element.
Code
I don't think I've mentioned this here before: Over the fall semester I've changed the style of my for loops for rational reasons. The way I always used to do it and what I've seen most of in the field is this:
for (int i = 0; i < n; i++)That's great, but it has some problems. What I write now is
for (size_t i = 0; i != n; ++i)The size_t is the pedantic version of unsigned int if you are going to index into arrays. The prefix increment is because ++i is never slower than i++, no matter what type i is since the prior has to return the pre-incremented value of i. That gets optimized away sometimes, but for complicated types the optimizer might not be able to figure it out. Most interesting is the use of != for a halting condition. One reason I shied away from using an unsigned index for loops is that I've been bitten by this:
for (size_t i = n - 1; n > -1; --n) // <- Bug!The bug is that i is unsigned so it will always be more than -1. The bug is actually that -1 gets converted to size_t which makes it a large positive number so the loop terminates immediately. If your halting criterion is !=, though, then the -1 gets converted to an unsigned value (232−1 on a 32-bit computer) which is exactly what you get when you decrement the unsigned integer 0. So Using != saves you from that wraparound bug.
As a novice, I thought != wasn't safe. After all, what if the computer makes a mistake and misses that one halting condition? At least < stops pretty soon, right? As a prof. last semester pointed out, the computer will always work correctly - computers don't make errors like that (if they do you are totally screwed) so you don't need to be defensive. Furthermore, if some logic error meant you missed the halting condition, you'd much rather it go on forever (or better yet crash) 'cause then you'll find out about the bug. Overrunning an array by one or a few is especially dangerous because you may never find out. Overrunning an array by 4 billion is much easier to catch.
Also, the loops with != and pre-increment are more generic - more objects are equality comparable than are less-than comparable and the same goes for pre- and post-incrementing. (E.g., you can test two linked-list iterators for (in)equality in constant time even if you can't easily say which comes first.)
Physics
From
avani, an awesome
discussion of quantum mechanics. Two quotes caught my attention:Now, what happens if you try to come up with a theory that's like probability theory, but based on the
2-norm instead of the 1-norm? I'm going to try to convince you that quantum mechanics is what inevitably results.
[link added] and...in 1998 Abrams and Lloyd used exactly this observation to
show that, if quantum mechanics were nonlinear, then one could build a computer to solve NP-complete problems in polynomial time.
[link not added]
Airplanes
Finally, I found
this list of flight cost per hour of jets interesting. Those seem a bit high compared with
other web searches, but still, a jumbo jet is at least $10,000/hr, or $166.67/minute. This was backed up by a funny segment from the flight podcast
Betty in the Sky with a Suitcase!. A
recent episode (at about 7:15) included a story of an exchange between the JFK tower and an approaching Lufthansa 747. Traffic was heavy so the plane was asked to do a 360° to move back in line. It goes something like this:
Tower: Lufthansa, we need you to do a right 360°.
Lufthansa: Do you have any idea how much fuel it costs to turn a 747 360°?
Tower: I have absolutely no idea.
Lufthansa: It costs approximately $400.
Tower: Good. Give me a $400 turn to the right.