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.
Nice one! It didn't occur to me I could split the string with regex expression.
This comment is hidden because it contains spoiler information about the solution
That's just so wrong and right at the same time:D
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. (thatelse if
andelse
)It doesn't work for
|end| >= 100
or|start| >= 100
, but you probably realise that:DI'm curious about
size_t
type ofi
variable. Could you or somebody else elaborate on advantages?I would also:
else
, it doesn't do anything useful and you risk returningNone
where you don't intend to (by the way, if anyone knows the general term for parts of statements likeelse
, please tell)break
statement from prime factorization loopsTrue
andFalse
)consec_kprimes
function toif kprimes[i] and kprimes[i + 1]
(Not trying to be mean or nitpicky, just verbalizing my thoughts on refactorization as a post-workout routine)
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!
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?
Any hints what I should read up on to be able to solve such combinatorial/disjoint sets problems? Thanks in advance:D
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.
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.Thing of beauty. I was looking for that one in my mind, but couldn't find it, congratz.
Not a best practice, all those
Math.ceil()
functions andreturn
s make the code very repetitive.There are issues with object prototypes within JavaScript version. It's not working properly with objects created with
null
prototype:which is the proper way to do maps in JavaScript in my opinion.
Loading more items...