Esistono diversi modi per creare intestazioni sui post sulla rete Stack Exchange. Il formato più comunemente usato 1 su PPCG sembra essere:
# Level one header
## Level two header
### Level three header
Nota lo spazio dopo i segni di hash. Inoltre, si noti che i segni di hash finali non sono inclusi.
Sfida:
Prendi una stringa (possibilmente multilinea) come input e genera la stringa nel seguente formato:
- Se l'intestazione è di livello 1, quindi emettere ogni lettera 4 per 4 volte
- Se l'intestazione è di livello 2, quindi emettere ogni lettera 3 per 3 volte
- Se l'intestazione è di livello 3, quindi emettere ogni lettera 2 per 2 volte
- Se una riga non è un'intestazione, la emette così com'è.
Illustrare:
--- Level 1 ---
# Hello
--- Output---
HHHHeeeelllllllloooo
HHHHeeeelllllllloooo
HHHHeeeelllllllloooo
HHHHeeeelllllllloooo
--- Level 2 ---
## A B C def
--- Output ---
AAA BBB CCC dddeeefff
AAA BBB CCC dddeeefff
AAA BBB CCC dddeeefff
--- Level 3 ---
### PPCG!
--- Output---
PPPPCCGG!!
PPPPCCGG!!
Semplice come quella!
Regole:
- È necessario supportare l'input su più righe. L'uso di
\necc. Per newline è OK.- Non ci saranno righe contenenti solo un
#seguito da un singolo spazio
- Non ci saranno righe contenenti solo un
- L'output deve essere presentato su più righe. Non è possibile eseguire l'output
\nanziché letteralmente nuove righe.- Gli spazi finali e le nuove righe sono OK.
Casi test:
Input e output sono separati da una riga di ....
# This is a text
with two different
### headers!
........................................................
TTTThhhhiiiissss iiiissss aaaa tttteeeexxxxtttt
TTTThhhhiiiissss iiiissss aaaa tttteeeexxxxtttt
TTTThhhhiiiissss iiiissss aaaa tttteeeexxxxtttt
TTTThhhhiiiissss iiiissss aaaa tttteeeexxxxtttt
with two different
hheeaaddeerrss!!
hheeaaddeerrss!!
This input has
## trailing hash marks ##
#and a hash mark without a space after it.
........................................................
This input has
tttrrraaaiiillliiinnnggg hhhaaassshhh mmmaaarrrkkksss ######
tttrrraaaiiillliiinnnggg hhhaaassshhh mmmaaarrrkkksss ######
tttrrraaaiiillliiinnnggg hhhaaassshhh mmmaaarrrkkksss ######
#and hash marks without a space after it.
# This ## is ### strange
#### ###
........................................................
TTTThhhhiiiissss ######## iiiissss ############ ssssttttrrrraaaannnnggggeeee
TTTThhhhiiiissss ######## iiiissss ############ ssssttttrrrraaaannnnggggeeee
TTTThhhhiiiissss ######## iiiissss ############ ssssttttrrrraaaannnnggggeeee
TTTThhhhiiiissss ######## iiiissss ############ ssssttttrrrraaaannnnggggeeee
#### ###
Multiple
### newlines! #
:)
........................................................
Multiple
nneewwlliinneess!! ##
nneewwlliinneess!! ##
:)
Line with only a hash mark:
#
### ^ Like that!
........................................................
Line with only a hash mark:
#
^^ LLiikkee tthhaatt!!
^^ LLiikkee tthhaatt!!
1: non ho verificato, ma penso sia vero.