Ad
  • Custom User Avatar

    Nice one! It didn't occur to me I could split the string with regex expression.

  • Custom User Avatar

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

  • Custom User Avatar

    That's just so wrong and right at the same time:D

  • Custom User Avatar

    Maybe I'm nitpicking, but for a best practive I would refactor delimiters to var delimiter = (index === aray.length - 1) ? " & " : ", ", it would simplify the logic too a little bit. (that else if and else)

  • Custom User Avatar

    It doesn't work for |end| >= 100 or |start| >= 100, but you probably realise that:D

  • Custom User Avatar

    I'm curious about size_t type of i variable. Could you or somebody else elaborate on advantages?

  • Custom User Avatar

    I would also:

    • separate prime factorization routine from counting the number of prime factors
    • lose that last else, it doesn't do anything useful and you risk returning None where you don't intend to (by the way, if anyone knows the general term for parts of statements like else, please tell)
    • refactor the break statement from prime factorization loops
    • use more idiomatic built-in constants for expressing boolean values (True and False)
    • simplify the condition in consec_kprimes function to if kprimes[i] and kprimes[i + 1]

    (Not trying to be mean or nitpicky, just verbalizing my thoughts on refactorization as a post-workout routine)

  • Custom User Avatar

    Thank you for your answer. It got me thinking how my solution differs from a nested loop. I implemented it through a single loop that sums up lagrange basis polynomials for every point. Every basis polynomial is in turn constructed from two other functions that implement numerator and denominator. Changing the sequence of operations - making all the multiplications first and divisions last caused both numerator and denominator to overflow! It didn't occur to me for a minute that I can switch the order of operations because of multiplications being encapsulated by functions. Because of that encapsulation my whole solution is helpless and ought to be discarded. So yeah, I kinda needed a smartass solution. Thanks again!

  • Custom User Avatar

    Okay, obviously naive approach of returning full blown lagrange polynomial won't work here, because numbers get too big in cosine function test case. I need a 'smartass solution' then. I can easily simulate lagrange basis polynomials for interpolation points, but any point other than that depends on all the other interpolation points. I need a full blown interpolation polynomial then. I got catch-22ed, well played. Any teeny-tiny hints? Am I missing something obvious?

  • Custom User Avatar

    Any hints what I should read up on to be able to solve such combinatorial/disjoint sets problems? Thanks in advance:D

  • Custom User Avatar

    It would be nice if this kata description would be more elaborate and had some examples, especially the part that two different cheat codes should produce two different outputs wasn't exactly obvious.

  • Custom User Avatar

    Nice for loop, I was looking for that this.received[i] !== undefined pattern! Only problem with that solution is that received array grows indefinitely, which may be problematic irl.

  • Custom User Avatar

    Thing of beauty. I was looking for that one in my mind, but couldn't find it, congratz.

  • Custom User Avatar

    Not a best practice, all those Math.ceil() functions and returns make the code very repetitive.

  • Custom User Avatar

    There are issues with object prototypes within JavaScript version. It's not working properly with objects created with null prototype:

    var object = Object.create(null);
    

    which is the proper way to do maps in JavaScript in my opinion.

  • Loading more items...