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.
Fixed
Re-raised as an issue.
make a python version and I share a Python3 winding number solution
My solution uses this "winding" technique. Imagine standing at the point in question. Face the first vertex, then turn to face each of the other vertexes in sequence, and finally back to the first vertex. If you made a net 360 degree turn, you're inside. If you're outside the net turn is zero. BTW, I never heard of "winding number" when I came up with this solution.
I also thought of counting intersections on lines from the point to each vertex with each line of the polygon but that seemed harder, and I think it would be slower.
I found at least 8 solutions that use
Math.atan2
. Also, take a look at my latest solution which does the same thing without using any mathematical functions.You're correct regarding the string "t four dead.Zombie ipsum" for the memory test.
But not correct on the numbers. The standalone text is:
The standalone text is repeated 5109x2x10= 102180 times.
(5109 times to fill memory with ~6Mo and a trick to duplicate this by 2 so that getChunk returns a ~12Mo string each call which forces you not to allocate more memory ; and repeated 10 times indeed).
102180*176 = 17983680 should be the correct word count
I've added an extra space between each block so the new characters count expected is: 124250880
I agree it not cool to have a "dead.Zombie" in a test case so I've just updated the test.
However, this is the last test case, you should already have a robust code with previous tests.
Adding random is a bit more complicated. I don't have time for this.
The goal of the test is to have fun and learn things.
If you look at people solutions, most don't use a hack.
This is not an official exam. If people don't play by the rules, it is their problem.
But they take a risk because I can update tests anytime.
Thank you for your feedback.
Didn't get a notification, thanks for pinging me again.
Ok let me take a look at your message about test case 44.
hello.world
never happend in the test cases.I've just checked them.
There is either a space or a \n, as mentionned in the instructions.
(but yes, I could have provided more examples)
The sentence "four dead.Zombie ips" doesn't exist.
For debug purposes, don't hesitate to add chunks to a single string variable and output it.
You won't pass some tests, but i'll be easier to troubleshoot.
I'v updated the failing-test message with your suggestions and also instructions.
Hello,
Your code is ok. But it can be faster.
Try to replace the call
boundParseChar(lastRead.charAt(i));
by the content of theparseChar
function itself.You'll see: test will pass!
This is because each function call has a cost. Very small but not free: context switch, parameters copy, ...
In the end, it adds up!
The threshold is indeed quite severe. But also a good idea to learn things ;)
You code was calling
parseChar
for EACH char!! And then theparseChar
function was calling another function 2 times:isWhitespace
.You better use variable to "cache"
isWhitespace(this.prevChar)
. But that'll make the code harder to understand.Take a look at other participants solution, you can do it without function call and without code duplication ;)
Note: I do prefer maintenable code, were things are separated in functions.
But here, we need performance, and it can be coded in a few lines.
Have fun and congrats on doing most of the job!