Created
May 16, 2015 15:29
-
-
Save satour/da0b1e48c6ad5f0ca76a to your computer and use it in GitHub Desktop.
SWAP NUMBERS - CodeEval
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
#https://www.codeeval.com/open_challenges/196/ | |
File.open(ARGV[0]).each_line {|line| | |
input_line = line.chomp.split(" ") | |
output_line = [] | |
input_line.each{|word| | |
swap = word.dup | |
swap[0] = word[-1] | |
swap[-1] = word[0] | |
output_line << swap | |
} | |
puts output_line.join(" ") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment