Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

The New Coffee Room

  1. TNCR
  2. General Discussion
  3. Puzzle Time - Read, Increment, Write

Puzzle Time - Read, Increment, Write

Scheduled Pinned Locked Moved General Discussion
22 Posts 5 Posters 141 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • taiwan_girlT taiwan_girl

    @jon-nyc said in Puzzle Time - Read, Increment, Write:

    When they are all done, the largest number that could be on the blackboard is 370,000.

    Hmmm, I will think some more (and probably not still be able to solve it),

    :::

    but I am not sure how it could be smaller than 370,000.

    100 * 100 * 37

    :::

    jon-nycJ Offline
    jon-nycJ Offline
    jon-nyc
    wrote on last edited by jon-nyc
    #12

    @taiwan_girl

    Recall the read/increment, and write are separate. And whatever happens to the number between your read and your write is essentially lost when you write.

    To put it another way, imagine you are one of the hundred. You go in first, see it at zero. Walk out. Then (say) all the other 99 do all 100 of their cycles. IOW, they’re done now. Then you finally walk back in, erase whatever number they got to, and write 37. So you basically reversed all of their work. Made it as if they had never even participated. And you’ve got 99 cycles left which will bring the grand total to 3700. That was basically Ax’s proposal.

    But it can go even smaller than that.

    "You never know what worse luck your bad luck has saved you from."
    -Cormac McCarthy

    1 Reply Last reply
    • jon-nycJ jon-nyc

      Here’s a hint.

      :::

      Let M(n,r) be the minimum final number with n scientists doing r rounds of read, increment, write. Observe that M(n+1, r) <= M(n,r) since given a minimal sequence with r rounds and n scientists, you can add another scientist with no impact by having all his activity occur after the read associated with final write but before that final write.

      :::

      KlausK Offline
      KlausK Offline
      Klaus
      wrote on last edited by
      #13

      @jon-nyc said in Puzzle Time - Read, Increment, Write:

      Here’s a hint.

      :::

      Let M(n,r) be the minimum final number with n scientists doing r rounds of read, increment, write. Observe that M(n+1, r) <= M(n,r) since given a minimal sequence with r rounds and n scientists, you can add another scientist with no impact by having all his activity occur after the read associated with final write but before that final write.

      :::

      So you want us to express M(n,r) as a recurrence relation and then solve it?

      I assume it's something like this:

      M(n+1,r) = minimum{ M(n,r) , -- the trick -- }
      M(n,r+1) = minimum { M(n,a) + M(n,b) | a+b=r+1} union { -- the-other-trick -- }

      1 Reply Last reply
      • jon-nycJ Offline
        jon-nycJ Offline
        jon-nyc
        wrote on last edited by
        #14

        Not necessarily. The implication of that hint that I was trying to communicate is that if you find a really low number with, say, 2 scientists, you’d be able to preserve that low number at 100 (or potentially do better).

        "You never know what worse luck your bad luck has saved you from."
        -Cormac McCarthy

        1 Reply Last reply
        • jon-nycJ Offline
          jon-nycJ Offline
          jon-nyc
          wrote on last edited by
          #15

          So if you can convince yourself that a solution you found for a smaller n must be a lower bound for any n, you are done.

          "You never know what worse luck your bad luck has saved you from."
          -Cormac McCarthy

          1 Reply Last reply
          • KlausK Offline
            KlausK Offline
            Klaus
            wrote on last edited by Klaus
            #16

            :::

            I made a little progress.

            In the scenario with 2 scientists and 3 rounds, Ax's method would yield a bound of 3*37.

            If we denote by R<n> the event of scientist n entering the room to read and W<n> the event of scientist n entering the room two write, then this sequence of events yields a final number of just 2*27.

            R0,R1,W0,R0,W0,W1,R0,R1,W1,R1,W1,W0

            Here's a sequence that yields just 2*37 for 4 rounds of 2 scientists:

            R0,R1,W0,R0,W0,R0,W0,W1,R0,R1,W1,R1,W1,R1,W1,W0

            Even for five rounds, 2*37 is sufficient.

            R0,R1,W0,R0,W0,R0,W0,R0,W0,W1,R0,R1,W1,R1,W1,R1,W1,R1,W1,W0

            And finally, one for six rounds with 2*37.

            R0,R1,W0,R0,W0,R0,W0,R0,W0,R0,W0,W1,R0,R1,W1,R1,W1,R1,W1,R1,W1,R1,W1,W0

            Based on this pattern, I assume that 2*37 is also sufficient for 100 rounds of 2 scientists and, since more scientists can be added without increasing the number, also in the original case with 100 rounds and 100 scientists.

            :::

            1 Reply Last reply
            • KlausK Offline
              KlausK Offline
              Klaus
              wrote on last edited by Klaus
              #17

              I think I got it.

              :::

              With my nomenclature from above, here's how to get by with 2*37 for 100 rounds with 2 scientists:

              R0
              99 times R1,W1
              W0
              R1
              99 times R0,W0
              W1

              For the remaining 98 scientists, insert them somewhere before a "W"rite in that sequence.

              :::

              1 Reply Last reply
              • KlausK Offline
                KlausK Offline
                Klaus
                wrote on last edited by
                #18

                Here's a counter puzzle for @jon-nyc :

                How many different scenarios/orders are there for n scientists and r rounds?

                I have worked out the solution for n=2. It's interesting.

                jon-nycJ 1 Reply Last reply
                • KlausK Klaus

                  Here's a counter puzzle for @jon-nyc :

                  How many different scenarios/orders are there for n scientists and r rounds?

                  I have worked out the solution for n=2. It's interesting.

                  jon-nycJ Offline
                  jon-nycJ Offline
                  jon-nyc
                  wrote on last edited by
                  #19

                  @klaus

                  Your answer is what I got.

                  As for your question, seems like it’s the problem of how many ways there are to interleave two (or k) ordered lists.

                  "You never know what worse luck your bad luck has saved you from."
                  -Cormac McCarthy

                  KlausK 1 Reply Last reply
                  • jon-nycJ jon-nyc

                    @klaus

                    Your answer is what I got.

                    As for your question, seems like it’s the problem of how many ways there are to interleave two (or k) ordered lists.

                    KlausK Offline
                    KlausK Offline
                    Klaus
                    wrote on last edited by Klaus
                    #20

                    @jon-nyc said in Puzzle Time - Read, Increment, Write:

                    As for your question, seems like it’s the problem of how many ways there are to interleave two (or k) ordered lists.

                    Yes. Both lists have length 2r. Once the positions of the first list in the interleaved list are fixed, the positions of the elements of the second list are fixed, too. Hence the number we are looking for is binomial(4r,2r). Which turns out to be (r+1) * C(r), where C(r) is the r-th Catalan number. Which in turn brings us back to my reference to Dyck languages, since the number of distinct Dyck words with exactly n pairs of parentheses is the n-th Catalan number.

                    1 Reply Last reply
                    • AxtremusA Offline
                      AxtremusA Offline
                      Axtremus
                      wrote on last edited by
                      #21

                      Cool, that's nice.

                      1 Reply Last reply
                      • jon-nycJ Offline
                        jon-nycJ Offline
                        jon-nyc
                        wrote on last edited by jon-nyc
                        #22

                        Repeating the answer w/o Klaus’s symbols:

                        2 scientists. Both go in and see zero. One does 99 of his 100 full cycles, taking the number high.

                        The 2nd comes in finally does his first write, replacing that high number with 37. 1st guy comes in for his last read and sees 37, leaves. 2nd guy does the remainder of his cycles, taking the number high again.

                        1st guy comes in, erases the high number, and writes 74 as his final write.

                        As we discussed earlier, when you expand to 100 scientists just have them do all their 100 cycles after the final guy’s last read but before his final write.

                        "You never know what worse luck your bad luck has saved you from."
                        -Cormac McCarthy

                        1 Reply Last reply
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups