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.
Thanks!
;-)
You've basically got the correct solution. I think you are spending too much time on
n % 2 == 0
. Try to think of alternative ways of testing for odd or even. May-be precompute/get all the bits ofn
in one operation. A number is stored in binary, isn't it? No need to recompute the bits.My solution calculates
fusc(1 << 100000)
in18 ms
. Your code is super inefficient.Yeah, I know it's frustrating. I just ran my own solution and it completed in under 5s so I don't think you can only blame the server.
This is simplified version of the kata. Bruteforce should be enough to pass all the tests. Either optimize or find another approach. And yes, there are many approaches, as you can see in harder version of the kata.