Math solutions can be found in surprising places, including the dark realms of the Internet. In 2011 an anonymous poster on the now infamously controversial image board 4chan posed a mathematical puzzle about the cult classic anime series The Melancholy of Haruhi Suzumiya. Though the bulletin board has become littered with hateful, violent and extreme content, that original post led to a solution to the sophisticated math problem.

The first season of this anime series consists of 14 episodes that were designed so that you can watch them in any order you like. (For people who are as unfamiliar with the anime world as I am: an eight-part live-action thriller called Kaleidoscope on Netflix follows the same principle.) At some point in a 2011 discussion of the series on 4chan, someone asked the minimum number of episodes they would have to watch to have seen it in every possible order.

In fact, this question is related to so-called superpermutations. And as it turns out, this mathematical area holds many puzzles: to this day, mathematicians are still unable to fully answer the problem that the 4chan user had posed.


On supporting science journalism

If you’re enjoying this article, consider supporting our award-winning journalism by subscribing. By purchasing a subscription you are helping to ensure the future of impactful stories about the discoveries and ideas shaping our world today.


But amazingly, in that discussion, one of the anonymous users made an estimate of the minimum amount of all episodes to watch with an approach that was previously unknown to mathematicians. “I’ll need to [elaborate on] this in multiple posts. Please look it over for any loopholes I might have missed,” wrote the user, who explained in several steps how they arrived at their estimate. Other users then took up the arguments and discussed them—but outside of 4chan, none of this made any waves. No one seemed to take any notice.

Extreme Binge-Watching

In mathematics, two objects permutate when they are rearranged or recombined. For example, you can permutate AB to BA. If an anime series consisted of only two parts, you could either watch the first and then the second episode (1-2) or the second and then the first (2-1).

If you want to watch a series in multiple arrangements—perhaps to figure out which sequence of episodes makes the most sense—you need a superpermutation. This is a sequence of all possible permutations. Imagine a marathon showing where you watch the first episode, followed by the second, and then watch the second episode, followed by the first (1-2-2-1). To avoid watching the second episode twice in a row, a shorter superpermutation would be 1-2-1; you would only have to watch three episodes to still have every possible order covered.

If a series consists of three episodes, it becomes a little trickier to find the shortest superpermutation. In this case, there are 3! = 6 different sequences: 1-2-3, 1-3-2, 2-3-1, 2-1-3, 3-1-2, 3-2-1. Fortunately, you don’t have to watch 3 × 6 = 18 parts but can find a clever shortcut, in this case: 1-2-3-1-2-1-3-2-1. That order contains all possible permutations of the numbers 1, 2 and 3, but you only have to watch nine episodes!

Mathematicians have also calculated the shortest superpermutations for a series consisting of n = 4 and n = 5 episodes (33 and 153 episodes, respectively). Beyond that, however, they are in the dark. The shortest superpermutations for n > 5 are not known.

In fact, the challenge relates to one of the most intractable problems in algorithmics: the traveling salesperson problem. In this problem, a person wants to visit different cities and end up back in their hometown. The task is to find the shortest route that connects all the cities. The shortest superpermutation is a variation of this problem in which the individual permutations represent different cities. In this case, you assign different distances between cities by determining the overlap of the permutations. For example, cities 1-2-3 and 2-3-1 have a large overlap: the last two digits of the first permutation match the first two digits of the second, so they can be combined to form 1-2-3-1. We can therefore assign a short distance between those two cities. On the other hand, 1-2-3 and 2-1-3 do not overlap. (To see both sequences, you have to look at a full six parts; no shortcut is possible.) Thus, these cities have a large distance between them.

To find the shortest route within permutations, you connect the permutations that overlap the most. There is only one difficulty: there is no known algorithm that solves the traveling salesperson problem quickly. If we are dealing with a few cities—or, in the case of an anime series, a few episodes—this is not a major drawback. But as soon as the n becomes large, computers fail at the task because the computing time grows exponentially with n.

Computers are able to calculate superpermutations for n = 4 and n = 5 but not for anything beyond that. And although it is possible to calculate elaborate superpermutations for larger numbers, finding the shortest superpermutation becomes more difficult.

Experts must therefore make do with estimates. For example, there is an algorithm that helps estimate the length of the shortest possible superpermutation for n objects: 1! + 2! + 3! + … + n! Using that algorithm, if n = 2, you get a superpermutation of length 1 + 2 = 3. For n = 3, this results in a length of 1 + 2 + 6 = 9. For n = 4, you get 33. And for n = 5, you get 153, which corresponds to the shortest superpermutation in each case.

For larger n, however, this algorithm no longer applies: computers have been able to find shorter superpermutations than it would suggest exists. In fact, the formula 1! + 2! + 3! + … + n! massively overestimates the length of the shortest superpermutation for large n. Although the algorithm offers only an approximate answer, mathematicians use it as a starting place, with the goal of narrowing down options to find more precise answers.

Coincidences and Rediscoveries

In 2013 Nathaniel Johnston, now a mathematics professor at Mount Allison University in New Brunswick, landed on a Melancholy of Haruhi Suzumiya fandom page. Johnston himself was not an anime fan. He had arrived at the site after Googling some search terms related to superpermutations. There he came across the discussion that had been held on 4chan almost two years earlier, which a user had copied to the fandom site.

Johnston didn’t bother doing the math but cited the fandom post on his blog. This comment, too, went unnoticed for several years.

Then in October 2018 mathematician Robin Houston came across his colleague’s blog post through a curious coincidence. Houston had just learned that Australian science fiction author Greg Egan had found a new maximum length for the shortest superpermutations, expressed as:

n! +(n –1)! + (n – 2)! + (n – 3)! + n – 3

That in itself was bizarre. But when Houston started learning more about this result, he realized that the minimum length of a superpermutation had been given a new value by an anonymous anime fandom user (he didn’t know about the origins on 4chan at that time). The formula for the minimum length is:

n! +(n – 1)! + (n – 2)! + n – 3

Houston shared his discovery on Twitter (now X) on October 23 of that year. “A curious situation. The best known lower bound for the minimal length of superpermutations was proven by an anonymous user of a wiki mainly devoted to anime,” he wrote.

Along with his colleagues, mathematicians Jay Pantone and Vince Vatter, Houston decided to check the 4chan user’s proof and write it down in a mathematical way. The researchers posted their mathematical work to the Online Encyclopedia of Integer Sequences that same month, and the first author is listed as “Anonymous 4chan Poster.”

So what do these formulas tell us? If you want to watch all episodes of an n-part series in all possible combinations, you must sit through at least n! +(n – 1)! + (n – 2)! + n – 3 episodes—that’s the 4chan user’s contribution—and at most n! +(n – 1)! + (n – 2)! + (n – 3)! + n – 3, which we know through Egan’s work.

In the case of the eight-episode series Kaleidoscope, you would have to watch at least 46,085 and, at most, 46,205 episodes. For The Melancholy of Haruhi Suzumiya, or Haruhi, with 14 episodes, the number increases drastically: a minimum of 93,884,313,611 episodes and a maximum of 93,924,230,411. Recall that this is not a complete solution—it’s just setting a range for the size of a superpermutation that would allow you to efficiently watch the series in every possible order.

Fortunately, Egan also provided an algorithm for constructing the corresponding superpermutation. This allows Haruhi fans to work out the best viewing order of episodes. But with an average episode length of around 24 minutes, it would take about 4 million years to sit through this superpermutation.

This article was originally published on this site