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.
Could you please explain to me why we need to subtract b from a!
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
They never said where to write it.
Clever. Caching a large range of computations and then using it over multiple requests. This efficiency rests on the assumption that the cache will persists from one call to the next.
The other downsides are that it is overkill for small ranges, and does not cover larger ranges.
Not a valid solution. I think you missed the point of the exercise.
This "solution" is like looking at the answer sheet and then just returning look-ups from its answer set. It doesn't show that one knows how the answer set was calculated.
My apologies for not adding value. What I should have said is that, yes, this solution will work, but that a switch-statement would be better practice and easier to read. The switch-statement was created to replace if-statements like these.
All valid points. Look-up tables are a time-tested optimisation in several computing solutions.
The only thing that this solution falls afoul of is that the problem specifically asks one to COMPUTE the value.
Lol! "Actually", maybe learn to read. (Oh look, other people can do ad hominem attacks too. Shocker) As I stated in my comment, the problem statement says "compute", it does not say "use a lookup table". Also, no generalization was made as I was specifically referring to this kata, and not computing in general.
Using lookup tables is an established technique for many computing solutions. However, it was not what was asked for in this problem, so it is understandable why other programmers are calling you out.
The problem statement clearly asks you to compute the value (emphasis added):
I intended no offense, just accuracy. That you took it personally is regrettable.
Actually, a lot of computations are done with lookup tables. You might want to learn more about computers before making generalizations about them.
Wow. Just hell no.
I like seeing an ES2015 implementation, BUT this does away with polymorphism entirely. Run-time checking of types is the naive (and ultimately more fragile) solution.
Re-writing this problem in a non-polymorphic way is clearly not best practice.
Very clever. Readable too.
Using pattern matching and guards on the value of n, would takeaway all this unnecessary complexity.
This comment is hidden because it contains spoiler information about the solution
Loading more items...