Back
Close

Z increment

Statement

 Goal

Increment by a all positive numbers following the character Z for each line of the input.
Some lines may not contain any character Z. Increment only if Z is not following any other character.

Example: for a = 3
Z10 => Z13
ABCZ1 => ABCZ1 (no changes because Z is following another character)
AB Z0 Z30 => AB Z3 Z33
ABC => ABC
Input
Line 1: An integer n, for the number of line. And an integer a, the increment value to use.
Next n lines: lines which may contain characters Z followed by numbers
Output
n lines with incremented number by a. Only positive numbers following the character Z should be incremented
Constraints
1 ≤ n ≤ 100
Example
Input
3 2
Z1
Z2
Z3xxxx
Output
Z3
Z4
Z5xxxx

Game modes
Fastest, Shortest, Reverse

Test cases
Test 1 Test
Input
3 2 Z1 Z2 Z3xxxx
Output
Z3 Z4 Z5xxxx

Validator 1 Validator
Input
3 5 Z1 Z2 Z3xxxx
Output
Z6 Z7 Z8xxxx

Test 2 Test
Input
3 1 Z10 Z100 Z50 Z120
Output
Z11 Z101 Z51 Z121

Validator 2 Validator
Input
3 2 Z10 Z100 Z50 Z120
Output
Z12 Z102 Z52 Z122

Test 3 Test
Input
4 10 Do not fall for this Z 100 Only for Z0 not for A0 B0... Not for Zoo either But do not forget Z15.
Output
Do not fall for this Z 100 Only for Z10 not for A0 B0... Not for Zoo either But do not forget Z25.

Validator 3 Validator
Input
4 1 Do not fall for this Z 100 Only for Z0 not for A0 B0... Not for Zoo either But do not forget Z15.
Output
Do not fall for this Z 100 Only for Z1 not for A0 B0... Not for Zoo either But do not forget Z16.

Test 4 Test
Input
5 5 Z Z10 useless text useless text Z20 useless text Z30 useless text; useless text
Output
Z Z15 useless text useless text Z25 useless text Z35 useless text; useless text

Validator 4 Validator
Input
5 5 Z Z10 text text Z20 text Z30 text; text
Output
Z Z15 text text Z25 text Z35 text; text

Test 5 Test
Input
4 5 Z0 AZ0 ZB0 AnythingZ0
Output
Z5 AZ0 ZB0 AnythingZ0

Validator 5 Validator
Input
3 2 Z0 AZ0 ZB0
Output
Z2 AZ0 ZB0

Test 6 Test
Input
2 5 Z-1 Z-10
Output
Z-1 Z-10

Validator 6 Validator
Input
2 5 Z-12 Z-15
Output
Z-12 Z-15

Solution language

Solution

Stub generator input