Cyclic groups
Statement
Goal
Given an integer n and a character c, we define a Group of size n generated by c as the string set: 0, c, c * 2, ... , c * (n - 1). For example, 0 a aa aaa, generated by the elementYou are given an integer n, a character c and a string s, and you have to:
(1) If the string s represents a Group of size n generated by c, just print its size.
(2) If it isn't, print the NEEDED elements (ranged by string size) to make s a Group of size n.
Examples (the number n appears first):
3, 0 a aa -> 3
3, 0 aa a -> 3 (order is irrelevant)
4, 0 bbb b -> bb (the only remaining for n = 4)
4, 0 c ccc -> cc cccc
5, 0 c ccc -> cc cccc ccccc
Input
Line 1: A positive integer n
Line 2: A character c
Line 3: A space separated string s representing the possible group to study.
Line 2: A character c
Line 3: A space separated string s representing the possible group to study.
Output
If s is a Group, it's size n.
If s is not a Group, a string with the NEEDED elements ranged by string size.
If s is not a Group, a string with the NEEDED elements ranged by string size.
Constraints
c can be any ascii character.
First character in s is always0 .
0 < n < 10
First character in s is always
0 < n < 10
Example
Input
3 a 0 a aa
Output
3
Game modes
Fastest, Shortest, Reverse
Test cases
1. Example Test
Input
3
a
0 a aa
Output
3
1. Example val Validator
Input
4
a
0 a aa aaa
Output
4
2. Not a group Test
Input
5
b
0 b bbbb
Output
bb bbb
2. Not a group val Validator
Input
7
c
0 c ccc cccc
Output
cc ccccc cccccc
3. Not a group (2) Test
Input
4
k
0 2 kkk o
Output
k kk
3. Not a group (2) val Validator
Input
7
k
0 A kk kkk kkkk < kkkkkk
Output
k kkkkk
4. Order doesn't matter Test
Input
6
&
0 & &&&&& && &&& &&&&
Output
6
4. Order doesn't matter val Validator
Input
9
&
0 & &&&&& && &&& &&&& &&&&&&&& &&&&&&& &&&&&&
Output
9
5. Extra Test
Input
6
Y
0 Y YYY YY Z
Output
YYYY YYYYY
5. Extra val Validator
Input
5
Z
0 ZZ Z Y YY YYY YYYY YYYYY
Output
ZZZ ZZZZ
6. Just zero Test
Input
3
(
0
Output
( ((
6. Just zero val Validator
Input
4
)
0
Output
) )) )))
Solution language
Solution
Stub generator input