The Two Generals’ Problem

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ส.ค. 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: www.dashlane.com/tomscott
    MORE BASICS: • The Basics
    Written with Sean Elliott / seanmelliott
    Directed by Tomek
    Graphics by Mooviemakers www.mooviemakers.co.uk/
    Audio mix by Haerther Productions haerther.net/
    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 dashlane.com/tomscott
    🟥 MORE FROM TOM: www.tomscott.com/
    (you can find contact details and social links there too)
    📰 WEEKLY NEWSLETTER with good stuff from the rest of the internet: www.tomscott.com/newsletter/
    ❓ LATERAL, free weekly podcast: lateralcast.com/ / lateralcast
    ➕ TOM SCOTT PLUS: / tomscottplus
    👥 THE TECHNICAL DIFFICULTIES: / techdif

ความคิดเห็น • 7K

  • @TomScottGo
    @TomScottGo  4 ปีที่แล้ว +11019

    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 www.dashlane.com/tomscott

    • @johandaun874
      @johandaun874 4 ปีที่แล้ว +57

      2 weeks ago?!?

    • @azarus8806
      @azarus8806 4 ปีที่แล้ว +8

      whattt

    • @AritroVlogs
      @AritroVlogs 4 ปีที่แล้ว +7

      2 weeks ago... Hmm...

    • @PepsiMan42069
      @PepsiMan42069 4 ปีที่แล้ว +18

      Tom Scott time travelling tom

    • @davidfordom1216
      @davidfordom1216 4 ปีที่แล้ว +66

      for those asking this was uploaded 2 weeks ago but just scheduled to be released today

  • @Statsy10
    @Statsy10 4 ปีที่แล้ว +8040

    I also put in a food order that night... and 30 minutes later a messenger showed up with orders about attacking some castle. Crazy night!

    • @StayAwayFromMyCat
      @StayAwayFromMyCat 4 ปีที่แล้ว +207

      So did the other army show up at the same time as you?

    • @painauchocolate2395
      @painauchocolate2395 4 ปีที่แล้ว +175

      What a crazy knight

    • @michaelfranciotti3900
      @michaelfranciotti3900 4 ปีที่แล้ว +153

      @glyn hodges we were waiting on your acknowledgement of our acknowledgment.

    • @theapexsurvivor9538
      @theapexsurvivor9538 4 ปีที่แล้ว +37

      @@michaelfranciotti3900 I told you this is why we needed an idempotency key.

    • @thiccchungo1041
      @thiccchungo1041 4 ปีที่แล้ว +18

      @glyn hodges your attack was pitiful from my view in the castle....

  • @y0uCantHandle
    @y0uCantHandle 3 ปีที่แล้ว +5183

    Lesson learned: don’t use deliveroo to deliver messages when attacking a castle. Got it.

    • @ServantofBaal
      @ServantofBaal 2 ปีที่แล้ว +213

      Instructions unclear; my peasants have begun burning my IT at the stake for witchcraft

    • @lungshenli
      @lungshenli 2 ปีที่แล้ว +42

      The knight of Uber eats and the loose conglomerate of individual Döner Shops will attack at nightfall!
      Are with us my brother?!

    • @DaddyBeanDaddyBean
      @DaddyBeanDaddyBean 2 ปีที่แล้ว +25

      Lesson delivery failed. Would you like to try again?

    • @mrbritannia3833
      @mrbritannia3833 2 ปีที่แล้ว +10

      @@ServantofBaal Then burn the peasants

    • @bamb8s436
      @bamb8s436 2 ปีที่แล้ว +5

      @@mrbritannia3833 Modern problems require modern solutions

  • @alfy01
    @alfy01 2 ปีที่แล้ว +3027

    "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." had me dying omg

    • @horsermchead2504
      @horsermchead2504 2 ปีที่แล้ว +18

      Me too. I laughed out loud.

    • @AjayKumar-fd9mv
      @AjayKumar-fd9mv 2 ปีที่แล้ว +8

      What. is this series ? i searched for the series I got a comedy show related series.

    • @stoobidthing
      @stoobidthing 2 ปีที่แล้ว +81

      @@AjayKumar-fd9mv This video is part of a series called The Basics, in witch Tom explains The Basics of computer science

    • @csurname
      @csurname 2 ปีที่แล้ว +14

      You lost your life

    • @SuprSBG
      @SuprSBG 10 หลายเดือนก่อน

      Same

  • @albertbatfinder5240
    @albertbatfinder5240 2 ปีที่แล้ว +507

    Finally I understand the Two Generals Problem. It’s dressed up as something fancy, but all it is saying is that if you don’t have a reliable means of communication, you don’t have a reliable means of communication.

    • @legendgames128
      @legendgames128 9 หลายเดือนก่อน +13

      As far as I can tell, I have a half-solution to the problem: General A sends a messenger to General B proposing a messenger meeting in the valley, say through 8:00PM to 8:10PM, General A doesn't care if anyone replies, but replies acknowledging that General B has heard the message are welcome. At 8:00PM, send a second messenger to the valley. If no one comes back by 8:10PM, or a messenger died during that meeting, assume failure, repeat the above. If a messenger comes back saying the other messenger made it out alive with a proposed attacking time, that must have been a success. Both armies are ready to attack.
      This ensures that neither army attacks individually, only that no army attacks or both armies attack.

    • @JordanYee
      @JordanYee 9 หลายเดือนก่อน +56

      ​@@legendgames128this doesn't ensure that though. What if the two messengers meet and agree, but one of them dies before making it back to report? The original problem still exists.

    • @legendgames128
      @legendgames128 9 หลายเดือนก่อน +1

      @@JordanYee Would the other messenger not realize their death and thus report that death?

    • @JordanYee
      @JordanYee 9 หลายเดือนก่อน +34

      @@legendgames128 only if they know about it, which they can't. The messengers meet and agree, but you cannot trust that both messengers make it back to their generals with the information. If you could trust in that, you wouldn't have this problem to begin with.

    • @josephthomas4900
      @josephthomas4900 8 หลายเดือนก่อน +25

      @@legendgames128 Keep in mind that, as this is a parallel to sending data, any messenger can die at any point, and the messengers wont be able to see each other or check each others status whilst moving. You could have them 'meet in the valley' on a third server, but either messenger could 'die' on the way back from that meeting without the other messenger or other general knowing.

  • @moomoo2214
    @moomoo2214 4 ปีที่แล้ว +23224

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

    • @christopherstokes9393
      @christopherstokes9393 4 ปีที่แล้ว +2891

      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.

    • @eddy3038
      @eddy3038 4 ปีที่แล้ว +658

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

    • @mannyokafor4609
      @mannyokafor4609 4 ปีที่แล้ว +55

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

    • @mr.animation5259
      @mr.animation5259 3 ปีที่แล้ว +245

      @@christopherstokes9393 weren't they still all his fault? Multiple mistakes by one Tom

    • @akkere4052
      @akkere4052 3 ปีที่แล้ว +175

      @@mr.animation5259 A system should ideally have its own backups put in place as a collective decision (I don't know the context of the database deletion, so I don't know if this was just a personal project or one done by a company). Everything else is on the single Tom though, even if it is multiple poor decisions being made compounded to one outcome.

  • @wolfelkan8183
    @wolfelkan8183 3 ปีที่แล้ว +9957

    "A single human error is never the root cause"
    Because if a single human error _is_ the root cause, then the blame also lies with everyone who allowed the project to be susceptible to a single human error.

    • @iiiiitsmagreta1240
      @iiiiitsmagreta1240 3 ปีที่แล้ว +90

      This is funnier if you just came from Tom's fireworks video

    • @IsaBella-ir4rf
      @IsaBella-ir4rf 3 ปีที่แล้ว +34

      content content content

    • @KnakuanaRka
      @KnakuanaRka 3 ปีที่แล้ว +85

      Remember the episode where Tom accidentally deleted an entire database?

    • @dionysusnu3881
      @dionysusnu3881 3 ปีที่แล้ว +196

      @@KnakuanaRka where the supervisor that tasked Tom with converting the database should've maybe backed it up in some way? Yes.

    • @json_bourne3812
      @json_bourne3812 2 ปีที่แล้ว +68

      *Writes entire application on my own for my own personal solo venture*
      *Issues arise with the application*
      "At least it's not ALL my fault!"

  • @SGTSkylor
    @SGTSkylor 2 ปีที่แล้ว +1572

    “When something goes this drastically wrong… A single human error is never a root cause.” Challenge accepted

    • @mrocto329
      @mrocto329 2 ปีที่แล้ว +201

      but your birth required 2 people

    • @TheIdiotPlays
      @TheIdiotPlays 2 ปีที่แล้ว +10

      @@mrocto329 :D

    • @lordsiomai
      @lordsiomai 2 ปีที่แล้ว +13

      @@mrocto329 yooooooooooooo

    • @user-nk6gu5er3v
      @user-nk6gu5er3v 2 ปีที่แล้ว +12

      @@mrocto329 yooooooooo duuuuuuuuuuude
      uncool

    • @list9016
      @list9016 2 ปีที่แล้ว +4

      @@mrocto329 OHHHHHHHHHHHHHHHHHH dude....

  • @TacComControl
    @TacComControl 2 ปีที่แล้ว +96

    This issue is so old, it's delightful, anyone who's ever run a print server in a school can tell you just exactly how common it is, especially when a printer suddenly starts handling spooled jobs that have been spooling up for an entire day, that it for some reason didn't start before, and it won't stop running them until well on into the night. And most of them are duplicates. Thankfully there are mitigation methods for that these days, but there didn't used to be

    • @furdiburd
      @furdiburd 8 หลายเดือนก่อน +4

      once at a school i worked as it supoort the printer got stuck due to trash wifi (thanks hp for making it internet based) and when it got resolved it started printing a math test 7 times 32 copies. and when you think it finaly stops, it just start another stack of test. i think i would be good to have a quick erase print queve button and not need to nail that 5 sec between print jobs

  • @ameliagryffon7097
    @ameliagryffon7097 3 ปีที่แล้ว +3831

    The real problem is when the castle intercepts the message and sends back a guy in the messengers clothes changing the time of the attack so they both attack at the wrong time.

    • @berksterb8475
      @berksterb8475 3 ปีที่แล้ว +170

      Then, when someone comes up with asymmetric crypto, you can introduce the integrity problem, where I don’t care what false time I sent, only that it is different :) it’s a fun little conceit!

    • @ameliagryffon7097
      @ameliagryffon7097 3 ปีที่แล้ว +53

      @@berksterb8475 I don't know what asymmetric crypto and integrity problem are XD

    • @irrelevant_noob
      @irrelevant_noob 3 ปีที่แล้ว +80

      @@ameliagryffon7097 asymmetric crypto is when you don't use a single password for both encryption and decryption... Like how the "public key + private key' system works. And integrity is just a hash (checksum) that you can check in order to determine whether the message was changed in transit or not.

    • @ameliagryffon7097
      @ameliagryffon7097 3 ปีที่แล้ว +10

      @@irrelevant_noob Oh okay I think I understand.

    • @Predator20357
      @Predator20357 2 ปีที่แล้ว +13

      I sort of like these little hypothetical scenarios, like you have to take it at face value and no other way or it’ll quickly fall apart.

  • @mathieukransfeld3183
    @mathieukransfeld3183 4 ปีที่แล้ว +24104

    the real question: why do you put a castle in a valley??

    • @chexyt3504
      @chexyt3504 4 ปีที่แล้ว +1638

      Ur right they were always on hills

    • @ExaltedPhoenix
      @ExaltedPhoenix 4 ปีที่แล้ว +4348

      Mathieu Kransfeld the problem actually makes more sense if the castle was in a hill, then you wouldn’t be able to see the other army

    • @mathieukransfeld3183
      @mathieukransfeld3183 4 ปีที่แล้ว +190

      @@ExaltedPhoenix someone didn't get the joke

    • @techwizpc4484
      @techwizpc4484 4 ปีที่แล้ว +761

      MACHICOLATIONS!!!
      Cheers if you get the reference.

    • @wibaswibas92
      @wibaswibas92 4 ปีที่แล้ว +20

      ha ha ha

  • @RvB_Fan_since_8
    @RvB_Fan_since_8 2 ปีที่แล้ว +200

    I’ve been saved so many times by this video. I remember to always double check when it says “order failed” after I get that check mark. That check mark, that Tom explained the significance of, saves me every time.

  • @Reczack
    @Reczack 2 ปีที่แล้ว +160

    A very similar thing happened on Uber Eats a few months ago. I'm a driver, and I repeated a route from a specific restaurant to a specific home at least six times.

    • @speakingof8106
      @speakingof8106 ปีที่แล้ว +15

      @Cal Alaeragod damnit david

  • @itaybron
    @itaybron 4 ปีที่แล้ว +2836

    As astronaut John Glenn put it: "As I hurtled through space, one thought kept crossing my mind - every part of this rocket was supplied by the lowest bidder."

    • @Roxolan
      @Roxolan 4 ปีที่แล้ว +210

      Including the astronaut! Even if the labour market has a little more friction.

    • @Graknorke
      @Graknorke 4 ปีที่แล้ว +49

      @@Roxolan
      Labour power has a set price generally rather than going to auction. I actually can't think of any time where workers have gone to auction that I know of.

    • @proliferatingprofligate7032
      @proliferatingprofligate7032 4 ปีที่แล้ว +138

      @@Graknorke slavery, graknorke. It was during slavery.

    • @Graknorke
      @Graknorke 4 ปีที่แล้ว +7

      Are slaves auctioned? I would've assumed it was just a set price.

    • @itaybron
      @itaybron 4 ปีที่แล้ว +69

      @@Graknorke I think it was both

  • @romi3996
    @romi3996 4 ปีที่แล้ว +9763

    Oi nothing wrong with ordering the exact same things 5 times in a row I have my reasons

    • @CleverCrumbish
      @CleverCrumbish 4 ปีที่แล้ว +374

      Order five copies of the same thing in the same order you're not fooling anyone at the restaurant

    • @elevown
      @elevown 4 ปีที่แล้ว +242

      Lots of us do this. But there's normally a week or so between each of the orders not 1 minute :)

    • @richardhee
      @richardhee 4 ปีที่แล้ว +138

      In some (rare) cases you are right, because when I buy one it's cheaper than buying multiple. I know it sounds totaly wrong and in my opinion it is wrong, however, some shops make an error, like, buy 3 get one free, buy 5 get 20% discount. (yep, buy 3 get 1 free is getting 4 items and translates in 25% discount)

    • @markstafford1410
      @markstafford1410 4 ปีที่แล้ว +16

      This "Two Generals Prob." has been quite frequently happened to us but in are minds eye we generally calculatingly cop it. Scott is just bring it out to the forefront in layman's terms, i.e the snag. That's is why most apps., have a cart order for the one order.

    • @Abdega
      @Abdega 4 ปีที่แล้ว +83

      “Haha… I ordered this all for a bunch of friends!”
      **cries eating 5 pizzas alone**

  • @JustAPolishAmerican
    @JustAPolishAmerican ปีที่แล้ว +34

    0:07 "A certain food-delivery app"
    5 seconds later:
    Deliveroo

  • @Themozartthug
    @Themozartthug 2 ปีที่แล้ว +49

    General A - sends a human
    General B - sends back a dog pushing a wheelchair
    Even the castle was lost for words

  • @robertkeddie
    @robertkeddie 3 ปีที่แล้ว +5222

    When I worked at the warehouse of a well-known internet retailer, I found myself picking 25 copies of Adele's new CD. I began to wonder if someone had accidentally typed the album title into the quantity box.

    • @tactcom7
      @tactcom7 3 ปีที่แล้ว +453

      Maybe it was Adele bumping her numbers up.

    • @DespicableDishwasher
      @DespicableDishwasher 2 ปีที่แล้ว +377

      @@tactcom7 actually it was a very devoted Latin American dictator who was a fan of hers

    • @jonmendelson1104
      @jonmendelson1104 2 ปีที่แล้ว +113

      @@DespicableDishwasher Nah, that only happens to Cherlene.

    • @slapslicks7531
      @slapslicks7531 2 ปีที่แล้ว +55

      100 BUCKS says he's at amazon

    • @MrGreghome
      @MrGreghome 2 ปีที่แล้ว +42

      @@jonmendelson1104 but that only happens with outlaw country music

  • @Tamhvm
    @Tamhvm 4 ปีที่แล้ว +5432

    "If you're in computer science and work on a problem which involves potential loss of life, I really hope you're not watching a series called The Basics."
    And here I am. Because Tom Scott.

    • @tummasmohr7160
      @tummasmohr7160 4 ปีที่แล้ว +124

      What are you working on? - if I may ask :)

    • @kakarot9919
      @kakarot9919 4 ปีที่แล้ว +23

      *USE MIRROR FLASH*

    • @casey6556
      @casey6556 4 ปีที่แล้ว +14

      Tamashii M. H. What do you work on?

    • @davidflores909
      @davidflores909 4 ปีที่แล้ว +33

      @@tummasmohr7160 getting sum likes... I hope...

    • @WaffleAbuser
      @WaffleAbuser 4 ปีที่แล้ว +169

      He's working on killer robots, obviously.

  • @stephenholland6328
    @stephenholland6328 2 ปีที่แล้ว +58

    I think it would be instructive to add that TCP/IP recognizes this problem and includes a packet ID. The two generals problem explanation increases my appreciation for TCP/IP. Thanks!

    • @waldolemmer
      @waldolemmer 6 หลายเดือนก่อน +6

      TCP, to be specific. TCP/IP is a protocol stack consisting of many different protocols

  • @Hybzy
    @Hybzy ปีที่แล้ว +8

    Another solution is what we would do in the electronics industry. Sometimes when you press an analog button, due to the speed of electricity, if the button doesn't make a clean connection, it registers multiple presses. To combat this, we would use a 'debounce' circuit, where a single press of the button temporarily disconnects the button through a semiconductor. This then means that the button will no longer work until a time-delay (usually discharge of a capacitor) has taken place. This would be akin to the solution mentioned here where an order to a restaurant could not be repeated for a specified duration (An hour, for example).

  • @TLGame
    @TLGame 2 ปีที่แล้ว +1788

    Imagine being the line cooks on that day. "I swear I made this order two times already."

    • @JohnRay1969
      @JohnRay1969 2 ปีที่แล้ว +61

      That was my thoughts exactly. I would immediately notice duplicate orders on my line. Similar is one thing, happens all the time. But duplicates, exactly the same is rare and noticable.

    • @gwen6622
      @gwen6622 ปีที่แล้ว +85

      i mean if it was something like a fast food place, theyre making a billion copies of the same order already anyway. a big mac is a big mac is a big mac. or in this case, a pizza

    • @joshyoung1440
      @joshyoung1440 ปีที่แล้ว +32

      @@gwen6622 small, simple orders sure. But most people order a combination of things, especially when they're already paying to get it delivered. I'm a delivery driver. Unique orders are DEFINITELY very rare and noticeable.

    • @nappman1999
      @nappman1999 ปีที่แล้ว +12

      I worked at a pizza place where our system failed one year due to time change, so we'd get orders when they arrived, and 1 hour after they arrived, we ended up with like 60 extra pizzas that night, it was chaos XD.

    • @natchu96
      @natchu96 ปีที่แล้ว +5

      @@joshyoung1440 And in this case, since the system is bugging out at the payment acknowledgement step and giving a retry prompt on the spot, the duplicate orders would be coming in at rapid succession. Which always looks dodgy.

  • @MrTrees
    @MrTrees 4 ปีที่แล้ว +2733

    4:49
    "A single human error is never the root cause"
    Me: *looking at line 456 of my code that has a missing semi-colon* "SEE?"

    • @ZippyDan
      @ZippyDan 4 ปีที่แล้ว +20

      Never

    • @da4127
      @da4127 4 ปีที่แล้ว +15

      Well that’s not your only life error making you miss that semi colon

    • @johnbyrne8948
      @johnbyrne8948 4 ปีที่แล้ว +1

      😅😅😅😅

    • @ChuckNorrizHIM
      @ChuckNorrizHIM 4 ปีที่แล้ว +6

      @@da4127 My exact excuse of a thought

    • @Kalahee
      @Kalahee 4 ปีที่แล้ว +34

      Missing a semi-colon, app would just not work and not result in such catastrophe.

  • @LouieBM
    @LouieBM ปีที่แล้ว

    This was spoke about in my lecture today and now it's in my reccomended, what a crazy thing.

  • @fluffy9050
    @fluffy9050 ปีที่แล้ว +14

    As someone working in IT without any formal training, I hate how much of this I understood.
    I really like how easily you explain this complex idea in a way normal people... could... could, understand.

  • @remcohamersma6436
    @remcohamersma6436 4 ปีที่แล้ว +4809

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

    • @cowboymooman8776
      @cowboymooman8776 3 ปีที่แล้ว +346

      you make a really valid point

    • @dylandarnell3657
      @dylandarnell3657 3 ปีที่แล้ว +517

      Or even more logically, a long ridge, so they can't just go around the side.
      It's also a more logical place to build a castle.

    • @woutertesselaar5725
      @woutertesselaar5725 3 ปีที่แล้ว +183

      most castles also are on hills

    • @xirenzhang9126
      @xirenzhang9126 3 ปีที่แล้ว +25

      Can’t they just go around the hill then?

    • @chrispalumbo5556
      @chrispalumbo5556 3 ปีที่แล้ว +107

      No, the generals need a way of knowing one another is there while also not being able to coordinate. For example if you were across a real valley you could see an army encampment on the other side if there was one, but you wouldn't be able to see well enough to make out specific people or to coordinate an attack properly. If it was the inverse then you'd have no idea another general is on the opposite base of the mountain also trying to attack the castle.

  • @IkisDragonFist
    @IkisDragonFist 4 ปีที่แล้ว +2300

    -"So what are we having? Chinese? Mexican?"
    -"Byzantine".

    • @Rolando_Cueva
      @Rolando_Cueva 4 ปีที่แล้ว +153

      Constantinople.exe stopped working.

    • @asrnyigit4040
      @asrnyigit4040 4 ปีที่แล้ว +111

      Do you want to execute Istanbul.exe?

    • @alexwang982
      @alexwang982 4 ปีที่แล้ว +16

      Asrın Yiğit Execute Constantine

    • @nikolatasic9452
      @nikolatasic9452 4 ปีที่แล้ว +30

      We will take Jerusalem.

    • @kevinboros7427
      @kevinboros7427 4 ปีที่แล้ว +10

      Then the winged hussars arrived!

  • @rosellastar468
    @rosellastar468 2 ปีที่แล้ว

    I don’t know what it is about this specific video of toms but I always find myself coming back to rewatch it

  • @Dark_Ronius
    @Dark_Ronius 2 ปีที่แล้ว +85

    This really opens your eyes as to how the financial system works when you pay for something. Like, the reality there is no solution to the two general problem. So anything, no matter how advanced and seemingly secure with how it works everyday, is limited by this. Anything is a work around, which just happens to work 99.9999% of the time

    • @stargazer7644
      @stargazer7644 ปีที่แล้ว +6

      Except that there is a solution. And he showed it to you.

    • @codinghub3759
      @codinghub3759 ปีที่แล้ว +1

      ​@@stargazer7644 There is still a fault in that system. Just rewatch the part at 5:50

    • @LineOfThy
      @LineOfThy ปีที่แล้ว +3

      @@stargazer7644 that isn't a foolproof solution, because the return data is still impossible to confirm

    • @unsolicitedditkapics9722
      @unsolicitedditkapics9722 8 หลายเดือนก่อน +2

      There a multiple solutions to the two generals problems. Smoke signals have been used throughout history to solve problems just like this. I hate when metaphors completely miss the point in life and EVERYONE eats it up thinking it's some higher wisdom

    • @unixtreme
      @unixtreme 7 หลายเดือนก่อน

      @@unsolicitedditkapics9722the metaphor is to try to visualize a computer problem. Which tbh isn’t a real problem, the way we solve this is by having an authoritative source in the middle, that say stores the order with a timeout, then repeat orders cannot be placed until acknowledged, then the server can set it a sack low edged and the client can see it’s been acknowledged. If the timeout is exceeded both now to cancel that order and it has to be booked again by the client.

  • @Tyguy161
    @Tyguy161 4 ปีที่แล้ว +4689

    Have you tried negotiating with the lord of the castle? Was peace even an option?

    • @anuh4308
      @anuh4308 4 ปีที่แล้ว +816

      *P E A C E W A S N E V E R A N O P T I O N*

    • @addisonchan3053
      @addisonchan3053 4 ปีที่แล้ว +152

      I can think of a solution. Move A to B (or vice versa). Two armies!

    • @haroldfisher7528
      @haroldfisher7528 3 ปีที่แล้ว +23

      @@addisonchan3053 I was looking for that comment.

    • @NeibasThe5th
      @NeibasThe5th 3 ปีที่แล้ว +101

      Addison Chan but then again the entire army could be destroyed just like how any number of messengers could be destroyed and then you only have one army

    • @KPIBM
      @KPIBM 3 ปีที่แล้ว +130

      This is magical computer science land, so *peace was never an option.*

  • @WMTeWu
    @WMTeWu 4 ปีที่แล้ว +682

    There are only two hard problems in distributed systems: 2. Exactly-once delivery 1.Guaranteed order of messages 2. Exactly-once delivery
    ~ Mathias Verraes

    • @ElectricityTaster
      @ElectricityTaster 4 ปีที่แล้ว +56

      I'll thumb you up to let you know I received your message.

    • @douggodsoe
      @douggodsoe 4 ปีที่แล้ว +12

      Don’t forget, messages of order guaranteed.

    • @Shepard_AU
      @Shepard_AU 4 ปีที่แล้ว +2

      WMTeWu I received message regarding the 10 million dollars you’re giving me.

    • @kagi95
      @kagi95 4 ปีที่แล้ว +1

      I laughed oud loud! :D

  • @feynthefallen
    @feynthefallen 2 ปีที่แล้ว

    Thanks for this video. You may just have helped me solve a problem I hadn't even realized I had.

  • @MeltyMel
    @MeltyMel 11 หลายเดือนก่อน +1

    the fact that it's 2023 and this exact thing has happened to me TWICE in the past month. I'm just tired at this point. HOW is this still happening. thank you for describing what's been happening to me i thought it was a me problem for the longest time

  • @muh1h1
    @muh1h1 4 ปีที่แล้ว +1606

    "Next time i'll just cook for myself"
    I was expecting:
    "This series of the Basics is sponosred by Blue Arpon"

    • @diamondflaw
      @diamondflaw 4 ปีที่แล้ว +17

      Same thought, but with Hello Fresh since I listen to NDQ and Hello Internet podcasts.

    • @tab160
      @tab160 4 ปีที่แล้ว +5

      @@diamondflaw Fellow Tim I see

    • @luelou8464
      @luelou8464 4 ปีที่แล้ว +17

      Most of the supermarkets deliver in the UK, so there's no good reason to pay for such a service here.

    • @yoshilovesyoshi
      @yoshilovesyoshi 4 ปีที่แล้ว +4

      @@luelou8464 WOAH THAT'S AWESOME! Step up California

    • @WilliamAndrea
      @WilliamAndrea 4 ปีที่แล้ว +2

      something something The Basics with Babish

  • @MuhsinFatih
    @MuhsinFatih 4 ปีที่แล้ว +4522

    "I was lucky" it's the opposite. You were cursed with the computer science knowledge. Had you made multiple orders you would have gotten a refund and also eat 5 meals :D

    • @theseangle
      @theseangle 4 ปีที่แล้ว +41

      😂😂🤔

    • @thecoolguy7403
      @thecoolguy7403 4 ปีที่แล้ว +74

      true though

    • @maruftim
      @maruftim 4 ปีที่แล้ว +112

      you... are right

    • @gierno4828
      @gierno4828 4 ปีที่แล้ว +56

      Or not gotten anything at all

    • @MrSamooska
      @MrSamooska 4 ปีที่แล้ว +74

      @SublimeHawk6 who doesnt?

  • @kyriwalkthrough
    @kyriwalkthrough ปีที่แล้ว +3

    The CS solution I learned in my network analysis class:
    1. "A" sends a messenger (MSG) to "B". It waits a specified amount of time. If it has not heard back an acknowledgement (MSG-ACK) from "B" within this time, it resends another messenger.
    2. When "B" receives a MSG from "A", it sends back a MSG-ACK to "A". Every time that "B" receives another MSG from "A" or some specified amount of time passes, it will send that same MSG-ACK in response.
    3. When "A" finally receives one of these MSG-ACKs from "B" , it will send back its own acknowledgement (ACK) to "B". Again, it will send back one of these ACKs for every MSG-ACK it receives, but NOT after some specified time period like it did previously.
    4. Once "B" receives this ACK from "A", it knows it can stop sending MSG-ACKs, since an ACK from "A" means it has received B's MSG-ACK.
    At this point, both A and B have authenticated the other's messages.
    If I missed anything or was wrong about something let me know!

    • @ammarratnani6209
      @ammarratnani6209 16 วันที่ผ่านมา

      Question: How does A know that B has received its ACK. It seems you're relying on the absence of MSG-ACKs to signal that. But, the same absence of MSG-ACKs could be produced if:
      * the ACK from A gets dropped, and
      * every retransmitted MSG-ACK from B also gets dropped.
      In that case, A will have sent its final ACK and decide to attack, but B will still be waiting for A's ACK and decide not to.
      There's also the question of how long A should wait for retransmitted MSG-ACKs before comitting to an attack time. The goal is for A and B to come to a consensus about when to attack within a bounded amount of time. But in your approach, A might have to service MSG-ACKs indefinitely. You'd have to tell A to assume B received the ACK if it doesn't see MSG-ACKs for some time. It's possible that B was sending MSG-ACKs for that entire time, but none of them were getting through. In that case, A will decide to attack but B won't.
      It's worth noting that the approach you describe is what's used by TCP when terminating a connection. Because of the Two Generals Problem, the last person to send an ACK can't be sure the ACK has gone through. So, we tell them to keep the connection open for some TIME_WAIT period - 120s by default. If they see a retransmission within that time, they resend their ACK and (I think) reset their timer. If the TIME_WAIT period expires and we haven't seen any retransmissions, we assume the network will never fail so badly as to deliver no retransmissions for that long, and we conclude that B has seen our ACK and we can terminate the connection.

  • @volumeburner195
    @volumeburner195 ปีที่แล้ว

    Thank you for this video. It explained the problem extremely well.

  • @lonagen9340
    @lonagen9340 4 ปีที่แล้ว +1067

    2:53: “if you’re dealing with a problem that involves potential loss of life, I really hope your not watching a series called the basics.”
    The military drone programmer watching this: *sweats profusely*

  • @lancejordan9638
    @lancejordan9638 4 ปีที่แล้ว +1469

    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.

    • @evetheeevee2977
      @evetheeevee2977 3 ปีที่แล้ว +30

      XD

    • @absolutelybagel2218
      @absolutelybagel2218 3 ปีที่แล้ว +15

      @imahumanandimagamer tesla is full online

    • @huisbaasbob1923
      @huisbaasbob1923 3 ปีที่แล้ว +172

      @imahumanandimagamer can you imagine spending 50k and when you get an error, you don't immediately call the seller in panic but you just try and try again

    • @frozenheartedgiant8330
      @frozenheartedgiant8330 3 ปีที่แล้ว +57

      @@huisbaasbob1923 When you have money for a Tesla, you probably don't worry about getting charged twice.

    • @TheMajorpickle01
      @TheMajorpickle01 3 ปีที่แล้ว +19

      @imahumanandimagamer Not having to go to a Dealer and just instantly getting what you want with no faff sounds amazing to me. You would only really need to see the car if it was used

  • @henryworks9089
    @henryworks9089 2 ปีที่แล้ว +31

    "I was tired and hungry, just like many of their employees."
    OOOOOH, sorry, I just burned myself off of that roast.

  • @mehulgupta3630
    @mehulgupta3630 ปีที่แล้ว +7

    Really like this way of explaining computer science problems as real world scenarios. Are there more videos or channels doing this stuff? Explaining algos and structures and all this way? If anyone does know please share

  • @DerAykac
    @DerAykac 4 ปีที่แล้ว +610

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

  • @Kinetik07
    @Kinetik07 4 ปีที่แล้ว +5636

    So it's like double posting by accident?

  • @nikooo042
    @nikooo042 2 ปีที่แล้ว

    Better explanation of the General's problem I've ever seen. Lovely

  • @GodfreyMann
    @GodfreyMann ปีที่แล้ว +1

    Data transactions solved this problem decades ago where the database only writes the transaction if it’s successful end-to-end. If any part of the transaction fails, then the database rolls back the entire transaction.
    Therefore, if the system was telling users that the transaction was successful when bits of it failed, then that’s either a transaction design or programming mistake.

  • @marbleswan6664
    @marbleswan6664 4 ปีที่แล้ว +987

    I find the idea of two armies going one by one through a valley sending acknowledgments back and forth until everyone is dead hilarious
    Just imagine the army in the castle being confused.

    • @goldfishy
      @goldfishy 4 ปีที่แล้ว +137

      “Why do they keep attacking one at a time?!?”

    • @Nonsense010688
      @Nonsense010688 4 ปีที่แล้ว +101

      I'm more confused on who builds the castle IN the valley and not on a Hill...

    • @TheUltraSonicKid
      @TheUltraSonicKid 4 ปีที่แล้ว +17

      Si Wi it’s over anakin! I have the high ground!

    • @10babiscar
      @10babiscar 4 ปีที่แล้ว +31

      @@Nonsense010688 That would work better for the problem actually. If the castle is in a valley the two armies would be able to see each other but if it was on a hill there wouldn't be a direct line of sight between the armies.

    • @dekaaizer2550
      @dekaaizer2550 4 ปีที่แล้ว +4

      What about them both sending a messenger at 8pm so they will meet in the middle to sync there attacks.

  • @blooddragonnetwork9545
    @blooddragonnetwork9545 4 ปีที่แล้ว +3973

    This guy is something between 20 and 60 years old i cant tell

    • @Flint_Inferno
      @Flint_Inferno 4 ปีที่แล้ว +167

      I literally have no idea what his age is

    • @algorithm1193
      @algorithm1193 4 ปีที่แล้ว +189

      I... I think you just discovered a new paradox

    • @colbyd7618
      @colbyd7618 4 ปีที่แล้ว +163

      He’s 34

    • @isaacbruner65
      @isaacbruner65 4 ปีที่แล้ว +246

      @@colbyd7618 so OP was spot on!

    • @teddywolfes1042
      @teddywolfes1042 4 ปีที่แล้ว +34

      Welcome to computer science...

  • @ivonakis
    @ivonakis ปีที่แล้ว

    I am back here after discussing the topic with my brother in person. I am spooked

  • @thaboranamane4534
    @thaboranamane4534 10 หลายเดือนก่อน

    Simply - wow! Subscribed. No questions asked.

  • @Carter-dv4hz
    @Carter-dv4hz 4 ปีที่แล้ว +1871

    General A could just move his whole army to general B.
    I guess that involves driving to the pizza place though.

    • @jyothia3958
      @jyothia3958 4 ปีที่แล้ว +14

      Haha

    • @SuperSox97
      @SuperSox97 4 ปีที่แล้ว +57

      @ivan ivanovitch ivanovsky What if all the sent messengers are killed on their way back?

    • @SuperSox97
      @SuperSox97 4 ปีที่แล้ว +59

      @ivan ivanovitch ivanovsky If all my sent messengers are killed on their way back, how do I know the messengers I sent weren't killed on the way there instead of on the way back? If they were killed on the way there, the other army wouldn't know when they're supposed to attack, so our attack would fail.

    • @Vousie
      @Vousie 4 ปีที่แล้ว +35

      Or general A could just move himself to general B... I guess that means going to the pizza place & leaving your computer at home.
      Now I have the mental image of a guy driving his car to a pizza place, but with his entire massive desktop computer along with all of the peripherals in his car with him - "I brought my army".

    • @Goombalove3000
      @Goombalove3000 4 ปีที่แล้ว +19

      @@Vousie if general a moves to general b's position, the army will get intercepted on the way and wiped out, since you need both armies to win a battle

  • @sipos0
    @sipos0 2 ปีที่แล้ว +1

    "Next time I'll just cook for myself" - bit drastic! It's not that bad.

  • @MrBogus213
    @MrBogus213 2 ปีที่แล้ว

    I could watch Tom Scott videos all day.

  • @ruwiki
    @ruwiki 4 ปีที่แล้ว +569

    "it's unsolveable"
    me at 2 am: well, there must be a way ...

    • @stephencooper5155
      @stephencooper5155 4 ปีที่แล้ว +68

      General A just sends the messenger over and over again until they receive a reply?! General B knows that as long as the message keeps arriving then his own messenger hasn't gotten through?

    • @abeltutor9034
      @abeltutor9034 4 ปีที่แล้ว +45

      @@stephencooper5155 This. If both A and B sends messengers and calls them back with the confirmation of an 8pm attack, they will know 100% that the other side got the message. 2-3 messengers does the trick. This "problem" is like elementary school level, I don't understand how can't people figure it out.

    • @Lamawalrus
      @Lamawalrus 4 ปีที่แล้ว +24

      @@stephencooper5155 How does general B know that "as long as the message keeps arriving then his own messenger hasn't gotten through"? You send a pre-message to tell what the strategy is? Human intuition? This is fantasy computer land, these things do not apply

    • @Lamawalrus
      @Lamawalrus 4 ปีที่แล้ว +144

      @@abeltutor9034 If a famously unsolvable problem appears to be an elementary school level problem, then it's more likely you misunderstood the problem

    • @dLzzzgaming
      @dLzzzgaming 4 ปีที่แล้ว +27

      @@Lamawalrus Yea they are missing the point, that this is computers.
      Say general (computer) A spams general B, B sends message to A saying let's go at 8. A receives the message, yes, but B can't know for sure that A received the message just because A stopped sending messages to B.
      If B doesn't get to A, and A stops because it eventually has to stop, how does B know it got through? If A updates the message it was spamming to say "We got your message, attack at 8 am doubly confirmyed!" then A can't know for sure that B is receiving THAT message.

  • @tiyenin
    @tiyenin 3 ปีที่แล้ว +579

    4:48 Old Tom: A single human error is *never* the root cause.
    18 or 19 y.o. Tom: *ONOSECOND*

    • @j.hawkins8779
      @j.hawkins8779 2 ปีที่แล้ว +23

      Or you know, *accidentally deleting an entire data base* do get the joke tho if there is one

    • @SSM24_
      @SSM24_ 2 ปีที่แล้ว +22

      @@j.hawkins8779 "onosecond" is a reference to that exact video you're talking about

    • @j.hawkins8779
      @j.hawkins8779 2 ปีที่แล้ว +1

      @@SSM24_ yes, I know

    • @crimsonstrykr
      @crimsonstrykr 2 ปีที่แล้ว +8

      @@j.hawkins8779 You know, but how do I know that you know? And if I know then how do you know that I know that you know? AND IF YOU KN-.....

    • @j.hawkins8779
      @j.hawkins8779 2 ปีที่แล้ว +3

      @@crimsonstrykr hm, yes. *infinite loop*

  • @astrojourneyuk
    @astrojourneyuk 2 ปีที่แล้ว

    Another great and interesting video, thank you.

  • @threepe0
    @threepe0 2 ปีที่แล้ว

    they also could have built in a polling mechanism so that if the original ack doesn't get through, the poll may still be successful and the app would update to show order successful

  • @sosirisos
    @sosirisos 4 ปีที่แล้ว +1238

    imagine if the sponsor at the end was deliveroo

    • @Nat-jf2ge
      @Nat-jf2ge 3 ปีที่แล้ว +3

      😅 That would be fun!

    • @mohammedhussain6749
      @mohammedhussain6749 3 ปีที่แล้ว +10

      I got a pre video ad for deliveroo.

    • @MrJoeDone
      @MrJoeDone 3 ปีที่แล้ว +4

      @@mohammedhussain6749 genius, that was exactly what i wanted to comment about, the algorythim just knows that this video is talking about food deliveries but not if good or bad :D

    • @seanmurphy4465
      @seanmurphy4465 3 ปีที่แล้ว +1

      Who Deliveroo? 😬

    • @Nat-jf2ge
      @Nat-jf2ge 3 ปีที่แล้ว

      @@seanmurphy4465 A chinese owned version of uber eats

  • @blu0065
    @blu0065 4 ปีที่แล้ว +1967

    "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.

    • @derek96720
      @derek96720 4 ปีที่แล้ว +187

      Sometimes intelligent people get too inside their own heads, and going back to basics can greatly help eliminate unnecessary considerations, leaving you with a clear answer.

    • @RKBock
      @RKBock 4 ปีที่แล้ว +62

      @@derek96720 sometimes, especially in programming, it leads to a programmer stopping his trust in certain packages/libraries and them reinventing the wheel.

    • @sniperbloom1305
      @sniperbloom1305 4 ปีที่แล้ว +1

      @@marclurr "explodes when you try to burn it"... doesnt that defeat the purpose 🤔

    • @Dolthra
      @Dolthra 4 ปีที่แล้ว +8

      @@marclurr Depends. Sometimes it produces a worse solution, sometime it produces a better solution... that only works for a certain specific type of cart.

    • @user-iu3ii8sq6t
      @user-iu3ii8sq6t 4 ปีที่แล้ว

      same here, and I'd never heart of 2 generals

  • @Lampe2020
    @Lampe2020 7 หลายเดือนก่อน +3

    That was about what I expected to be the solution - just send several messages if you don't get a reply and find a way for the server to identify duplicate requests.

  • @720JC
    @720JC ปีที่แล้ว +1

    I wish I had someone explain it to me like this when I was in college

  • @turdanc
    @turdanc 4 ปีที่แล้ว +1687

    "A single human error is never the root cause"
    A single human error: I'm about to end this man's whole career

    • @KaiserTom
      @KaiserTom 4 ปีที่แล้ว +62

      Ah, but why does that single human have so much power to completely ruin such a system by themselves? In which case the root cause is actually poor change management or lack of adherence to principle of least privilege or lack of protections for certain key equipment. The key word is "root" cause which dives down much further than the fact that a single human may have caused the problem, but isn't themselves the "root" cause. And a malicious actor bringing down something is not really an "error", and even still may have root causes in poor security measures.

    • @ghosty918
      @ghosty918 4 ปีที่แล้ว +15

      It's not a SINGLE error. Tom mentions a couple things that should be there (the token, the inability to order the same thing in a set period, that sort of thing).

    • @Voron_Aggrav
      @Voron_Aggrav 4 ปีที่แล้ว +7

      Usually most failures of systems are a culmination of various factors that either together or independently causes something to behave in unintended ways

    • @tcoren1
      @tcoren1 4 ปีที่แล้ว +4

      EpicKaiserTom sometimes a single programming error can bring down an entire operation (I think once an unmanned spacecraft crashed because a typo).
      There really isn’t any think that could’ve been done to prevent it, it’s not a result of poor choices or management, it’s just the way things are in this world

    • @SendarSlayer
      @SendarSlayer 4 ปีที่แล้ว +1

      @@KaiserTom Ahem Ahem Y2K was caused by one dude saying "Lets do dates DD/MM/YY and everyone copying him. Single human could've destroyed almost all computers if no one had picked up on it.

  • @jlinkpro
    @jlinkpro 4 ปีที่แล้ว +347

    "I was tired and hungry... as are a lot of their drivers."
    Never stop being savage.

    • @petarus625
      @petarus625 3 ปีที่แล้ว +3

      @@DvH_2 ikr? I had no clue the word savage had anything to do with the Pauls.

  • @RonaldSimkin
    @RonaldSimkin ปีที่แล้ว +3

    2:45 What if each side sends a guy to the middle, and they communicate at the middle, and they each return and each report the success of an agreement.

  • @Objectified
    @Objectified ปีที่แล้ว

    It's always striking to me how on one hand you seek to dispel memes, stereotypes, tropes, and misconceptions yet intersperse your videos with interjections of sociopolitical memes, stereotypes, tropes, and misconceptions.

  • @user-rw6xo9jc3n
    @user-rw6xo9jc3n 4 ปีที่แล้ว +671

    See you all in 2023 when this video gets recommended again

  • @dunpealhunter
    @dunpealhunter 2 ปีที่แล้ว

    Goddamn, the way you tell these stories in way that most of us (who don't know anything about computer science) can understand is extremely good! 👍👍

  • @silentwhisper868
    @silentwhisper868 3 หลายเดือนก่อน +1

    Just set up a protocol:
    General A sends a messanger. If more than twice the time it takes a messanger to get to the other side and no messanger got back this means one of the messangers failed. So general A sends another one.

  • @erraticonteuse
    @erraticonteuse 2 ปีที่แล้ว +3930

    Tom: The Two Generals Problem is a classic of computer science.
    Me: Given how much the development of computer science was tied up with World War II and then the Cold War, I wonder if there's any bonus military history insights.
    Tom: So there's a castle in a valley...
    Me: The insight is that computer scientists don't know military history.

    • @GeneralAceTheAwesome
      @GeneralAceTheAwesome 2 ปีที่แล้ว +338

      The thing is though, the valley has nothing to do with the problem. If it was a flat plane, or a castle on a hill, you could still have the same problem. I wonder if the valley was in the original version of the problem?

    • @zeroyuki92
      @zeroyuki92 2 ปีที่แล้ว +159

      Possible if the castle is protecting something like a holy site or is an important crossroad between mountains, for example.

    • @noahjordan6761
      @noahjordan6761 2 ปีที่แล้ว +64

      Like there would be military history when a point needed to be made. Peoples attention spans are at stake here!

    • @unrelatedK
      @unrelatedK 2 ปีที่แล้ว +22

      @@noahjordan6761 and so are the two generals

    • @NoriMori1992
      @NoriMori1992 2 ปีที่แล้ว +62

      The insight is that it's not supposed to resemble a real military situation.

  • @alexihickin230
    @alexihickin230 4 ปีที่แล้ว +187

    I work for deliveroo and I remember this evening, i delivered Wagamamas to a house who had already received their order. I had to wait with them while they got a refund, long story short I got 50 quids worth of Wagamamas for free.

    • @luckymouse1988
      @luckymouse1988 4 ปีที่แล้ว +4

      That's rather _selfish_

    • @natebit7167
      @natebit7167 4 ปีที่แล้ว +4

      wtf is a wagamama

    • @brentcouncil1489
      @brentcouncil1489 4 ปีที่แล้ว

      Sorry but do you speak English? I have no idea what what you are talking about :(

    • @AlfiRizkyR
      @AlfiRizkyR 4 ปีที่แล้ว +1

      @@luckymouse1988 underrated pun right there.

    • @natebit7167
      @natebit7167 4 ปีที่แล้ว +1

      No actually, wtf is a wagamama someone pls

  • @DBqFetti
    @DBqFetti 2 ปีที่แล้ว +1

    Happened to me, having my car towed. They had a mobile credit card device to charge you right at place and the signal was bad. So it always responded an error and the guy tried it like 5 times or so. Eventually they charged me twice.

  • @Flogervideo
    @Flogervideo 2 ปีที่แล้ว

    These animations are gorgeous! Thanks for the super informative video.

  • @somethinggreatishappening8536
    @somethinggreatishappening8536 3 ปีที่แล้ว +155

    lesson learned: if you want to attack a castle, just cook for yourself

  • @sinshadow1993
    @sinshadow1993 4 ปีที่แล้ว +780

    Tom, I am a safety critical programmer and I am watching a series called the basics, but more cause I like your stories and less for use at work :)

    • @joebleasdale5557
      @joebleasdale5557 4 ปีที่แล้ว +12

      Robby Maura is potential loss of life involved? 😂

    • @TecSanento
      @TecSanento 4 ปีที่แล้ว +1

      But how do you solve this problem at work?

    • @ratdude747
      @ratdude747 4 ปีที่แล้ว +7

      Same here... not my main job, but I do design and tweak safety systems at work when needed (robotic welding cells, etc.). Rule #1: "Why is this wrong?"

    • @NatoBoram
      @NatoBoram 4 ปีที่แล้ว

      @@ratdude747
      Rule #2 : Why is this right?

    • @57thorns
      @57thorns 4 ปีที่แล้ว +1

      It is also a good idea to get a refresher now and then, especially when it is entertaining.

  • @rationalcase
    @rationalcase 2 ปีที่แล้ว

    In the UK Fire Service, when we need to request additional resources and/or assets for an incident (over the radio to our control-centre) we say something like: “Make pumping appliances 4, aerial-rescue appliances 2”.
    If there are 3 pumping appliances and 1 aerial-rescue appliance already at the incident, then just one of each will be mobilised, regardless of how many times the message is (or has been) sent and by whom. This is a very practical, real-world example of idempotency. In this case the ‘key’ is embedded in the semantics of our spoken language.

  • @agar322
    @agar322 8 หลายเดือนก่อน

    This is happening right now in Brazil, and with a food delivery app too

  • @uniqueusername_
    @uniqueusername_ 2 ปีที่แล้ว +2547

    “I know.”
    “I know you know.”
    “I know you know I know.”

    When I was little, I was so confused by this. Good to know it’s actually an unsolvable problem!

    • @RGC_animation
      @RGC_animation 2 ปีที่แล้ว +54

      It's unsolvable, I know.

    • @jebbsredemption
      @jebbsredemption 2 ปีที่แล้ว +71

      @@RGC_animation I know you know it's unsolvable.

    • @JohnFiala
      @JohnFiala 2 ปีที่แล้ว +43

      @@jebbsredemption I know you know I know it’s unsolvable.

    • @scriptshowcasechannel4515
      @scriptshowcasechannel4515 2 ปีที่แล้ว +34

      It's solvable - if you send a person to deliver a message tell them to come back once they have delivered it. If they don't come back send another message until one person comes back. Then you know they got the message and therefore will attack at the same time.

    • @scriptshowcasechannel4515
      @scriptshowcasechannel4515 2 ปีที่แล้ว +12

      It's solvable - if you send a person to deliver a message tell them to come back once they have delivered it. If they don't come back send another message until one person comes back. Then you know they got the message and therefore will attack at the same time.

  • @nebulamage8394
    @nebulamage8394 3 ปีที่แล้ว +819

    Is this problem the thing where you send a text message and it says “message not sent” so you spam it and then your friend says you sent 10 of the same message?

    • @ryanmunn4134
      @ryanmunn4134 3 ปีที่แล้ว +68

      yep

    • @airkami
      @airkami 3 ปีที่แล้ว +55

      And the solution is anti-spam bots in twitch chat. You try to say the exact same thing twice in a row and it will let you know your duplicate message won't go through and you need to wait X amount of time before posting the same message again.

    • @MrJoeDone
      @MrJoeDone 3 ปีที่แล้ว +2

      @@airkami well in twitch its just identical messages not the same message (different massage id if you would create one)

    • @airkami
      @airkami 3 ปีที่แล้ว +7

      @@MrJoeDone Depends on how they implement the bot. Since the bot will have a cache of the original messages, it could update the id of the message to be the same as the id of the old message thus making it effectively the same exact message as far as the system is concerned.

    • @unliving_ball_of_gas
      @unliving_ball_of_gas 3 ปีที่แล้ว +4

      That sometimes happens on yt too

  • @ManMakerMan
    @ManMakerMan 2 ปีที่แล้ว +5

    well eventually they would just go, "yep, the other person got the letter we've been sending acknowledgements for the last hour, we attack at 8"

  • @LRM12o8
    @LRM12o8 2 ปีที่แล้ว +3

    Reminds me of my Christmas shopping experience last year:
    I ordered some gifts from a store that I hadn't ordered from in a while and didn't realize that the credit card still linked to that account has expired in the meantime. So I ordered and used the stored credit card info to pay and the website didn't notice either. It just displayed the usual "thanks for your order" page and I went on to different things.
    A week later I wondered why I still haven't received the stuff and realized that I hadn't gotten an order confirmation per e-mail either. So I ordered again and the website got me through checkout again, saying everything's fine. This time I monitored my inbox and after two hours of nothing, checked my order history in my account, found no order and ordered again, but got no mail again.
    It took two days of back and forth with the customer support for them to find out why my orders weren't processed. I wonder why they were confirmed on the website though... 🤔

    • @eaaeeeea
      @eaaeeeea ปีที่แล้ว

      I would imagine a check and prompt for a card expiration would be one of the must-have features in any webshop. Crazy to think that on this day and age someone didn't implement it.

  • @megiant
    @megiant 3 ปีที่แล้ว +82

    Total War AI is so advanced it doesn’t need a two generals problem to just rush towards a castle without waiting for your half of the army.

  • @findingteemo6833
    @findingteemo6833 4 ปีที่แล้ว +603

    "That's how to solve the two generals problem", but that doesn't really solve it right? It just is a good way to deal with it.

    • @JesusJuenger
      @JesusJuenger 4 ปีที่แล้ว +77

      Correct, it's just a way to work around it in practice.

    • @airRozi
      @airRozi 4 ปีที่แล้ว +6

      bitcoin solves it.

    • @HTFFanOfFlaky
      @HTFFanOfFlaky 4 ปีที่แล้ว

      @@hairyairey it already did tho

    • @chantolove
      @chantolove 4 ปีที่แล้ว +5

      ...otherwise known as a solution?

    • @PiezasdeAjedrez
      @PiezasdeAjedrez 4 ปีที่แล้ว

      Only in that very specific orders repetition case :v

  • @juergenhaas3530
    @juergenhaas3530 ปีที่แล้ว +10

    Third video I've watched Tom Scott. He makes it so easy to follow, the videos are simple enough in visual information that it will not feel like visual overkill to me, yet interesting enough to stick to what he is telling and let me keep watching... I will make sure to come back for more. Thank you for that.

  • @user-xg8yy7yl1d
    @user-xg8yy7yl1d 3 ปีที่แล้ว +244

    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

    • @goekhanbag
      @goekhanbag ปีที่แล้ว +20

      The attacking sides would run out of supplies before the castle would.

    • @alex2005z
      @alex2005z ปีที่แล้ว +10

      Option D: smoke signals

    • @baron2062
      @baron2062 ปีที่แล้ว +34

      @@goekhanbag seems unlikely if they can figure out how a supply wagon works

    • @chanclink2383
      @chanclink2383 ปีที่แล้ว +1

      Well that was a strategy used during the Civil War in the USA; Check the Fort Sumter

    • @alex2005z
      @alex2005z ปีที่แล้ว +28

      @@chanclink2383 sieging has been a thing since forever

  • @vulpeeze
    @vulpeeze 3 ปีที่แล้ว +168

    Watched this months ago and now I'm being told to watch it again by my university professor. Tom Scott never fails to impress.

  • @Grigsy
    @Grigsy 10 หลายเดือนก่อน +3

    This is why statistics is important. There are few areas in life where you can be certain about anything. You make decisions based on probability.

  • @TheCalmack
    @TheCalmack ปีที่แล้ว +1

    by chance you just fixed a bug I was having actually :) thanks

  • @riveraluciano
    @riveraluciano 4 ปีที่แล้ว +324

    "If you're in computer science and work on a problem which involves potential loss of life, I really hope you're not watching a series called The Basics."
    Meanwhile, everyone at StackOverflow...

    • @Hyperus
      @Hyperus 4 ปีที่แล้ว +5

      Not a lot to go wrong when all you have is a "Ctrl", C and a V Button to use :>

    • @kalebbruwer
      @kalebbruwer 4 ปีที่แล้ว +27

      "Hey so I got this error, it says 'Segmentation fault (Core Dumped)'. You know what I did wrong?

    • @SubjectMRF37
      @SubjectMRF37 4 ปีที่แล้ว +10

      Kaleb Bruwer oh that’s nothing, just turn ur computer off and on again and it should be fine.. computers just tired

    • @TheAlison1456
      @TheAlison1456 4 ปีที่แล้ว +2

      what the hell is the basics

    • @LukaMiljak
      @LukaMiljak 4 ปีที่แล้ว +2

      Unknow0059 One of his video series. This episode belongs to it.

  • @Marinealver
    @Marinealver 4 ปีที่แล้ว +193

    "Would you like to pay again?"
    Sounds like everything is working as intended to me.

    • @georgelionon9050
      @georgelionon9050 4 ปีที่แล้ว +2

      Now special offering: All you can pay!

  • @rowanmales3430
    @rowanmales3430 7 หลายเดือนก่อน +3

    That "solution" runs into other niche problems. Like if you order a meal, and just after you order another family member wants to get something too, and if it happens to be the same order then the second order will be ignored. Sometimes people want duplicate things.

  • @omargoalzz
    @omargoalzz ปีที่แล้ว +2

    It can be like this maybe:
    Army A's messenger goes and sends the message and tells the general about it, with a proposed time, and the rest of Army A knows that Army B got the message if the messenger of Army A returned.

    • @icantthinkofaname8139
      @icantthinkofaname8139 ปีที่แล้ว

      Ok what if on the return trip the messenger is shot down? A will think B didn’t get the message and not attack; but B will, and they’ll lose

    • @joshualayton1905
      @joshualayton1905 11 หลายเดือนก่อน

      ​@@icantthinkofaname8139its a valley, wouldnt army a see their messager get shanked?

  • @nickolas474
    @nickolas474 4 ปีที่แล้ว +238

    If I was an engineer working on a computer science problem with human lives on the line, I might still watch a series titled "the basics" because Tom Scott is worth watching.

    • @maxximumb
      @maxximumb 4 ปีที่แล้ว +5

      Everyone can always learn something new. The secret is keeping your mind open to different ways of doing things.

    • @huttj509
      @huttj509 4 ปีที่แล้ว +16

      @@maxximumb There's also the aspect of "That's a really good way of putting what I wasted an hour trying to explain to that one manager!"

    • @icemysta30
      @icemysta30 4 ปีที่แล้ว

      ishmael

    • @jirm18
      @jirm18 4 ปีที่แล้ว

      Exactly!

  • @Voodoomancer
    @Voodoomancer 4 ปีที่แล้ว +150

    Moral of the story: If you want to be a programmer, learn to cook.
    ...wait.

  • @judgemoses9015
    @judgemoses9015 2 ปีที่แล้ว

    Hey you mean Brit! It's good for professionals to hear other peoples takes on the basics from time to time!

  • @NoriMori1992
    @NoriMori1992 2 ปีที่แล้ว +6

    This is one of my favourite problems because it's the simplest problem that I can think of that is unsolvable, and also the easiest to understand why it's unsolvable.

    • @stargazer7644
      @stargazer7644 ปีที่แล้ว

      If it was unsolvable, the internet would be impossible. It is solved a billion times a second all over the internet.

    • @TimothyCho
      @TimothyCho ปีที่แล้ว +4

      ​@@stargazer7644 its unsolvable as in you can not remove uncertainty, only mitigate it.

  • @eggyrepublic
    @eggyrepublic 4 ปีที่แล้ว +83

    "A single human error is never the root cause"
    Me: *observe*

  • @twinklestar3556
    @twinklestar3556 4 ปีที่แล้ว +64

    I almost ordered pizza multiple times recently when they said payment wasn't recieved, but I was too tired to care about reordering and gave up.
    Imagine my surprise when it showed up an hour later, lmao

  • @cmfrtblynmb02
    @cmfrtblynmb02 ปีที่แล้ว

    Where I live you buy tickets on the app. And the app often says payment failed. If you don't check the ticket status and try to pay again, you will usually end up buying two tickets.

  • @Kohdok
    @Kohdok ปีที่แล้ว

    Weird that they would say the castle was in a valley rather than on a mountain, where the mountain itself would obstruct the view between the armies. I guess the valley was more photogenic in this case?

  • @mattpinkerton6562
    @mattpinkerton6562 4 ปีที่แล้ว +22

    Because of this video I avoided a similar problem with uber eats, it said there was a problem ordering and I remembered this video, made sure to check my bank account. Sure enough while Uber said the order wasn't placed, the money was out of my account. 20 minutes later my order arrives, thanks Tom!

  • @RedesCat
    @RedesCat 4 ปีที่แล้ว +76

    "next time I'll just cook for myself"
    Tom, we both know next time you'll order out again