Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
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.
Yeah, totally, but why not make it a little more complicated? :P Although, I might use that one for performance purposes instead.
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.
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.I considered it, but how am I supposed to test infinite loops?
EDIT: How about this?
And just run it a bunch of times?
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.
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.
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 :\