Created
April 2, 2015 00:12
-
-
Save shadeslayer/87508f97288040677688 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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