The Two Generals’ Problem

Tom Scott
29 308 Áhorf 3 m.

Time to tell a story about idempotency, computer science, and the Night of the Multiple Orders. • Sponsored by Dashlane -try 30 days for free at:
Written with Sean Elliott SeanMElliott/
Directed by Tomek
Graphics by Mooviemakers
Audio mix by Haerther Productions
Thanks to Dashlane for sponsoring the video! If you're techie enough to watch this video, you should be using a password manager. Get a 30-day free trial at
I'm at
on Twitter at tomscott
on Facebook at tomscott
and on Instagram as tomscottgo


  1. Tom Scott
    Tom Scott
    11 mánuðum síðan

    Yes, I had help with the graphics for this series. There's no way I'd have animated that myself! On that note, thanks to Dashlane for sponsoring and helping me hire an animator: their free trial link is

    1. Hyper Bear
      Hyper Bear
      7 dögum síðan

      Has anyone asked Rick Sanchez for the answer?

    2. k
      10 dögum síðan

      I couldn't track the metaphor it was too general

    3. Thread Bomb
      Thread Bomb
      16 dögum síðan

      I'm really bothered by the unnecessary apostrophe in the video title. We expect better, Tom!

    4. Youcant Stopme!
      Youcant Stopme!
      Mánuði síðan

      Use smoke stacks

    5. therealsonic101
      Mánuði síðan

      A solution to the army problem?: Red goes over with a message and comes back with a blue. When they get halfway to red, blue turns around and goes back. Keeping the same pace, they should get back to their side around the same time. Once they both get back, they start to attack.

  2. CloudandZack1st
    2 klukkustundum síðan

    I always have the energy to cook - but I can't cook.

  3. LK007
    4 klukkustundum síðan

    Idempotent A*A=A

  4. Critical Indicator
    Critical Indicator
    Degi Síðan síðan

    So are we all now agreeing that "gig economy jobs" are the same as anti-union anti-worker jobs?

  5. LuckyLouie
    Degi Síðan síðan

    This hits me in something weird that makes me watch more. Almost like actually fun learning.

  6. dragonfly5732
    Degi Síðan síðan

    Just move the army to the other castle

  7. Lance Jordan
    Lance Jordan
    Degi Síðan síðan

    Tesla just had this issue with their website. Someone ordered 28 cars by clicking the buy button again and again after it said there was an error.

  8. Arvind Sami
    Arvind Sami
    2 dögum síðan

    Anyone else interested in what pizza it was?

  9. Jj Pelham
    Jj Pelham
    2 dögum síðan

    use a horn, thats what they did.

  10. Golden GT
    Golden GT
    2 dögum síðan

    I’m real late to this but: one generals army sends 2 messengers at once, and tells the second messenger to only return if they both make it through to the other general and deliver the message, and if they do not come back, send another 2 messengers with the same instructions. Then they will know if they made it through because the one messenger will have guaranteed seen the other messenger make it through, and also they will have made it back so both sides are aware of the plan and they are aware the other general is aware of the plan.

  11. Havoc 09
    Havoc 09
    2 dögum síðan

    Each army sends two messengers around the same time. Each messenger meets the other and makes sure the other survived by telling the army who sent it that Their messenger made it across. This riskiest part is that either of the messengers didn’t make it after meeting with the other. Another problem might be that they may not know the plan. It might have holes but could work.

  12. Daniel M
    Daniel M
    2 dögum síðan

    In "Long Dark Tea Time of the Soul," Douglas Adams lamented the fact that Brits could not get pizza delivery, something that has been normal in the US for more than 50 years.

  13. TheRealSta1k3r
    2 dögum síðan

    Answer: If you can respawn after you die, the Generals can just send their armies one after another, nonstop

  14. Goose 6.0
    Goose 6.0
    2 dögum síðan

    Theoretically, Couldn't both generals send a message containing a time, and continue sending messages containing a time until both times were in agreement

  15. Anton.fwp
    2 dögum síðan

    that problem applies to every single conversation

  16. Dududu
    2 dögum síðan

    thats why i wanted to be in computers but i resigned xD

  17. Master Ed
    Master Ed
    2 dögum síðan

    Could of just sent two (one from blue and one from red) messengers to meet each other in a ditch!

  18. Peter Hall
    Peter Hall
    3 dögum síðan

    I might be just being slow but I don't see how being idempotent "fixes" the two generals problem? I'd like to understand

    3 dögum síðan

    "Many poor decisions made over a long period of time" life, bro.

  20. Lee O’kelly
    Lee O’kelly
    3 dögum síðan

    I’ll stick with Uber eats thanks

  21. Cloud
    3 dögum síðan

    "Idempotence. Idempotence is a funky word that often hooks people. Idempotence is sometimes a confusing concept, at least from the academic definition. From a RESTful service standpoint, for an operation (or service call) to be idempotent, clients can make that same call repeatedly while producing the same result."

    1. ydertgf
      2 dögum síðan

      Cloud bruh you have 1 like yet ur near the top

    3 dögum síðan

    Answer: call for support.

  23. Remco Hamersma
    Remco Hamersma
    5 dögum síðan

    For me it would be more logical if the castle was on a hill. In that case the generals couldnt just see eachother

  24. VodShod
    5 dögum síðan

    I had this problem when trying to deposit a check at multiple ATMs

  25. Boab Joab
    Boab Joab
    5 dögum síðan

    General C would solve the problem.

    1. Boab Joab
      Boab Joab
      5 dögum síðan

      And if not, D, E and the rest might. Infinite generals... Infinity +1😵

  26. Mr.Memetic
    5 dögum síðan

    Just use the same courier

  27. theWORSTluck
    6 dögum síðan

    The same thing was happening on door dash around the same time 👀

  28. SuperLemonfish
    6 dögum síðan

    my solution to the generals problem: send 2 messangers simultaneously, once they get to the castle they will iether be captured or not, if not, then one continues forward to the other side and one comes back, letting us know that they crossed the castle. but if they are captured, then nobody comes back, so we know we have to send another pair.

    1. Boab Joab
      Boab Joab
      5 dögum síðan

      It.. Might.... Just.... Work. 🤔

  29. Podaj747
    6 dögum síðan

    1. There's a chance both messengers will be sent at the same time (with the generals not knowing where they are), reach an agreement, and go back to their armies. They will attack at the same time provided both messengers will tell their general an agreement has been reached and the attack takes place on (for example) 6pm.

  30. darci peeps
    darci peeps
    7 dögum síðan

    I have watched this video a few times and still don’t really get it

  31. Matthew Huang
    Matthew Huang
    7 dögum síðan

    You can just send billions of cards, at least one of them would go through.

    1. Cujo
      6 dögum síðan

      That's the most common solution used in the real world way of thinking, but it has nothing on the theroeticals. There is a chance, no matter how small, that every single messenger would die. Even if it's 0.000000000000001% chance, it's still there. In the real world this would mean nothing, but that's the point of theroreticals.

  32. The Guy That makes you mad
    The Guy That makes you mad
    7 dögum síðan

    *Solution is not to send 200 messages, but to send message-floods until you get a repply? Ok...*

  33. Bezza
    7 dögum síðan

    to solve it simply send a messenger from both sides to meet in the middle, exchange a message then come back, if neither come back they died if one comes back so will the other as they met in the middle and either both get killed or neither get killed by the castle

  34. klarigi4219
    7 dögum síðan

    It's the people's fault for not realising the payment had gone through and bought more. Stupid-ass lazy people should've watched Tom Scott ;)

  35. TrveIrrlicht
    9 dögum síðan

    And now I have a blocked payment of 100 USD in my Paypal account because I ordered the same shipment by UPS twice

  36. Sebastian Buchfink
    Sebastian Buchfink
    9 dögum síðan

    if the two generals problem equals the german internet connection not only the messanger will get lost but also two armies while atacking XD

  37. Just one more thing
    Just one more thing
    10 dögum síðan

    Hey! I don't watch this series because I faked my way into nato high command. I watch it because it's entertaining. Also I'm an admiral. Could you perhaps elaborate how this problem applies to nucular submarines?

  38. Marty W.
    Marty W.
    10 dögum síðan

    i mean, couldn't you just call the restaurant?

  39. Scott L.
    Scott L.
    10 dögum síðan

    Carrier pigeon?

  40. k
    10 dögum síðan

    I couldn't track the metaphor it was too general

  41. Luke Madsen
    Luke Madsen
    10 dögum síðan

    "Next time, I'll cook for myself" **After 4 math exams in one week** Me: Yes, I would like a pizza

  42. El Fro
    El Fro
    11 dögum síðan

    The problem solution: why can’t the original sender just come back and say it went through

  43. Papa Putin
    Papa Putin
    11 dögum síðan

    Aint caszles like on hills instead of in valleys

  44. Minecrafter123456789
    11 dögum síðan

    bruh just send a scout and wait for that scout to return

  45. crystalpie
    12 dögum síðan

    use a paper plane simple

  46. Silver Unknown
    Silver Unknown
    12 dögum síðan

    Can’t the messenger from the red army just come back to his original army?

  47. RhiRhy
    12 dögum síðan

    I know its impossible to have a 100% surefire way but, General A could send 2 messengers, 1 would return during the halfway point. Assuming it was safe, they would continue Probably would be the best choice other than spamming messengers between A and B

  48. Vulpovile
    12 dögum síðan

    I once paid for someone else's e-book because of this

  49. maxcyaneye
    13 dögum síðan

    i have an idea use dashlane to make a password for another password manager

  50. Chris Kelly
    Chris Kelly
    13 dögum síðan

    all i’m thinking is how you up pick this kind of problem in real-time with managers, social media managers and execs stressing at you. aaaaaaa

  51. Derek Lamers
    Derek Lamers
    13 dögum síðan

    Right just hear me out, what if General A sent a message saying ''if you get this message, light a huge fire at 8pm, once we see the smoke we shall attack.'' If at 8pm there's no fire, they don't attack. If they see the fire they know that General B has received the message.

    1. Mr_Magnus
      10 dögum síðan

      Because computers trying to communicate over a network connection don't have the equivalent of a huge fire and bellowing smoke. All they have is that network connection.

  52. Максим Кузьмин
    Максим Кузьмин
    13 dögum síðan

    You only need 3 messages to 1. Deliver time 2. B confirms to A 3. A confirms to B Now they both know the time & that the other knows it. (MiM attacks aside)

  53. PongoThomas
    14 dögum síðan

    It's easy, just have A send amessenger, and if they don't return to A, don't attack. If they return, both attack. The scenario doesn't say that they can die on the way back

  54. Walker
    14 dögum síðan

    Light a signal fire

  55. Amy C.
    Amy C.
    15 dögum síðan

    How about you send the scout back

  56. Chayden S
    Chayden S
    16 dögum síðan

    Surly if A made a direct line connected to B, then the people in the middle started to attack the castle. Then the next 2 from A and B. Then the next 2... So on so on... It'd get back to the whole arm at the same time like a fuse, setting both into motion.

  57. michael smith
    michael smith
    17 dögum síðan

    If only there was some way to talk to a person?!!!

  58. Nathan Heuton
    Nathan Heuton
    20 dögum síðan

    You're very good at making difficult subjects easily understandable. Excellent channel.

  59. R4Z7
    20 dögum síðan

    Why can't it just go back? For example A can agree on that they will know that B received the msg only if the solder comes back. I feel like I am missing something

  60. Hugh Gordon
    Hugh Gordon
    20 dögum síðan

    The only way to solve this is to go outside the system, eg send up a certain flag to acknowledge the receipt

  61. 1234Daan4321
    20 dögum síðan

    I once accidentally ordered 2 pizzas instead of 1, because my computer's mouse wasn't working properly.

  62. Lando
    21 degi síðan síðan

    But if they make it the solider will come back, right?

  63. FCNMike1
    22 dögum síðan

    If you send a wave of messengers, you have the possibility of one making it(all at once) and the way you acknowledge it is by shooting a fire arrow at night.

    22 dögum síðan

    Solution: whatever message makes it is the time.

  65. Riverpaw 323
    Riverpaw 323
    22 dögum síðan

    Bruh just send the one messenger back with the acknowledgement

  66. Boris Gleichmann
    Boris Gleichmann
    24 dögum síðan

    My attempt to solve this as good as i can: Have both sides send a Messenger at the same time, then Attack at the time it says in the msg If u get one. Assuming the times arent the same, and the Chance of being spotted is 50% theres a 66.6% chance to sucessfully Take down the castle: If both of them fail, the whole thing Just repeats because nothing happened, effectively Putting us Back to the start -> we can ignore this scenario If A or B but not both make it, it works If both make it it doesnt work (unless the times are the same, in which Case its 100%, because all scenarios lead to attacking at the same time or restarting from the start) Edit: Just to clarify, yes, this IS built around the 50% of being caught or Not, changing the odds Changes the result, duh

    1. Lkxemmeji
      22 dögum síðan

      both armies have to know "the same time" before sending a messenger. And if they know it they can already attack at the same time without use of messengers.

  67. Drone Dude
    Drone Dude
    24 dögum síðan

    OK so I haven’t watched the video yet, but couldn’t they both send a messenger at the same time at the Castle Valley, where the two would talk to each other and figure out a time. then they would each go back to their side and tell their armies

  68. Raphael Lenkwane
    Raphael Lenkwane
    24 dögum síðan

    Why don't the general use the same messenger to go and come back, if the messenger doesn't return within, say a day, send another messenger until the same messenger does a return trip

  69. The Bush Telegraph
    The Bush Telegraph
    24 dögum síðan

    Two solutions to the unsolvable two generals problem. One, why don't the generals, providing the a and b flags are actually being held by a flag holder for each army, being they are both most likely in view of each other, wave their flag at each other to say they are in position and ready to attack. Another solution would be the good old tin and string phone method to communicate, only requiring one member of the army to send one tin to the other army with a string attached.. Regarding your pizza order, wouldn't it just be easier to ring the pizza place or cook as you mentioned 😊

  70. Peter The Content But Moody Rabitt
    Peter The Content But Moody Rabitt
    24 dögum síðan

    The only solution for the Two Generals Problem, is for each side to send a message at the same time, so they meet in the middle and "bounce" off of each other, simultaneously confirming message received, assuming that the messenger is safe once it begins moving away from the castle.

  71. ClarkeZor
    25 dögum síðan

    TCP... syn, syn/ack, ack. Positive acknowledgment is already a thing.

  72. megalexantros
    26 dögum síðan

    You weren't lucky. You were smart enough to not pay for the same thing 3 times...

  73. 1sammyson
    26 dögum síðan

    Why are there dislikes on this video? It’s brilliant.

  74. Ian Turley
    Ian Turley
    26 dögum síðan

    Maby they did it on purpose.. All those extra orders generate a lot of cash. Which could be traded with to make more cash. And as long as they pay back what they owed, they get to keep the profit..

  75. Q. E. D.
    Q. E. D.
    26 dögum síðan

    Don’t know why they don’t just txt each other. Or they could have a zoom conference with all their senior officers, too.😉😁

  76. Evg Likov
    Evg Likov
    27 dögum síðan

    how come they can't just set a huge fire or like this

  77. Moo Moo
    Moo Moo
    27 dögum síðan

    Tom Scott: A single person can never be the root problem. Also Tom Scott: ONCE I DELETED AN ENTIRE DATABASE

    1. Dr. 2avAge
      Dr. 2avAge
      17 dögum síðan

      Like @Christopher Stokes said there were multiple errors that lead up to that.

    2. Eddy
      17 dögum síðan

      @Christopher Stokes good point actually! Thanks for the insight, I was thinking the same way as the guy above you.

    3. Christopher Stokes
      Christopher Stokes
      22 dögum síðan

      Even then, there were multiple poor decisions leading up to that problem (e.g. not taking a backup, working on the live system, not starting a transaction) - so, that case is another example in favour of his point.

  78. Varun Gupta
    Varun Gupta
    27 dögum síðan

    Only if we were thought the TCP/IP stack in Uni like this.

  79. Ye local wierdo
    Ye local wierdo
    27 dögum síðan

    Just press any button to continue. Duh

  80. Simon Beck
    Simon Beck
    27 dögum síðan

    why is a castle in a valley