• kleeon [he/him, he/him]@hexbear.net
    link
    fedilink
    English
    arrow-up
    68
    ·
    22 days ago

    the simulation in question:

    for (int i = 0; i < 80000; i++) {
       if (rand() % 2 == 0) {
          printf("Kamala wins\n");
       }
       else {
          printf("Trump wins\n");
       }
    }
    
    • carpoftruth [any, any]@hexbear.net
      link
      fedilink
      English
      arrow-up
      13
      ·
      22 days ago

      could you please input that into chatgpt so it will give me a summary of the code output? I’m a busy data driven guy so I don’t have time for the details. however, I do have time for this post

        • plinky [he/him]@hexbear.net
          link
          fedilink
          English
          arrow-up
          2
          ·
          edit-2
          22 days ago

          Gotta dump results in some accumulate tho, and if then logic might be eh (although with branch prediction it might be auto 2 threads actually soviet-hmm or similar utilization at least)

          • DaPorkchop_@lemmy.ml
            link
            fedilink
            English
            arrow-up
            2
            ·
            22 days ago

            A reasonable compiler could optimize this into a bitwise AND, load the pointer to the appropriate string constant into a register branchlessly using a lookup table or cmov instruction, and then execute a single call to printf.

            • plinky [he/him]@hexbear.net
              link
              fedilink
              English
              arrow-up
              1
              ·
              edit-2
              22 days ago

              I mean if I want to know the precise number, like 40012 or whatever. Obviously single call is fast, but printf of 40000 strings single strings is meh. I mean in my variant I don’t run comparison, even bitwise, just 80000 rand and sum, single ceil and print

    • merthyr1831@lemmy.ml
      link
      fedilink
      English
      arrow-up
      8
      ·
      22 days ago

      huh, the sync for Lemmy code block renderer doesn’t show the \ even within the code block 👁️👁️

    • Hexboare [they/them]@hexbear.net
      link
      fedilink
      English
      arrow-up
      7
      ·
      22 days ago

      I’m guessing it literally is a few lines in R, plugging in the polling data after running it through a “model” (i.e. tinkering with the variables based on how polls have historically translated into votes)