Howdymattic Outtakes

Yesterday, I shared with you the introduction video I made for my new employer. A few friends commented that it seemed very well-presented and complimented me on my presentation, so I thought I’d dispel the illusion by providing this: the “outtakes”. My process was to write a loose script and then perform it multiple times (while being sure to wear the same hoodie) over the course of several days as I walked or cycled around, and then take only the “good” content.

That I’m able to effortlessly make a longer video out of a selection of the outtakes should be evidence enough that I’m just as capable of mucking-up a simple task as anybody else, probably moreso.

You may observe in this video that I made a number of “Hey, I found a…” snippets; I wasn’t sure what would scan best (I eventually went with “Hey, I found a… nothing?”). Folks who’ve seen this video have already criticised my choice; apparently the cow I found was more photogenic than me.

Also available on: VideoPress, QTube, YouTube.

Time-Efficient Shuffling

Some years ago, a friend of mine told me about an interview they’d had for a junior programming position. Their interviewer was one of that particular breed who was attached to programming-test questions: if you’re in the field of computer science, you already know that these questions exist. In any case: my friend was asked to write pseudocode to shuffle a deck of cards: a classic programming problem that pretty much any first-year computer science undergraduate is likely to have considered, if not done.

Interview with paper visible.
Let’s play at writing software. Rather than a computer, we’ll use paper. But to make it sound techy, we’ll call it “pseudocode”.

There are lots of wrong ways to programmatically shuffle a deck of cards, such as the classic “swap the card in each position with the card in a randomly-selected position”, which results in biased results. In fact, the more that you think in terms of how humans shuffle cards, the less-likely you are to come up with a good answer!

Chart showing the probability bias for an incorrectly-implemented Fisher-Yates shuffle, for a 6-card deck.
If we shuffled a deck of six cards with this ‘broken’ algorithm, for example, we’d be more-likely to find the card that was originally in second place at the top of the deck than in any other position. This kind of thing REALLY matters if, for example, you’re running an online casino.

The simplest valid solution is to take a deck of cards and move each card, choosing each at random, into a fresh deck (you can do this as a human, if you like, but it takes a while)… and that’s exactly what my friend suggested.

The interviewer was ready for this answer, though, and asked my friend if they could think of a “more-efficient” way to do the shuffle. And this is where my friend had a brain fart and couldn’t think of one. That’s not a big problem in the real world: so long as you can conceive that there exists a more-efficient shuffle, know what to search for, and can comprehend the explanation you get, then you can still be a perfectly awesome programmer. Demanding that people already know the answer to problems in an interview setting doesn’t actually tell you anything about their qualities as a programmer, only how well they can memorise answers to stock interview questions (this interviewer should have stopped this line of inquiry one question sooner).

Riffle shuffling
Writing a program to shuffle a deck takes longer than just shuffling it, but that’s hardly the point, is it?

The interviewer was probably looking for an explanation of the modern form of the Fisher-Yates shuffle algorithm, which does the same thing as my friend suggested but without needing to start a “separate” deck: here’s a video demonstrating it. When they asked for greater efficiency, the interviewer was probably looking for a more memory-efficient solution. But that’s not what they said, and it’s certainly not the only way to measure efficiency.

When people ask ineffective interview questions, it annoys me a little. When people ask ineffective interview questions and phrase them ambiguously to boot, that’s just makes me want to contrive a deliberately-awkward answer.

So: another way to answer the shuffling efficiency question would be to optimise for time-efficiency. If, like my friend, you get a question about improving the efficiency of a shuffling algorithm and they don’t specify what kind of efficiency (and you’re feeling sarcastic), you’re likely to borrow either of the following algorithms. You won’t find them any computer science textbook!

Complexity/time-efficiency optimised shuffling

  1. Precompute and store an array of all 52! permutations of a deck of cards. I think you can store a permutation in no more than 226 bits, so I calculate that 2.3 quattuordecillion yottabytes would be plenty sufficient to store such an array. That’s about 25 sexdecillion times more data than is believed to exist on the Web, so you’re going to need to upgrade your hard drive.
  2. To shuffle a deck, simply select a random number x such that 0 <= x < 52! and retrieve the deck stored at that location.

This converts the O(n) problem that is Fisher-Yates to an O(1) problem, an entire complexity class of improvement. Sure, you need storage space valued at a few hundred orders of magnitude greater than the world GDP, but if you didn’t specify cost-efficiency, then that’s not what you get.

