Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

The Cheaper Cab CodeChef Solution

Problem – The Cheaper Cab CodeChef Solution

Chef has to travel to another place. For this, he can avail any one of two cab services.

  • The first cab service charges X rupees.
  • The second cab service charges Y rupees.

Chef wants to spend the minimum amount of money. Which cab service should Chef take?

Input Format

  • The first line will contain T – the number of test cases. Then the test cases follow.
  • The first and only line of each test case contains two integers X and Y – the prices of first and second cab services respectively.

Output Format

For each test case, output FIRST if the first cab service is cheaper, output SECOND if the second cab service is cheaper, output ANY if both cab services have the same price.

You may print each character of FIRSTSECOND and ANY in uppercase or lowercase (for example, anyaNyAny will be considered identical).

Constraints

  • 1≤T≤100
  • 1≤X,Y≤100

Sample 1:

Input: 3
30 65
42 42
90 50
Output: FIRST
ANY
SECOND

Explanation:

Test case 1: The first cab service is cheaper than the second cab service.

Test case 2: Both the cab services have the same price.

Test case 3: The second cab service is cheaper than the first cab service.

The Cheaper Cab CodeChef Solution in C++14

#include <iostream>
using namespace std;

int main() {
	int t;
	cin>>t;
	while(t--)
	{
	    int x,y;
	    cin>>x>>y;
	    if(x<y)
	    {
	        cout<<"FIRST"<<endl;
	    }
	    else if(x==y)
	    {
	        cout<<"ANY"<<endl;
	    }
	    else
	    {
	        cout<<"SECOND"<<endl;
	    }
	}
	return 0;
}

The Cheaper Cab CodeChef Solution in Pyth 3

n=int(input())
l1=[]
for i in range(n):
    n=input().split(" ")
    l1.append(n)
for i in range(len(l1)):
    if(int(l1[i][0])==int(l1[i][1])):
        print("ANY")
    elif(int(l1[i][0])>=int(l1[i][1])):
        print("SECOND")
    else:
        print("FIRST")
The Cheaper Cab CodeChef Solution Review:

In our experience, we suggest you solve this The Cheaper Cab CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the The Cheaper Cab CodeChef Solution

Find on CodeChef

Conclusion:

I hope this The Cheaper Cab CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Coding Solutions >>

LeetCode Solutions

Hacker Rank Solutions

CodeChef Solutions

Leave a Reply

Your email address will not be published. Required fields are marked *