Questions tagged [code-golf]
Code-golf is a competition to solve a particular problem in the fewest bytes of source code.
12,031
questions
628
votes
333
answers
241k
views
Produce the number 2014 without any numbers in your source code
Note to challenge writers as per meta consensus:
This question was well-received when it was posted, but challenges
like this, asking answerers to Do X without using
Y
are likely to be poorly received....
523
votes
986
answers
195k
views
"Hello, World!"
So... uh... this is a bit embarrassing. But we don't have a plain "Hello, World!" challenge yet (despite having 35 variants tagged with hello-world, and counting). While this is not the most ...
396
votes
50
answers
58k
views
Covfefify a string
In this challenge, you must take a string matching the regex ^[a-zA-Z]+$ or whatever is reasonable (you don't have to consider uppercase or lowercase letters if you ...
380
votes
1
answer
119k
views
Regex that only matches itself
There are some pretty cool challenges out there involving regex (Self-matching regex, Regex validating regex)
This may well be impossible, but is there a regex that will ONLY match itself?
NOTE, ...
331
votes
179
answers
144k
views
Tips for golfing in Python
What general tips do you have for golfing in Python? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Python (e.g. "remove comments" is ...
306
votes
7
answers
35k
views
Draw with your CPU
I have come across an article where students used network traffic to draw their university on the country's IPv6 graph. [image]
Your goal is simple to tell, but hard to implement. Draw the text MAIL (...
289
votes
73
answers
79k
views
We're no strangers to code golf, you know the rules, and so do I
Write the shortest program that prints the entire lyrics of "Never Gonna Give You Up" by Rick Astley.
Rules:
Must output the lyrics exactly as they appear in the above pastebin*. Here's the raw dump:...
244
votes
456
answers
65k
views
Golf you a quine for great good!
Using your language of choice, golf a quine.
A quine is a non-empty computer program which takes no input and produces a copy of its own source code as its only output.
No cheating -- that means ...
239
votes
114
answers
44k
views
Print every character your program doesn't have
Your task is to build a program (using only printable ASCII characters and/or tabs and newlines) that prints out exactly the characters in the printable ASCII space (...
236
votes
369
answers
66k
views
Is this number a prime?
Believe it or not, we do not yet have a code golf challenge for a simple primality test. While it may not be the most interesting challenge, particularly for "usual" languages, it can be nontrivial in ...
235
votes
30
answers
24k
views
DISARM THE B.O.M.B.!
You have been hired for your tech knowledge as a Secret Agent's sidekick to ensure that the good guy can get his job done and the world can be saved.
This is your last mission before retiring with a ...
229
votes
65
answers
19k
views
No A, just CAPS LOCK
What happens when the CapsLock key on your keyboard doesn't have a notch in it?
"This hPPENS."
The goal of this program is to consistently emulate keyboard misses where each A press is replaced with ...
199
votes
215
answers
46k
views
The Programming Language Quiz
Congratulations to Dennis who won both the cops' and the robbers' challenge! Calvin's Hobbies has already delivered on his promise and wrote this challenge for Dennis for winning the robbers' ...
198
votes
418
answers
77k
views
1, 2, Fizz, 4, Buzz
Introduction
In our recent effort to collect catalogues of shortest solutions for standard programming exercises, here is PPCG's first ever vanilla FizzBuzz challenge. If you wish to see other ...
198
votes
123
answers
27k
views
I'm not the language you're looking for!
Isn't it annoying when you find a piece of code and you don't know what language it was written in? This challenge attempts to somewhat solve this.
Challenge
You will have to write a program that ...