-- One thing I did not mention is that Dijkstra's algorithm is designed to solve the problem of finding the shortest path from the start node to all other nodes of the graph. It does this job very well, in almost linear time, so there is not much to improve there. It is the problem of finding the shortest path between two nodes where A* usually improves upon Dijkstra.
-- Here is a link to another example of A* run from Sarajevo to east Italy. You can see how the algorithm quickly reaches the first city, Tirana, but then it gets stuck because of the Adriatic sea. So it searches along its coastline until it finds Italy. After that it confidently runs through Italy until it finds the destination. github.com/polylog-cs/Astar/blob/main/Explore.mp4
-- If your heuristic is not consistent, but at least admissible, A* will still return the correct answer, though its time complexity may be exponential in the network size.
-- IDA* is a popular algorithm that relates to iterative deepening depth first search the same way as A* relates to Dijkstra/breadth first search.
-- See also this codeforces blog post that collects some applications of potentials in competitive programming. codeforces.com/blog/entry/95823
-- The underlying reason why potentials are often so useful is that they are dual to the concept of distances in the sense of linear programming duality.
Problems:
-- Prove that heuristics from the video are consistent.
-- Prove that the maximum of two consistent heuristics is still consistent. (Thus, if you have two incomparable heuristics, you should combine them this way. )
-- Prove that for any heuristic that is consistent, equal to zero for the goal state and otherwise nonnegative, A* always explores less states than Dijkstra. That is, apart for the time spent on computing the heuristic, A* is never worse than Dijkstra in the problem of finding the shortest path between two points.
Big thanks to: Richard Hladik, Matěj Konečný, Martin Mareš, Yannic Maus, Jan Petr, Vojtěch Rozhoň, Hanka Rozhoňová, Tom Sláma
Credits: To make this video, we used manim, a Python library: https://docs.manim.community/en/stable/ The color palette we use is solarized: ethanschoonover.com/solarized music: Thannoid by Blue Dot Sessions: https://app.sessions.blue/browse/track/126782 music: Also sprach Zarathustra from Strauss from wikimedia commons image of the scroll: pxfuel.com/en/desktop-wallpaper-aadkb images of the cities are from wikimedia commons
The hidden beauty of the A* algorithmPolylog2023-01-20 | 00:00 Intro 01:38 Change the lengths! 06:34 What is a good potential? 12:31 Implementation 16:20 Bonus
-- One thing I did not mention is that Dijkstra's algorithm is designed to solve the problem of finding the shortest path from the start node to all other nodes of the graph. It does this job very well, in almost linear time, so there is not much to improve there. It is the problem of finding the shortest path between two nodes where A* usually improves upon Dijkstra.
-- Here is a link to another example of A* run from Sarajevo to east Italy. You can see how the algorithm quickly reaches the first city, Tirana, but then it gets stuck because of the Adriatic sea. So it searches along its coastline until it finds Italy. After that it confidently runs through Italy until it finds the destination. github.com/polylog-cs/Astar/blob/main/Explore.mp4
-- If your heuristic is not consistent, but at least admissible, A* will still return the correct answer, though its time complexity may be exponential in the network size.
-- IDA* is a popular algorithm that relates to iterative deepening depth first search the same way as A* relates to Dijkstra/breadth first search.
-- See also this codeforces blog post that collects some applications of potentials in competitive programming. codeforces.com/blog/entry/95823
-- The underlying reason why potentials are often so useful is that they are dual to the concept of distances in the sense of linear programming duality.
Problems:
-- Prove that heuristics from the video are consistent.
-- Prove that the maximum of two consistent heuristics is still consistent. (Thus, if you have two incomparable heuristics, you should combine them this way. )
-- Prove that for any heuristic that is consistent, equal to zero for the goal state and otherwise nonnegative, A* always explores less states than Dijkstra. That is, apart for the time spent on computing the heuristic, A* is never worse than Dijkstra in the problem of finding the shortest path between two points.
Big thanks to: Richard Hladik, Matěj Konečný, Martin Mareš, Yannic Maus, Jan Petr, Vojtěch Rozhoň, Hanka Rozhoňová, Tom Sláma
Credits: To make this video, we used manim, a Python library: https://docs.manim.community/en/stable/ The color palette we use is solarized: ethanschoonover.com/solarized music: Thannoid by Blue Dot Sessions: https://app.sessions.blue/browse/track/126782 music: Also sprach Zarathustra from Strauss from wikimedia commons image of the scroll: pxfuel.com/en/desktop-wallpaper-aadkb images of the cities are from wikimedia commonsWhat OpenAIs breakthrough means for mathematicsPolylog2026-06-23 | Recently, OpenAI’s model managed to disprove Erdős’s famous unit distance conjecture. We explain the conjecture in depth and talk about what this news tells us about the future of math.
Credits Richard Hladík: Animator, video editor. Site: https://rihl.cz Václav Rozhoň: Narrator, animator, video editor. Site: vaclavrozhon.github.io Václav Volhejn: Narrator, video editor, animator. Site: vvolhejn.com
Animations: Canvas Commons, a TypeScript library canvascommons.io
0:00 Intro 0:45 Erdős problems 1:31 The unit distance conjecture 2:09 The asymptotic question 3:12 Erdős’s n^1.5 upper bound 5:28 Erdős’s n^(1+o(1)) construction 7:43 OpenAI's n^(1+ε) construction 9:50 Strengths and weaknesses of current LLMs 11:22 What happens next? 12:26 But we'll still be writing definitions, right? 15:09 OutroHow to stop an evil postman (ft. Amit Sahai)Polylog2026-06-12 | How to communicate securely even if someone listens? A video about the Diffie-Hellman protocol and its generalizations.
0:00 Intro 0:58 The evil postman riddle 01:38 Double-padlock protocol 02:46 Translating the double-padlock protocol to software 03:35 Take 1: additive double-padlock protocol 05:04 Why this breaks 06:04 Hardness of the discrete logarithm 07:35 Fixing the double-padlock protocol 08:40 Diffie–Hellman 10:49 Man-in-the-middle 11:41 The Internet security stack 12:16 Solving the gossip riddle 13:55 Oblivious transfer discussion 15:06 Outro99% is easy, 100% is hardPolylog2026-02-11 | Why is randomness so powerful for algorithms?
Credits Richard Hladík: Writer, animator. Site: https://rihl.cz Tomáš Sláma: Script editor, animator, video editor. YT channel: youtube.com/@YTomS Václav Rozhoň: Script editor. Site: vaclavrozhon.github.io Václav Volhejn: Narrator, animator, script editor. YT channel: youtube.com/@vvolhejn
First presented as a talk at SNiC 2025.
Animations: Motion Canvas, a TypeScript library motioncanvas.io Music: From the Bodytonics album by Blue Dot Sessions
0:00 Intro 2:07 Equation testing 4:31 Quicksort 5:24 Worst case luck / input 7:55 Rock Paper Scissors 8:30 In conclusion 10:04 Thanks100k Anniversary Livestream 🎉Polylog2025-09-03 | We hit 100k subscribers, so we're celebrating with a livestream! 🎉
We’ll do a Q&A, solve problems, play games, and rate algorithms together.
Timestamps: 0:00 - Stream Start 6:25 - Introductions 14:23 - Competitive Programming with Václav V. 1:04:45 - Algorithm Tier List with Václav R. 2:12:30 - Break 2:19:56 - Game Bot Programming with Tom S. 3:00:37 - Q&A with Everyone
Schedule: 19:00 CEST Competitive programming with Václav V. 20:10 CEST Algorithm tier list with Václav R. 21:20 CEST Game bot programming with Tom S. 22:00 CEST Q&A with everyone
Links: Competitive Programming: atcoder.jp/contests/abc420/tasks Tier List: polylog-cs.github.io/tier-list Game Bot Programming: https://cw.slama.dev/The fastest sorting algorithmPolylog2025-08-16 | Radix sort is older than the computer yet quicker than quick sort. Why aren’t we all using it?
100k subscribers celebration livestream!! It will start 2 September 2025, 19:00 CEST. We’ll do a Q&A, an algorithm tier list, and small coding games where you can join in. Save the date!
Machines from technikum29 IBM O83 sorter: https://technikum29.de/en/computer/punchcard.php Player piano: https://technikum29.de/en/miscellaneous.php
Credits Richard Hladík: Script editor, animator. Site: https://rihl.cz Tomáš Sláma: Narrator (museum scene), script editor, animator. YT channel: youtube.com/@YTomS Václav Rozhoň: Writer, animator. Site: vaclavrozhon.github.io Václav Volhejn: Narrator, animator, script editor, video editor. YT channel: youtube.com/@vvolhejn
Thank you to all our beta testers for their feedback: the KSP gang, Carmen Bach. Thank you to Technikum29 for letting us play with their amazing punch card sorter.
Animations: Motion Canvas, a TypeScript library motioncanvas.io Music: From the Bodytonics album by Blue Dot Sessions
Obama sort video: youtube.com/watch?v=k4RRi_ntQc8 If you wonder why Obama knew bubblesort -- John McCain got the same question a few months earlier, so this was likely a diligent preparation of his team.
0:00 Intro 1:12 100k subs celebration livestream 1:29 Bucket sort 3:18 Radix sort, first attempt 4:42 Radix sort, second attempt 7:10 But is it fast? 8:57 Punch card sorter from 1958 10:45 Why isn’t everyone using it? 11:30 Floating point trick 14:30 In conclusion 15:38 80,000 Hours 16:45 ThanksA mathematical magic trickPolylog2025-03-24 | Zero-knowledge proofs: proving that I've solved a Sudoku without revealing my solution.I can prove I’ve solved this Sudoku without revealing itPolylog2025-03-16 | I can convince you that I’ve solved a sudoku without giving you any information about my solution. We discuss how to do this using what cryptographers call a zero-knowledge proof, and how the same tricks can be used for almost any other problem you can think of.
Richard Hladík: Script editor, video editor, animator. Site: https://rihl.cz Tomáš Sláma: Script editor, video editor, animator. Channel: youtube.com/@YTomS Václav Rozhoň: Writer, animator, the verifier. Blog: vaclavrozhon.github.io Václav Volhejn: Narrator, animator, script editor, the prover. Channel: youtube.com/@vvolhejn
Thank you to our beta testers: Matěj, Honza, Filip. Thank you to Gabor Hollbeck for helping with the video equipment.
0:00 Intro 0:50 Interactive proofs 2:28 Graph coloring 3:22 A simple protocol 6:31 Building the full protocol 10:24 Commitment schemes 12:37 Reducing sudoku to coloring 14:28 General reduction 17:04 Discussion 19:09 OutroWhat P vs NP is actually aboutPolylog2024-08-19 | What if we could run algorithms backwards? We discuss how we could do this by turning algorithms into circuits and encoding those into satisfiability problems. We then explain how it all connects to P vs NP.
Richard Hladík: Script editor, animator Gabor Hollbeck: Video recording, video editor Václav Rozhoň: Writer, animator Václav Volhejn: Narrator, animator, script editor
Thank you to our beta testers: Matěj, Honza, Filip
Animations: manim, a Python library https://docs.manim.community/en/stable/ Color palette: Solarized ethanschoonover.com/solarized Music: Thannoid by Blue Dot Sessions Pictures: * Intel 8008: righto.com/2016/12/die-photos-and-analysis-of_24.html * Stephen Cook: heidelberg-laureate-forum.org/laureate/stephen-a-cook * Leonid Levin: https://www.cs.bu.edu/fac/Lnd/ * Richard Karp: https://www.icsi.berkeley.edu/icsi/people/karp * Mick Jagger, Keith Richards: Wikipedia * Hash function circuit: https://www.academia.edu/download/31149146/498-497.pdfAnd this years Turing Award goes to...Polylog2024-05-11 | We explain why Avi Wigderson got this year’s Turing award: We show how you can make any randomized algorithm deterministic.
Richard Hladík: Script editor, animator Václav Rozhoň: Writer, animator Václav Volhejn: Narrator, animator, script editor
Thank you to our beta testers: Matěj, Honza, Filip
Animations: manim, a Python library https://docs.manim.community/en/stable/ Color palette: Solarized ethanschoonover.com/solarized Music: Thannoid by Blue Dot Sessions Pictures: Wikipedia, Internet
Video clips used: Avi Wigderson: youtube.com/watch?v=YOrBVEwDqAg and youtube.com/watch?v=ZzsFb-6wvoE Seismograph: youtube.com/watch?v=mbKEarx9CCsThe Byzantine Generals problem, and why it matters for the InternetPolylog2024-02-20 | We solve the Byzantine Generals problem, a fundamental problem of distributed computing. Then, in classic Polylog fashion, we spend the latter half of the video discussing why it matters in the broader context, specifically for distributed databases and blockchains.
0:00 Intro 0:31 The byzantine generals problem 3:51 First solution 10:13 Importance 12:00 Blockchain-based solution 15:57 Wrap-up
Filip Hlásek: Animator, script editor, beta reviewer Richard Hladík: Script editor, beta reviewer Václav Rozhoň: Writer, animator Václav Volhejn: Narrator, animator, script editor
Thank you to our beta testers: Aashna, Coralie, Frido, Gabi, Jan (hi dad!), Julia, Martino
Animations: manim, a Python library https://docs.manim.community/en/stable/ Color palette: Solarized ethanschoonover.com/solarized Music: Thannoid by Blue Dot Sessions Pictures: Wikipedia, DALL-E 3, InternetThe flaw in every voting systemPolylog2023-08-10 | A story about the fundamental flaw in every voting system -- strategic voting. We prove a simplified version of the Gibbard-Satterthwaite theorem, the most fundamental theorem of the voting theory.
pictures: MidJourney, Wikipedia, InternetThe most powerful (and useless) algorithmPolylog2023-04-04 | 0:00 Intro 2:44 The Algorithm 6:38 Why it works 9:28 Code 10:41 Final Thoughts
-- To prove that the universal search is asymptotically optimal, we implicitly used the fact that there exists a linear time algorithm for multiplying two numbers. This is true if you work with standard models of computers like the so-called Word RAM or pointer machine (Schonhage's algorithm, see 4.3.3. in Art of Computer Programming). For arithmetic operations, people also often consider a bit different model, where the time complexity of multiplication is O(n log n) (algorithm by Harvey & van der Hoeven).
-- A historical note: Levin presented his universal search in the same paper where he presented his discovery of NP-completeness which was independent of Steve Cook. This is why the main theorem about NP-completeness is called Cook-Levin Theorem. The paper of Levin is from early 1970's. Blum's speedup theorem (see next paragraphs) is even older, from 1960's. You can see how people back then thought about these super fundamental questions like "Is it clear that there is an asymptotically best algorithm for every problem?". It turned out that some of the results proven back then (Blum's speedup theorem, universal search) were too abstract to be useful, and it was the concept of NP completeness and related concepts that won and now they form the basis of our theory of algorithms.
-- The way we explained universal search, it is applicable only to "search problems" where you are searching for something (factors of a number) and once you find it, it is easy to check that what you found is correct. However, there exists an improved universal search by Hutter that searches not only over all programs, but also over all possible mathematical proofs that analyze those programs. This way, you can get an asymptotically optimal algorithm for any problem you like, except for some absolutely insane cases like when the fastest algorithm cannot be mathematically proven to work (although it works) or the time complexity f(n) is so complicated function that computing the value of f(n) takes more than O(f(n)) time. In fact, Hutter's search can be implemented in such a way that for algorithm with time complexity f(n), it takes only 1.01f(n) + O(1) time (for absolutely humongous O(1)).
-- On the other hand, there is a so-called Blum's speedup theorem that says that there exists a certain problem and a certain function f(n) such that you can have algorithms for this problem with complexities O(f(n)), O(log(f(n))), O(log(log(f(n)))) and so on but there is no fastest algorithm. Why is this not contradicting Hutter's universal search? Because this function f(n) is so weird that computing f(n) takes more than O(f(n)) time.
Big thanks to: Tomáš Gavenčiak, Matěj Konečný, Jan Petr, Hanka Rozhoňová, Tom Sláma Also, big thanks to 3blue1brown and the manim community for manim!
Credits: To make this video, we used manim, a Python library: https://docs.manim.community/en/stable/ The color palette we use is solarized: ethanschoonover.com/solarized music: Thannoid by Blue Dot Sessions: https://app.sessions.blue/browse/track/126782 picture of monkey: DALL-E 2 picture of Leonid Levin: https://www.cs.bu.edu/~lnd/ picture of Weierstrass and Cantor function: Wikimedia Commons Brainfuck suggestion: ChatGPT Levin’s quote taken from here: http://www.hutter1.net/idsia/nipsws.htm He definitely said something similar here: https://www.cs.bu.edu/fac/lnd/expo/qc.htmThe OPTIMAL algorithm for factoring!Polylog2023-04-01 | Our program: github.com/polylog-cs/universal-search/blob/main/code/universal_search.py
Credits: To make this video, we used manim, a Python library: https://docs.manim.community/en/stable/ The color palette we use is solarized: ethanschoonover.com/solarized music: Thannoid by Blue Dot Sessions: https://app.sessions.blue/browse/track/126782 music: Ride of the Valkyries from R. Wagner from wikimedia commonsAI cracked this Codeforces problem. Can you?Polylog2022-10-06 | Patreon: patreon.com/Polylog Website: polylog.cc
Credits Big thanks to Davin Choo, Christoph Grunau, Filip Hlásek, Matěj Konečný, Hanka Rozhoňová, Tom Sláma, Erik Stavarache for a review of an early version of the video.We designed special dice using math, but there’s a catchPolylog2022-08-16 | How would you order the players randomly? Tell us in the comments. :)
Some proposals that already appeared in the comments section:
- Put cards with player names in a sack, shuffle, then take them out one by one to get the order. - Simulate the above process using dice (see the comments by Jordan Weitz and samuraiwarm for how to do it). - Just reroll the dice if there are ties. More precisely, the tied guys go to the next round where they decide the order between themselves (or some of them need to go to the third round etc.). - One die with n! sides, write the final permutations on it.
The first two solutions are also similar to our solution with cards and to a so-called Fisher-Yates algorithm for sampling a random permutation.
If you consider the third solution with coins instead of dice, what it is doing is that each player is basically sampling a uniformly random number from [0,1], bit by bit. Then, they are ordered by the size of sampled numbers. This corresponds to a simple and popular algorithm to create a random permutation: just sample n random reals from [0,1] and order them by size; the probability of ties is negligible.
#SoME2
00:00 Intro 06:53 General Construction 15:26 Final Thoughts
A few more facts and (open) problems if you are interested:
-- You can generalize the lower bound on the number of sides of fair dice for general n; concretely, you can use the prime number theorem (or bounds on the so-called primorial) to show that n same-sized fair dice have to have 2^{\Omega(n)} sides each.
-- On the other hand, our construction gives dice with (n!)^{n-1} = 2^{O(n^2 \log n)} sides. It would be interesting to see these two bounds getting closer, if you have progress on that, let us know!
-- The lower bound on the number of sides can be generalized to the case when the dice are allowed to have different numbers of sides, then it tells you that for any n fair dice, at least 99% of them have to have 2^{\Omega(n)} sides. But we don't know whether all dice have to have exponentially many sides.
-- Suppose I give you a string of length n over alphabet with k letters and ask you whether it is fair. The naive way to check it has time complexity O(n^k). Can you do it in time O(f(k) * n) for some function f?The Simplest Sorting Algorithm (You’ve Never Heard Of)Polylog2022-04-13 | Patreon: patreon.com/Polylog Website: polylog.cc
webpage "God's number is 20" http://www.cube20.org The fact it was verified computationally that every cube can be solved in at most 20 moves is super impressive and much more complicated than the problem of solving just one cube that we covered in this video!
Convince yourself that the meet in the middle algorithm finds the shortest path!
Convince yourself that the meet in the middle algorithm for Rubik's cube does not need to know that every cube can be solved in 20 steps.
------------------------ Real Algorithms:
The first algorithms solving a random scramble like Korf's algorithm https://www.cs.princeton.edu/courses/archive/fall06/cos402/papers/korfrubik.pdf work roughly as follows:
First, although there are around 10^20 possible cube configurations, if you focus on just the possible configurations of 8 corner cubies, the number of possibilities drops to around 10^8. Using breadth first search, you can precompute for each such configuration of corner cubies how many steps you need to put them into the correct position. You need at least that many steps to solve the full cube configuration, probably even more as you need to solve not just the corners but also the edges.
You can now iterate a breadth first search from your scrambled cube, each time looking into further distance from it. For each cube you look up in your table of size 10^8 to find how many steps, at least, are needed to finish the search. If it is more than the current maximum distance you are looking at, you stop searching, as you can be sure you will not find the solved cube in this branch of the breadth first search.
This approach is similar to the meet in the middle algorithm in that we first precompute some information from the solved cube and then run breadth first search from the scrambled cube. However, now you need much less memory.
Triple DES is kind of a hack made to prolong the life of the DES cipher when it became apparent that it is not strong enough. However, because of the meet in the middle attack, its "security level" is only 2*56 bits and not 3*56 bits as one would naively expect. But you still need to apply DES three times. So you can guess it is not the most efficient way of doing the encryption; it is now superseded by the so-called AES standard. en.wikipedia.org/wiki/Advanced_Encryption_Standard
------------------------ Riddles:
If you like to solve algorithmic puzzles, here you can find more algorithmic problems that can be solved with this technique: youtube.com/watch?v=18sJ3mK173s&ab_channel=Errichto2 https://wiki.algo.is/Meet-in-the-middle
Try to prove, just with pen, paper and calculator that there is a cube for which at least 16 moves are needed to solve it.
Try to convince yourself that by blind search of the cube graph you cannot beat the sqrt(N) time, at least if you do not use anything else than that the graph "looks random". Hint: Birthday paradox
------------------------ Attributions:
To make this video, we used manim, a Python library: https://docs.manim.community/en/stable/
Thumbnail: Alžběta VolhejnováHow to Use Beads and Strings to Find the Diameter of a TreePolylog2021-08-22 | This video was made for the Summer of Math Exposition 1. Check out other cool videos there! 3blue1brown.com/blog/some1 #some1
To make this video, we used manim: https://docs.manim.community/en/stable/
Our video is based on the following great book: Explaining Algorithms Using Metaphors by Michal Forišek and Monika Steinová you can buy it here: https://www.springerprofessional.de/en/explaining-algorithms-using-metaphors/1793398
0:00 Intro 0:40 Trees 6:19 The algorithm 7:43 Why it works
It is a good exercise to fill in the missing gaps in the proof sketch that we gave in the video, where we focused on a particular tree instead of analyzing our algorithm in full generality. For example: we started by observing that if we hang a tree by its longest path, its nodes are contained in a triangle. How is this fact used in the actual proof?
Also: it can help with understanding the algorithm to consider the case when the tree is simply a path.
What else follows from the triangle picture:
The one or two nodes that are in the middle of the top edge of our triangle (see the end of the video) are also called the center of the tree. They have the following properties (formally, you would use one of these to define the center of the tree):
- The center is in the middle of any longest path of the tree - Leaves are the nodes with just one connection. If you repeatedly remove leaves from the tree (in each step, you remove all current leaves, in the next step the nodes that became leaves, and so on), the center is the last remaining node(s) before the whole tree is removed. - Eccentricity of a node is the distance to the farthest node from it. The center is the node(s) with minimum eccentricity.
Fun Riddles:
- Compute eccentricities of all nodes of a tree with an algorithm with linear time complexity (=number of steps at most some constant times number of nodes) - Compute the number of longest paths in a tree with an algorithm with linear time complexity
More Connections:
A more general question is: what is the diameter of a general network (there, diameter = longest distance between two nodes in it). This problem can be again solved by a naive algorithm that iterates over all nodes and finds the farthest node from each one. There is a substantially faster algorithm that uses similar ideas to those we saw in the video. The downside is that the algorithm is only approximate. If the true answer is D, it returns some number D’ that satisfies 2D/3 ≤ D’ ≤ D. That may seem unsatisfactory, but we know that if there is a nontrivial algorithm with at least slightly better approximation than the one above, something similar to P=NP happens (whether P=NP is the biggest problem in computer science and is considered unlikely to be true). The relevant paper: https://people.csail.mit.edu/virgi/diam.pdf