Stack of shuffled cards
If you’ve got a thousand galaxies worth of free space you can just fill them with actual decks of cards – one for each permutation – and physically pick one at random. That sounds convenient, right?

You’re also going to need a really, really good PRNG to ensure that the 226-bit binary number you generate has sufficient entropy. You could always use a real physical deck of cards to seed it, Solitaire/Pontifex-style, and go full meta, but I worry that doing so might cause this particular simulation of the Universe to implode, sooo… do it at your own risk?

Perhaps we can do one better, if we’re willing to be a little sillier…

(Everett interpretation) Quantum optimised shuffling

Quantum ungulations
If you live in a universe in which quantum optimised shuffling isn’t possible, the technique below can be adapted to create a universe in which it is.

Assuming the many-worlds interpretation of quantum mechanics is applicable to reality, there’s a yet-more-efficient way to shuffle a deck of cards, inspired by the excellent (and hilarious) quantum bogosort algorithm:

  1. Create a superposition of all possible states of a deck of cards. This divides the universe into 52! universes; however, the division has no cost, as it happens constantly anyway.
  2. Collapse the waveform by observing your shuffled deck of cards.

The unneeded universes can be destroyed or retained as you see fit.

Let me know if you manage to implement either of these.

So You Want To Start An Unpopular Blog

This article is a repost promoting content originally published elsewhere. See more things Dan's reposted.

Very occasionally I get asked how to start blogging by people who would like to create exciting and engaging articles that will build a following by delighting an audience hungry for more. Perhaps they envision spreading their views far across the face of the web.

To which I always reply, “Have you read my blog? I don’t know about any of those things!”

What I do have are 10 years of logs and some vague observations about beginning a blog.

As I’m sat here anyway, helping people get started on the Indieweb, here’s a great (tongue in cheek) look at how you can expect your new blog Indieweb presence to take off and become the Most Popular Thing Ever. Or rather, not.

But as I and others have said before, my blog is first and foremost for me. If you get something out of it too, that’s great, but that’s a secondary goal!

Caverna Do Dragão

This article is a repost promoting content originally published elsewhere. See more things Dan's reposted.

Dungeons & Dragons (80s TV show)Remember that 80s TV show Dungeons & Dragons?

It turns out that Renault’s target customer base in Brazil do, too. Presumably it was a way bigger deal over there than it was here, because this new car ad feels like it could genuinely be a trailer for a live-action reboot of the series. And now I want to watch it.

(I do have some questions, though. Like: Diana was only 14 years old when she and her friends were transported to the Realm of Dungeons and Dragons… so when did she learn to drive? Am I supposed to believe that she just rolled a natural 20 on that driving check? And where does Sheila go when she turns invisible so that Bobby doesn’t end up sitting on her transparent-lap? And how does the car’s navigation computer work: are we to believe that there’s a GNSS network in the skies above the Realm? The Internet must know!)

Danny Daycare

This article is a repost promoting content originally published elsewhere. See more things Dan's reposted.

“Have you had a good wee day out?”

This isn’t how I behave when I’m out cycling with one of our little ‘uns in tow. But sometimes, just sometimes, when I see a solid-looking jump… I wish it could be. Honestly: our eldest would be well up for this! (And would probably be quite disappointed to sit around until the end where they reveal that, obviously, they swapped the small child for a doll for many of the shots.)

Jon Snow oh oh EXTENDED REMIX oh oh oh oh oh oh oh oh oh oh oh oh oh

This article is a repost promoting content originally published elsewhere. See more things Dan's reposted.

This epic video (which contains spoilers for Game of Thrones through the third episode of season eight The Long Night). If you’re somehow not up-to-date, you can always watch the earlier iteration, which only contains spoilers through The Spoils of War, the fourth episode of the seventh series.

And now my bedsheets smell like Jon Snow.

There’s lots of ugliness in the world right now, so I think it’s important to share these photos…

This article is a repost promoting content originally published elsewhere. See more things Dan's reposted.

There’s lots of ugliness in the world right now, so I think it’s important to share these photos of what happened when my friend Marvin called me & said: “I’m getting married & we can only invite 100 people. You didn’t make the cut. But you can come if you come as a drunk clown.”
(1) There’s not a lot of story to tell, but for anyone who wants some DRUNK CLOWN AT THE WEDDING backstory:

