About

Do I need to log in to play?
No. Submitted solutions will be executed and checked without logging in, but nothing will be saved and you won't appear on the leaderboards.
Is code.golf free as in speech?
Yes! It is written in Go, licensed under MIT, and available on GitHub; patches welcome!
Is code.golf free as in beer?

Yes! However hosting isn't, so if you enjoy Code Golf consider donating to its continued existence and improvement via GitHub Sponsors.

Sponsors will receive a couple of additional perks, with more planned:

* Badge hidden if sponsorship is anonymous.
Free Sponsor
Profile Badge No Yes *
Follow Limit 10 24
What languages are supported?

><>

4.76 MiB
96b1cfc
github.com/primo-ppcg/fish-jit

Assembly

94.7 MiB
DefAssembler 2.4.0
npmjs.com/package/@defasm/core

AWK

1.77 MiB
5.3.0
gnu.org/software/gawk/

Bash

1.19 MiB
5.2.26
gnu.org/software/bash/

BASIC

205 MiB
FreeBASIC 1.10.1
freebasic.net

Berry

973 KiB
1.1.0
berry-lang.github.io

brainfuck

51.1 KiB
9cd183f
github.com/primo-ppcg/bfci

C

1.7 MiB
Tiny C Compiler 0.9.27
bellard.org/tcc/

C#

151 MiB
C# 12.0 on .NET 8.0.1
docs.microsoft.com/dotnet/csharp/

C++

132 MiB
17.0.6
clang.llvm.org

Clojure

65.8 MiB
Babashka 1.3.189
babashka.org

COBOL

4.56 MiB
GnuCOBOL 3.2.0
gnucobol.sourceforge.io

Coconut

121 MiB
3.1.0
coconut-lang.org

Crystal

252 MiB
1.11.2
crystal-lang.org

D

309 MiB
D 2.103.1 on LDC 1.33.0
dlang.org

Dart

235 MiB
3.3.0
dart.dev

Elixir

158 MiB
1.16.1
elixir-lang.org

F#

146 MiB
F# 8.0 on .NET 8.0.1
fsharp.org

Factor

172 MiB
0.99
factorcode.org

Forth

2.86 MiB
GNU Forth 0.7.3
gnu.org/software/gforth/

Fortran

87.8 MiB
GNU Fortran 13.2.0
gcc.gnu.org/fortran/

Go

353 MiB
1.22.1
go.dev
gs

GolfScript

24.2 MiB
6155e9f
http://www.golfscript.com/golfscript/

Haskell

410 MiB
Glasgow Haskell Compiler 9.4.7
haskell.org/ghc/

Hexagony

8.82 MiB
770406a
github.com/SirBogman/Hexagony

J

11.2 MiB
9.5.5
jsoftware.com

Janet

836 KiB
1.33.0
janet-lang.org

Java

51.1 MiB
17.0.1
openjdk.java.net

JavaScript

39.6 MiB
V8 12.1.285.27
v8.dev

Julia

313 MiB
1.10.2
julialang.org

K

629 KiB
2780e5eb57
codeberg.org/ngn/k

Lisp

31.1 MiB
GNU CLISP 2.49.92
clisp.sourceforge.io

Lua

354 KiB
5.4.6
lua.org

Nim

15 MiB
2.0.2
nim-lang.org

OCaml

80.6 MiB
5.1.1
ocaml.org

Pascal

31.1 MiB
3.2.2
freepascal.org

Perl

5.46 MiB
5.38.2
perl.org

PHP

8.4 MiB
8.3.3
php.net

PowerShell

178 MiB
PowerShell 7.4.1 on .NET 8.0.1
docs.microsoft.com/powershell/scripting/overview

Prolog

49.2 MiB
SWI-Prolog 9.2.2
swi-prolog.org

Python

71 MiB
3.12.2
python.org

R

79.2 MiB
4.3.1
r-project.org

Raku

73.5 MiB
Raku 6.d on Rakudo 2024.01
raku.org

Rockstar

167 MiB
2.1.2
github.com/gaborsch/rocky

Ruby

27.7 MiB
3.3.0
ruby-lang.org

Rust

426 MiB
1.76.0
rust-lang.org

sed

236 KiB
4.9
gnu.org/software/sed/

SQL

1.19 MiB
3.45.2
sqlite.org

Swift

549 MiB
5.9.2
swift.org

Tcl

5.25 MiB
8.6.14
tcl-lang.org

TeX

9.58 MiB
3.141592653
tug.org

V

52.5 MiB
0.4.4
vlang.io

VimL

24 MiB
9.1
vim.org

Wren

496 KiB
0.4.0
wren.io

Zig

279 MiB
0.11.0
ziglang.org

If you'd like to see another language added then raise an issue.

Are warnings ignored?
Yes. Only STDOUT is checked against the solution, STDERR is however shown back to you to ease debugging.
How are arguments passed to my program?
Some holes pass arguments, for those your program should read them from the command line arguments (ARGV).
How do I print Unicode characters?

Your source code is sent to the interpreter encoded in UTF-8, and is expected to write output encoded in UTF-8 to STDOUT. For languages where it matters, your code is run in the en_US locale with a UTF-8 output encoding.

In Unicode-aware languages like Python, this means print("๐Ÿ™‚") and print(chr(0x1f642)) both produce the emoji U+1F642 "Slightly Smiling Face" ๐Ÿ™‚, which is encoded as f0 9f 99 82 in UTF-8.

In less Unicode-aware languages where strings are byte strings, you might still get away with UTF-8 in string literals. For example, OCaml treats "๐Ÿ™‚" as a string of length 4 (four bytes), but Char.chr 0x1f642 is an error.

In yet other languages, like brainfuck, you have to print the individual bytes f0 9f 99 82 one by one.

How are solutions ranked?
There are two scorings in use, bytes and chars. Bytes is the number of bytes of a solution encoded in UTF-8. Chars is the number of Unicode codepoints of a solution. Users may submit up to two solutions per hole per language. This is handled automatically when you enter two solutions and each minimizes a different scoring. Each scoring has its own set of leaderboards. For the chars scoring, both โ€œAโ€ (U+0041 Latin Capital Letter A) and โ€œ๐Ÿ˜‰โ€ (U+1F609 Winking Face) cost the same despite the 1:4 ratio in byte count in UTF-8.
How are solutions scored?
For each hole, in each language, up to 1,000 points are available. The formula is:
Points = Sb รท Su ร— 1000
Where Su is the length of the user's solution, and Sb is a Bayesian estimator of the form:
Sb = ((โˆšn + 2) รท (โˆšn + 3)) ร— S + (1 รท (โˆšn + 3)) ร— Sa
n is the number of solutions in this hole in this language. S is the length of the shortest solution in this hole in this language. Sa is the shortest solution among all languages in this hole.

The confidence interval is chosen such that the shortest solution in any language will receive a score of at least 750.

Your overall score is the sum of your highest points in each hole.

Are submissions resource-constrained?
Yes. Execution time is limited to 5 seconds, CPU & RAM usage is unbounded but this will probably change soon. The length of each solution must be lower than 128 KiB as that's the maximum length of any program argument under Linux.
Is there an API?
An API is currently being developed and documented in standard OpenAPI format. A legacy API that just returns scores in JSON exists. The URL is /scores/all-holes/all-langs/all. Note that all-holes and all-langs may be replaced by the names of specific holes and languages.
Can I see other people's solutions?
No, that way all holes stay competitive. If you're stuck on how to shave a couple of strokes off your solution then why not visit our Discord server for some advice.