Posted by David Brady on November 3, 2010
Huh, that’s odd.
Just farting around, reducing the set of Integers to their prime factors—typically Friday-night stuff, amirite?—and I noticed an interesting pattern.
- Start with a keyspace of 0 and all of the integers in order as your available keys.
- Write a 0.
- You’ve exhausted the keyspace, so get another key, 1.
- Write the entire series so far, add the new key, and write the series (minus the new key) again. You should have 010.
- You’ve exhausted the keyspace again, so get another key, 2.
- Repeat: 010, 2, 010 -> 0102010.
- Repeat with 3: 010201030102010.
- Repeat with 4: 0102010301020104010201030102010.
And so on.
The “Huh!” moment is this: you’re writing the exponent of two in the prime factorization of the list of integers:
3 20 * 3
5 20 * 5
6 21 * 3
9 20 * 32
10 21 * 5
12 22 * 3
14 21 * 7
15 20 * 3 * 5
Posted by David Brady on June 5, 2010
Until last week I only knew 2 good math jokes. But then I heard this one! Without further ado, I hereby inflict it upon you:
An engineer, a physicist and a mathematician are chatting over lunch when the engineer says, “I just don’t get problems in higher dimensions. I mean, stuff in 3 dimensions I can visualize quite easily, but how do you visualize something with more?”
The physicist shrugs and says “You just have to imagine integrating. For example, if you have an object in three dimensions and integrate it over time, you have added a fourth dimension, time. It’s like taking an object’s position and integrating it to get the object’s velocity. You can do it again with time, to get the object’s acceleration, or with another dimension; each integration changes the units appropriately.”
The engineer thinks for a minute and says, “That’s okay for a few dimensions, but what about some of the really wacky stuff like 17 dimensions?”
The mathematician looks up and says, “Oh, that’s really easy, actually. Just imagine an n-dimensional space and set n=17.”
Posted by David Brady on June 4, 2010
Until last week I knew exactly 2 funny math jokes. Now I know three. I’ll post the third one tomorrow. Here’s the second one.
An engineer, a physicist, and a mathematician are asleep in a hotel when the curtains in each of their rooms catch fire. (Inexplicably, and all at the same time. Don’t ask why, it’s not important.)
The engineer wakes up and sees the fire, runs into the bathroom, fills the wastebasket with water, comes back and throws it on the fire. The fire goes out immediately, but there’s quite a bit of water damage.
The physicist wakes up and sees the fire, and pauses to estimate the rate at which the curtains are being consumed. He runs into the bathroom, fills the wastebasket with exactly 1.7 liters of water, comes back and carefully pours it on the fire. There’s a bit more fire and smoke damage due to the delay, but not a drop of water is spilled unnecessarily.
The mathematician wakes up and sees the fire, and pauses to contemplate the problem. Then he calmly walks into the bathroom. He turns on the faucet and strikes a match, then douses the match under the running water. He examines the match closely for a minute, then says, “Ah yes, this problem has a solution.” And then he goes back to bed.
Posted by David Brady on May 31, 2010
Until yesterday I knew exactly 2 funny math jokes. Now I know three. Here’s the first one.
Two math professors are arguing in a cafe about the education level of the average person. One insists that the average person has little grasp of mathematics beyond arithmetic. The other asserts that the average person knows at least rudimentary calculus. They pass their lunch in fruitless debate.
Finally, the first professor goes to the bathroom. The second professor waves the waitress over. “I am having a bit of a debate with my friend here. When he returns, I’ll ask you a question. If you answer with the exact phrase ‘one third x cubed’, I’ll leave a ten dollar tip.”
“Ten bucks? You bet,” says the waitress.
The first professor returns. The second professor announces, “Here, I’ll prove it to you.” He turns to the waitress and asks, “What is the integral of x squared?”
“One third x cubed,” replies the waitress. They both laugh and the second professor leaves the $10 tip.
As they’re leaving, the waitress mutters, “…plus a constant.”
Posted by David Brady on April 22, 2010
Yesterday I posted my Twitterable Mandelbrot, a ruby script that generates the Mandelbrot Set in 134 characters. A few of you took this as a challenge to shorten my code even further. I didn’t mind, and in fact was interested to see your results; I was sure that an extra character here or there could be shaved off.
What I didn’t expect at all was that somebody would shave fourteen characters off.
Reader brahbur on rubyflow came up with this:
a couple of these changes could be considered “cheating” (-:
Brahbur’s solution does look different; there are quote marks on each line and it outputs 1s and 0s instead of #s and .s, but the mandelbrot is still clearly visible (Edit: I reduced the size from 300×80 to 240×60 just to keep the outputs roughly the same size):
Click for larger version (1400×800)
I think this is just awesome. Once we’re playing with 0′s and 1′s, I can see another optimization:
i>98?0:1 can be replaced with
99<=>i. This bring us down to 118:
I have to give most of the credit to brahbur, though–I just saw a tiny tweak, on top of the amazing rewrite they already did. So great. THANK YOU brahbur!
Now, the challenge continues: can you shorten this further? Brahbur was concerned about “cheating”, so let’s define the rules for clarity: Output should be 240×60 (extra quotes and padding are okay) and it should be visually recognizable as a Mandelbrot set. Other than that, go for it.
Posted by David Brady on April 21, 2010
As a kid I always thought fractals were neat, but every time I tried to learn how to do them, I got lost in the math. I guess 20 years makes all the difference: today I went and read up on the Mandelbrot set and had one of those “wait, that’s it?” moments.
It took me about 15 minutes to write the program. Here’s the output:
Click for larger version (1400×800)
The whole program was about 400 characters long. I got to thinking, “that’s *almost* small enough to fit into a single tweet…” and then I spent the next hour and a half refactoring my code for size.
What do you mean I need a hobby? I have one. See?