- [After a visit to New York.] If I lived in Manhattan I’d eat at Grey’s Papaya for lunch every goddamned day.
- Is it my imagination, or did bananas used to be easier to begin peeling?
- Who is the mad genius who first came up with chicken-fried bacon?
- Tonight I had the opportunity to say, “I remember Husker Du.” But no one got the joke.
- Once again I am near a drug store and can’t for the life of me remember what I’m supposed to pick up at the drugstore.
- When I shave, the beard goes first, then the mustache. The sides of the mustache go before the middle. There’s always a moment of micropanic: “If I’m interrupted RIGHT NOW, I’ll look like Hitler.”
- The Arby’s on El Camino in South San Francisco is straight out of a David Lynch movie.
- When I start a band, our first album will be called, “Reboot the Franchise.”
- Of all the songs to get stuck in my head — “Non Dimenticar”? Really?
- If I ever open a beauty salon, I’m calling it Fiat Looks.
- Is anyone else troubled by the fact that Anonymous is now a name?
- Nothing against Donald Sutherland, but Robert Culp would have made a _perfect_ President Snow.
- What are some things that have made you say, “Now I’ve seen everything”? For me, one was seeing competitive goat-pantying at the Arizona Gay Rodeo Association rodeo this past weekend. Yes: a team of two gay rodeo cowboys putting panties on a goat as fast as they can.
- [When Rush Limbaugh called a woman a slut for wanting contraceptives covered by her health plan.] Outspoken conservative blowhard says something outrageous. Entire liberal world goes apeshit — playing right into his hand. What else is new.
- I can just imagine Limbaugh’s latest performance review. “We haven’t had a major dust-up in a while, Rush. Come up with something quick, and it better be a good one.”
- Here’s my problem with Mission: Impossible: Ghost Protocol (besides too many colons in the title). The premise is, the team’s on a mission that goes horribly wrong, so they’re “disavowed” and are then completely on their own for completing it, as if that’s a big deal. But that’s the normal state of affairs for the Impossible Mission Force. “If any of your team is caught or killed, the Secretary will disavow any knowledge of your actions” means you’re ALREADY ON YOUR OWN.
- I spent decades joking that I ought to start needing glasses any day now, like all the other people around me who spend all their time on computers. Now that I finally actually _do_ need glasses, I’m experiencing outrage every time I can’t see something clearly just by pointing my eyes at it like I’ve always done.
- Though Geraldine played hard to get, Geraldo knew he’d woo her yet.
- New txting shorthand: LOLMCWWU. (Laughing out loud making coworkers wonder what’s up.) Help spread it!
- Lessons of middle age: you can eat after 9pm, or you can sleep through the night, but not both.
- Paid for coffee and croissant at Peet’s with my phone. Magic! Japan says: welcome to the 90’s.
- Today’s puzzle-of-the-day-calendar puzzle was an algebra word problem: some friends have to chip in for a cake, but then some back out and the remaining friends have to pay more, etc. I read it to my kids and asked, “Does either of you know how to approach this problem?” Archer didn’t miss a beat: “Sneak up on it from behind.”
- Nowadays every night / Flashes by at the speed of light
- I’m a muppet of a man [Followed by one of my favorite-ever status replies: “I KNEW it!”]
- I holler, you holler, we all holler for challah bread.
- The latest craze at home: vintage Gilligan’s Island episodes on Amazon Prime. I didn’t remember just how sweet Mary Ann was on Gilligan, or how much Ginger teased the Professor. Hot stuff!
- The eternal paradox: the number of different keys in which a group of people sing Happy Birthday together is always greater than the number of people singing.
- The law of conservation of behavior: When one child is in big trouble, the other one behaves himself really well.
- Five years no mom.
- Of course I’m thrilled that Obama came out in support of gay marriage. But if he fails to tie that support to a broader narrative about fairness and justice, he’ll be missing a real opportunity to educate a nation that wouldn’t recognize civics if it ran up and bit them on the ass.
- Thanks Joss, that was awesome.
- I was deeply unhappy after seeing 2010’s deplorable “Piranha 3D.” But I gotta hand it to the filmmakers, they got the sequel name right: “Piranha 3DD.”
- A paradox: the man who knows he’s no better than anyone else, actually is.
- Folding cardboard “gable-top” milk and juice cartons: They worked fine for generations, and were biodegradable to boot. Adding a plastic spout to them is like mounting a steering wheel on the back of a horse’s head. Yes, it works; yes, it makes one device resemble a similar but more modern one. But what problem does it solve, exactly?
- Superficially, Moonrise Kingdom sounds a lot like 1979’s Rich Kids: 12-year-old lovers spy on/flee from clueless parents whose relationships are in shambles.
- Every Tuesday there’s a meeting. If the president names someone at that meeting, that person dies. Tell me again why we rebelled against King George III?
- Goodbye Ray Bradbury. Thanks for the mind-expanding dreams and nightmares both.
- [For my nephew.] Your twenty-first birthday today! / But drinking would be so cliche / So I recommend / Surprising your friends / By having a cafe au lait
- I keep waiting for star systems to start slipping through the fingers of the tightening grip of conservatism, and it keeps not happening.
- “I know all about yer standards and if ye don’t mind my sayin’ so there’s not a man alive who could hope to measure up to that blend o’ Paul Bunyan, Saint Pat, and Noah Webster ye’ve concocted for yerself out o’ yer Irish imagination, yer Iowa stubbornness, and yer liberry full o’ books.”
- Two episodes in on “The Legend of Korra” (on Amazon Instant Video). To my pleasant surprise it is shaping up to be a worthy successor to “Avatar: The Last Airbender.”
- Prometheus: among the worst movies I’ve ever seen. I don’t get that many date nights with the wife. Why was I not duly and unambiguously warned? Film critique profession, you have failed me.
- [For my niece.] Birthday limerick! “There once was a girl named Mckenna / Who wanted to visit Vienna / The airfare was high / So rather than fly / She sent herself there by antenna.” Happy birthday Mckenna!
- A couple of days ago, Andrea did something out of character for her: she started humming a TV theme song. It was the theme from The Andy Griffith Show. Today Andy Griffith died. For $50,000 she will hum another TV theme song of your choice.
- Saw Rocky again last night, first time in forever. No wonder it launched Stallone into stardom. Considering what followed, it’s a surprisingly sincere, authentic, big-hearted character drama. Everything’s fresh, nothing’s cliche (yet). The best friend is actually a jerk. The slimy loan shark is actually sympathetic. The wise old trainer is actually just an embittered opportunist. Even the training montage isn’t just a training montage — it was THE ORIGINAL training montage, included because it helped show character development, not depict mere training like all the training montages that have come since (including in Rocky sequels).
- Goodbye to Donald Sobol, the man who taught me that opposite faces on a standard die always add up to 7 (and who figured out how to hang a mystery on that fact).
- This must be a milestone of some sort: while Jonah was drinking a glass of milk yesterday, Archer got him to spit it onto the table with the well-timed display of his cartoon drawing “lady with big naked boobs.”
- All those damn seeds in my teeth. How does anyone like raspberries?
- [After the movie-theater shooting spree in Colorado.] One of the great sorrows of life is having to learn how to live in a world where events like the Aurora shooting not only can happen, but do with some regularity.
- No one is allowed to make movie sequels ever, except for James Cameron and Christopher Nolan.
- [More about Aurora.] I have a GREAT idea. Every now and then, when a handful of our young people are senselessly murdered and maimed, let’s give the killer all the notoriety he was seeking, let’s utter the same platitudes and rote expressions of grief as the last time, and let’s change nothing at all. Because America’s perfect just as it is!
- How many lovely afternoon naps have been ruined by a telemarketer or a wrong number? And yet do I ever silence the ringer? No, of course not, because that would mean I was actually thinking.
- It’s too much to hope that if I’m thinking enough to silence the ringer before my next afternoon nap, I will also be thinking enough to turn it back on when I wake up.
- Thanks Suzanne Glickstein, you were right: Safety Not Guaranteed was a great movie.
- Oh my God does “Weird Al” Yankovic put on a good show.
- Archer just performed as Don John in Act I, Scene 3 of Much Ado About Nothing at the conclusion of three weeks of Shakespeare camp. He was amazing.
- The word “iconic” is hereby off limits. You all just can’t be trusted with it.
- [After watching the season 5 episode, “Dead Freight.”] The writers of Breaking Bad are twisted and brilliant.
- Have seen all three of the Marin Shakespeare Company’s productions for this season (kids too!) and have loved them so much we’re about to see one of them again.
- “There _is_ no William Windom.” “DON’T YOU THINK I KNOW THAT? THERE WAS, BUT NOT ANYMORE!”
- In. Stop. Park. Walk. Yield. Enter. Exit. One way. Jane Street. Jones Street. Park Avenue. No right turn. No left turn. What can he do? Gas. Car wash. Subway. Don’t walk. No parking. Tow-away zone. Uptown. Downtown. First Avenue. Home sweet home!
- Recently I was craving a bottle of beer, only the phrase that kept popping into my head was the old-timey expression, “I could murder a bottle of beer.” What’s up with that?
- If I ever open a pho restaurant, I’m going to call it Pho-nom-e-nom.
- [After reading the Vanity Fair article about the stunning craziness surrounding Tom Cruise and his marriages.] Just imagine all the stories about Scientology that don’t leak.
- “Keep, ancient lands, your storied pomp!” cries she
With silent lips. - One great thing about the vastness of space: years and years of “Voyager nearing the edge of the solar system” articles, and all of them are right.
- Huh. Varicose veins. Getting older is awesome. [Andrea later informed me they’re merely spider veins.]
- Since hearing the news about Neil Armstrong I have had an irresistible craving for Tang.
- [On 9/11/2012.]A detail I remember from 9/11/2001: a majority (or so it seemed) of the eyewitnesses lacked any language for describing the sight of the catastrophe other than variations of, “It was just like a movie.”
- [For my friend Joelle.] I wanted to write something clever for your birthday but couldn’t think of anything. J’oh well.
- The BBC’s “Sherlock,” apart from being excellent in itself, really rewards viewers who are familiar with the original canon.
- Even an outlandish premise can make for a good movie, if the internal logic is coherent and the other elements add up; and I’m a willing suspender of disbelief. Afterward, if the movie was crap, I will gladly blame its stupid premise if it’s warranted; but it’s the rare film whose premise I can’t grant up front. So help me, I just cannot make myself pretend to believe in cars and trucks that turn into giant battling anthropomorphic robots. [Followed by another great status reply: “But they turn into giant robots that fight! Did you not get that?”]
- Which one of us is the one we can’t trust? You say “I think it’s you,” but I don’t agree with that.
- Earlier, someone asked me if today’s date was the fourth of October. In confirming that it was, I failed to answer, “10-4.” #regret
- The International terminal at San Francisco Airport has six main entrances. They are prominently labeled “DOOR 01” through “DOOR 06.” What exactly are the leading zeroes accomplishing there?
- Guys: When you get a Facebook friend request from a hot-looking woman you don’t know, whose Friends List is all men, and you accept it, be aware that the Friends List is really a gallery of pathetic losers, and now you’re on it too.
- In 1988, I was annoyed that the movie “Beetlejuice” used dumbed-down spelling in its title because audiences would have had no idea how to pronounce Betelgeuse. Now I work for “Google.”
- [On my birthday.] So this is 46. I have GOT to learn to stop asking my knees to do things they haven’t been capable of for years.
- [Also on my birthday: the Giants won the pennant.] What a nice birthday gift the Giants just gave to me, personally!
- Everyone who knows comedy agrees that Bob Newhart was a groundbreaking comic genius. That may be true, and I have my own fond memories of being entertained by him, but don’t make the mistake I made, of putting those memories to the test by watching a 1972 episode of The Bob Newhart Show. Unwatchable with 2012 eyes.
- My most vivid fantasy is to spend a weekend with a reincarnated scientific luminary from the past, bringing him up to date on advances in science and technology that he’s missed. Does that make me weird?
- With John Michael Higgins’ performance in Pitch Perfect, this generation has finally found its Fred Willard.
- [Birthday limerick for my friend Greg.] “About a fine fellow named Greg / Folks said he’s a pretty good egg / There most men would end / But women append: / I wish he would show some more leg.”
- [Hurricane Sandy struck while my sister Suzanne was visiting from NY.] It’s Suzanne’s birthday, and if you ever doubted how awesome my sister is, I direct your attention to the tantrum that New York is throwing due to her absence for a mere day. Other people leave the city now and then, and they don’t shut down the subway!
- [On Suzanne’s birthday.] The Giants won the pennant for my birthday. They won the World Series for Suzanne Glickstein’s birthday. Happy birthday, sis!
- [After Disney acquired LucasArts.] OK Disney, this is your big chance to get on the fans’ good side. GREEDO DID NOT SHOOT FIRST. Make it right. The power is yours.
- Stupid Subway. I asked for a 6″ Cold Cut Combo with mustard, mayo, and lettuce, not a 6″ Cold Cut Combo with mustard, mayo, lettuce, and bacteria.
- [In the aftermath of Hurricane Sandy.] In nine months there are going to be so many babies.
- [Election day.] Think of that big idiot you know, the one with the deplorable politics. The responsibility for canceling out that dummy’s misguided vote — by casting your own tomorrow — is yours and yours alone. Everyone else has their own idiot to cancel.
- [The next day.] It’s almost like the whole campaign never happened. (*checks shower for Patrick Duffy*)
- [Hostess bankruptcy.] Be honest. How many Twinkies have you bought lately? It’s all your fault.
- [Almost identical to a sentiment posted earlier in the year. I must have really meant it.] Opportunities for sleeping in are so few. You’d think I’d have learned by now to unplug the phone before bed.
- I know more than I ever cared or expected to know about Transformers — names, personalities, capabilities — and it occurred to me, this is not very different from the days I knew more than I ever cared or expected to know about Thomas the Tank Engine. Transforming trainbots battling for control of the island of Sodor — that’s something I’d pay to see.
- Sir Tophamus Hattron: “You have caused confusion and delay. Prepare to be destroyed!”
- That frisson of outrage when Angry Birds ends your level just as the last pig is about to fall.
- Help me, children of the 70’s: a memory popped into my head today of a watery orange drink we used to get all the time from the school cafeteria and/or ice cream trucks. It wasn’t orange juice, it wasn’t Tang, and it wasn’t soda. It probably came in half-pint cartons. What was it? [One friend came through: It was Sun-Dew. Another replied, “I just had a total sense memory when I read the name Sun-Dew. It was not a good feeling.”]
- I am below [symbolic weight threshold] for the first time in years. Eliminating sweets, soda, and salty snacks actually works — like, immediately. Who knew?
- Just spent a fair chunk of my Sunday going back through the Facebook timeline of Steven Stern, curator par excellence, building a YouTube playlist out of all the videos he’s ever shared.
- [After the shooting spree in Newtown, Connecticut.] Back-of-the-envelope calculation: if the federal government offered to purchase every privately owned firearm for its fair market value plus $1,000, and if 50% of gun owners took advantage of this offer, it would cost about 100 billion dollars, or about 11% of what we already spend on national security.
- [More about Newtown.] Somewhere in America, right now, NRA lobbyists are hard at work, calculating how to contain the damage, keep lawmakers in line, and fan the suspicious belligerence of their base.
- That they are in crisis mode right now is a testament to the great job they did last time around.
- Today I am fully one month ahead-of-plan toward my weight-loss goal. I am *not* going to celebrate with a cupcake.
- All these interview candidates with impressive CS degrees and high-powered-sounding programming jobs at big companies you’ve heard of, and barely one in twenty can code worth a damn.
- …which is what I call “job security.”
- Here’s what bothers me about the latest idea in pop cosmology: that we’re living inside a giant computer simulation. First, it suffers from if-the-only-tool-you-have-is-a-hammer problem: in our modern age we are inclined to see computers everywhere. But more importantly, it does nothing to answer the question, “What is the nature of reality?” I mean, if _our_ reality is in some cosmic information processing device somewhere, it only begs the question, what is the nature of the reality containing that device?
- I’m not the same man I used to be. Time was, the line from It’s a Wonderful Life that best spoke to me was George Bailey railing against the forces keeping him in Bedford Falls: “I want to do what *I* want to do!” Now, merely contemplating watching that movie again, the thought of hearing Mary say, “Remember the night we broke the windows in this old house? This is what I wished for” causes my throat to close right up and my vision to go all watery. I blame Andrea Glickstein.
- Pendiculating.
- [On 12/21/2012, which we now know wasn’t the end of the world.] Eating like there is a tomorrow.
- It is better to give than to receive. Proof: as happy as my childhood memories of Christmas are, they’re nothing compared to the feeling I get from making new happy childhood Christmas memories for my kids.
Author: bobg
Sand two glosses
Ewe bed err knock rye
Ewe bed err notch out
I’m telling you eye
Sand two glosses car mint to town
He’s may king’ll list
Shaking it wise
Khan a fine tout who’s
Gnaw tea and ice
Sand two glosses car mint to town
He seize hue in yours leaping
He no swan euro ache
He no sieve you’ve bin batter could
Soapy good fur could nose ache
Ewe bed err war shout
Ewe bed err knock rye
Ewe bed err notch out
I’m telling you eye
Sand two glosses car mint to town
(Previously.)
Santa is dead. Long live Santa.
It happened on my birthday, of all days, a year ago. The boys were seven-and-a-half and nine-and-a-half. For a few months prior, whenever Santa Claus came up in conversation, whichever boy was speaking would cast me or my wife a sidelong glance and say pointedly, “a.k.a. Mom and Dad!” and the conversation would continue without further comment. So the bubble had already burst, they just lacked official confirmation — which notably they didn’t explicitly seek until we were sitting all together in the living room, getting ready to watch my birthday movie selection. When they did, I asked if they really wanted to know the truth. Archer, who is younger, just barely did, in my judgment. Jonah was burning for it.
So I opened the Wikipedia page about the real St. Nicholas and talked about him for a bit, and how he became renowned as a gift-giver. He was an ordinary man, so of course he died; but the gift-giving idea lived on.
Today, around Christmas every year, the spirit of St. Nicholas takes hold of parents everywhere. So although there’s no guy with a magical sleigh, and other parts of the story certainly are made up, still, in a very real way — and I told them this is honestly exactly what I believe — there is a Santa Claus, and Santa Claus is the idea of giving, and he/it really does travel around the whole world in a single night! He just needs us parents to do his work for him. You’ve heard of Santa’s elves? We’re it.
The boys seemed pretty happy with this explanation. Jonah, for his part, was happy merely to have Santa Claus officially debunked. I repeated my point about the reality of Santa Claus, and Archer said, “I half-believe you and I half-believe Jonah.” “Making up your own mind. I love that,” I told him.
Soon after that we let the boys see Batman Begins, despite some concerns about age-appropriateness. There’s the scene where Bruce Wayne decides he has to have a costumed alter ego:
“As a man, I’m flesh and blood. I can be ignored. I can be destroyed. But as a symbol? As a symbol I can be incorruptible. I can be everlasting.” The point being that if Bruce Wayne is ever injured or killed (or grows too old, which is the premise of Batman Beyond), someone else can don the suit and take over as Batman. In a way this is exactly what happened with St. Nicholas — the Bruce Wayne of gift-giving. Now that was a Santa explanation the kids could relate to.
How (and why) to program, part 2
It’s National Computer Science Education Week! That must mean it’s time for part 2 of my How (And Why) To Program series. Today I will discuss a tricky but powerful concept in computer science: recursion.
Briefly, recursion means accomplishing a task by performing it in terms of smaller versions of the same task. For example, each morning I execute my “drive to work” routine, which is really my “drive from point A to point B” routine, where point A is home and point B is work. To do that, I first do “drive from point A to point B” where point A is home and point B is the Golden Gate Bridge (which is about halfway to work for me), followed by “drive from point A to point B” where point A is now the Golden Gate Bridge and point B is work. Each of those steps, of course, can be decomposed into smaller “drive from point A to point B” tasks.
One classic example for illustrating recursion in computer code is the Fibonacci sequence — the mathematical sequence in which each number is the sum of the two before it. You might already see the weakness in that definition: what can the first and second numbers in the sequence be, if they don’t have two numbers before them that can be added together? This is a key feature of recursive functions: at some point they reduce the problem into parts so small that they reach the “base case,” where the recursive rule breaks down. It happens that the base case of the Fibonacci sequence says the first two numbers are 0 and 1. From there, the recursive rule takes over to give the numbers that follow: 1, 2, 3, 5, 8, 13, 21, 34, and so on.
Let’s look at a “function,” which is the computer programming equivalent of a recipe: you give it some inputs, and it gives you an output, the result of processing the inputs in specific ways. Our function is called fibonacci and it takes one input, or “argument”: a number, which we’ll call n. The result of fibonacci(n) will be the nth number in the Fibonacci sequence, where the first two numbers — fibonacci(0) and fibonacci(1) (recall that in programming, lists and sequences of things are almost always numbered beginning at zero) — are 0 and 1.
As before, code samples are presented in the Python programming language, though the same concepts we’re discussing apply to most other programming languages too.
def fibonacci(n): if n == 0 or n == 1: return n else: return fibonacci(n-1) + fibonacci(n-2)
We start with “def fibonacci(n),” which simply means “define a function named fibonacci taking one argument called n.” The body of the function follows. First it checks for the base case: does the caller (whoever is invoking this function) want one of the first two Fibonacci numbers? If so, the function simply “returns” (or hands back to the caller) the value of n, since by coincidence the value of fibonacci(n) is n when n is 0 or 1.
If it’s not the base case, the function returns a different value: the sum of invoking fibonacci first on n-1 and then on n-2. Those recursive calls give the two prior Fibonacci numbers. For instance, if we invoke fibonacci(9), then n is 9 and fibonacci(n-1) is fibonacci(8), which is 21; and fibonacci(n-2) is fibonacci(7), which is 13. Adding those together gives 34, which is the correct result for fibonacci(9).
Enough about the Fibonacci sequence. It’s a contrived example and, though it explains recursion pretty well, it doesn’t demonstrate the real-world applicability of the technique. (It also happens that, for reasons I won’t go into here, recursion is a terribly inefficient way to compute Fibonacci numbers compared to other possibilities like iteration.)
A few days ago, my Mensa Puzzle-a-Day Calendar presented this riddle:
The letters of a certain three-letter word can be added in sequential order (though not necessarily with all three letters together in the same place) to each of the letter strings below to form common, uncapitalized English words. You don’t need to rearrange any of the letters below. Simply add the three needed letters in sequential order. What is the three-letter word, and what are the nine new words formed?
1. alp 2. wl 3. marit 4. ealus 5. urneman 6. cke 7. disintedl 8. traectr 9. epard
(To illustrate the puzzle: the letters of what three-letter word can be inserted in both “hoyde” and “ckear” to produce common English words? The answer is “new,” to produce “honeydew” and “neckwear.”)
Staring at the puzzle for a while, I was unable to solve it. So I sat down and wrote a program to solve it for me. How’s that for real-world applicability?
Once again I relied on the file /usr/share/dict/words (or sometimes /usr/dict/words, or /usr/lib/dict/words) that is a standard feature of some operating systems; it’s simply a list of many common English words (and many uncommon ones, plus some frankly questionable ones), one per line. Reading that file, I produced two sets of words: one set of all the words, and one set of all three-letter words. Here’s how that looks:
three_letter_words = set() all_words = set() wordlist = open('/usr/share/dict/words') for word in wordlist: word = word[:-1] all_words.add(word) if len(word) == 3: three_letter_words.add(word) wordlist.close()
(Very similar code is explained in detail in part 1 of this series.)
With those two word sets in hand, and the nine letter-strings from the puzzle, this was my strategy: try all possible ways of inserting the letters of all the three-letter words in each of the letter-strings. For any three-letter word, if none of its combinations with a given letter-string produces a valid word, remove the three-letter word from further consideration. In other words, beginning with all possible three-letter words, we whittle them away as they become disqualified. In the end, the only three-letter words left should be ones that combine, one way or another, with all of the nine letter-strings to produce valid words.
So, for example, the three-letter words “see” and “era” both can be added to the letter-string “alp” to produce valid words (“asleep” and “earlap”). But the three-letter word “new” can’t be, so after running through all the three-letter words on the letter-string “alp,” “see” and “era” will still be in the set three_letter_words, but “new” won’t be.
Here’s how that strategy looks:
for string in ("alp", "wl", "marit", "ealus", "urneman", "cke", "disintedl", "traectr", "epard"):
This starts a loop that will run nine times, once for each letter-string, giving each letter-string the name “string” on its turn through the body of the loop.
three_letter_words_to_discard = list()
This creates an empty list called three_letter_words_to_discard. It’s empty now but as we progress we will fill it with words to remove from the three_letter_words set.
(If you’re wondering why I sometimes use lists for collections of things, and sometimes use sets, gold star! The answer is that they are two different kinds of data structure, each one good at some things and bad at others. A set is very fast at telling you whether a certain item is in it or not; a list is slow at that. On the other hand, a list keeps things in the same order in which you added them; a set doesn’t do that at all.)
for three_letter_word in three_letter_words:
This starts a nested loop. It’ll run through the complete list of three_letter_words each of the nine times that the outer loop runs.
combinations = combine(three_letter_word, string)
Here we presume there’s a function called combine that takes the current three-letter word and the current letter string, and produces the complete list of ways that the letters of three_letter_word can be interspersed with the letters of string. For example, combine(“abc”, “def”) should produce the list [“abcdef”, “abdcef”, “abdecf”, “abdefc”, “adbcef”, “adbecf”, “adbefc”, “adebcf”, “adebfc”, “adefbc”, “dabcef”, “dabecf”, “dabefc”, “daebcf”, “daebfc”, “daefbc”, “deabcf”, “deabfc”, “deafbc”, “defabc”]. That’s where recursion is going to come into play. We’ll get to writing the combine function in a moment.
good_combinations = list() for combination in combinations: if combination in all_words: good_combinations.append(combination)
With the list of combinations in hand, we now look through them to see which of them are valid words, if any. We set good_combinations to be a new empty list where we’ll accumulate the valid words we find. We loop through the combinations, testing each one to see if it’s a member of the set all_words. If one is, we add it to the list good_combinations.
if good_combinations: print three_letter_word, "+", string, "=", good_combinations else: three_letter_words_to_discard.append(three_letter_word)
After the “for combination in combinations” loop, we check to see whether good_combinations has anything in it. (“If good_combinations” is true if the list has something in it, and false otherwise.) If it does, we print out the current three-letter word, the current letter-string, and the list of valid words they make. If it doesn’t, then three_letter_word goes into our list of three-letter words to discard.
for word in three_letter_words_to_discard: three_letter_words.remove(word)
After the “for three_letter_word in three_letter_words” loop, this small loop does the discarding of disqualified three-letter words.
Why not simply discard those words from three_letter_words in the preceding loop, as we run across them? Why save them up to remove them later? The answer is that when you’re looping through the contents of a data structure, it’s a bad idea to add to or remove from the data structure. The loop can get confused and lose its place in the structure. It may end up running twice with the same list member, or skip a member entirely. It’s safe to make changes to the membership of the data structure only after the loop finishes.
Finally, after the outermost loop has finished, it’s time to see which three-letter words remain in our set:
print three_letter_words
And that’s all! All except the tricky part: the combine function. Here is how it starts:
def combine(string1, string2):
It takes two strings. We’ll give them generic names, string1 and string2, so as not to assume that either one is a three-letter word. As you’ll see, often neither one is.
Now, how to approach writing a recursive function? It’s usually a safe bet to start with the base case, the conditions under which combine isn’t recursive. The recursive step will involve passing shorter and shorter strings to combine, so the base case is when one or both of the strings is empty. Obviously if either string is empty, the result should be the other string — or more precisely, the list containing the other string as its one member (since we’ve already stipulated that the result of combine is a list of strings). In other words, combine(“”, “def”) should produce the list [“def”] — which after all is the result of interspersing the letters of “” among the letters of “def” — and combine(“abc”, “”) should produce [“abc”].
So here’s the body of combine so far. It’s just the base case:
if len(string1) == 0: return [string2] elif len(string2) == 0: return [string1]
(Recall that “elif” is Python’s abbreviation for “else if.”)
Now for the case where string1 and string2 are both non-empty; the recursive case. The key to writing the recursive step of a function like this is figuring out (a) how to make the problem the same but smaller, and then (b) what to do with the result of computing the smaller solution.
One way to make the problem smaller is to lop off the first letter of string1. So if combine were originally invoked with the strings “abc” and “def,” the recursive call would invoke it with “bc” and “def.” Presuming combine works correctly — which is the counterintuitive assumption you must always make about the recursive step in a function like this — we’ll get back the list [“bcdef”, “bdcef”, “bdecf”, “bdefc”, “dbcef”, “dbecf”, “dbefc”, “debcf”, “debfc”, “defbc”]. None of those belongs in the result list of combine(“abc”, “def”); but if we now restore to the beginning of each of those strings the same letter we lopped off, we get [“abcdef”, “abdcef”, “abdecf”, “abdefc”, “adbcef”, “adbecf”, “adbefc”, “adebcf”, “adebfc”, “adefbc”]. This is halfway to the complete answer: it’s all the strings in the result list that begin with the first letter of string1. We only need to add all the strings in the result list that begin with the first letter of string2, and we’re done. We do this by treating string2 the same way we just treated string1: we lop off its first letter in another recursive call to combine, then paste it back on to each string in the result. Continuing the example, this means calling combine(“abc”, “ef”), which produces [“abcef”, “abecf”, “abefc”, “aebcf”, “aebfc”, “aefbc”, “eabcf”, “eabfc”, “eafbc”, “efabc”]. Sticking the “d” back onto the beginning of each of those strings gives [“dabcef”, “dabecf”, “dabefc”, “daebcf”, “daebfc”, “daefbc”, “deabcf”, “deabfc”, “deafbc”, “defabc”], and adding this list to the list from the first recursive call gives the complete solution.
In Python, the first letter of string is denoted string[0]. The rest of string, without its first letter, is denoted string[1:]. So here’s the complete version of combine, with the (double) recursive step added in.
def combine(string1, string2): if len(string1) == 0: return [string2] elif len(string2) == 0: return [string1] else: recursive_result1 = combine(string1[1:], string2) recursive_result2 = combine(string1, string2[1:]) result = [] for string in recursive_result1: result.append(string1[0] + string) for string in recursive_result2: result.append(string2[0] + string) return result
This is the crazy magic of recursion: at each step, you simply assume the next-smaller step is going to work and give you the result you need. All you have to get right is the base case and the way to process the recursive result, and — well, look:
hol + alp = ['alphol'] has + alp = ['alphas'] sae + alp = ['salpae'] her + alp = ['halper'] see + alp = ['asleep'] eta + alp = ['aletap'] era + alp = ['earlap'] soe + alp = ['aslope'] yin + alp = ['alypin'] pus + alp = ['palpus'] een + alp = ['alpeen'] kas + alp = ['kalpas'] ecu + alp = ['alecup'] ist + alp = ['alpist'] doh + alp = ['adolph'] pal + alp = ['palpal'] cul + alp = ['calpul'] ped + alp = ['palped'] Moe + alp = ['Malope'] clo + alp = ['callop', 'callop'] gos + alp = ['galops'] tid + alp = ['talpid'] yum + alp = ['alypum'] pon + alp = ['palpon'] hin + alp = ['alphin'] joy + alp = ['jalopy'] hol + wl = ['wholl', 'wholl'] sae + wl = ['swale'] soe + wl = ['sowel', 'sowle'] joy + wl = ['jowly'] joy + marit = ['majority'] joy + ealus = ['jealousy'] joy + urneman = ['journeyman'] joy + cke = ['jockey'] joy + disintedl = ['disjointedly'] joy + traectr = ['trajectory'] joy + epard = ['jeopardy'] set(['joy'])
PayPal arbitration opt-out
Bob Glickstein
[address]
[phone number]
[e-mail address]
13 Oct 2012
PayPal, Inc.
Attn: Litigation Department
2211 North First Street
San Jose, CA 95131
To whom it may concern,
I am a PayPal user at the e-mail address above. I do not agree to the Agreement to Arbitrate as delineated in your Amendment to the PayPal User Agreement and Privacy Policy dated Nov 1st, 2012. By this letter I hereby reject it per the opt-out procedure described in section 14.3 (e). Kindly exclude me from the Agreement to Arbitrate.
I further request that you consider dropping the arbitration clause altogether, for all your customers, as a matter of principle. Hand-wringing about frivolous lawsuits notwithstanding, citizen access to the public court system is one of the things that makes America great. I invite you to read my fuller thoughts on the matter at www.geebobg.com/2008/09/20/the-sue-s-of-a/
Timely written acknowledgment of this request sent to the above address would be greatly appreciated.
Sincerely,
[signature]
Bob Glickstein
Where were you in ’62?
Happy birthday to Beatlemania! The Beatles’ first single, “Love Me Do,” was released on this date fifty years ago. And happy birthday to James Bond! Dr. No, the first movie in the world’s longest-running film franchise, also opened today, also in 1962.
Earlier this year we observed the fiftieth anniversary of John Glenn’s historic orbit of the Earth, and the fiftieth anniversary of Kennedy’s landmark “we choose to go to the moon” speech.
In 1962, Stan Lee and the other adolescents at Marvel (I use the term affectionately) created Spider-Man, Thor, and the Hulk. Fifty years later, those creations are still relevant enough to star in their own brand-new blockbuster films.
The films Lawrence of Arabia, To Kill a Mockingbird, and The Music Man are fifty years old too. The famous escape from Alcatraz happened fifty years ago. The Seattle Space Needle opened to the public. Polaroid introduced its instant color film. Rachel Carson published her world-changing book, Silent Spring.
I don’t recall celebrating so many fiftieth anniversaries last year, do you? Something about 1962 appears to have been so special that we are still celebrating its achievements and events.
It wasn’t all good. People everywhere braced for global annihilation during the Cuban Missile Crisis, fifty years ago this month. Marilyn Monroe OD’d. But there was enough nostalgia for 1962 that, years later, George Lucas set the events of American Graffiti in that year, and it’s also when the action in Animal House takes place.
What was it about 1962? Fifty years from now, what events or achievements of today will people still be celebrating?
The arrow that springs from the bow
In 1996, some friends and I started our own software company, Zanshin. But by 1999, suffering from a lack of focus and a tendency toward overengineering, we had still not managed to produce a salable version of our world-changing software. Luckily for us we got a consulting gig for Amazon.com (unrelated to my involvement with the Internet Movie Database). That contract went so well that after a few months of it, in early 2000, Amazon offered to hire us all. We would have to close Zanshin and move up to Seattle. Andrea and I, newly married, got as far as scoping out Seattle neighborhoods. We were leaning toward accepting Amazon’s offer. Zanshin clearly was going nowhere, and Amazon had interesting work for us.
We had a Zanshin company meeting to talk it over. Some of us wanted to accept, some wanted to keep trying with Zanshin. We had the frank discussion about our plans and lack of progress that we should have been having all along. In the process, we brainstormed some exciting new ideas. In the days that followed we fleshed those out. The uninspired daily grind that working at Zanshin had become took on a new feeling of hopefulness. My co-worker Steve, who had also been in favor of the Amazon offer, gave a stirring speech about continuing on our own.
When it came time to give Amazon our final decision, we voted unanimously to turn them down. Knowing I’d previously been the strongest vote in favor of the Amazon offer, my co-worker Greg asked if I was sure. I replied, “I’m like the arrow that springs from the bow. No hesitation.”
It was a line spoken by Michael O’Hare as Jeffrey Sinclair in Babylon 5. I have used that sentiment a few times since then as a way to gauge my readiness for something — starting a family, for instance. If I can’t say that line with conviction I know I’m kidding myself.
Today came news that Michael O’Hare died. Nerds all over the web are paying him tribute for his role in a beloved space adventure, but his legacy is a little more personally meaningful to me. His memorable reading of that one line has attended every important decision of my life since he spoke it.
Who are the real monsters?
A British film about Americans in Mexico. That seemed odd. But it didn’t stop me from watching 2010’s Monsters on Netflix recently, and enjoying it.
It’s six years after a NASA probe to Jupiter’s moons crash lands on its return to Earth, “infecting” an area of Northern Mexico near the U.S. border with samples of alien life, which thrive there and multiply, growing huge and destructive. The U.S. has erected an enormous wall along its Mexican border and its military makes regular incursions across it to suppress the creatures and limit their spread. Our two main characters have to make it back to the U.S. while traveling dangerously near, and eventually through, the infected zone. Their journey has a vérité feel and is full of suspense, with a few moments of terror and some interesting character development. By the end I found it compelling enough to go online and see what opinions others had written about it.
I was disappointed by what I found. Without exception the reviews and opinions that I read evaluated Monsters as a conventional monster movie — that is, as a mere shocker — and by that metric many critics found it lacking in terms of horror and body count and creature biology and so on, though everyone commended the guerrilla filmmaking techniques and how far the tiny budget was stretched for the sake of producing credible special effects. The principal filmmaker, Gareth Edwards, is now being talked about as a hot new talent for directing sci-fi epics.
All of which was missing the point. Not one writer commented on the glaringly obvious subtext, the very reason the film was made and the answer to why a British filmmaker chose Mexico as his setting and Americans as his characters: it’s a story about the failure of America to adapt to a changing world.
[Spoilers follow.]
Basket handle protocol
There is no hope, and here’s the proof: shoppers often stack empty store baskets with one handle positioned as shown.
It’s widely agreed that if we’re going to save the world, we have to plan beyond the next quarterly statement, stop being so selfish, reduce our footprint, eat less beef, burn less oil, invest in infrastructure, conserve resources for future generations. But how can we keep future generations in mind when we can’t even keep in mind the next shopper who has to stack an empty basket?
Please, let the future begin. Keep the next shopper in mind and move your empty basket handles to the sides.
Predicting the present
One day long ago, when the IBM PC was still new, my friend Mike asked me to imagine my ideal computer. I described something very like the IBM PC, but with more memory and a bigger hard drive — 50 megabytes, say, instead of 10 or 20. I couldn’t imagine any use for much more than that. (Today of course you can’t even buy a thumb drive that tiny.) I grudgingly allowed that a bitmap display might be more useful than the 80-column-by-24-line character terminal that PC’s had, but that was all I would consider adopting from the then-brand-new Apple Macintosh, which I dismissed as a silly toy unworthy of Real Programmers.
“Why?” I asked Mike. “What’s your ideal computer?”
Mike described something no bigger than an 8.5×11 sheet of paper and no more than an inch or so thick, whose entire surface was a full-color display. It could be carried in the hand or slipped into a backpack. “What about the CPU, where would that go?” I asked. I wasn’t getting it. Mike patiently explained that the whole system — CPU, RAM, video driver, power supply — was inside that little slab. I scoffed. Cramming everything into such a small space was obviously impossible, and no battery that could fit in such a thing would ever have enough power to spin a floppy disk drive for long. “Anyway, even if you could build it,” I told him, “it wouldn’t be as convenient as you’d like. You’d have to carry around a keyboard too and plug it in every time you wanted to use it.” No you wouldn’t, said Mike. The display could be touch-sensitive. The keyboard could be rendered on the screen as needed and input accepted that way.
This was 1984. What Mike described was pure science fiction. (In 1987 that became literally true, when the touch-controlled “padd” became a staple prop on Star Trek: The Next Generation.) Yet here I am, the proud new owner of a Nexus 7, the latest in high-powered touch-sensitive computing slabs that put even Mike’s audacious vision to shame.
It wasn’t the first time I’d had a failure of technological vision, nor was it the last.
Several years earlier, before even the IBM PC, I was spending a lot of afterschool hours at my friend Chuck’s house, and a lot of those hours on his dad’s home computer, one of the only ones then available: the beloved but now mostly forgotten Sol-20. (The TRS-80 and the Apple ][ were brand new and just about to steal the thunder from hobbyist models like the Sol-20.) It had a small black-and-white monitor that could display letters, numbers, typographical marks, and a few other special characters at a single intensity (i.e., it really was “black and white,” not greyscale). It looked like this:
The display was so adequate for my meager computing needs there in the late 1970’s that when the computer magazines I read started advertising things like Radio Shack’s new Color Computer (that’s what it was called — the “Color Computer”), I dismissed them as children’s toys.
Once, Chuck and I entertained the idea of making a little science fiction movie. A scene in Chuck’s script had a person’s face appearing on a computer monitor and speaking to the user. It was his plan to film this scene using his father’s computer. I said, “How are we going to make a face appear on a computer monitor?” I had only ever seen letters and numbers blockily rendered on it. Chuck pointed out that the monitor was really just a small TV. “Oh yeah,” I said, feeling stupid. It ought to be able to display anything a TV could. Of course we’d have to hook it up to a different source; obviously no computer could handle rendering full-motion video. Yet here I am, a software engineer at YouTube.
There’s more. In the mid 80’s, my sometime boss Gerald Zanetti, the commercial food photographer and computing technophile, once described his vision for composing and editing photographs on a high-resolution computer display. If a photograph included a bowl of fruit, he explained, he wanted to be able to adjust the position of an orange separately from the grapes and the bananas surrounding it. I said that such technology was far in the future. I’d seen graphics-editing programs by then, but they treated the image as a grid of undifferentiated pixels. Separating out a foreground piece of fruit from other items in the background simply was not feasible. Yet just a couple of years later Photoshop exactly realized Zanetti’s vision.
In the mid 90’s, when the web was new, my friend and mentor Nathaniel founded a new company, First Virtual, to handle credit card payments for Internet commerce. At the time there was no Internet commerce. Nathaniel and company invented some very clever mechanisms for keeping sensitive credit-card information entirely off the Internet while still enabling online payments. But I felt their system was too complicated to explain and to use, that people would prefer the familiarity and convenience of credit cards (turns out I was right about that), and that since no one would (or should!) ever trust the Internet with their credit card information, Internet commerce could never amount to much. Yet here I am, receiving a new shipment of something or other from Amazon.com every week or two.
Oh well. At least I’m in good company. I’m sensible enough finally to have learned that however gifted I may be as a technologist, I’m no visionary. Now when someone describes some fantastical new leap they imagine, I shut up and listen.