-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path192.rb
More file actions
22 lines (19 loc) · 688 Bytes
/
Copy path192.rb
File metadata and controls
22 lines (19 loc) · 688 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
def coordinates?(a,b)
a < b
end
def cooridnates_eq?(a,b)
a == b
end
File.open('192.txt').each_line do |line|
my_coordinates = [line.split(' ')[0],line.split(' ')[1]].map(&:to_i)
group_coordinates = [line.split(' ')[2],line.split(' ')[3]].map(&:to_i)
x_my,x_group = my_coordinates[0],group_coordinates[0]
y_my,y_group = my_coordinates[1],group_coordinates[1]
if cooridnates_eq?(y_my,y_group) && cooridnates_eq?(x_my,x_group)
puts "here"
else
a = ("N" if coordinates?(y_my,y_group)) || ("" if cooridnates_eq?(y_my,y_group)) || "S"
b = ("E" if coordinates?(x_my,x_group)) || ("" if cooridnates_eq?(x_my,x_group)) || "W"
puts a + b
end
end