The Problem Statement: Anagrams (Filename: 41)
The Problem Statement: Anagrams (Filename: 41)
Sample 1 Sample 2
Input 1 Output 1 Input 2 Output 2
2 IMPOSSIBLE 8
whisper
start whisper
person
finish format
sonnet
perform
network
sonnet
workshop
person
shopper
shopper
perform
workshop
format
network
Hiss... Hiss... Hiss... (Filename: 43)
Snakes and Ladders is an ancient Indian board game regarded today as a worldwide
classic. It is played between two or more players on a gameboard having numbered,
gridded squares. A number of "ladders" and "snakes" are pictured on the board, each
connecting two specific board squares. The object of the game is to navigate one's game
piece, according to die rolls, from the start (bottom square) to the finish (top square), helped or
hindered by ladders and snakes respectively. You are an pessimistic personality, hence let us
fix that your Snakes and Ladders board doesn't have any Ladders and has ONLY SNAKES.
The board is represented by a 10 X 10 matrix with its elements placed as indicated in the
adjacent diagram.
The elements of the squares where the snake's mouth and tail are located is indicated.
You then roll your dice and add the value that turns up to your present location on the board.
If there is a mouth of the snake at that location, then you will incur a loss by climbing DOWN
the snake and reach the square at the tail of the snake.
After several attempts of rolling the dice, determine your location and print the same.
Assumption: Single unbiased dice, has 6 faces, displays only one number at a time, from
1 to 6 (both inclusive).
Input Specification:
• First line of the input is an integer , indicating the number of snakes on your 10 X 10 board.
• Subsequent lines, contain 2 integers each, separated by space, which indicate the mouth and tail of
each snake respectively.
• Next line of input is an integer , indicating the number of times you roll your dice
• Subsequent line contains integers in the range 1 to 6 (both inclusive), separated by space.
Output Specification
A single integer value indicating your present location on the board after executing all your chances
on the dice, otherwise print “INVALID LOCATION”.
Largest Palindrome (Filename: 44)
A word is a unit of language that carries meaning and consists of one or more morphemes
which are linked more or less tightly together, and has a phonetical value. A word is called a
palindrome if it reads the same when you reverse it.
Your program should take an input as a string and produce the largest palindrome in the string.
If the string contains two palindromes, which are equal in length and are the largest among all
possible palindromes in the string, then your program should output the lexicographically first
largest palindrome.
Input Specification
It is a single line input of a string.
Output Specification
Print the largest and lexicographically first palindrome in the string, on a new line.