Math solutions can be found in surprising places, including the dark realms of the Internet. In 2011 an anonymous poster on the website 4chan posed a mathematical puzzle about cult classic anime series The Melancholy of Haruhi Suzumiya. The online bulletin board is now infamously controversial and has become littered with hateful, violent and extreme content. But that 2011 post led to a solution to a sophisticated math problem.
The first season of this anime series consists of 14 episodes that were designed so viewers could watch them in any order they liked. (For people who are as unfamiliar with certain media worlds as I am, an eight-part live-action thriller on Netflix called Kaleidoscope follows the same principle.) At some point in a discussion of the series on 4chan, someone asked about the minimum number of episodes they would have to watch to see the entire season 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 solve the problem that the 4chan user 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 anonymous user estimated the minimum number of 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 had arrived at their estimate. Other users then took up the arguments and discussed them—but outside 4chan, none of it 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 watch either the first and then the second episode (1-2) or the second and then the first (2-1).
Computers are able to calculate superpermutations for n = 4 and n = 5 but not for anything beyond that.
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, meaning a sequence of all possible permutations. Imagine a marathon viewing in which 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, you could use a shorter superpermutation of 1-2-1; you would have to watch only three episodes to have every possible order covered.
If a series consists of more episodes, it becomes a little trickier to find the shortest superpermutation. With three, there are 3! = 6 different sequences: 1-2-3, 1-3-2, 2-3-1, 2-1-3, 3-1-2 and 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. This order contains all possible permutations of the numbers 1, 2 and 3, but you have to watch only nine episodes!
Mathematicians have also calculated the shortest superpermutations for 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. But 1-2-3 and 2-1-3 do not overlap. (To see both sequences, you have to look at the full six parts; no shortcut is possible.) Thus, these cities have a large distance between them.

People attend the 10th Anime Japan, the Japanese animation industry's biggest event, in March 2023 in Tokyo.
Richard A. Brooks/AFP via Getty Images
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 therefore must make do with estimates. For example, there is an algorithm that can help you estimate the length of the shortest possible superpermutation for n objects: 1! + 2! + 3! + ... + n! Using this method, if n = 2, you get a superpermutation of length 1 + 2 = 3. For n = 3, the result is 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 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 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) in October 2018. “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 he 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 first 14 episodes of The Melancholy of Haruhi Suzumiya, or Haruhi, 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 algorithm 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 four million years to sit through this superpermutation.

