Neo is trying to hack the Matrix. He has one specific code that might be the key to his success. However, to decipher it, he needs to extract certain characters from this code following special instructions.
Instructions:
-
Iterate through each character of the code using its index. For this, you can get all indexes
.indices; -
For each character:
- If the character's index in the string is even (0-based indexing), extract the first character from the code and use
.removeFirst()for this; - If the character's index in the string is odd, extract the last character from the code use
.removeLast()for this.
- If the character's index in the string is even (0-based indexing), extract the first character from the code and use
-
Print the series of extracted characters as the result.