Skip to content

Instantly share code, notes, and snippets.

@djanatyn
Created May 16, 2014 17:15
Show Gist options
  • Save djanatyn/54cd7bd330697e0dbc77 to your computer and use it in GitHub Desktop.
Save djanatyn/54cd7bd330697e0dbc77 to your computer and use it in GitHub Desktop.
def rule_one string
return [string + "U"] if string[-1] == 'U'
return false
end
def rule_two string
return ["M" + (string[1..-1] * 2)]
end
def rule_three string
n = 2
results = []
while n <= string.length
new_string = string.clone
if new_string[(n-2)..n] =~ /III/
new_string[(n-2)..n] = 'U'
results.push new_string
end
n += 1
end
return results
end
def rule_four string
n = 1
results = []
while n <= string.length
new_string = string.clone
if new_string[(n-1)..n] =~ /UU/
new_string[(n-1)..n] = ''
results.push new_string
end
n += 1
end
return results
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment