#PROBLEM LINK: Contest Page | CodeChef

Author: Setter’s name

Tester:Tester’s name

Editorialist:Editorialist’s name



The people of Vestland 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 are the same. If both are the same then the player wins. We call such numbers palindrome. Ash happens to see this game and wants to simulate the same on the computer. As the first step, he wants to take input from the user and check if the number is a palindrome and declare if the user wins or not.

(A palindromic number is a number that remains the same when written forward or backward. eg:11,121,262,9449,17371…….)

int main(){
int n ;
int j;
int a=0,b=0,temp=0;
temp = a ;
while(temp != 0){
b = b*10;
b = b + temp% 10 ;
temp = temp/10 ;
if(a== b)
return 0 ;


Here, the user is asked to enter an integer. The number is stored in variable ‘a’. We then assigned this number to another variable temp. Then, the reverse of ‘a’ is found and stored in ‘b’.If ‘a’ is equal to ‘b’, the number entered by the user is a palindrome. Hence it will be printed wins otherwise loses.
Sample case: Here the number of test cases is 3 and the numbers are 331,666,343. Each number will be validated whether it is palindrome or not. If the number is palindrome it will be printed wins otherwise loses. Here the result is: