2
\$\begingroup\$

I've noticed that sometimes people using exotic languages like Brainfuck don't ever explicitly wrap a solution into a method/function. While sometimes I see solutions in Java and such where they are wrapping their solution into a function.

Is it actually necessary (if the question didn't specify it) to wrap a solution into a reusable function?

As an example, here is my solution to The Letter A without A:

(3<2).ToString()[3-2]

Is it necessary to make it like so?

void Solution { (3<2).ToString()[3-2] }

Which also leads me to ask is it necessary to also explicitly print the result when things like PowerShell implicitly print the result all the time, and this can be done with my C# snippet using C# Interactive for instance?

\$\endgroup\$
4
\$\begingroup\$

The difference is, some esoteric languages (like Brainfuck) don't have a function-like construct in the language. In those languages, the submissions are full programs - you run it, pass the input in (through STDIN or whatever method it uses), and you get the output (from STDOUT or whatever method it uses).

We require that all submissions be full programs or reusable functions. For REPL (read-eval-print-loop) environments like Python, Javascript, and PowerShell consoles, having the output implicitly printed is fine - so long as you mark the answer as being a REPL answer (as opposed to a full program that doesn't require the REPL).

Here are some resources you might want to check out:

\$\endgroup\$
  • \$\begingroup\$ Thanks for the quick and concise answer! \$\endgroup\$ – AquaGeneral Aug 21 '16 at 7:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .