Skip to main content

Questions tagged [code-golf]

For questions about code golf challenges and/or submissions. DO NOT post code golf challenges themselves as questions here; those belong on the main site or in the Sandbox if you want to get feedback on them.

Filter by
Sorted by
Tagged with
127 votes
118 answers
39k views

Default for Code Golf: Input/Output methods

It looks like we have a consensus that we want certain defaults for the format which answers are expected in for code-golf. On that poll, the question arose twice, which input/output formats should be ...
Martin Ender's user avatar
50 votes
6 answers
8k views

Default for Code Golf: Program, Function or Snippet?

One of the things many (new?) users forget to specify in code-golf challenges is whether the answers should provide a full program or a function (or even just a snippet). For most such things, we have ...
Martin Ender's user avatar
156 votes
17 answers
10k views

J and GolfScript suck all the enjoyment out of Code Golf

I have found code-golf a fascinating pastime for several weeks now. However, I’m already losing interest because the contests allow any language, and because of that it is pretty much impossible for ...
Timwi's user avatar
  • 12.9k
132 votes
16 answers
8k views

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

Every other month someone expresses their (negative) feelings about golfing languages. Here is how this usually goes: they complain that they don't enjoy golfing in the languages they know because ...
Martin Ender's user avatar
53 votes
0 answers
2k views

How to count bytes FAQ

We've got a lot of questions asking how to count the bytes in different situations. This question is here to put them all in one spot. General questions How to count "interactive" answers ...
13 votes
4 answers
3k views

Language Handicap [duplicate]

This question is because my favorite language C++ does not lend itself to code golf. Now I could try and pick up a new scripting language (like golf-script) or brush up on an old favorite (perl), but ...
Martin York's user avatar
15 votes
4 answers
2k views

Should function literals be allowed when a function is asked for?

I'm arguing with the poster of this answer. The function literal as is doesn't cause the function to be defined, it has to be assigned to a variable, giving it a name or wrapping it like ...
user avatar
76 votes
9 answers
17k views

Interpretation of Truthy/Falsey

Quite a few code-golf questions require output to be "truthy or falsey". This is possibly confusing as these terms can possibly mean different things to different people, and especially in different ...
Digital Trauma's user avatar
10 votes
6 answers
923 views

Fair size comparison across languages with different source alphabets

For fair comparison of codegolf solutions in languages with different source alphabets, there should be a common unit of information. Most sizes here are expressed in "characters" or "bytes", but not ...
John Tromp's user avatar
  • 1,176
33 votes
8 answers
6k views

Programming in Minecraft (Redstone) - how to measure program size?

Since programs may be created in vanilla (un-modded) Minecraft using redstone to create logic gates (and more), someone could create such a program for a challenge on this site. How would such an ...
mbomb007's user avatar
  • 23.4k
16 votes
1 answer
800 views

What are our rules about additional code accompanying function submissions?

This is an extension of this meta question. I've always assumed that function submissions were allowed under the premise that the code would be evaluated once and would in the process either: Define ...
Martin Ender's user avatar
13 votes
2 answers
2k views

Unnamed Functions in Code Golf

For many code golf questions, we allow functions as answers. What exactly does it mean for some code to be a valid submission as a function? This question came up during a discussion on built-ins, ...
isaacg's user avatar
  • 42k
34 votes
6 answers
3k views

Can numeric input/output be in unary?

Some string-based languages (including but not limited to sed, Retina, ///) can't really handle integer arithmetic in decimal (or other normal bases). Therefore, these almost always have to start by ...
Martin Ender's user avatar
28 votes
3 answers
2k views

Do function submissions have to be reusable?

Simple question: if I answer a code golf with a function (for a task which is supposed to terminate), does the function actually have to be reusable? Or could it, say, modify some globals which break ...
Martin Ender's user avatar
23 votes
3 answers
1k views

What details should always be given for a code golf task?

Related: For Code Golf, how do you deal with languages without a traditional print/echo statements? Related: What programming language should we consider for the code-golf solution ? Related: Use of ...
16 votes
2 answers
568 views

Are compiler-specific submissions allowed?

For example, in a c++ submission, this is valid if you use g++ #include <iostream> main() { std::cout << "Hello world!"; } but in any other ...
DJMcMayhem's user avatar
  • 59.2k
12 votes
3 answers
718 views

How to determine the length of a Piet program?

I noticed that Piet is not mentioned in the How to count bytes FAQ. How should we determine the length of a piet program?
Mike Bufardeci's user avatar
10 votes
2 answers
644 views

On scoring imported functions

There are lots of questions about whether to count the bytes in an import statement, etc. This question is not about that. Instead, this question is more inline with this question but I think it would ...
Ogaday's user avatar
  • 469
10 votes
1 answer
445 views

What is a character encoding, exactly?

Preface I've 'failed' twice at this whole golf language design thing, once with JAISBaL and again with Clack. Now that I've had a go twice, I am obviously an expert and am attempting to design the ...
Socratic Phoenix's user avatar
21 votes
3 answers
912 views

Does PPCG fulfil a role as a catalogue for golfed solution of standard programming exercises?

Rosetta Code collects solutions to standard programming exercises in hundreds of programming languages. However, it focuses on "good" or idiomatic solutions in those languages. I'm not aware of a ...
17 votes
2 answers
1k views

Can numeric input/output be in the form of byte values?

This answer just prompted a question, which I've wondered about a few times when answering challenges in esoteric languages: For some esoteric languages, the only means of input/output is reading and ...
Martin Ender's user avatar
12 votes
6 answers
899 views

Is a code golfing library legitimate? [duplicate]

My read on the current state of meta.CG opinion is that the use of libraries is acceptable and that the library call should count in the character count: Use of built-in functions and libraries in ...
Ari B. Friedman's user avatar
8 votes
4 answers
3k views

How are bytes counted in assembly?

I was told bytes in assembly are counted by the byte of machine code. Is that true? If so what steps should be taken to correctly get bytes?
user avatar
26 votes
3 answers
617 views

Where does Programming Puzzles & Code Golf fit in the SE mission?

Don't get me wrong, I love this website. I think it's fun and all but I can't help thinking... How does it correspond to Stack Exchange's mission : What is Stack Exchange? Stack Exchange is a ...
user avatar
18 votes
4 answers
792 views

How to Make Code Golf More Enjoyable: Winners by Language?

So, I was reading the related question here, when I went off on a tangent. The point of the given post, as I read it, is that certain languages like GolfScript, K, and some other extremely-high level ...
Andrew Gray's user avatar
16 votes
4 answers
973 views

Can serious contenders do more than the challenge asks for?

As our help center likes to put it: All solutions to challenges should: Correctly implement the required specification. Be a serious contender for the winning criteria in use. For example, an entry ...
Dennis's user avatar
  • 210k
14 votes
2 answers
1k views

How should vim answers be scored?

I like vim a lot. I've been golfing with it a lot recently. We already have clearly established that vim is a programming language, but there aren't any clear rules on how to score vim answers. The ...
DJMcMayhem's user avatar
  • 59.2k
14 votes
3 answers
466 views

Should language-specific code golf challenges be explicitly disallowed?

In light of a recent code golf challenge in which the specification restricts participation to JavaScript, I think it's time we revisited making a hard rule about language-specific golfs. We may ...
Alex A.'s user avatar
  • 24.6k
14 votes
3 answers
1k views

Counting bytes for multi-file programs

So far, submissions consisting of multiple files have simply been counted by summing up the scores of the individual files. Also file names aren't counted as long as they are arbitrary. (We do count ...
Martin Ender's user avatar
27 votes
2 answers
1k views

How does this site work?

Hello, I have spent time looking at the StackExchange sites and especially this has seemed quite interesting to me. But I would like you to explain how it works and what it is about. I know how to ...
ESCM's user avatar
  • 101
27 votes
25 answers
3k views

Announcing Advent of Code Golf 2021! (+ Event challenge sandbox)

Originally from caird coinheringaahing's idea, I thought about how we could do it this year with such a short time before December, and I decided to gather some ideas from previous AoC events. (There'...
Bubbler's user avatar
  • 76.8k
22 votes
1 answer
2k views

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

Let's say a code-golf challenge is asking for a program without arguments or function without parameters. Are we allowed to take an empty parameter instead we won't use anywhere? As example: In Java ...
Kevin Cruijssen's user avatar
15 votes
1 answer
424 views

Is a transliteration tool enough to grant count as SBCS?

Prompted by this. I'll speak about Dyalog APL here, but this could really apply to any language. Background Dyalog APL has its own SBCS called ⎕AV. For backwards ...
Adám's user avatar
  • 30.3k
13 votes
2 answers
702 views

Byte count for imports (or other things) not needed for definition, but for execution

When we define a function that needs an import, we have to add it to the byte count. So far, so good. What about cases where the definition itself doesn't need the ...
nimi's user avatar
  • 35.8k
11 votes
4 answers
453 views

Presolving Golf Questions

I notice some users are posting questions where they are immediately posting a long-standing (or just extremely well golfed) solution to the problem. On StackOverflow posting your own questions has ...
jtjacques's user avatar
  • 1,145
9 votes
3 answers
351 views

Can code-golf answers be too slow?

This answer is a fairly extreme example. For the largest input it would create an array with 1.048576e+26 elements which is not going to fit in RAM anytime soon (maybe not even physically possible). ...
gnibbler's user avatar
  • 15.1k
8 votes
1 answer
1k views

How to count bytes in 7 (and other languages that use fractional numbers of bytes) [duplicate]

(See also this question, which is similar, but talks about the situation where the language is normally stored on disk with one command per byte.) This question originally came up in connection with ...
user avatar
4 votes
3 answers
232 views

How should we handle Excel answers with drag-down formulas? [duplicate]

This is a very grey area, because while excel is fun to enter, and play around with, often times it's seen as a pseudo-programming language. In Excel, one can drag-down formulas to automatically match ...
user avatar
45 votes
2 answers
3k views

Golfing Class of a language

I feel like we may have enough data on this site to meaningfully break programming languages into classes. What I mean by classes is akin to Go's ranking system: If a player can win 90% of even games ...
Not that Charles's user avatar
18 votes
4 answers
3k views

How to score TI-BASIC

How do we score code written in TI-BASIC, when it comes to multi-character words? For example: :If X>2:Then:Stop Seemingly, the above should count as 17 ...
Ypnypn's user avatar
  • 10.9k
16 votes
4 answers
648 views

Should bonuses be allowed for [code-golf] questions?

Prompted by a discussion between Peter Taylor and myself, I'd like to solicit the community's opinion on the following issue: Should awarding score bonuses for extra features disqualify a challenge ...
Ilmari Karonen's user avatar
11 votes
5 answers
840 views

Use of built-in functions and libraries in Code Golfs

This answer used a built-in Python function to solve the question in a very short amount of code. Should we allow it and let people not up-vote, or should we police library abuse to some degree? If ...
moinudin's user avatar
  • 12.7k
4 votes
1 answer
276 views

Should point-free function expressions be allowed when a function is asked for?

Should an expression evaluating to a function count as a function for the purpose of providing a solution when a function is asked for? An earlier question on meta seems to indicate a consensus that ...
FireFly's user avatar
  • 7,258
3 votes
3 answers
395 views

Creating new language. Would it be legal?

Today with friend of mine discussed about code golf, I want to ask your opinion about the thing we discussed about. Would it be legal if I create my own programming (actually scripting) language with ...
ST3's user avatar
  • 1,359
2 votes
2 answers
156 views

Do I need to use imports or can I call a class explicity?

New to code golf and tried finding an answer to this question but couldn't (surprisingly) When scoring my golfed Java code I was told that I need to add in my imports as part of my score. My question ...
yitzih's user avatar
  • 111
37 votes
25 answers
3k views

Advocate languages to golf in

I'm sure many of you want to attract golfers to compete in your favorite language. Given that it takes time to learn a language for golfing, why choose it over others? What aspects of the language ...
xnor's user avatar
  • 145k
25 votes
2 answers
2k views

Programming in LabVIEW - how to measure program size?

Inspired by this question, how would a LabVIEW program be scored? As one of the only graphical languages in common use today, LabVIEW is a bit of an outsider. As odd as it is, LabVIEW is a serious ...
Kyle G's user avatar
  • 870
24 votes
28 answers
2k views

Announcing Code Golf Advent Calendar 2022! (+ Event challenge sandbox)

Following last year's event, we're doing Advent of Code Golf Code Golf Advent Calendar 20221! On each day between Dec 1st and Dec 25th (inclusive), a new challenge will be posted at UTC midnight2. It ...
Bubbler's user avatar
  • 76.8k
18 votes
4 answers
721 views

Code Golf Tutorials?

There are a lot of intelligent people on PPCG, and for that reason a lot of our usual challenges are hard. This means that we are throwing new users straight into the deep end with huge problems which ...
Beta Decay's user avatar
  • 23.4k
12 votes
2 answers
231 views

Do I have to verify all answers?

I have an idea about a code-golf challenge. Will I need to verify/test every answer submitted ? Will I need to run code submitted to be sure that the answer meets the requirements ?
Luc M's user avatar
  • 101