Word Diamonds
Time limit1sMemory limit1024 MB
Given a word whose first and last letters match, print its word diamond, with the letters spreading out from the top and bottom to the middle row.
- Level
Easy2 of 10
- Topics
- Implementation, String
- Solved
- No attempts yet
Problem
A word diamond is formed from a word that begins and ends with the same letter. Consider this word diamond for the word 'ENCODE':
E
N N
C C
O O
D D
E E
D D
O O
C C
N N
E
The leftmost letter of the diamond just touches the left margin. A shorter diamond, for example for the word 'DAD', looks like this:
D
A A
D D
A A
D
Write a program that reads in a word and prints the word diamond associated with that word.
Input
A single line with a word that:
- Has all capital letters.
- Has the same first and last letters.
- Is between 3 and 13 letters in length.
Output
Print the word diamond itself. The word diamond for a word of length has lines. There are no spaces at the end of any line.