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.
I don't know what that means. Have you read the description?
when you say "why", are you suggesting there's an order that forms a higher number? if so, what order is that?
you're not asked to sort the numbers if that's what you mean. that seems to be what you're saying.
Also, your code fails for cases like
Because your
founded
will store7
, but you output the 1st occurence or index (position) of that value, in which the correct result should be7
(index) instead of3
(first occurence of the value7
)If
n
is greater than the length ofvalues
, you should return the sum of the whole array. That's not what you are doing there :There
I haven't yet unlocked this kata so I can't see test cases, but thinking logically:
this example is using a function called
trueIfLengthEqualsIndex
- in other words it will returnTrue
if the element in the array has the samelength
as its index.Working through the example array given - write down the length of each element and its index:
The input array
["one","two","three","four","five","six"]
therefore gives - where e.g.
len("three")=5
:[ index 0 len=3, index 1 len=3, index 2 len=5, index 3 len=4, >>>> index 4 len=4 <<<< , index 5 len=3]
so I would expect
4
to be the correct result here.