The Two Generals’ Problem

  • Published on: 12 August 2019
  • 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 by Sean M Elliott and Tom Scott
    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
    on Facebook at
    and on Instagram as tomscottgo
  • Runtime : 8:26
  • tom scott tomscott the basics computer science two generals problem two generals' problem the two generals problem idempotency idempotency key idempotency token idempotence


  • Tom Scott
    Tom Scott   2 months ago

    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

  • Shashank Tangirala
    Shashank Tangirala   9 hours ago

    This explain why a person repeatedly presses the floor buttons in an elevator. Interesting.

  • Ethan M
    Ethan M   15 hours ago

    Just shoot some arrows from the top of the hill, g'all darn it...

  • Paquin13
    Paquin13   15 hours ago

    And then there was Bitcoin

  • Kian Doyle
    Kian Doyle   1 days ago

    Is his hands also looking light blue, when you just look at his face throughout the video?

  • Martin Brochhaus
    Martin Brochhaus   2 days ago

    This problem has been solved. Look into byzantine fault tolerance and bitcoin.

  • quithread01
    quithread01   2 days ago

    What if two messengers meet in the middle and then head back.

  • Джонатан д
    Джонатан д   3 days ago

    If you're talking about computers and not this exact "two generals" situation, then no, they aren't analogous. I can solve the two generals. That was pointless.

  • Irishcrossing
    Irishcrossing   3 days ago

    me a history nerd: ah, to seige the castle, there are plenty of ways to communicate in this strange but ultimately solvable science: no you can't do any of those.oh

  • Oscar Guerrero
    Oscar Guerrero   3 days ago

    This is a microservices mesh problem. Your idempotency key would not work. It would require policy on the client and not all retry solutions have the path you explained. The solution is multiple internal retry layers and full error contracts that are transparent and granular for all micro services.

  • Ryan Wilder
    Ryan Wilder   4 days ago

    "Now, with computers you're not usually dealing with such high stakes. If you are in computer science and working on a problem that involves potential loss of life, I really hope you aren't watching a series called 'The Basics'." I'm literally taking lunch at my desk watching this video before I get back to development of a major electronic health record. :|

  • Ray Shi
    Ray Shi   4 days ago

    Why not send the whole army across?

  • Michael McCarty
    Michael McCarty   4 days ago

    I remember imagining this paradox when I was a kid. It was one of the many philosophical questions I asked without realizing someone else already thought of it. Zeno’s Paradox is another.

  • Taran Singh
    Taran Singh   4 days ago

    I dont get whats so difficult. General A should just facetime General B

  • Noah Ord
    Noah Ord   5 days ago

    If both generals send down two messengers and have them meet in the middle and then have two of the messengers go on to the opposite castle while the other messenger returns to the general that sent it with the messenger sent by the other general it might work

  • N/A Gaming
    N/A Gaming   6 days ago

    The guy who goes to deliver the message just has to come back to base camp and say they delivered it:/

  • Alex Smith
    Alex Smith   6 days ago

    I have my credit card company text me whenever there is a charge. This way I know within a few seconds that a transaction has happened, and can see if I get charged when I shouldn't

  • Austin Lindsay
    Austin Lindsay   6 days ago

    I guess the castle is so tall you can't have general b shoot up a flaming arrow to signal they recieved the message? Or they lack bows/fire? Maybe i missed part of the rules.

  • Jack Rocker
    Jack Rocker   6 days ago

    quantum computing using entanglement while computing a simple algorithm using time of day variables, with an open step to represent the message. instantaneous messaging with error correction.

  • Axl Raveling
    Axl Raveling   1 weeks ago

    I solved the problem..... just send the the Messenger you recieved return

  • Omenvreer
    Omenvreer   1 weeks ago


  • Adam Schnepp
    Adam Schnepp   1 weeks ago

    Wouldn't only a third confirmation be enough? That way both sides are aware of the time and both sides have recieved a confirmation from the other side?

  • Isoruku Yamamoto
    Isoruku Yamamoto   1 weeks ago

    I mean this is also a practical solution to the actual two generals problem. There is no reason whatsoever to keep repeating after party B has been informed and party A has gotten a confirmation. Detailed invite + specific confirmation means you should always proceed. Only if the initial message or the respons message does not come through you cannot proceed, because you haven't established a two-way communication then, which is vital in this kind of problem.

  • kumfroik
    kumfroik   1 weeks ago

    But, if you get the message, that your answer to the answer of the letter you wrote has been received, isn't it than clear, that both generals know when to attack?

  • Matthew Morris
    Matthew Morris   1 weeks ago

    "This problem is unsolvable". No. One general agrees to raise a flag, as agreed in the message, or lights a fire, or fires a cannone. There are endless ways to resolve this analogy.

  • Marvin Heyboer
    Marvin Heyboer   1 weeks ago

    Funny. My service program does this. I can't charge the same card for anything that might seem close to the same charge in the same 24 hours. It's a fail safe. Frustrating when the second charge is accurate, but I just need to wait a day to charge for the second payment. Better safe than sorry. People get pissed when you charge them twice by mistake!

  • sld1776
    sld1776   1 weeks ago

    If there's no solution, it's a pardox, not a problem.

  • Ben Norris
    Ben Norris   1 weeks ago

    except its not pronounced like omnipotence

  • Koray Gun
    Koray Gun   1 weeks ago

    Why complexity just use the phone .

  • XDarkPhoenixX
    XDarkPhoenixX   1 weeks ago

    Common sense also solves this problem. If you think you have paid, check your account, if money is missing, call the store and check on your order. Not hard. People trust websites and apps far too much nowadays.

  • Laurent Cardinal
    Laurent Cardinal   1 weeks ago

    "If you are in computer science and working on a problem that involves potential loss of life, I really hope you aren't watching a series called 'The Basics'." It's these little jokes (along with the dumbed-down analogies and similies) that make me love this series as opposed to any other basic computer science series

  • blu 006
    blu 006   1 weeks ago

    "If you're in computer science and working on a problem that could cause a potential loss of life, I really hope you aren't watching a series titled 'the basics.'"Oh. If it's any comfort, I'm watching because it's my Lunch break and I love your videos.