Help with Ruby method - how to phrase

I’m trying to build a method that takes in a string, and returns the previous letters of the string. For example, “abc” would return “zab”
This is what I have so far:

def decrypt(string)
index = 0
alphabet = “abcdefghijklmopqrstuvqxyz”
while index < string.length
if string[index] == " "
puts string[index] = " "
index += 1

I understand what you’re trying to do.
Do you know anything about ascii?
wouldn’t that be what you need for this?

I don’t know about ascii, I’m just starting out in Ruby. Is there any beginner way to solve this problem? maybe using .index on alphabet string?

actually, i looked more into this, and ruby might be a good language to do this in.
This isn’t actually a beginner problem, and i don’t know that there is an easy way to go through this, but i found some other examples of people writing caesar ciphers in ruby, and you could actually do a list of something like:

l_alphabet = ("a".."z").to_a

I don’t know if this gives you a sort of idea for what you could use an index for .
I could direct you to examples of caesar ciphers, but i don’t know if that might be cheating.
Are you doing this for fun/experience or for something else?

1 Like

Well I found a good sort of walkthrough to build it, I don’t know if this will help :confused:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.