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.
There are 20000 JS tests in total, your code handles about half of them, I have run it several times - the result is
10_000 - 12_000
. To be honest, I haven't looked closely at your code and can't tell you exactly what the problem is, but your algorithm needs to be improved. However, before you change anything, maybe you can add caching for some “heavy” calculations (if there are any and it is possible), it might work.I managed, not without difficulty, to find a solution to this Kata!
But I can't get past the random tests...
Code Wars gives me a timeout before the tests are finished.
I didn't use a brute force algorithm; the algorithm solves a puzzle in an average of 1ms, so I don't know what more I can do...
(Tests done in JS.)
I think it's because of the asynchronous nature of my tests, but I don't know how to fix it... Does anyone have any ideas?
Thank you for the feedback. The issue has been resolved.
The initial solution has
function twoOldestAges
.This comment is hidden because it contains spoiler information about the solution