Nella resa musicale di Les Miserables, appare una canzone chiamata "Red and Black". Ecco parte di quella canzone:
Rosso: il sangue degli uomini arrabbiati!
Nero: il buio dei secoli passati!
Rosso: un mondo che sta per sorgere!
Nero: la notte che finisce finalmente!
Il tuo compito è trasformare l'input in un clamoroso inno "rosso e nero".
Ingresso
Testo delimitato da newline o un input di testo adatto simile. Per esempio,
The blood of angry men!
The dark of ages past!
A world about to dawn!
The night that ends at last!
L'input vuoto non è definito (al di fuori dell'ambito).
Produzione
Se la lunghezza (numero di righe, o lunghezza dell'array di input o simile) dell'input è dispari, o output nulla o output false. L'invio potrebbe non generare errori o tentare di produrre l'output corretto.
Altrimenti, trasforma l'ingresso in un testo rosso / nero. Trasforma le lettere maiuscole all'inizio di una riga in minuscolo. Aggiungi Redpiù un delimitatore nella parte anteriore delle linee dispari e Blackpiù un delimitatore (visibile) nella parte anteriore delle linee pari. Il delimitatore deve anche essere circondato da spazi, quindi l'output sembra non affollato (e non rigato;)).
Ora hai il tuo output.
Casi test
Il delimitatore di output è -.
In:
The blood of angry men!
The dark of ages past!
A world about to dawn!
The night that ends at last!
Out:
Red - the blood of angry men!
Black - the dark of ages past!
Red - a world about to dawn!
Black - the night that ends at last!
In:
test test
1
[][][]
BBB
Out:
Red - test test
Black - 1
Red - [][][]
Black - bBB
In:
I feel my soul on fire!
The color of desire!
The color of despair!
Out:
falsey OR nothing
In:
Red - I feel my soul on fire!
Black - My world if she's not there!
Out:
Red - red - I feel my soul on fire!
Black - black - My world if she's not there!