• jol
    link
    fedilink
    arrow-up
    7
    arrow-down
    5
    ·
    vor 1 Monat

    Binary search only works if the fuses were correctly sorted in the same order as the houses though.

    • domdanial@reddthat.com
      link
      fedilink
      English
      arrow-up
      22
      ·
      edit-2
      vor 1 Monat

      I don’t think that’s true, it’s more of a set problem. If you pull half the fuses, and the thing is still on, then you’ve ruled out that half. Then you pull half the remaining fuses, and if it turns off it was one of the new half you pulled. Then you put another half back in, ect .

      • jol
        link
        fedilink
        arrow-up
        6
        ·
        vor 1 Monat

        Ah, I didn’t think of it that way. That indeed would work.

    • Ephera@lemmy.ml
      link
      fedilink
      English
      arrow-up
      4
      ·
      vor 1 Monat

      You know, after posting that comment, I really doubted myself, if it really is binary search, because Wikipedia also tells me it needs to be a sorted array.

      But yeah, I think that’s only relevant, if your method of checking whether it’s in one half or the other uses > and <. As far as I can tell, so long as you can individually identify the fuses, a.k.a. they’re countable, then you can apply binary search.

      • lunarul@lemmy.world
        link
        fedilink
        arrow-up
        3
        ·
        vor 1 Monat

        If when you divide your set in two, you can reliably tell which of the two subsets definitely has what you’re looking for, then it’s binary search.