Marvin had a vision of a drunk clown crashing his wedding. It’s all he ever wanted. Laura was on board. That’s the kind of perfect-for-each-other weirdos they are.

(2) I arrived in a regular suit. I had the clown outfit, face paint, shavingg stuff (I had a full beard & needed to shave for the make-up) and two 40oz’s (Marvin asked for a drunk clown, so I was giving him a D*R*U*N*K clown) in a bag I hid in a bathroom next to the ceremony.
(3) I only knew a handful of people at the wedding. Didn’t know Marvin or Laura’s families. More importantly, they didn’t know me. Which made me the perfect surprise drunk clown.
(4) I didn’t want them to recognize me when I showed up as a clown — the idea was to make it feel like an actual drunk clown had crashed the festivities — so I didn’t mingle much.
(5) As soon as the ceremony was over, people were directed to another area for a wine reception. I slipped away to the bathroom with @AimieRocks, who was helping with my make-up. I shaved off the beard, did my face, got into the clown suit, and pounded one of the 40oz’s.
Total lightweight here. I was hammered pretty quickly. I’m a method actor, so I drank half the other 40oz too. Then I stumbled over to the wine reception.
(7) I barged in, marched over to Laura’s mom, grabbed her wine, downed it, then handed the empty glass back to her. CONFUSION. MILD CHAOS.

WHO IS THIS DRUNK CLOWN?

(8) I accidentally shattered a few wine glasses, but I gotta say I brought a real JOVIAL DRUNK CLOWN vibe to the whole affair, so people embraced me pretty quickly, even though I kept drinking their wine.
(9) Except for Laura’s dad, who called for security to escort me out. She had to tell him that I was AN OFFICIAL MEMBER OF THE WEDDING PARTY.

Best Man ☑️
Maid of Honor ☑️
Drunk Clown ☑️

(10) At some point, we must have gone into the vineyard to take those photos in the original tweet up above, but honestly I was so drunk that I don’t remember taking them.

Anyway, I told you there wasn’t much backstory. It was an awesome wedding. <end>

ADDENDUM: just found this photo & it made me laugh. This is after security was called off, after everyone found out I wasn’t a DRUNK CLOWN STRANGER but a DRUNK CLOWN FRIEND. And everyone’s just…so…completely…CHILL. Just like, “whatevs,” as I drink more.
(12) OMG okay so I guess I have to make a SECOND ADDENDUM because @AimieRocks just emailed me some more photos from the wedding. Adding them to this thread…
(13) What I wore to the wedding ceremony. (That’s not my hat, that’s @AimieRocks‘s hat, I’m *not* a hat person but wearing it made me feel like Diane Keaton.) Posting these photos so you can see the beard I had before my clown transformation. I shaved that thing off SO QUICKLY.
(14) DRUNK WEDDING CLOWN, A PORTRAIT. I hate beer so much, but I had to get in character and I feel like drunk wedding clowns drink beer??? I’ve barely had any of the beer and already a little drunk in this photo. We didn’t leave the bathroom until after I finished that bottle.
(15) Last three photos. I love how Laura’s pretending not to know me in that first one. The kissing photo is with another good college friend, Michal. I have no idea who I’m talking to in that third photo. <end addendum> xx
Marvin just joined twitter to tell me that’s his mom I’m hugging in the third photo in this tweet. I’M SORRY, MARVIN. But welcome to twitter. xo

(17) ADDENDUM #3: @MarvinSolomon8 just texted me the name of their wedding photographer. Shoutout to SAMUEL POTTER PHOTOGRAPHY in Paso Robles. Here’s his website:

He took the three vineyard photos & obviously has a great eye. THANK YOU SAMUEL POTTER.

I was at a party this afternoon and an old friend introduced me to his wife, then told her: “honey, this is the drunk clown I told you about.”
Someone messaged me asking if they could interview me about the drunk clown stuff for a TV show & we’re about to skype. I texted my mom and asked “how do I look?” This is her reply. WHAT DOES THIS EVEN MEAN??? IS THAT A GOOD THING OR A BAD THING??? WHAT ARE YOU TELLING ME, MOM???
My grandma’s been in the hospital with bad shingles & infection. It’s been a scary, stressful week, & she’s been in bad pain. But she’s getting A LOT better. And thankfully she just got moved to rehab facility.

My mom just texted me this photo she took of grandma’s new room.

A friend just texted that he’s showing these drunk wedding clown photos to his family tomorrow and I hope it brings them all closer together.