The Block Game | Codechef solution
The Block Game | Codechef solution Problem:-
The citizens of Byteland regularly play a game. They have blocks each denoting some integer from 0 to 9. These are arranged together in a random manner without seeing to form different numbers keeping in mind that the first block is never a 0. Once they form a number they read in the reverse order to check if the number and its reverse is the same. If both are same then the player wins. We call such numbers palindrome.
Ash happens to see this game and wants to simulate the same in the computer. As the first step he wants to take an input from the user and check if the number is a palindrome and declare if the user wins or not.
Input of The Block Game | Codechef solution
The first line of the input contains T, the number of test cases. This is followed by T lines containing an integer N.
Output
For each input output “wins” if the number is a palindrome and “loses” if not, in a new line.
Constraints
1<=T<=20
1<=N<=20000
Input:
3
331
666
343
Output:
loses
wins
wins
Code:-
#include <iostream> using namespace std; int main() { int t,n,rev=0; cin>>n; while(n--) { cin>>t; rev=0; int a; a=t; while(a!=0) { int r=a%10; rev=rev*10+r; a=a/10; } if(rev==t) cout<<"wins"<<endl; else cout<<"loses"<<endl; } return 0; }
Recommended Post:
Wipro :-
- Update the booking ID | Wipro previous year question paper solution
- Pages in PDF
- Find the location id
- Find the odd digits
- Find the Product ID
Infytq :-
Key Points;-
Hackerrank:-
- Python : missing characters : hackerrank solution
- Python : string transformation | Hackerrank solution
- Active Traders certification test problem | Hackerrank Solution
- Usernames changes certification test problem | Hackerrank Solution
- string Representation of objects certification test hackerrank solution
- Average Function | hackerrank certification problem solution
C-tutorial:-
- Micros in C
- Pointer in c
- Function declaration
- Types of user define function
- return type of function
- 2D array
See more:-
- c program to convert specified days into years weeks and days
- Print Reverse Hollow Pyramid
- Update the booking ID | Wipro previous year question paper
- Pages in PDF | Wipro previous year question paper
- Sparse Matrix in data structure
- Find the location ID | Wipro previous year Coding question
- find the odd digits | Wipro Coding question
- Find the product id | Wipro Coding question
- Difference between static and dynamic memory allocation
- What is asymptotic Notation