I use Racket as my primary programming language and have been having fun the past week solving challenges using it. I came across a few answers from other programming languages that use TIO's header and footer options to add code outside of the main golfed code:

// Header

// Code (6 bytes)

// Footer
for (let i = 0; i < 10; ++i) {

Try it online!

Isn't the f= required for the answer to be accepted?

I also noticed a few submissions where C/++ #includes and main were placed in the header/footer and weren't counted.

What's the case towards Racket's #lang statement? It is required to run Racket programs as it tells Racket's system what language to load. Does it count towards byte count? Or may I place it in the header, then explain in the answer what #lang it uses?

I did find a question in this Meta that asks whether #lang should count towards bytes or not, but I'm finding it confusing to choose because the two answers and their comments seem to contradict each other.

Any feedback would be appreciated.

Have an awesome week ahead!


1 Answer 1


Anonymous functions are fine

So, we have a long established site policy that anonymous functions (things like n=>n+1 instead of requiring f=n=>n+1) are perfectly fine, and that you don't need to score the name and assignment (so long as they don't reference the function themselves, e.g. recursive functions). Additionally, in typed languages, lambdas do not need to include their types.

Racket's #lang does not need to be counted

The linked discussion has a pretty overwhelming consensus (+22/-2 vs +5/-6 at writing) that Racket answers do not need to count their #lang racket line.

includes and mains

The key distinction here is whether the stuff included is required for the function to work, or just to demonstrate that it works. For example, a very basic* function like

int f(int n) { return n+1; }

doesn't need to count #includes for printing, nor does it need to count the program's main code, as the submission itself is the function. However, if it used something that did require an #included function (e.g. this Hello, World program), then the answer would need to count the #include

*: Disclaimer, I'm not super proficient in C/++, this is just an example, functionality is not guaranteed

In short, a good rule of thumb is to only count what is actually necessary, rather than inflate your byte count with adjacent bits of code

  • \$\begingroup\$ Except that the Hello, World does work with gcc's implicit includes. It just generates a warning. \$\endgroup\$
    – Saladin
    Jul 19, 2023 at 3:17
  • \$\begingroup\$ Suggest updating the first paragraph to clarify that the variable assignment must be included in the byte count if the function is recursive. \$\endgroup\$
    – Shaggy
    Aug 2, 2023 at 9:19
  • 1
    \$\begingroup\$ @Shaggy Good point, made a note of that \$\endgroup\$ Aug 2, 2023 at 10:51
  • \$\begingroup\$ this meta seems incredibly relevant. Is this not covered there? I feel as though it should be if it isn't. \$\endgroup\$ Sep 7, 2023 at 23:00
  • 1
    \$\begingroup\$ @thejonymyster It is, under "how to count shebangs" \$\endgroup\$ Sep 8, 2023 at 18:57

You must log in to answer this question.

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