Skip to content

Instantly share code, notes, and snippets.

@shadeslayer
Created April 2, 2015 00:12
Show Gist options
  • Save shadeslayer/87508f97288040677688 to your computer and use it in GitHub Desktop.
Save shadeslayer/87508f97288040677688 to your computer and use it in GitHub Desktop.
def process_input(input)
my_stack = [] of Char
result = ""
input.each_char do |c|
if c == 't'
my_stack << c
else
if c != 'h'
my_stack.each do |t|
result += t
end
my_stack.clear
end
result += c
end
end
result + my_stack.join("")
end
INPUT = [ "the theater", "interesting stories", "authentic atthic", "thththththththt"]
OUTPUT = [ "hte hteater", "interesting stories", "auhtentic ahttic", "hhhhhhhtttttttt" ]
INPUT.each_with_index do |v, i|
if OUTPUT[i] == process_input(v)
puts "Pass"
else
puts "Fail"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment