## Saturday, December 28, 2013

### [Review] Welcome to Your New Life, by Anna Goldsworthy

I recently read Anna Goldsworthy's Welcome to Your New Life, a memoir addressed from mother to firstborn child, detailing their story, from conception to first birthday.

In many ways the book is an honest, unabashed look into Goldsworthy's mind, an unerringly human account of how her heart and mind open and mould themselves around the entrance of her (spoiler:) son into her life. Her account of the pregnancy, for instance, lingers around a theme of anxiety — of all the little ways things could go wrong. In one particularly poignant passage she expresses the full extent of this fear:

Parenthood comes with its own foreign set of concerns and neuroses. In one memorable chapter Goldsworthy recounts a trip that she, her partner and their child take to a farmhouse near the coast. A weekend that begins with them settling into an idyllic farmhouse for the night takes a dark turn when Goldsworthy discovers that the house's toilet is an outhouse. Her mind instantly turns to fears for her baby's mortality.

I have seen how you would fall, she writes. That moment in which clumsiness ticks over into disaster.

As the night continues, Goldsworthy recounts how she is kept awake by constant fears of all the possible permutations of misfortune that might lead to tragedy.

You are incapable of locomotion... The only people of capable of taking you into the composting toilet are me and Nicholas... I repeat these statements in my head as though counting sheep. You are incapable of locomotion... The only people of capable of taking you into the composting toilet are me and Nicholas... I will not take you into the composting toilet... Therefore, the person who will take you into the composting toilet is Nicholas.

It is in this way that Goldsworthy maps out the changes in her mind like an expert cartographer. The everyday becomes sinister; the mundane becomes deadly; every word spoken near her becomes an implicit judgement on her worth as a parent and her son's worth as a human being.

And yet amidst all the worry, there are moments of unqualified joy:

It's in moments like these that Goldsworthy's earnestness shines brightest. Newborns, as she puts it, are transient, and amidst all the tumult and trouble she describes her new world as, she certainly doesn't hide her joy in watching that world go by.

## Thursday, December 19, 2013

### Monster

Gregor Samsa wakes up to discover he has become a monster. You, on the other hand, wake up day after day, gradually realising that you always have been a monster.

Imagine you were born with a special power: the power to make others do anything you ask them to.

Your power is not foolproof: it works not by magic nor mind control, but instead simple things like charisma and social norms and subconscious terror. Your power has little effect on those deemed your superiors, but works without fail on your peers. You ask for someone’s hand and the implicit lines of obligation and normalcy and shift around the two of you like tangled vines until they cannot refuse you without demeaning themselves. You ask them to betray their friends’ secrets and their tongues are unbound by the unspoken ancient warnings against lying to you.

Thus you cannot bend others’ minds; only actions. You cannot make someone see you as a friend, but by merely treating them as one you can force them to reciprocate.

Now imagine this: you cannot control the power. It is always on.

(Were this truth couched in storytelling, this would be metaphor. This is the reverse. This is storytelling couched in truth. You have a collection of facts; between what lines is the narrative hiding?)

You weren’t always aware of this power. Once upon a time you thought you existed in a world of free information flow, where if you asked someone “Want a game?” they would respond with “Yes” if and only if the answer was yes. You asked questions, you asked people for favours, you suggested favourite books to friends, and sometimes the outcomes weren’t the best possible ones, but more often than not they were. You thought this was normal.

When you begin to realise that people subliminally acquiesce to you, the thought weighs upon your every interaction. You can’t distinguish friend from serf with any real conviction; what stock can you put in anything? Sometimes you drift away from people because you were heading different directions in life; sometimes you drift away from people because they were terrified of you and had no other way of escaping your influence. Whenever this happens, you cannot ascertain the difference. You can only conjecture.

“Do I make you uncomfortable?” you ask your best friend, who you’ve known since middle school.

He looks up at you, countenance equal parts baffled and offended by the question. “Of course,” he jokes without missing a beat, “Who wouldn’t be uncomfortable looking at a mug like that?”

