Ad
  • Default User Avatar

    This also helps check if people have used decodeURI and encodeURI correctly. N.B. the path after the hostname, the parameter name and the parameter value can all have URI encoded characters in them! I reckon nearly all the current solutions won't work at all.

  • Custom User Avatar

    Yeah, totally, but why not make it a little more complicated? :P Although, I might use that one for performance purposes instead.

  • Custom User Avatar

    I haven't finished my version yet, so I may be wrong about the specifics... but I think this would generate a random 0 or 1.

    ?1.@.0
    
  • Custom User Avatar

    Yeah, I added a test for this. Using the code I replied above this, I ran it 2000 times and if 0.47 < (# of ones) / 2000 < 0.53 then it's deemed good.

  • Custom User Avatar

    I considered it, but how am I supposed to test infinite loops?

    EDIT: How about this?

    v@.<
     >1^
    >?<^
     >2^
    

    And just run it a bunch of times?

  • Custom User Avatar

    Haha, well, that's what happens. I'd advise you, if you're really stuck, to simply just start logging the pointer location and contents of the stack on every iteration. I've found that can help.

  • Custom User Avatar

    Yeah, running the interpreter to a limit is a good idea.

    I wish there were a way to do intermediate testing but with this particular language it's fairly difficult to do... And the way Codewars captures debugging it's even more difficult.

    What I did in testing this was run the code in Node. If you have Sublime Text you can set up a build system to run the code, but otherwise you can always just run "node befunge.js" at the command line and it'll execute it. Likewise for CoffeeScript.

  • Custom User Avatar

    Premature generalization, I guess?
    If something else unrelated to logins wanted to do the same pattern check, they could reuse this function without having to refactor any variable names.
    Doesn't really matter for katas, I admit, force of habit :\