The Two Generals’ Problem


Comments • 2 666

  • Tom Scott
    Tom Scott   4 months back

    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

    • Akin Turhan
      Akin Turhan  3 weeks back

      I have thought about dashlane I want to know the advantage over Google chrome random password generator and manager that is synced with one master password. they don't know any of the passwords either.

    • The Superginge
      The Superginge  1 months back

      As glad as I am that you're getting sponsored, I feel I should tell people that Firefox is starting to offer this password security option for free, though before anyone gets angry at me, I don't know what level of security it is, comparatively, I just want to make people aware of options!

    • Matti Lüdke
      Matti Lüdke  2 months back

      Why not send a person from each army to the middle of the valley. Then both discuss a time and go back to their army. That way they will know if the message was received by the other army. As the Danger of the route lies in the middle of the valley they will get back safely.

    • صالح
      صالح  2 months back

      Hey there is a way to solve the 2 genrals problem and it's a horne or war drums because they are loud enugh to hear

    • Dark Thoughts
      Dark Thoughts  2 months back

      Now you know the issues protocol standards committees have to 'foresee' when designing a communication protocol.

  • TARINunit9
    TARINunit9  12 hours back

    Proposition for the two generals problem: instead of sending one messenger, send a pair of messengers. One messenger stays at camp B and the other returns to camp A. If no messengers return to camp A, then it's obvious that the message was intercepted on one of the two trips, so you send another pair

    • Lloyd Thorpe
      Lloyd Thorpe  3 days back

      What they should have done is just starve the castle out like they most commonly did

      • The Nintendo Fan
        The Nintendo Fan  3 days back

        Honestly, the red army would automatically assume the blue army got the message and would attack on that time

        • Eric ON
          Eric ON  3 days back

          Atleast once invocation solves this issue as well. I.e. let the client keep spamming the same request until one confirm has been recieved.

          • Emil Sørensen
            Emil Sørensen  5 days back

            I'd definitely not like having a master password that, if lost, renders my entire online life unrecoverable.

            How can you possibly make your one password unforgettable? Chisel it into an immovable rock?

            • NO STOP!
              NO STOP!  6 days back

              Send the entire army as the messenger

              • Beowulf Macbethson
                Beowulf Macbethson  6 days back

                I was watching a video about Morgoth from Lord of the Rings, why am I here.

                Also your video is great and informative.

                • TIMΞ СнΛИGΣ
                  TIMΞ СнΛИGΣ  7 days back

                  But the generals would know after a few acknowledgements? What am I missing here

                  • andrew allen
                    andrew allen  1 weeks back

                    Good grief, a Hewlett-Packard computer I can do component level repairs and maintenance on!

                    • man0z
                      man0z  1 weeks back

                      I may have double paid for Nandos last night

                      • IlluminatiBG
                        IlluminatiBG  1 weeks back

                        We solved this problem for banking application at work. The app is designed to work offline and synchronize when online. The acknowledgment problem is that you do not know if a message did not reach the server or it reached the server, but the confirmation was lost. As a result each message is uniquely identified in the client and safe to repeat. You can resend a message to the server a million times, but it will result in one transaction only for both client and the server.

                        • Curtis Moore
                          Curtis Moore  1 weeks back

                          This sort of thing happened to me 3 years ago through Amazon. The progress wheel after clicking "Buy Now" kept freezing when I hit it. I foolishly kept refreshing and hitting "Buy Now" again until getting to the confirmation screen. This was why, two weeks later, I had to ship back 15 identical USB phone chargers.

                          • Joshua Anderson
                            Joshua Anderson  1 weeks back

                            So how does general A know that general B got the message?

                            • Joshua Anderson
                              Joshua Anderson  5 days back

                              @lorvincent Thank you but I'm still not getting it for some reason. Are you saying that general A and B have 1000 other generals to get messages from? If general B relays the message to 1000 other generals how does general B know the other generals got the message? I'm stuck on something here...

                            • lorvincent
                              lorvincent  7 days back

                              Because 1000 other generals also got the message, and general B relayed to all 1001 of them, which caused the other 1000 to relay to general A that B got the message. It isn't the method described in the video, but this is the basic idea behind distributed ledgers with byzantine fault tolerance.

                          • Asma Hasmalaria
                            Asma Hasmalaria  1 weeks back

                            I have the solution: Instead of sending messengers to general B, general A picks up his phone, dials the number of the favorite pizzeria and says "I want a valley castle, with cheese dip and onions" and Deliveroo gets nothing while the pizzeria gets the money they deserve.

                            • iHunterKiller
                              iHunterKiller  1 weeks back

                              We’re looking at this as a 2d plane. In 3d, don’t go through the castle, go around it, meet up, attack together. Done.

                              • MrCocktaiI
                                MrCocktaiI  2 days back

                                Few things are as boring as giving 'clever' answers to puzzles that totally disregard the actual problem

                            • Banned From Existance
                              Banned From Existance  1 weeks back

                              So what if we get two messengers, one tries to go through the valley meanwhile the other observes the messenger at a safe distance. If the message gets killed, the other person can come back to let them know they failed! Thus they keep attempting until the get it right.

                              • BillyViBritannia
                                BillyViBritannia  1 weeks back

                                So the actual question is 'can you make sure a message arrives if you can't ensure the message' s arrival?'
                                Well, doesn't take a genius to see why that's impossible.

                                • BillyViBritannia
                                  BillyViBritannia  1 weeks back

                                  How is the comment section of such a technical/educational video so God damn funny.

                                  • Jonny boy
                                    Jonny boy  1 weeks back

                                    Can quantum computing utilizing quantum entanglement solve this issue?

                                    • Solo Playzz
                                      Solo Playzz  2 weeks back

                                      2 messengers meet in the middle before ya say

                                      • Solo Playzz
                                        Solo Playzz  2 weeks back

                                        Ok so you dont come to this conclusion... I'm gonna get an ego problem

                                      • Solo Playzz
                                        Solo Playzz  2 weeks back

                                        Wait... do you not come to this conclusion??

                                    • Lucas nada mas
                                      Lucas nada mas  2 weeks back

                                      What if you want one of the food and then you decide for whatever reason you want another... you cant

                                      • MightyGalactus
                                        MightyGalactus  2 weeks back

                                        What if General A send a messenger to General B with a message. Send a soldier to the middle at 5pm if they meet then the attack will be at 8pm. If they dont the attack will be at 9. After General B confirms that B received the msg from A.

                                        • No pe
                                          No pe  2 weeks back

                                          Isn't this what Bitcoin is trying to solve for money?

                                          • No-Feet McGee
                                            No-Feet McGee  2 weeks back

                                            "If you are in computer science and working on problems that involve potential loss of life, I really hope you aren't watching a series called the Basics." Look, just because you already know something doesn't mean it's not fun to watch an entertaining YouTube personality talk about it, okay ;)

                                            • David Aykac
                                              David Aykac  2 weeks back

                                              "But I was tired, and i was hungry. As are a lot of their drivers"
                                              sheeeeeesh, that was a harsh one xD

                                              • jamoecw
                                                jamoecw  2 weeks back

                                                idemptity? before computers it was called an order number. it doesn't solve the 2 generals problem either. this can be solved by a single person as well (the programmer).

                                                • BuzzaB77
                                                  BuzzaB77  2 weeks back

                                                  Known as the Byzantine problem. How Blockchain solved their ledger tech

                                                  • Fuddleton
                                                    Fuddleton  2 weeks back

                                                    I feel like there's another answer. What if instead of request/acknowledgement, each sent a request with an expected value, and the value was resent to track closer to the original requested value. When both are independently sending the same value, it's confirmation of receipt for both sides.

                                                    • macronencer
                                                      macronencer  2 weeks back

                                                      Personally, I would have constructed a giant wooden badger and left it at the gates as a gift.

                                                      • Jay Bivins
                                                        Jay Bivins  2 weeks back

                                                        I read the title as "The Two Genders Problem" I was like oh God no

                                                        • HottieTobby
                                                          HottieTobby  2 weeks back

                                                          about the valley thing. the message only has to go back and forth 2 times then once more for confirmation ???

                                                          • DomagojPS3
                                                            DomagojPS3  2 weeks back

                                                            Launch an arrow straight up if you received this message? Problem solved. Ok boomer

                                                            • pjax_
                                                              pjax_  2 weeks back

                                                              An Idempotency Token wouldn't have worked. You shouldn't get the same Idempotency Token if the you went through the app again and re-ordered food. If the app issues an Idempotency Token for exactly identical orders, that would prevent customers from ordering the same food the next day for example. Idempotency Tokens will only work if you didn't leave the shopping cart.

                                                              • Cypher791
                                                                Cypher791  2 weeks back

                                                                My pizzas never show up... possibly because I live in a castle 🤔

                                                                • JAJ Sentina
                                                                  JAJ Sentina  2 weeks back

                                                                  What if general A just send all his army to general B. Then they both storm the castle on general B side? Sure they risk being killed while transfering. But that scenario is also true if they pass messages.

                                                                  • Tangent
                                                                    Tangent  2 weeks back

                                                                    Idemponcy key.. Oh, so like a CSRF key! Similar solution to two very different problems.

                                                                    • xlaythe
                                                                      xlaythe  2 weeks back

                                                                      sounds like trying to set up plans to go out with people

                                                                      • Charley Ball
                                                                        Charley Ball  2 weeks back

                                                                        Love your videos, interesting and through provoking but explained clearly. Thank you.

                                                                        • Paul Blue
                                                                          Paul Blue  2 weeks back

                                                                          Best. dashlane plug. ever.

                                                                          • d d
                                                                            d d  2 weeks back

                                                                            Bitcoin has solved this issue with proof-of-work.

                                                                            • Jonathan Silverblood
                                                                              Jonathan Silverblood  2 weeks back

                                                                              To make the problem worse - the deliveryman could get copted, replaced or intimidated into providing false data with the intent of having the two armies attack at different times.

                                                                              It's a very interesting problem, and for those technologically minded that want to really dig down on this, I suggest you start researching bitcoin - a practical solution to the byzantine generals problem.

                                                                              • Jason Lei
                                                                                Jason Lei  2 weeks back

                                                                                But what if you’re just watching for entertainment?

                                                                                • Elyrx
                                                                                  Elyrx  2 weeks back

                                                                                  If general A's message is written in a way that only B will understand, the encrypted message could be to simply be a light/fire/smoke signal so that they wont have to risk a second messenger

                                                                                  • Tazin Davos
                                                                                    Tazin Davos  2 weeks back

                                                                                    Where's the Taz in that?

                                                                                    • Milo Summers
                                                                                      Milo Summers  2 weeks back

                                                                                      Thing about Dashlane is that it doesn’t work if you are at school because you can’t download dashlane into school computers and because there are som many different computers in my school it would be to long to download dashlane and log into on everyone one every time I want to look at my emails even if I could download it. So I have to check my password on a phone I’m not meant to have out in school and read a long complicated string of characters which takes a few tries to enter correctly

                                                                                      • Da Fuk
                                                                                        Da Fuk  2 weeks back

                                                                                        Can each general not send a messenger and they meat together and then go back

                                                                                        • Nate Scherer
                                                                                          Nate Scherer  2 weeks back

                                                                                          No because neither general would know if the other generals messenger made it back.

                                                                                      • Jan Doe
                                                                                        Jan Doe  2 weeks back

                                                                                        It also means that the server is very much prone to replay attacks because there is no freshness for the messages...