Skip to content

Instantly share code, notes, and snippets.

@satour
Last active August 29, 2015 14:21
Show Gist options
  • Save satour/f2978e10ef0ddf307c15 to your computer and use it in GitHub Desktop.
Save satour/f2978e10ef0ddf307c15 to your computer and use it in GitHub Desktop.
COMPARE POINTS - CodeEval
#https://www.codeeval.com/open_challenges/192/
File.open(ARGV[0]).each_line do |line|
x, y, q, r = line.split(/ /).map(&:to_i)
operation = ""
operation += "N" if (r-y) > 0
operation += "S" if (r-y) < 0
operation += "E" if (q-x) > 0
operation += "W" if (q-x) < 0
operation = "here" if operation == ""
puts operation
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment