This would work like this:

  • A function scaffold is specified containing a variable name
  • You do not need to declare a function or print a value, just use a return statement.



def palindromize_string(s)

Then only the part of the code symbolized by <code> would be counted in the score.

  • 1
    \$\begingroup\$ What's the point of this? It seems just like implementing snippets \$\endgroup\$
    – Blue
    Nov 14, 2016 at 21:21
  • \$\begingroup\$ Would this make it a language specific challenge? \$\endgroup\$ Nov 14, 2016 at 21:22

1 Answer 1


No, this is a bad idea.

  • It's either language specific, or making a lot of assumptions about language features. Both are bad things. A lot of languages don't even have functions. Can you declare a universal function scaffold? I certainly couldn't.

  • If it's not language specific, it's very abuse prone. On the less extreme side, you could do something like preprocessing/defining variables inside of the function declaration. For example, I could submit this record breaking python "Hello world" function:

    def f(s="Hello, world!"):

    The contents of this function are only 8 bytes long! On the more extreme side, I could imagine a language called "Meta-functionscript", where all of the code is function declarations, and the contents of the function don't matter at all. Instead, you interpret the name of the function as a base-64 encoded number, representing the n-th enumerated golfscript program, and then you run that as the function.

    Obviously we could patch these holes, but I'm sure there are many more, and this just overcomplicates everything.

  • It's unecessarily complicated, especially since languages have very different conventions for declaring functions.

  • It would remove one of my favorite parts of golfing. For example, if I'm writing a python answer, it usually goes something like this. I write a full program that accomplishes the task. Then, I squish it to a function to take off a few bytes. But then I realize that a lambda is even shorter, so I re-write it. But wait a second, I could do a recursive approach! Now I need to name the lambda, which costs a few bytes but might save a lot too. Obviously I'll have to try both. But then I realize building up a list and returning that might be unecessary. Maybe I could just directly print the value. And so on and so forth. A lot of golfing comes from these kind of decisions, and simplifying everything down to just "function contents" would remove this entire aspect of golfing.

Above all else, I just don't really see any benefit. Sure, submissions would tend to be a little bit shorter, but that's not necessarily good. For example, I don't think gzipping source code and submitting the compressed version should be made standard.

Since every language has the same byte penalty for the function declaration, comparing submissions in the same language is still perfectly fair without any need to clutter up the rules with "Function contents".


You must log in to answer this question.

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