Ad
  • Custom User Avatar

    This is a terrible problem statement to inflict on beginners. We're told not to use any kind of measurement, but we're not given any indication of what moves we are allowed to use. The author just assumes that their solution is canonical and that anyone can be expected to reach the same conclusion. Personally, I would hold one end of the curtain in my left hand, loop it around some fingers of my right hand, then back around the fingers of my left, then grasp the other end in my right hand, and pull them taut so that the curtain is exactly tripled over. In principle, this procedure could be repeated until the folded length is small enough. But that's not the intended solution, so it's "wrong".

  • Custom User Avatar

    Ooh, I get it. The runBFBF function creates and runs each output*.bf in one fell swoop, so you never get a chance to see it if everything crashes.

    I split up that function in the Preload and changed the "few selected bytes" section of the Sample Tests to read

      Test.it("Works for a few selected bytes", function () {
          runBFToOutput(0)
          console.log('0: ' + String.fromCharCode(...execSync("cat /workspace/output0.bf")))
          runBFToOutput(1)
          console.log('1: ' + String.fromCharCode(...execSync("cat /workspace/output1.bf")))
          runBFToOutput(12)
          console.log('12: ' + String.fromCharCode(...execSync("cat /workspace/output12.bf")))
          runBFToOutput(123)
          console.log('123: ' + String.fromCharCode(...execSync("cat /workspace/output123.bf")))
          runBFToOutput(255)
          console.log('255: ' + String.fromCharCode(...execSync("cat /workspace/output255.bf")))
          Test.assertEquals(runBFOutput(0), 0)
          Test.assertEquals(runBFOutput(1), 1)
          Test.assertEquals(runBFOutput(12), 12)
          Test.assertEquals(runBFOutput(123), 123)
          Test.assertEquals(runBFOutput(255), 255)
      });
    

    This allows the player at least to see the output code before the crash.

    I've republished the kata with the changes. Due to issue #144/#106, you may not see the updated Sample Tests until you resubmit a solution, but the issue should be resolved for new players.

  • Custom User Avatar

    This kata does use the usual bf interpreter, and the comment-loop trick is working for me. Can you give me a specific example of code that causes the incorrect behavior?

    To your second point, the example test cases do console.log the program's output code in the "few selected bytes" section. You can see them by clicking the triangle for that section in the Output pane. If you want to see other outputs, you can see how to modify the test cases even without knowledge of Javascript.

  • Custom User Avatar

    When I try to edit it, it runs into the issue

    https://github.com/Codewars/codewars.com/issues/1134

    So I tried forking it here:

    https://www.codewars.com/kumite/5b8957fc979532035500010c?sel=5bd486507645b91db500003f

    It appears to be awaiting approval.

  • Custom User Avatar

    No worries! I'll be around whenever you get the chance, just let me know!

  • Custom User Avatar

    Python. I had tremendous fun; thank you.

  • Custom User Avatar
  • Custom User Avatar
  • Custom User Avatar

    Why should the empty string be rejected? An empty binary string is the sum of no powers of two. The sum of no things is zero. Zero is divisible by 7.

  • Custom User Avatar

    My solution here doesn't work. For one thing, the "carry" flag never gets set back to zero. Even if the rest of it worked it'd be clumsy. So, uh, don't do as I have done.

  • Custom User Avatar

    Please check out Python translation in kumite https://www.codewars.com/kumite/5b8957fc979532035500010c

    Unfortunately, after fiddling with it for a while, I found I still had to reduce the number of test cases to get the solution within the time limit somewhat reliably.

  • Custom User Avatar

    Did that test case just rickroll me?!

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This is reminiscent of a project I was supposed to do in school but never did. And now I have!