Ad
  • Custom User Avatar
  • Custom User Avatar

    Re-raised as an issue.

  • Custom User Avatar

    make a python version and I share a Python3 winding number solution

  • Custom User Avatar

    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.

  • Custom User Avatar

    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.

  • Custom User Avatar

    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:

    • length = 1231, which turns in:
    • words: 176
    • chars: 1215
    • lines: 17

    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.

  • Custom User Avatar

    Didn't get a notification, thanks for pinging me again.
    Ok let me take a look at your message about test case 44.

  • Custom User Avatar

    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.

    • It would be "Zombie ips four dead." not the other way around (you switched first and last)
    • There are other words in between : "Zombie ips ... four dead."

    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.

  • Custom User Avatar

    Hello,
    Your code is ok. But it can be faster.
    Try to replace the call boundParseChar(lastRead.charAt(i)); by the content of the parseChar 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 the parseChar 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!