///, 35 bytes
/I///,*/+,//+/I//**,/,A//*/A//,//,I
Try it online!
Takes input in unary using symbol *
, and output in unary using symbol A
. This is allowed for some specific languages, including /// (meta)
Because there is no way to take input in ///, input should be hardcoded:
/I/«put input here»//,*/+,//+/I//**,/,A//*/A//,//,I
for input = 4.
Explanation: (before reading, you need to know that the only syntax of ///
are /pattern/replacement/
, which replace every occurence of pattern
by replacement
; and \
for escaping; other characters is printed to output)
For n=4
:
/I/****//,*/+,//+/I//**,/,A//*/A//,//,I Start program.
/I/****/ Replace all `I` in the program by the input.
/,*/+,//+/****//**,/,A//*/A//,//,**** Remaining part of the program.
/,*/+,/ Use the `,` as a scanner, scan through `*` after it and convert to `+`.
/+/****//**,/,A//*/A//,//++++, Note that only `*` in the second group is affected.
/+/****/ Replace all `+` (which is just created) by `n` asterisks (from the first `I` group)
/**,/,A//*/A//,//****************, Now at the last of the program before the `,` there are `n²` asterisks.
/**,/,A/ Scan the `,` to the left to perform division by 2:
replace each `**` by a `A` as the scanner `,` pass through.
/*/A//,//,AAAAAAAA Remaining program.
/*/A/ If there is any `*` remaining (if `n²` is odd), replace it with `A`.
/,// Remove the scanner `,`.
AAAAAAAA Output the result.