Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm still on the first level playing with various 'P's and 'D's (no 'I's yet), but I think I have a novel scheme!

    function controlFunction(block)
    {
      let L = Math.floor;
      let x = block.x;

      // Use Collatz. L(x+½) is the closest integer. 
      return 
        -(L(x+0.5) % 2 === 0
                        ? x/2     // Even, we chop it
                        : 3*x + 1 // Odd, we triple-plus-one it. 
         );
    }
It's not very good, but it does beat or tie some of my earnest attempts to get below 8 seconds.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: