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.
No need for fancy functions. I love it
absolute winner!
This is what I ended up doing
a for loop of n value seems like a bad idea for large numbers, yet clever solution for a kata without methods.
He did the operation without using methods
This is nice except that every single one of 4
if
s will be tested even though at most 1 can be truthy.Well that's one way to do it
My eyes
Wht?
this is the smartest way, without built in methods
Why? You are reducing to a single number according to the data ops. The only time there is no operation on that number is for operation
o
, which just pushes the number to the main function's output array. Seems pretty straightforward.I've done it a bit differently in that my reduce function builds the main output array but I like this top solution, focusing on the number itself.
In my opinion it would be better to start from
x = 1
to avoid a division by zero.Using reduce as a quasi loop without even returning any reduced value is kind of ugly to my taste.
Wow, this is too good.
Can anyone explain why there is n / 2? Thanks
Loading more items...