20
2
There are several ways to create headers on posts on the Stack Exchange network. The format that's most commonly1 used on PPCG seems to be:
# Level one header
## Level two header
### Level three header
Note the space after the hash marks. Also, note that trailing hash marks are not included.
Challenge:
Take a (possibly multiline) string as input, and output the string on the following format:
- If the header is level 1, then output each letter 4-by-4 times
- If the header is level 2, then output each letter 3-by-3 times
- If the header is level 3, then output each letter 2-by-2 times
- If a line is not a header then output it as it is.
To illustrate:
--- 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!!
Simple as that!
Rules:
- You must support input over multiple lines. Using
\n
etc. for newlines is OK.- There won't be lines containing only a
#
followed by a single space
- There won't be lines containing only a
- The output must be presented over multiple lines. You may not output
\n
instead of literal newlines.- Trailing spaces and newlines are OK.
Test cases:
Input and output are separated by a line of ...
.
# 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: I haven't really checked, but I think it's true.
May we take input as a string array? – Ian H. – 2017-11-16T21:56:12.383