You have the answer you wanted to hear; you have no answer at all.

You could try to change the way you talk, the way you imply. You could swap your “Let’s grab a drink after work”s with “Want to grab a drink after work?”s. You could swap your “Want to grab a drink after work?”s with “Would you be comfortable grabbing drinks after work?, just briefly, no pressure”s. You could swap those with very carefully worded invitations stuffed full of gracefully-decline options, delivered through a neutral third party.

Perhaps it works. Perhaps if you relate to them gently enough, the people around you will be acting of their own free will. But perhaps no amount of equivocation infallibly turns an imperative into a request.

You meet someone you want to grow to trust: a potential new friend, or partner, or mentee, or anything in between.

You make the first move—

## Monday, October 7, 2013

### Range trees and profiling in Haskell

Range trees. Those of my friends who've had a lot of programming competition experience would be well-acquainted with them. They're neat recursive data structures which I thought would make an excellent toy project for me to learn a bit more about performance profiling in Haskell.

### ...range trees?

A range trees is a binary-tree-based data structure used to implement range queries.

1D range query problem. Given a semigroup (i.e. an associative binary operator $\bullet$ over a domain $S$), we seek a data structure that implements the following operations over some virtual array a:

$\textrm{update}(x,v)$: set $\texttt{a}[x] := v$

$\textrm{query}(x_1,x_2)$ [given $x_1 \leq x_2$]: return $\texttt{a}[x_1] \bullet \texttt{a}[x_1+1] \bullet \cdots \bullet \texttt{a}[x_2-1]$

For example, the range minimum query problem requires a data structure that updates integers in an array and answers queries of the form What is the lowest element in the range $[x_1,x_2)$?. The range sum query problem requires a data structure answering queries like what is the sum of elements 4 to 17 inclusive?, and so on.

Range trees offer us $O(\lg W)$ updates and queries using $O(W)$, where $W$ is the size of the array. They're constructed as balanced binary trees where each leaf corresponds to an element in the array (ordered left to right, sensibly enough), and where each non-leaf node contains the sum of all the leaves underneath it.

When the value of an array element changes, only $O(\lg W)$ tree nodes need to be updated. Likewise, querying for the sum of a range of elements also only requires looking at the values stored in $O(\lg n)$ nodes. (In the example diagram above, finding the sum from a[1] to a[4] inclusive requires looking at three nodes: the ones storing the sums for a[1], a[2] + a[3], and a[4].)

Here’s a first pass attempt at implementing a range tree in Haskell:

data RangeTree = RangeTree {width :: Int, tree :: RangeTreeNode}

newRangeTree w = RangeTree {width = w, tree = newRangeTreeNode 0 w}

update :: RangeTree -> Int -> Int -> RangeTree
update rt x v = rt {tree = updateRangeTreeNode (tree rt) 0 (width rt) x v}

query :: RangeTree -> Int -> Int -> Int
query rt = queryRangeTreeNode (tree rt) 0 (width rt)

-- Internals

data RangeTreeNode =
Leaf Int
| Branch RangeTreeNode Int RangeTreeNode

rtnValue :: RangeTreeNode -> Int
rtnValue (Leaf v) = v
rtnValue (Branch _ v _) = v

newRangeTreeNode :: Int -> Int -> RangeTreeNode
newRangeTreeNode x1 x2
| x1 == x2-1 = Leaf 0
| otherwise = Branch
(newRangeTreeNode x1 ((x1+x2) div 2))
0
(newRangeTreeNode ((x1+x2) div 2) x2)

updateRangeTreeNode :: RangeTreeNode -> Int -> Int -> Int -> Int -> RangeTreeNode
updateRangeTreeNode rtn x1 x2 x' v
| x1 > x' || x2 <= x'
= rtn
| otherwise   = case rtn of
Leaf _ -> Leaf v
Branch l _ r -> Branch l' (rtnValue l' + rtnValue r') r'
where
l' = updateRangeTreeNode l x1 ((x1+x2) div 2) x' v
r' = updateRangeTreeNode r ((x1+x2) div 2) x2 x' v

