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.
Your code fails for cases like
two_sums([2, 2, 3], 4)
as.index
only checks the 1st position of that element in the list and not its corresponding position, so for the case above the right index should be0, 1
but your code checks for.index
-->0 != 0
-->False
, so it skips that condition.This comment is hidden because it contains spoiler information about the solution
I get you, the description is a little difficult to understand, and staring at the examples don't really help.
Essentially what the description is telling you to do (to encrypt) is to split the string(s) into two groups, one group is the parts of the string at an odd index location, and the other group being the parts of the string at an even index location. Then simply combine these two groups and you have the encryption method.
And you have to repeat this n number of times.
I hope that clears it up for you - and I don't believe anything I wrote here is a spoiler, it's merely a rewriting of the description (people can be a little heavy handed with flagging spoiler content, and that may stop you and others from seeing it if needed).
yes