Skip to content

Instantly share code, notes, and snippets.

@satour
Created May 16, 2015 15:29
Show Gist options
  • Save satour/da0b1e48c6ad5f0ca76a to your computer and use it in GitHub Desktop.
Save satour/da0b1e48c6ad5f0ca76a to your computer and use it in GitHub Desktop.
SWAP NUMBERS - CodeEval
#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