Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions bin/Lost Robot/Solution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#According to question we can only instruct robot up or down or left or right. So in his current coordiantes and home coordinates one of the/
#coordinate either X or Y must be same.
for _ in range(int(input()):
x1,y1,x2,y2=map(int,input().split())#This will parse input to x1,y1,x2 and y2
if x1!=x2 and y1!=y2:
print('sad')
elif x1==x2 and y1<y2:
print('up')
elif x1==x2 and y1>y2:
print('down')
elif y1==y2 and x1<x2:
print('right')
elif y1==y2 and x1>x2:
print('left')

34 changes: 34 additions & 0 deletions bin/Lost Robot/quiz
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

Robot Bunny is lost. It wants to reach its home as soon as possible. Currently it is standing at coordinates (x1, y1) in 2-D plane.
Its home is at coordinates (x2, y2). Bunny is extremely worried. Please help it by giving a command by telling the direction in which it
should to go so as to reach its home. If you give it a direction, it will keep moving in that direction till it reaches its home.
There are four possible directions you can give as command - "left", "right", "up", "down". It might be possible that you can't instruct
the robot in such a way that it reaches its home. In that case, output "sad".

Input
First line of the input contains an integer T denoting the number of test cases. T test cases follow.

First line of each test case contains four space separated integers x1, y1, x2, y2.

Output
For each test case, output a single line containing "left" or "right" or "up" or "down" or "sad" (without quotes).

Constraints
1 ≤ T ≤ 5000
0 ≤ x1, y1, x2, y2. ≤ 100
It's guaranteed that the initial position of robot is not his home.
Example

Input
3
0 0 1 0
0 0 0 1
0 0 1 1

Output:
right
up
sad

Explanation
Test case 1. If you give Bunny the command to move to the right, it will reach its home.