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.
Great! But how this works?
Thank you!
def encrypt(text, n)
return text if n <= 0
text.length.times.select { |i| i.odd? }.each_with_index do |e, i|
text.insert(i, text.slice!(e))
end
encrypt(text, n - 1)
end
def decrypt(encrypted_text, n)
return encrypted_text if n <= 0
count = encrypted_text.length/2
count.times do |i|
encrypted_text.insert(count + i, encrypted_text.slice!(0))
end
decrypt(encrypted_text, n - 1)
end
This comment is hidden because it contains spoiler information about the solution
Please fix expectation random decrypt tests.
Nice!
Awesome!