Sostituisci una stringa con se stessa
Il tuo obiettivo è sostituire una stringa con se stessa sostituendo ogni carattere nella stringa originale con quello precedente, iniziando dal primo carattere e avvolgendolo. Ecco alcuni esempi per mostrare cosa intendo:
1o esempio:
Input: program
Output: apgopra
How:
Program -> mrogram (replace p by m in program)
-> mpogpam (replace r by p in mrogram)
-> mprgpam (replace o by r in mpogpam)
-> mpropam (replace g by o in mprgpam)
-> mpgopam (replace r by g in mpropam)
-> mpgoprm (replace a by r in mpgopam)
-> apgopra (replace m by a in mpgoprm)
2 ° esempio:
Input: robot
Output: orbro
How:
Robot -> tobot (replace r by t in robot)
-> trbrt (replace o by r in tobot)
-> trort (replace b by o in trbrt)
-> trbrt (replace o by b in trort)
-> orbro (replace t by o in trbrt)
3 ° esempio:
Input: x
Output: x
How:
x -> x (replace x by x in x)
4 ° esempio:
Input: xy
Output: xx
How:
xy -> yy (replace x by y in xy)
-> xx (replace y by x in yy)
Note a margine:
- La stringa
xconterrà solo caratteri e spazi alfanumerici minuscoli - Questo è code-golf, quindi vince il codice più breve in byte !