The Two Generals’ Problem

Tom Scott

4,1 milj. näkymät532

    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

    Julkaistu Vuosi sitten


    1. Tom Scott

      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. allahm-ast3mnly wlatstbdlny

        Mashallah tbark Allah alhamudillah inshallah better astgfrallah

      2. Tomas

        Bitwarden does the same thing for free

      3. absol761

        that video is dumb they will no if they got it if the messenger comes back

      4. Olives Of Truth

        @Azarus . jj

      5. DarkPulse Gaming

        nvm just watched the rest of the video and its about computers

    2. Traffic Light

      It's common sense to check if a payment went through before considering another attempt.

    3. FCSΩ //FCSectorΩ

      Send a guy to the other side and require them to come back. If they do not come back after a reasonable time, send another

    4. Ruff_man

      Generally when things like this happen, I check my pending transactions through my bank (I know the uk bank I used to work with has only within the past few years allowed you to see these). Its a great way to double check, but their are instances where this may not work, I.e. offline transactions.

    5. goober

      It was until BTC came along...

    6. Basti5454

      What if they both send messenger and the same time

    7. artm pir

      I thought computers were boring and complicated so I still can't believe that I am watching this and also subscribed Awesome video thanks

    8. 十四Ralph

      So what happened to those that ordered more then once?

    9. Ezekiel Arincorayan

      What if both sides sent a messenger at the same time, asked if would do this time, and went back to tell their side and in the middle the messengers find a good time to attack

    10. Sub Bot 1,000

      Ok with the generals you could possibly maybe have them set off a fire work?

      1. Anders And

        Did you even watch the video

    11. scrappylikemetal

      Easy. Just attack. The castle's forces get focused on one side while the other attacking force finds a skeleton crew on the other. They'll know when they start seeing smoke.

      1. Anders And

        Did you even watch the video, this is a computer problem, not real life

    12. John Price

      Here, we call it the byzantine general problem

    13. Michael Sherwin

      Should have let the Post Office handle the communications. ....everyone would have been shafted !

    14. Nicholas Cleaves

      what do you mean not such high stakes. My teammate might not hear my callout in warzone.

    15. Elija Barz

      What tom does while waiting for his food

    16. Aaron Long

      Idk, tom. Sending 800 messengers probably wouldn't send the message to attack **later**

    17. logon235

      Try using this to explain the silliness of the dominion voting allegations. Running the ballot through the machine again will not duplicate the vote.

    18. Diogo Macena

      General B should be fired.

    19. Foxy

      ok but why doesn't general a send a person to meet general b then go back? (sorry for the bad grammar I'm running on coffee and energy drinks)

    20. nanorider426

      WeI had this problem in class once - waaay long ago - and Scot is right.

    21. Isaac Starling

      They can go around the castle. Or get far enough away from the castle then go to the other side of the valley then walk along the top of the valley to general b deliver the message. return back to general a and say general b got the message

      1. Anders And

        did you even watch the video

    22. Ali 2JZ

      Ahh yes the old SYN/ACK

    23. moonshiry

      i dont get it. isnt this problem solved/worked around by TCP communication?

    24. A.J. Steinman

      2:55 Is this a "series called The Basics"? I've never seen such a title on these videos.

    25. nebulousJames12345

      debounce that sucker.

    26. Mary Gibson

      This is the only time I've wanted to use dashlane. Every other sponsor says dashlane "saves" your passwords for you. Or that it "stores them." And my brain always goes "nooooo way!"

    27. David Ayliffe

      Very interesting. Thanks for taking the time to make this

    28. White Line

      I have watched this several times before and now I still have no idea what this is gonna be about

    29. C0ma_T0astッ

      just send the same messanger both times so if the messanger that a sent doesnt come back with the message they dont fight

    30. P77777777

      Option C: Both sides just sit there and let the forces in the castle who are cut off from the outside sit and run out of supplies

    31. Riptide Anomy

      If we’re talking castles, starting a fire can help signal, then it sets as a beacon, it’s up to the other side to do the same, then when both are put out they’re ready to attack

    32. Roger Szmodis

      A few weeks ago a pizza place sent my order twice by mistake. Got a free pizza out of it though

    33. Colleen Forrest

      This video won't age well when quantum computers become a thing :)

    34. Robert Porter

      The "Example" of two Generals is Flawed! In reality, attacks in actual conflicts have had less coordination that your scenario! Anyone who knows history will get disinterested and not think of a solution ;)

    35. George Stanmore

      Er that solves the order problem but not the generals

    36. Jakub S.

      Post pigeons.

    37. David Whittaker

      The person will be back

    38. Eli Nors

      Just use a paper airplane and fly it over the castle to deliver the other army.

      1. Mr. Hat

        the castle could have SAM batteries

    39. Momo

      I thought this said "the two genitals problem"

    40. Gerandar

      Flags and smokes no need to run a message.

    41. ThomasHaberkorn

      a castle would never be in a valley

    42. catoleg

      TCP three way handshake is there to solve this problem

    43. no nono

      You need A to send the message, then B to send an acknowledgement, then A to send one and in the last B needs to send one but this one is different. It doesn't matter if the last one will be received or not as both generals will already have an acknowledgment of receipt of the original message at this point.

    44. Hans and his panzerfaust

      What if A sent an acknowledgment saying: if you retrieve this letter give us a signal, like a horn or flag waving after B sent an acknowledgment to A’s message of attack at 8pm? Or just walk around to the other army then attack from one side?

    45. A Rock.

      Hello there

    46. Puerto Alto

      Satoshi Nakamoto enters the chat...

    47. Bri’ish European

      Send a small division (20 soldiers, 4 messengers) because there’s no way they could’ve been killed with that number

    48. John Doe

      easy solution. One army runs whenever they feel like it, and when the other army sees them running, they also run.

    49. Bene

      Actually by the 6th message (arriving or not) both sides know that both sides know.

    50. ares106

      I thought this was called Byzantine generals problem.

    51. Debbiebabe69

      How would the identiwhatsit token work though? Say you order a full pizza, then you get a message that the order has failed. You create a new order, select a pizza, then pay. Since thats a completely new order, wont it have a completely different identitywhatsit token?

    52. Deej Eh

      Once Gen. A acknowledges Gen. B's acknowledgment it's over. Ex: 1-attack 2-attack confirmed 1- attack confirm acknowledged

    53. VALSGARDE gaming

      Just send two men, one sits in the middle and waits for the other to return while the message to B is delivered. B runner returns saying message aknowledged and they both return to their respective sides. This is still not perfect but by meeting and leaving in the most dangerous area, if they aren't found, then you can assume they have a high likelyhood of having delivered the message.

    54. Bert Ernie

      Same reason you can’t measure the 2 way speed of light

    55. Bert Ernie

      This dude just makes interesting videos...

    56. Rational Agent

      Send all the troops of one army to the other as messengers

    57. DEDSEC17

      Ummm I thought instantly couldn’t you just have a general use a code or a signal using sound that could easily work. e.g. morse code

    58. rojoshow13

      I think I had something similar happen to me at Walmart several years ago when I tried buying a PS4 Pro. I put my debit card in and the cashier said the transaction "timed out", which usually happens when it can't connect online. So I had to swipe my card again. And my bank account ended up being charged for 2 PS4's. Walmart blamed my bank and said it was an error on their end where the money is in "limbo" and it'll be recredited within a few days. And the bank blamed Walmart and told me that it was definitely showing 2 separate transactions for $400. But Walmart couldn't find the 2 transactions in their system. Only the 1 transaction.

    59. Scabeiathax Novastorm

      Which clot built a castle in the valley rather than on the adjacent ridges?

    60. Insertname Here

      Easy!, as army A is red that means its the Brotherhood of Nod, so all you do is build a temple of Nod then nuke the castle! Sorted.

    61. bakunicorn

      who tf builds a castle in a valley?

    62. Professor Haystacks

      I haven't checked this, but it seems like the original problem set stakes so high the only rational solution is to not attack at all. Plus side, you'd get fewer wars that way.

    63. Guilherme F. Arantes Souza

      Wait, isn't that what TCP is for?! Does TCP use idempotency tokens?

    64. Michael Taylor

      A simple smoke signal solves this entire delima

    65. IWAG

      To make sure the other general gets the letter just make them send a smoke signal back to verify, idiots.

    66. Joey Buttafucko

      You are totally wrong about the communication problem. The General B could send up a smoke signal when message was received, just like American Indians did. Dude, learn some history.

    67. Jack Gilcrest

      *stares in byzantine consensus*

    68. Randall Cell

      Tom where did you get the name of this problem? Is it from "Byzantine Generals"?

    69. Andy West

      Dashlane's all well and good until you forget the master password and lock yourself out of all your data

    70. uhhhscizo

      Agree beforehand that when you start a fire they both attack and then start a fire

    71. Lloyd Winslow

      "a single human error is never the real cause" citation needed

    72. Cheese Biscuits

      The solution is to talk in person beforehand about the time.

    73. Lordlouckster

      Dashlane, THE password manager

    74. NS777

      Here’s what you do to solve the problem (in practice): send like 5 people instead of one, vastly increasing your chances of getting one there

    75. Harry Parkin

      This "fix" can actually work the other way round. When I tried to update my FIblock profile picture, I uploaded one called profile.jpg or whatever, then when I realized one part looked slightly dark when actually on FIblock, I went back and edited it slightly. However, because it still had the same file name, it didn't change it on FIblock when I tried, and I could see that despite me clicking the "upload image" button, it wasn't actually changing anything.

    76. Cookie_flop_K

      What if a general from team A is to send a message to team B saying”we will attack at 8:00. Send a message back.if we do not get your message then we will send this message to you again” if the message from team A does not make it to team B then team B wont send a message back so team A knows something went wrong and so they send the same message again. If team B gets team A,s message but team B,s message doesn’t make it then team A will again send the same message. So no matter what both of them get the message so they both fight at the same time and win.

    77. Mr Mora

      My solution is send a acknowledgment with different contents, a yes or no message. If no message is received resend the question message. Send a response each time a question is sent.

    78. sunalwaysshinesonTVs

      Ummm... isnt the real logic problem presented here is why in hell did some schmo aristocrat build a castle in a valley?

    79. This statement is false Nothing is true

      Why can’t they just make like a big ass sign and then when they see it they make a sign

    80. James Porter

      Ew. Opening is "I did something not very woke, but I am very woke trust me." Why? What did that add to this video?

    81. Catweasle

      Easy. Don't order a pizza by using a f**king app. Ring and speak to a human. Get his / her name and ring back to abuse him / her if there is an issue with the order. It's worked for many many years.

    82. Vincrand

      I'm just wondering why the castle is in the valley and not on the hill.

    83. mdavis7298

      I wonder if his use of the word "semaphore" in a computer science video was on purpose. MULTI THREADED PROGRAMMING JOKE?

    84. Peter B

      Hey I work with things that are possibly life involved... I watch this because Tom Scott is good at entertainment for me

    85. Alexander Finney

      Have general A give all his men torches through a forced night March to close the gap to the castle but not attack. General B will see the marker and approach. When General A gets to the castle, then send the runners. The force projection will cause the castle scouts to return and the runners will be fine. Siege when both armies are position

    86. Keith Bird

      No one builds a castle in the dip of a valley.

    87. Nathan Lang

      I have been on the receiving end of two identical orders. Happened on two occasions, actually. But where I work, we usually only get around 3-4 grubhub orders on a given day, so it's very noticeable when the exact same order comes through twice with a 30 minute delay. Unfortunately, we have no way to actually contact the customer if this happens; only the driver can do that. So we have to wait around for the driver to show up, get the driver to contact the customer, greatly wasting everybody's time.

    88. Crypto Facts

      The two generals problem? You mean the problem Satoshi Nakamoto solved?

    89. Keiran Ferrier

      Restaurants when that happened: business is boomin'!

    90. KidUnicorn13

      Why wouldn’t general A send two messengers, when they get half way send one back to general A and the other continue to general B

    91. Lefinat

      ....Or armies can merge, then attack together :)

    92. Sami Hulkko

      Well if there is a messanger it has properties(funtionality) and a message. If it has properties(functionality) it can meet the other messanger somwhere in the woods, and exchange messages. If it has properties it can back track to generals and deliver message. If you just spam messages you really don't have messanger, only a message. In technical terms: Messanger software with message(encrypted) travels to router node and meets the other messager (they all have ID's) to exchange messages.... and returns to server software. Load balancing vice it is lighter due the fact that only half way or max 2/3 way is needed to exchange messages. Also messager with properties(functionality) can do traceroute, echo UDP for counterpart for message exchange at router node etc.

    93. Deez Nuts

      Instructions unclear Started using child soldier’s on a suicide mission

    94. Animaster89

      why would someone build a castle in a short valley?

    95. SoulJah876

      Hmm doesn't the TCP 3-way handshake work like that without an issue? SYN, SYN-ACK, ACK.

    96. Alexander Kurt

      I know how to deal with this. 1. Send a message what time to go. 2. There must be at least 2 ticks to be prepared for the fight.

    97. IncendiarySolution

      "This is not the kind of thing that is one programmers fault" is the kind of thing that one programmer says to their manager after something like this happens

    98. Derpydogz025

      How about if they agreed that when the sun strikes 12 they will charge, and insure their messengers arrive back to ensure the message is made clear. Then they both charge at the same time

      1. Matías García Casas

        But how would both of them know that the messengers arrived back?

    99. Biggledorf

      Be more specific, problem solved

    100. Mutant The Great

      That was a lot just to explain serial numbers