Fireship · @fireship
10 weird algorithms every developer should know
Uploaded December 21, 2023 · Length 9:06
Summary
10 unusual algorithms used in programming, including wave function collapse, diffusion, simulated annealing, sleep sort, and RSA.
- algorithms
- programming
- computer science
- wave function collapse
- diffusion algorithm
- simulated annealing
- sleep sort
- bogo sort
- rsa algorithm
- quantum computing
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
have you ever woken up in the middle of
- 0:01
the night in a panic wondering how to
- 0:03
extract a polygonal mesh of an ISO
- 0:05
surface from a three-dimensional
- 0:06
discrete scalar field yeah I didn't
- 0:08
think so but back in ' 87 two
- 0:10
programmers at General Electric did they
- 0:12
created and patented the marching cubes
- 0:14
algorithm an algorithm that is likely
- 0:16
saved countless lives by allowing
- 0:17
doctors to visualize data from CT and
- 0:20
MRI scans whenever you instruct a
- 0:22
machine to solve a problem with code
- 0:23
you're creating an algorithm a procedure
- 0:25
for rearranging ones and zeros that can
- 0:27
make animals talk and vacuums walk most
- 0:30
algorithms belong in the dumpster but
- 0:32
some are fast some are beautiful and
- 0:34
some are so weird they're
- 0:35
indistinguishable from Magic today we'll
- 0:37
look at 10 of the most interesting
- 0:38
algorithms ever engineered and how
- 0:40
they're used to solve very interesting
- 0:42
problems in the real world first on the
- 0:44
list we have wave function collapse one
- 0:46
of the weirdest things in all of science
- 0:47
is the double slit experiment where
- 0:49
particles behave like a wave when you're
- 0:51
not looking but when you look they
- 0:52
suddenly collapse down to a particle it
- 0:54
seems counterintuitive but it makes
- 0:56
total sense when you realize we're
- 0:57
living in a simulation and the universe
- 0:59
wrote this algorithm to cut down on its
- 1:01
AWS bill it's an interesting concept to
- 1:03
think about philosophically but the
- 1:04
general idea behind wave function
- 1:06
collapse can also be implemented
- 1:07
programmatically imagine we have a map
- 1:09
for a video game but what if this is a
- 1:11
sidescrolling game that can go on for
- 1:13
eternity we can't just make a bigger map
- 1:15
we need an algorithm to procedurally
- 1:17
generate it on the Fly what's so weird
- 1:19
is that we can take this initial map and
- 1:20
think of it as being in the initial
- 1:22
super position of all possibilities it's
- 1:24
the wave function then upon observation
- 1:26
it collapses into a particle or in other
- 1:28
words it selects a Rand a map tile but
- 1:30
follows a consistent set of rules like
- 1:32
in this case making sure that the roads
- 1:34
are always connected providing a random
- 1:36
yet cohesive result and doesn't rely on
- 1:38
any sort of modern generative AI
- 1:40
speaking of which AI is weird as hell
- 1:42
diffusion is a machine learning
- 1:43
algorithm originally developed at open
- 1:45
Ai and is the magic behind image
- 1:47
generators like Dolly and stable
- 1:49
diffusion but the concept of diffusion
- 1:51
actually comes from thermodynamics where
- 1:53
particles spread from areas of higher
- 1:55
concentration to lower concentration in
- 1:57
artificial intelligence the process is r
- 1:59
reversed the algorithm starts by


