Fireship · @fireship

10 weird algorithms every developer should know

Uploaded December 21, 2023 · Length 9:06

10 weird algorithms every developer should know

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.

  1. 0:00

    have you ever woken up in the middle of

  2. 0:01

    the night in a panic wondering how to

  3. 0:03

    extract a polygonal mesh of an ISO

  4. 0:05

    surface from a three-dimensional

  5. 0:06

    discrete scalar field yeah I didn't

  6. 0:08

    think so but back in ' 87 two

  7. 0:10

    programmers at General Electric did they

  8. 0:12

    created and patented the marching cubes

  9. 0:14

    algorithm an algorithm that is likely

  10. 0:16

    saved countless lives by allowing

  11. 0:17

    doctors to visualize data from CT and

  12. 0:20

    MRI scans whenever you instruct a

  13. 0:22

    machine to solve a problem with code

  14. 0:23

    you're creating an algorithm a procedure

  15. 0:25

    for rearranging ones and zeros that can

  16. 0:27

    make animals talk and vacuums walk most

  17. 0:30

    algorithms belong in the dumpster but

  18. 0:32

    some are fast some are beautiful and

  19. 0:34

    some are so weird they're

  20. 0:35

    indistinguishable from Magic today we'll

  21. 0:37

    look at 10 of the most interesting

  22. 0:38

    algorithms ever engineered and how

  23. 0:40

    they're used to solve very interesting

  24. 0:42

    problems in the real world first on the

  25. 0:44

    list we have wave function collapse one

  26. 0:46

    of the weirdest things in all of science

  27. 0:47

    is the double slit experiment where

  28. 0:49

    particles behave like a wave when you're

  29. 0:51

    not looking but when you look they

  30. 0:52

    suddenly collapse down to a particle it

  31. 0:54

    seems counterintuitive but it makes

  32. 0:56

    total sense when you realize we're

  33. 0:57

    living in a simulation and the universe

  34. 0:59

    wrote this algorithm to cut down on its

  35. 1:01

    AWS bill it's an interesting concept to

  36. 1:03

    think about philosophically but the

  37. 1:04

    general idea behind wave function

  38. 1:06

    collapse can also be implemented

  39. 1:07

    programmatically imagine we have a map

  40. 1:09

    for a video game but what if this is a

  41. 1:11

    sidescrolling game that can go on for

  42. 1:13

    eternity we can't just make a bigger map

  43. 1:15

    we need an algorithm to procedurally

  44. 1:17

    generate it on the Fly what's so weird

  45. 1:19

    is that we can take this initial map and

  46. 1:20

    think of it as being in the initial

  47. 1:22

    super position of all possibilities it's

  48. 1:24

    the wave function then upon observation

  49. 1:26

    it collapses into a particle or in other

  50. 1:28

    words it selects a Rand a map tile but

  51. 1:30

    follows a consistent set of rules like

  52. 1:32

    in this case making sure that the roads

  53. 1:34

    are always connected providing a random

  54. 1:36

    yet cohesive result and doesn't rely on

  55. 1:38

    any sort of modern generative AI

  56. 1:40

    speaking of which AI is weird as hell

  57. 1:42

    diffusion is a machine learning

  58. 1:43

    algorithm originally developed at open

  59. 1:45

    Ai and is the magic behind image

  60. 1:47

    generators like Dolly and stable

  61. 1:49

    diffusion but the concept of diffusion

  62. 1:51

    actually comes from thermodynamics where

  63. 1:53

    particles spread from areas of higher

  64. 1:55

    concentration to lower concentration in

  65. 1:57

    artificial intelligence the process is r

  66. 1:59

    reversed the algorithm starts by