Skip to content

Instantly share code, notes, and snippets.

@ykzts
Created April 26, 2010 03:50
Show Gist options
  • Save ykzts/378955 to your computer and use it in GitHub Desktop.
Save ykzts/378955 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
def test(s)
ret = []
for line in s.split("\n")
if line
ret.push(line + line.reverse[1,line.length].to_s)
else
ret.push('')
end
end
ret.join("\n")
end
if $0 == __FILE__
sample1=<<_STR_
12345
abcde
_STR_
sample2=<<_STR_
#include <iostream>
int main(int argc, char* argv[]){
std::cout << "Test Program" << std::endl;
return 0;
}
_STR_
sample3=<<_STR_
X X Y Y ZZZZZZZ
X X Y Y Z
X X Y Y Z
X Y Z
X X Y Z
X X Y Z
X X Y ZZZZZZZ
_STR_
puts sample1
puts test(sample1)
puts '--'
puts sample2
puts test(sample2)
puts '--'
puts sample3
puts test(sample3)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment