Your goal in this code golf is to take two strings, language
and code
(if the golfed code you wrote for this is multiline, then this variable would be multiline.), and one integer, bytes
. They represent the variables for a programming language, number of bytes it takes, and the code itself.
After that, you are going to format it like a code golfer does it.
The output variable is a multiline string called answer
.
You can use multiline strings on:
If you search Stack Overflow, you should be able to find more programming languages that support it.
Here is a template of the output markdown. The code
variable is in a code block, and there is a second-level header.
## {language}, {bytes} bytes
{code}
Here is what the output would look like when pasted into a Markdown parser.
{language}, {bytes} bytes
{code}
Variables are assumed to be filled out already as the language you coded your code golf entry in, the number of bytes it takes, and the actual code for it.
Here is another example of the output as code, this time with variables filled out:
## JavaScript, 1337 bytes
document.getElementById("foo").innerHTML = bar;
Here is the version as a blockquote:
JavaScript, 1337 bytes
document.getElementById("foo").innerHTML = bar;
Bytes can be taken off from your code if you use a way to set the text of a <p>
element in HTML by the id result
, like the following JavaScript code:
document.getElementById("result").innerHTML = answer;
Make sure to also include the <p id="result"></p>
in the HTML section of JSFiddle for this to work.
Scoring
Like all code-golf questions, the code that uses the least amount of bytes is the best.
{code}
ever be a multiline code? \$\endgroup\$language
,bytes
andcode
are input or whether this is a quine variant where those things should match the solving code itself. (And if so, whether directly or indirectly reading that source code is allowed, and whether quine built-ins are allowed.) \$\endgroup\$code
can itself contain linefeeds? \$\endgroup\$code
will not be multiline, or can't we? Please indicate that in the challenge text \$\endgroup\$