Sphere Online Judge

SPOJ Problem Set (tutorial)

5132. Hello Kitty

Problem code: HELLOKIT


Kitty sends a kind of original email messages to her friend Garf. To write a message, she
chooses a word W and a number n and replicates W n times horizontally. Then she repeats this
string in the next line, but rotating the characters once to the left. And she repeats this 'rotate-
and-output' process until the word W appears displayed as the rst column of the rectangular
pattern that she produces.
As an example, when she chooses the word Hello and the number 3, she gets the pattern:


HelloHelloHello
elloHelloHelloH
lloHelloHelloHe
loHelloHelloHel
oHelloHelloHell


Kitty has been sending such emails during the last three years. Recently, Garf told her that
perhaps her work may be automatized with a software to produce Kitty's patterns. Could you
help her?

Input

The input le contains several test cases, each one of them in a separate line. Each test case
has a word and a positive integer that should generate the corresponding rectangular pattern.
The word is a string of alphabetic characters (a..z). The number is less than 10.
A line whose contents is a single period character means the end of the input (this last line
is not to be processed).

Output

Output texts for each input case are presented in the same order that input is read. For each
test case the answer must be a left aligned Kitty pattern corresponding to the input.

Example

Input:
Love 1
Kitty 2
.

Output:
Love
oveL
veLo
eLov
KittyKitty
ittyKittyK
ttyKittyKi
tyKittyKit
yKittyKitt

Added by:Daniel Gómez Didier
Date:2009-10-31
Time limit:1s
Source limit:50000B
Memory limit:256MB
Cluster: Pyramid (Intel Pentium III 733 MHz)
Languages:All except: NODEJS PERL 6

hide comments
2013-07-07 14:12:39 pika_pika
Easy, AC in 1st attempt with java
2013-07-02 20:55:11 UnrealNinja
Nice Pattern Question.
Length of the word in the question is 26 characters.

For C/C++ users,
Use this for input as you might be getting 'TLE' due to wrong input methods/logic.
char inputWord[26];
scanf("%s", &inputWord);
if(input[0] == '.') break;
scanf("%d", &number);
2013-05-17 10:25:03 manu
how to mark the end of file in the code while inputting strings?
2013-04-20 02:36:32 ahmed el kashef
what is the end of file ?
2013-04-12 15:23:58 (Tjandra Satria Gunawan)(曾毅昆)
Yeah! finally 0.00s using 531B of brainf**k code ;-)
2013-04-12 14:59:11 (Tjandra Satria Gunawan)(曾毅昆)
don't understand why in some problem the input data is using '\r', not '\n'? can anyone explain this, what is the use of '\r' character?
2013-03-22 16:24:17 Syntax Terror
PHP is best to solve this...
2012-05-02 07:26:27 Mostafa Ahmed Sultan
easy cake ^___^
2012-04-02 08:47:51 Darky
Python is best to solve this.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.