queryRangeTreeNode :: RangeTreeNode -> Int -> Int -> Int -> Int -> Int
queryRangeTreeNode rtn x1 x2 x1' x2'
| x1' >= x2 || x1 >= x2'
= 0
| x1' <= x1 && x2' >= x2
= rtnValue rtn
| otherwise
= queryRangeTreeNode l x1 ((x1+x2) div 2) x1' x2'
+ queryRangeTreeNode r ((x1+x2) div 2) x2 x1' x2'
where
Branch l _ r = rtn


The implementation is quite standard. The module exposes the functions update and query, which are wrappers for the recursive functions updateRangeTreeNode and queryRangeTreeNode.

Let's see how this runs on some random data sets:

## Thursday, September 26, 2013

### Utility and Equivalence

In a previous post, I outlined the four von Neuman-Morgenstern axioms for preferences (completeness, transitivity, continuity and independence), discussed my interpretation of the outcome consequentialism that underlies sensible interpretations of the axiom, and finished by talking about how they imply the existence of utility functions:

Theorem (von Neumann–Morgenstern utility theorem): Assuming the VNM axioms, there exists some linear (weighted-average preserving) function $u: \mathcal{O} \rightarrow \mathbb{R}$ such that: $o_1 \prec o_2 \Leftrightarrow u(o_1) < u(o_2)$

These functions aren't unique: given any such function you can translate it or multiply it by a positive scalar to get another function that represents the same preference relation $\prec$. In fact, for all intents and purposes, utility functions can be considered invariant under positive affine transformations.

## Wednesday, September 18, 2013

### Castigate or forgive...?

(N.B. This post's a little rough around the edges; I wrote most of it near the start of this year and haven't given it the level of polish it deserves.)

When I was in year seven, I used to torment a boy — who was several years above me and twice my size, mind you — by throwing my lunchbox at him whenever I saw him in the yard. Eventually, teachers had to intervene.

When I was in year seven, I was pressured into all kinds of embarrassing antics by a boy in my classes who was probably happy that they were all laughing at someone other than him. Nothing ever became of that.

A few months back I stumbled across this short piece by Gint Aras, writing for The Good Men Project, titled Should we forgive apologetic bullies?. Take a look: it's short and bittersweet. In it, Aras poses the titular question, asking about reformed bullies, about past aggressors who really do seem to have seen the error of their ways.

The idea of retribution transcends cultures. One need look no further than our traditional stories — whether it's the hubris and (literal) downfall of Icarus, the creation mythos of Australian Aboriginal Dreamtime stories, or the countless deluge myths that exist across cultures, punishment has always gone hand in hand with crime.

It's not too much of a stretch, then, to say that we're born with a sense of tit-for-tat justice. (One imagines that creatures who let their selfish brethren off the hook did not do a particularly good job at staying in the gene pool.) It's not taught. Society didn't invent our moral compasses: it merely reinforced them.

So here's a question. Whence cometh forgiveness?

## Thursday, September 5, 2013

### Thoughts on "Monsters University"

