Back
Close

Repetitive strings

Statement

 Goal

You are given a string w, and a single character c.
c is equal to either S or D.

You need to print the word w as many times as the length of w. You print w once and then print w reversed, you print w once and then print w reversed and so on...

if c equal to S you need to have spaces between each word.

if c equal to D you need to have line breaks between each word.

Good luck!
Input
A word w.
A character c equal to S or D.
Output
The word w, alternatively reversed.
w must be outputted on different lines if c is D, or on the same line (with line breaks) if c is S.
Constraints
c = D or S
Example
Input
Hello
S
Output
Hello olleH Hello olleH Hello

Game modes
FastestShortestReverse

Test cases
Test 1 Test
Input
Hello S
Output
Hello olleH Hello olleH Hello

Validator 1 Validator
Input
olleH D
Output
olleH Hello olleH Hello olleH

Test 2 Test
Input
CodinGame D
Output
CodinGame emaGnidoC CodinGame emaGnidoC CodinGame emaGnidoC CodinGame emaGnidoC CodinGame

Validator 2 Validator
Input
emaGnidoC S
Output
emaGnidoC CodinGame emaGnidoC CodinGame emaGnidoC CodinGame emaGnidoC CodinGame emaGnidoC

Test 3 Test
Input
ClashOfCode S
Output
ClashOfCode edoCfOhsalC ClashOfCode edoCfOhsalC ClashOfCode edoCfOhsalC ClashOfCode edoCfOhsalC ClashOfCode edoCfOhsalC ClashOfCode

Validator 3 Validator
Input
edoCfOhsalC D
Output
edoCfOhsalC ClashOfCode edoCfOhsalC ClashOfCode edoCfOhsalC ClashOfCode edoCfOhsalC ClashOfCode edoCfOhsalC ClashOfCode edoCfOhsalC

Test 4 Test
Input
ChampionCoder D
Output
ChampionCoder redoCnoipmahC ChampionCoder redoCnoipmahC ChampionCoder redoCnoipmahC ChampionCoder redoCnoipmahC ChampionCoder redoCnoipmahC ChampionCoder redoCnoipmahC ChampionCoder

Validator 4 Validator
Input
redoCnoipmahC S
Output
redoCnoipmahC ChampionCoder redoCnoipmahC ChampionCoder redoCnoipmahC ChampionCoder redoCnoipmahC ChampionCoder redoCnoipmahC ChampionCoder redoCnoipmahC ChampionCoder redoCnoipmahC

Solution language

Solution

Stub generator input
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants