Created
April 26, 2010 03:50
-
-
Save ykzts/378955 to your computer and use it in GitHub Desktop.
This file contains 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
#!/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