I didn't see Monsters University while it was in the cinemas, making it the second Pixar movie in a row that I've missed (after last year's Brave). But I finally got around to it on a plane trip a few days ago (ermahgerd i was on a plane), and was suitably impressed.

Of course, I have a soft spot for Pixar movies, but no wonder — their script writing has been solid for as long as I can remember... and of course, their visuals have always been artful as well as cutting-edge. (Maybe Cars 2 was crap? I've never seen it; I think it was a direct-to-DVD release.)

In any case, the movie was a lot of fun. Here are a few things I was thinking immediately after seeing it.

## Thursday, August 22, 2013

### Utility: an introduction for ivory tower mathematicians

I identify as utilitarian—

—which is not to say that I believe in the weird sort of aggregative add the happiness scores moral codes that prefer a society of a billion slaves and one obscenely happy person to today's world, but which is to say that I believe (approximately) that the highly complicated human notion(s) of good obey(s) the von Neumann–Morgenstern axioms given sufficient computational resources and bias correction—

—and so I decided I may as well get around to explaining and playing around with the VNM axioms and a couple of little mathematical-philosophical thoughts surrounding them. And yes, this is hardly groundbreaking stuff never before seen on the Internet, but hey, it could be worse: I could be trying to explain what Haskell monads are.

### What things have utility?

Let $\mathcal{O}$ be the set of outcomes. These represent events like the cat lives and the cat dies, as well as more probabilistic events like 50% chance the cat lives.

## Monday, August 19, 2013

### [Review] The House of Silk, by Anthony Horowitz

Anthony Horowitz's The House of Silk is a contemporary addition to Sherlock Holmes canon that is in every way in the spirit of Arthur Conan Doyle's original stories, which, despite having had a strong influence on English-language crime fiction, have a distinctive style of their own which doesn't quite fit in the same mold as most mystery tales. It's not a six-character locked door whodunnit in the vein of Christie or Sayers, nor does it have the bombastic cartoonishness of the Robert Downey Jr. movies; instead, The House of Silk is a thing of its own: a crime adventure filled with twists, intrigue and a level of scandal that would titillate any Victorian reader (not that that'd be much of a feat).

## Tuesday, August 13, 2013

### Notes on set cardinality

I'm working through LMU's Introduction to Mathematical Philosophy on Coursera at the moment. I stumbled across something that confused me (specifically, the claim that has fewer elements than defines a total order), so I'm using this blog post as a medium in which to work through it methodically enough to explain it to someone else.

(Warning: maths below the fold.)

## Thursday, August 8, 2013

### If you asked your MP one question...

TL;DR: meta-politics.

There's an election on in Australia soon, and if you're 18 or over you may be wondering who to vote for. (Having paid attention in school, you're of course aware that under the Westminster system, you don't vote for a prime minister: you vote for your local MP.)

There's a fairly useful question worth asking your local candidates, and it happens to be perfectly generic:

If push came to shove, what issues would you put the people's values ahead of yours for?

## Monday, August 5, 2013

### Race to the centre

Seth is running against Olivia for Class President. It's not as exciting as it sounds, because the Class President only really gets to decide one thing: how long lunch time is.

It's a pretty divisive issue. Some of their classmates enjoy playing outside and would love for lunch to be longer. Others are total bookworms and want shorter lunch times so that they can get back to reading The Magic School Bus.

You might even say that the whole situation is a bit like a political spectrum:

I had some trouble deciding which way around to make the diagram. On the one hand, longer lunch times are definitely right-wing, because they represent greater social autonomy. On the other hand, longer lunch times are definitely left-wing, because they represent greater social autonomy.

Seth and Olivia have their own personal opinions on the idea lunch time length, which we can mark out on the spectrum like so:

When the election occurs, students will vote for whichever candidate's position is closest to theirs. This means that the outcome of the election is actually very predictable: whoever's policy is closer to the median is going to win.

### [Reblog] "Time" (xkcd)

Original post: Creator of xkcd Reveals Secret Backstory of His Epic 3,099-Panel Comic, Wired.

I'm endlessly fascinated by the new possibilities that the Internet opens in storytelling. The coherent crowd-sourced mythology of SCP. The memetic hypertextuality of Homestuck.

I wasn't really following Randall Munroe's Time, but the nature in which the story was told is fascinating in much the same way. Its 'serial' nature invites, maybe even necessitates, frame-by-frame analysis.

And of course, on top of that, there's the attention to detail and stylistic elegance of Munroe's best xkcd work.

## Friday, August 2, 2013

### The mathematics of war and dodgeball

Lanchester's Laws are a handful of mathematical formulae describing armed combat between two forces. I'll talk about their derivation for a little bit, then move on to dodgeball (duh).

### Ranged combat

Two armies of foes face one another. One is armed with rifles; the other with crossbows. Which army prevails?

Let's call the size of the respective armies $x$ and $y$, and call their soldiers' lethality $\alpha$ and $\beta$ respectively. (The lethality of a soldier is the number of enemy soldiers they can strike down per unit time.)

## Monday, July 29, 2013

### Happenstance and friendship

You move to a village, or maybe a high school. You pass people on the streets, or maybe in the hallways between classes. There are more people than you can keep track of names, but even so, as time passes the faces become familiar. Some people, you nod to when you pass them by. Some people, you say hi to. Some, you befriend; some, you avoid. You see the same faces again and again.

## Thursday, July 25, 2013

### Bad Piggies vs. Gourmet Race

TL;DR: video-game-music-induced feels.

I stumbled across this beautiful ohrwurm the other day:

(Context: I've never played the game, though I've watched people play it.)

Listen to that. Just sit back and listen to that majestic thing for a few minutes.

The light-hearted meandering across the piano. The upbeat mood in a minor mode. The bouncing tuba, supported on the offbeats. (Bouncing 4-beat tuba is instant shorthand for adorably unsubtle. It's the sort of musical trope you'd use to depict a litter of baby hippos trying to bake a cake, filling the room with billowing clouds of flour.)

This music makes me so inexplicably happy. :D

## Sunday, June 23, 2013

### Fungibility and gifts

I have five hundred dollars sitting in my desk drawer, in a little red envelope. It was a gift to me. The money is mine to use. There is a part of me that refuses to do anything with it.

## Tuesday, June 11, 2013

### A few thoughts on "The Internship"

My company paid for the entire office to go see The Internship. We took up three cinemas at Event Cinemas on George Street. We ate terrible food and laughed at all the serious bits and cringed at all the jokes. After all was said and done, this is what was on my mind:

The movie is absolutely a sugar-coated PR coup for Google. Despite all the major inaccuracies that portray company life and culture as far, far worse than it is.

I mean, sure, if any work environment was difficult to honestly insult, it would make sense for it to be a multiple-time best place to work. But man it's a little embarrassing seeing how shiny and wonderful a workplace they made Google seem.

(The having a beer with your boss line makes a little more sense now that I've seen it than how the trailer implied. One less thing to complain about.)

There was a wonderful (if obligatory) sports scene in which the main cast played an exceptionally rough, entertaining match of unnamed-game-with-Quaffles-Bludgers-Snitches-and-broomsticks... which, yes, is an obvious Twilight reference that they clearly avoiding directly naming for trademark reasons — fuck draconian enforcement of trademarks, incidentally; broomstick-sport is an utterly harmless non-brand-damaging example of fan culture at its finest.

## Monday, June 3, 2013

### [Reblog] Dignity, not disciplining

From child trauma support and resource site Aces Too High comes this article: Lincoln High School in Walla Walla, WA, tries new approach to school discipline — suspensions drop 85%.

In short: zero tolerance approaches to misbehaviour may be counterproductive, causing additional stress for the students who are acting out and causing them more trouble in the long run.

Indeed, once the external factors that lead to misbehaviour have arisen, that misbehaviour is practically a fait accompli, the completion of a cycle.

Depending on your view of education and developmental psychology, the message here may be either paradigm-shifting or completely unsurprising. There's a lot more inside the article; check it out here.

## Wednesday, May 29, 2013

### On well-poisoning and letting "the team" down

(Alternate title: Your fellow ideologues are idiots and there is nothing you can do.)

Ever gotten into a political discussion and then someone who agreed with you started calling your opponents names and playing buzzword non sequitur bingo and making your side look like jerks? Yup. That's pretty much reality.

No matter what you believe or how reasonable you think your views are, there is some utter waste-of-a-first-world-life asshole out there who agrees with you.

I spent a lot of years self-identifying as not an atheist, just an agnostic, not because I believed in the supernatural to any significant degree, but because I wanted to stay the fuck away from the assholes who currently represented the atheist label. You know the type. Richard Dawkins. Wannabe nihilist teens with unlimited access to black hair dye and a painfully feigned understanding of Nietzsche. Self-important private school intellectual hipsters saying I knew there was no God the moment I found out Santa wasn't real.

## Sunday, May 26, 2013

### Facebook photos and high school algebra

When I get around to uploading phone camera photos to Facebook, I start off by looking at the twenty or so photos I've taken since last time, and end up actually uploading a fairly small fraction (perhaps a quarter?) of them. Somewhere in between that, I need to spend some time in Photoshop (i.e. the just-as-good open-source program, GIMP) compensating for how terrible all my phone's photos look.

Let $N$ be the original number of photos, and $M$ be the number of photos worth keeping.

• Hand-pick the photos that will probably look nice after touching up. (Estimated time: $0.1N$ minutes.)
• For each photo I want to use, open it in GIMP (i.e. Photoshop but free). Auto-correct the colour in GIMP. Play around with contrast, saturation and cropping settings in GIMP. (Estimated time: $2.5M$ minutes.)
• Upload those photos to Facebook. (Estimated time: $0.1M$ minutes.)
• Add captions, dates, tags, etc. (Estimated time: $0.5M$ minutes.)

Estimated total time: $0.1N + 3.1M$ minutes.

E.g. typical upload spree (20 original photos, 6 actually uploaded): 20 minutes.

• Upload all the photos to a private Google+ album. (Estimated time: $0.1N$ minutes.)
• Hand-pick the photos that look nice after Google+ applied Auto Enhance to them. Download them back to my computer. (Estimated time: $0.3N$ minutes.)
• Upload those photos to Facebook. (Estimated time: $0.1M$ minutes.)
• Add captions, dates, tags, etc. (Estimated time: $0.5M$ minutes.)

Estimated total time: $0.4N + 0.6M$ minutes.

E.g. typical upload spree (20 original photos, 6 actually uploaded): 12 minutes.

### Discussion

Rough analysis suggests that the new method saves time when: \begin{align} 0.1N + 3.1M &> 0.4N + 0.6M \\ \Leftrightarrow 2.5M &> 0.3N \\ \Leftrightarrow M &> 0.12N \end{align}

So if I have twenty photos and only one of them is any good, I'd be better off doing the GIMP method than wasting all my time going through Google+.

### Further research

• How much time will it save once I set up my phone to sync my photos with Google+?
• If/when Facebook rolls out photo enhancement technology, how much time will I save directly uploading to them?
• Is $M$ independent of the method I use? E.g. am I subconsciously happier to select more photos using the "new method" because I know it'll take less time-per-photo-used?

#science

## Thursday, May 23, 2013

### SIGGRAPH 2013 Preview (or: ZOMG)

The annual SIGGRAPH conference is one of the most notable technical gatherings for industries like motion pictures and video gaming.

And this preview video for this year's July conference was too cool not to share:

Here's a couple of things that look exciting:

• A Material Point Method for Snow Simulation — Because when was the last time you saw snow that realistic in a video game? (No, cutscenes don't count.)
• Make it Stand: Balancing Shapes for 3D Fabrication — If you own a 3D printer or have ever used Shapeways et al., I think this speaks for itself. Look at the tiny surface areas those things are resting on! Look at them! o_O
• Scalable Real-time Volumetric Surface Reconstruction — Okay so mostly I'm impressed by the technical challenge the researchers must have overcome here. If I understand the abstract correctly, that's realistic 3D modelling from a single 2D video feed.

Which ones do you want to get your hands on?

## Tuesday, May 21, 2013

### [Reblog] "All Hail the Queen?"

Shout out to Tamara Winfrey Harris (writing for Bitch Magazine) for an excellent essay on feminism, race and dangerously high standards: All Hail the Queen? — What do our perceptions of Beyonce's feminism say about us?.

## Monday, May 20, 2013

### On hyperconsent

I first heard the term "hyperconsent" on a couch while my fingers ran along a new friend's collarbones. It wasn't her place — her city, even — but she seemed perfectly at home on the couch cushions the same way that the weary are lying down at a long day's end. The air was thick with the intermingling scents of incense and goon, and the taste of the latter still weighed heavy on my tongue (we'd had just enough to stain our lips slightly red).

She and I spoke in hushed tones, trying not to disturb the flat's usual inhabitants, who'd excused themselves to bed not much earlier.

## Thursday, May 16, 2013

### What happens to your tax dollars?

The ABC brings us an excellent interactive infographic showing exactly how your Australian tax dollars will be spent* in the 2013-14 financial year.

Hovering over one of the coloured segments shows you what portion of the budget the government has allocated to that sector. For example, 6.42% of your money goes to medical services and benefits, and 5.53% goes to defence. (A better state of things than I'd thought!)

* It's possible you don't pay any tax in Australia! Maybe you don't work in Australia, or maybe you're Paul Hogan. In that case... You get to see how other people's money is spent...?

## Wednesday, May 15, 2013

### Why both "Chocolate Factory" film adaptations are worse than each other

"Worse than each other?" you say, furrowing your brow at the title of this post. "Isn't that logically impossible? Either they're just as bad, or one of them is the worst..."

No. I'm sorry. Your common sense and your actual understanding of primary school maths have no sway over me today, friend.

I never read Roald Dahl's Charlie and the Chocolate Factory -- blasphemy, perhaps? -- though I have great fondness for his work. (Matilda and The BFG spring to mind, as do many of his short stories for an adult audience -- I had a fondness for Mr. Botibol.) If you asked me, which you didn't, I'd say that I enjoyed both Mel Stuart's 1971 adaptation (f. Gene Wilder) and Tim Burton's 2005 adaptation (f. Johnny Depp) of the book. The latter lacked the former's indefatigably catchy Oompa Loompa song, but whether that's a plus or a minus is anyone's guess.

The original film wasn't well received by everyone, especially not by Roald Dahl himself. His former publisher, Liz Attenborough, was quoted saying:

So, assuming the badness of a Charlie and the Chocolate Factory film is measured by how much extra attention the movie plays to its bigwig film star Wonka instead of Charlie the, uh, protagonist, then we can safely say the following:

One respect in which the Gene Wilder movie was undeniably worse than the Willy Wonka one:

## Friday, May 10, 2013

### Sequences without identical neighbours

Last April, in the middle of an Australian Informatics Olympiad camp, I and a number of colleagues ran an intense team event for the high school students at the camp, where we threw lots of mathematical and general knowledge puzzles at them rapid-fire. The students were grouped in teams of three, and each time was given two computers, an internet connection, and barely even ten person-minutes per problem.

I believe Luke Harrison and I came up with this particular problem. We realised about two hours before the competition was due to start that it was even more interesting than we'd previously thought.

"How many sequences of positive integers are there such that (1) no two consecutive integers are the same (i.e. the sequence is "valid"), and (2) they sum to $N$?"

This can be calculated in $O(N^2)$ time using straightforward dynamic programming:

int nVS[N+1];
// nVS[x]      := number of valid sequences summing to x
int nWays[N+1][N+1];
// nWays[x][y] := number of valid sequences summing to x
//   and ending on y
nWays[0][0] = 1;
nVS[0] = 1;
for (int x = 1; x <= N; x++) {
for (int y = 1; y <= x; y++) {
nWays[x][y] = nVS[x-y] - nWays[x-y][y];
nVS[x] += nWays[x][y];
}
}
return nVS[N];


These sequences are called Carlitz Compositions [Kn98], and the number of sequences summing to $N$ (OEIS A003242) can be computed an alternate way:

## Sunday, May 5, 2013

### [Poetry review] "I don't mean to oogle"

I recently received the following cold-call message on LinkedIn: