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 ...
3 votes
2 answers
172 views

Using tio.run, how does this C function return a value?

I'd like to shorten my answer below by applying this tio.run technique from this C example. Here's their C example Code ...
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 ...
6 votes
1 answer
152 views

How can I know when to stop golfing?

For example, I've spent several days reducing an assembly submission from an initial 456 bytes down to 330 322 bytes. How can I determine when a code golf solution has reached its most compressed or ...
15 votes
1 answer
425 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 ...
2 votes
1 answer
77 views

How is Subleq code counted?

How are "bytes" counted in Subleq, in which code is a list of integers with no fixed size?
1 vote
0 answers
85 views

Are there specific types of code golf challenges on this site?

I posted a question in hope of starting a shortest code challenge, but it seems to attract lots of downvotes and the only answer tried to help as a programming problem. One comment on the question ...
7 votes
2 answers
202 views

Equivalence between strictly increasing integer sequences and decision problems

I have noticed that sequence questions are often looking at strictly increasing integer sequences. For these types of sequences, the sequence task of outputting the values in the sequence is largely ...
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 ...
3 votes
1 answer
161 views

Is the interpreter part of the language or a separate language?

As I understand it, for our purposes a language is more or less defined by its implementation. That's one of the reasons why a program like Vim can also be "language". You just count keystrokes ...
7 votes
0 answers
216 views

Does the initial `:` in a TI-BASIC program count?

According to this meta post, TI-BASIC is scored in tokens rather than characters, to more accurately reflect the byte count in-memory. On my graphing calculator (TI-84 Plus C Silver Edition), the ...
10 votes
2 answers
647 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 ...
2 votes
2 answers
117 views

Can the binary representations of argv[n] be used for numeric input?

TL;DR: Is int d = *(int*)argv[1]; allowed to obtain a integer input? A special case of this question: Can numeric input/output be in the form of byte values? This ...
-1 votes
1 answer
140 views

Maximum code-golf length

If we have a code-golf question that we have a golfed answer to in, say, Python, how long does that program have to be for it to not be a good idea to ask that question/for that to be code-golf (if ...
-6 votes
2 answers
212 views

Why do I feel like Code Golf is ruining the point of Python?

The Zen of Python ...
3 votes
1 answer
89 views

Is byte count on TIO valid, specifically for non-ASCII C code?

When I have non-ASCII characters in my C code, TIO counts them as 1 byte. For example, the following C program prints 56 music-related characters on the terminal. Link TIO reports its length as "...
6 votes
2 answers
148 views

What is a good ASCII boundary-character for regex unary, and will using that instead of a delimiter affect the perceived legitimacy of my answers?

So far, I have only used comma-delimited unary for my answers taking a list / array as input, since it's the "obvious" choice. That looks like ...
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 ...
1 vote
1 answer
73 views

Is outputting by modifying an input with no modifying access allowed?

Say Round to nicer numbers where it's possible to always output n'=m. I submitted a Javascript solution that does this. I can require input be f(x,n,[m]) and then ...
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 ...
12 votes
3 answers
668 views

What do we rename Advent of Code Golf?

Recently, Seggan received an email from Eric Wastl, the owner of Advent of Code, part of which is quoted below: Please do not call your event something like "Advent of Code Golf"; this ...
2 votes
2 answers
76 views

Byte counting for BASIC style DATA / READ inputs

Background Many BASIC dialects idiomatically use DATA and READ commands to store and read input data from the source code. We ...
1 vote
3 answers
66 views

Can Function Objects be Appened to STDIN From the Stack?

This is mostly specific to Vyxal, but I've worded the language so that any hypothetical stack language could utilise this Say you have a stack-based language which supports function objects on the ...
2 votes
1 answer
97 views

Using compression tools

Are you allowed to use compression tools (e.g. gzip, xz) in your code? For example, a shell script with: cat script.sh.gz|gzcat|sh (25 bytes) where the content of ...
12 votes
6 answers
900 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 ...
15 votes
0 answers
183 views

Advent of Code Golf 2021 is over! (Stats, Hall of Fame)

Advent of Code Golf 2021 is over! Thanks to everyone who participated in and/or helped me run the Advent of Code Golf 2021 event. It wouldn't have been so successful without the help of the community. ...
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'...
2 votes
1 answer
257 views

Why are golfing languages allowed?

I'm a bit confused about the use of golfing languages in golfing challenges. In the standard loopholes there is a point about using self-made languages that solve the problem in one symbol. And it's a ...
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 ...
1 vote
0 answers
69 views

What loopholes should be assumed when a name-specific file is used for code golf?

I have posted this golfing tip for Bash before: In Pure Bash (or any other pure shellscript), use . for looping. It's a tip that recomments using a file whose the ...
9 votes
1 answer
243 views

Has there been any large-scale attempt to assemble libraries or programs from aggressively-golfed solutions in a given language?

It occurred to me when I was browsing threads here that there is an immense collection of simple and extremely space-efficient functions on this site. Although I imagine the end result of such an ...
-3 votes
1 answer
99 views

What's your favorite code golf video? [closed]

Do you have a favorite code-golf video? Maybe someone golfing before it was cool? Or because it was a way to solve a problem?
4 votes
3 answers
625 views

Online tool to determine number of bytes for UTF-8 characters?

Is there an online tool that will tell me the number of bytes in a UTF-8 character? Or, if not, how do I determine this? I'm currently trying to determine the number of the bytes for the left and ...
0 votes
1 answer
170 views

Is the Chrome UserScript still recommended?

If I recall correctly, the chrome user script used to be recommended in the About/FAQ pages somewhere, but I can't find it anymore. I know that UserScripts must be installed from the Chrome Web Store ...
-1 votes
1 answer
71 views

Shouldn't the users on codegolf be able to close their questions?

Shouldn't the users on codegolf be able to close their question after let's say the question's winners are announced without them having to have some amount of reputation?
0 votes
1 answer
94 views

Sort by code size for code-golf problems [duplicate]

For easier position calculation and as a handy way for the questioner, a sort by code size feature should be added which would sort out all the answers from the very least byte-ed to the most byte-ed.
8 votes
4 answers
304 views

Metadata for answers?

It would be great to have an option in answers to add metadata. (This would be most useful for questions tagged code-golf, but maybe also other tags?) You would be able to put in the language, the ...
12 votes
3 answers
719 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?
-4 votes
1 answer
150 views

Need help with code golf [duplicate]

What in the world is code golf and how is it important to me? I have already looked in the tour.
4 votes
1 answer
104 views

Should "import" statement be included in byte count if I'm not using it directly [duplicate]

Related: On scoring imported functions I knew that if I want to use some imported functions, I had to include "import" statement in the byte count. For example, I want to find out the most ...
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 ...
1 vote
1 answer
93 views

Is returning a longer array allowed?

There exist some questions that it's easier to output an array longer than intended to output, and it costs to slice. Longer array behave like small ones as long as you don't access its length or out-...
1 vote
0 answers
68 views

Can we assume computer be fast enough?

Consider such a question Take a program P and an integer n, check whether P halts. You may ...
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 ...
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 ...
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?
1 vote
1 answer
136 views

What to count in assembly?

Yes, I've checked this post (How are bytes counted in assembly), but I'm asking a different question. I'm asking, if I have an .asm file, an ...
4 votes
0 answers
118 views

How should answers that time out be judged?

Suppose a challenger submits a code-golf challenge to do a particular task, together with test inputs. (That is, they've determined that, in order to be convinced that the code in an answer correctly ...
8 votes
1 answer
219 views

Byte counting policy for library imports in Factor

As this month's LotM (Forth) was not gaining much participation, I guessed it's partly because it's way too low-level, so I was looking into Factor as a modern, high-level alternative to Forth. If it ...
10 votes
5 answers
829 views

Ruleset for RGS's Golfing Showdown - competition is over!

RGS RGS stands for RGS's Golfing Showdown, a golfing competition. The competition has ended, final leaderboard at the end of this post! 1 - The format The RGS will be a virtual golfing competition ...

1
2 3 4 5