Skip to main content
35 votes
Accepted

How does this site work?

What does "Code Golf" mean? Code golf, (Or Codegolf) as the name suggests, is the art of making programs that are as short as possible that complete a task. What is "Code Golf & Coding ...
ATaco's user avatar
  • 11.2k
33 votes

Default for Code Golf: Input/Output methods

Submissions may use list of strings instead of multi-line strings Input or output may be the equivalent of the string separated by newlines. For example, the multiline string: ...
Jo King's user avatar
  • 47.5k
32 votes

Default for Code Golf: Input/Output methods

In languages without any method of input (e.g. ///) programs may get input through an insertion into the source code
boboquack's user avatar
  • 2,317
31 votes

Can serious contenders do more than the challenge asks for?

Serious contenders do not contain superfluous code I propose the following: If a part or multiple parts of the code can be deleted without affecting its functionality with regard to the challenge ...
Dennis's user avatar
  • 211k
28 votes

Default for Code Golf: Input/Output methods

Multiple arguments to a function can be taken as a list or tuple instead For example, if you needed to take in two integers as arguments, you can take one argument: a list of both integers. Apparently,...
The Thonnu's user avatar
  • 18.3k
28 votes
Accepted

What do we rename Advent of Code Golf?

Code Golf Advent Calendar (As suggested in the question) While I think "Advent of Golf" is snappier, I think it should be clearer that this is referring to code golfing in the name. 'Code ...
27 votes

Default for Code Golf: Input/Output methods

Full programs may take array/string input (of unknown length) via stdin in the form of <length> <contents> or ...
Bubbler's user avatar
  • 78.4k
26 votes

Default for Code Golf: Input/Output methods

Functions may return their result in an optional type wrapper Relevant meta discussion. By "optional type wrapper" I mean something like Maybe a in Haskell, ...
Esolanging Fruit's user avatar
26 votes

Default for Code Golf: Input/Output methods

I/O for sequence questions may either be 0-indexed or 1-indexed Any sequence question that has the user output the \$n\$th term, first \$n\$ terms, etc. of a sequence should allow programs to index ...
lirtosiast's user avatar
  • 21.5k
25 votes

Default for Code Golf: Input/Output methods

An array may be represented in input as a pointer and length. For example in C you could use: int f(int*p,int l){...}
MegaTom's user avatar
  • 4,286
24 votes
Accepted

How to count bytes in languages with autoformatters

Count code size before autoformatting Rationale: You can type or paste unformatted code into the interpreter, hit run, and it works. The fact that the interpreter adds whitespace or expands shortcuts ...
DLosc's user avatar
  • 39.2k
21 votes

Default for Code Golf: Input/Output methods

black-box functions to be taken as input can be passed as an argument This holds for functional languages or languanges that do have first class functions/anonymous functions/lambda functions or ...
flawr's user avatar
  • 43.9k
21 votes

Default for Code Golf: Input/Output methods

You may assume that the input is valid When parsing an input, you may assume that the input is already valid. You are not required to validate it unless the challenge is specifically about testing ...
Xwtek's user avatar
  • 2,039
21 votes

How can we help users who are put off by the use of golfing languages?

For me I joined because it is fun. I spend all day writing readable code and sometimes it's nice to write something just because I can. I have no problems with golfing languages. The shortest code ...
ElPedro's user avatar
  • 6,469
20 votes

Default for Code Golf: Input/Output methods

Functions may return a function that returns the result This is very similar to currying, the only difference being that only the first call includes an argument. Sometimes it's useful to curry a ...
ETHproductions's user avatar
20 votes
Accepted

Are we allowed to use empty input we won't use when no input is asked (regarding functions)?

Yes Building off of Martin's great post: If your program takes extra input, that input must be empty. In the case of Java, this is easy: Objects must be null, and primitives must have their ...
Nathan Merrill's user avatar
20 votes
Accepted

Equivalence between strictly increasing integer sequences and decision problems

This isn't a good default I wouldn't expect or want for my sequence challenges to allow membership-oracle solution by default just because the sequence is increasing. While sequence allows various ...
xnor's user avatar
  • 147k
19 votes

Interpretation of Truthy/Falsey

Don't forget program exit codes! If my C or C++ or perl or bash or ... program calls exit(0) this action could be considered truthy, and calling ...
BenGoldberg's user avatar
19 votes

Default for Code Golf: Input/Output methods

Programs and functions may return a boolean value via the presence or absence of output
Khuldraeseth na'Barya's user avatar
18 votes

How to determine the length of a Piet program?

Here's an encoding for Piet programs I've published an encoding (with a translator program) that represents a Piet program as a series of ASCII characters. It encodes each codel as one character, and ...
DLosc's user avatar
  • 39.2k
18 votes
Accepted

What is a character encoding, exactly?

Character encodings are just a convenience to make programs more readable if they make use of more than the usual 97 ASCII bytes (printable, plus linefeeds and tabs). At the end of the day, the only ...
Martin Ender's user avatar
17 votes

Default for Code Golf: Input/Output methods

When a challenge asks for an array as input/output, you may use a list instead, and vice-versa Note that some languages may lack one of these concepts. For example, TI-Basic does not have an array ...
O.O.Balance's user avatar
  • 1,609
17 votes

Default for Code Golf: Input/Output methods

Lists of decimal digits and strings that match ^[0-9]*$ are interchangeable... ...but not when this may make the input format inconsistent. For example, let's say ...
Erik the Outgolfer's user avatar
17 votes

Advocate languages to golf in

Haskell Haskell is the functional language Want to dive into the deep end of functional programming? In Haskell, lambdas are cheap, higher order functions are powerful, and all operations short-...
Zgarb's user avatar
  • 42.8k
17 votes

Potential execution flag rule break

What should we do to prevent this type of shenanigan? Firstly, we should all solemnly commit to downvoting every answer we see in a language which is deliberately designed to try to exploit PPCG-...
Peter Taylor's user avatar
  • 43.1k

Only top scored, non community-wiki answers of a minimum length are eligible