Reshape String
Statement
The program
Your program must prepare a text for encryption and reshape it in a grid.
You are given a text and a number of columns col.
First, you need to remove all whitespaces.
Then divide the processed text into parts of col characters each.
The last part can contain less than col letters.
Each part is placed on the new line.
You are given a text and a number of columns col.
First, you need to remove all whitespaces.
Then divide the processed text into parts of col characters each.
The last part can contain less than col letters.
Each part is placed on the new line.
INPUT:
Line 1: a text.
Line 2: an integer number col.
Line 2: an integer number col.
OUTPUT:
The text grid with col columns.
CONSTRAINTS:
0 ≤ textLength ≤ 100
0 < col ≤ 10
A text contains at least one non whitespace character.
0 < col ≤ 10
A text contains at least one non whitespace character.
EXAMPLE:
Input
Hello Perfect World
5
5
Output
Hello
Perfe
ctWor
ld
Perfe
ctWor
ld
Game modes
Fastest, Shortest, Reverse
Test cases
Test n°1 Test
Input
Hello Perfect World
5
Output
Hello
Perfe
ctWor
ld
Validator n°1 Validator
Input
Hello Perfect World
4
Output
Hell
oPer
fect
Worl
d
Test n°2 Test
Input
Coding Game!
1
Output
C
o
d
i
n
g
G
a
m
e
!
Validator n°2 Validator
Input
Game coding?
1
Output
G
a
m
e
c
o
d
i
n
g
?
Test n°3 Test
Input
One Two Six
10
Output
OneTwoSix
Validator n°3 Validator
Input
One two one
10
Output
Onetwoone
Test n°4 Test
Input
Z
9
Output
Z
Validator n°4 Validator
Input
X
8
Output
X
Test n°5 Test
Input
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent eget ligula interdum orci aliquam.
9
Output
Loremipsu
mdolorsit
amet,cons
ecteturad
ipiscinge
lit.Praes
entegetli
gulainter
dumorcial
iquam.
Validator n°5 Validator
Input
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent eget ligula interdum orci aliquam.
8
Output
Loremips
umdolors
itamet,c
onsectet
uradipis
cingelit
.Praesen
tegetlig
ulainter
dumorcia
liquam.
Test n°6 Test
Input
AaGpttaetdtoaahpcwelknre
4
Output
AaGp
ttae
tdto
aahp
cwel
knre
Validator n°6 Validator
Input
AaGpttaetdtoaahpcwelknre
8
Output
AaGpttae
tdtoaahp
cwelknre
Solution language
Solution
Stub generator input