0% found this document useful (0 votes)
45 views

The Problem Statement: Anagrams (Filename: 41)

The document describes 4 problems related to strings and words: 1. An anagram checker that determines if two strings are anagrams ignoring case. 2. A word chaining problem that reorders words to form a chain where each word starts with the end of the previous word with at least 3 overlapping characters. 3. A "Snakes and Ladders" game where the board only has snakes, and the program outputs the player's location after multiple dice rolls. 4. A program that finds the largest palindrome in a given string based on length then lexicographical order.

Uploaded by

Shashank Pandey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

The Problem Statement: Anagrams (Filename: 41)

The document describes 4 problems related to strings and words: 1. An anagram checker that determines if two strings are anagrams ignoring case. 2. A word chaining problem that reorders words to form a chain where each word starts with the end of the previous word with at least 3 overlapping characters. 3. A "Snakes and Ladders" game where the board only has snakes, and the program outputs the player's location after multiple dice rolls. 4. A program that finds the largest palindrome in a given string based on length then lexicographical order.

Uploaded by

Shashank Pandey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Note: For each statement create a file name as suggested next to the title of

the problem statement

Anagrams (Filename: 41)


Two strings A and B are called anagrams if they consist same characters, but may be in different
orders. So the list of anagrams of CAT is CAT, ACT, TAC, TCA, ATC, CTA.
Given two strings, print Anagrams if they are anagrams, print Not Anagrams if they are
not. The strings may consist of at most 50 alphabetical characters; the comparison should NOT
be case sensitive.
Sample Input 1 Sample Output 1 Sample Input 2 Sample Output 2

anagram Anagrams anagramm Not Anagrams


margana marganaa

ShabdKhosh (Filename: 42)


You have to write a program to chain some words. A word is properly chained if it starts with a trailing
sub-string of its predecessor word with a minimum overlap of three (3) characters. Given a number of
words, you have to reorder them to appropriately chain them. The first word in the input is used as a
starting word in the chain. It may happen that there is no chaining possible for a given set of words. If
chaining is possible, assume that there will be a unique word chain.

Note: A word is a sequence of alphabetic characters.


Input Specification
The first line will be an integer N, indicating the number of words that will follow. Assume N will
never be greater than twenty (20)
The next N lines of input will contain words, which are to be chained. Assume that the maximum
length of a word will never exceed thirty (30) characters.
Output Specification
Your program should output the chain of words, one word on a separate line. If there is no chain
possible from the given words, the program should print IMPOSSIBLE.

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.

Sample Input Sample Input


dearmadamdear database
Sample Output Sample Output
madam aba

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy