Linked Questions
355 questions linked to/from Tips for golfing in Python
194
votes
413
answers
74k
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 ...
145
votes
333
answers
31k
views
Shortest code to produce infinite output
Write the shortest code you can that produces an infinite output.
That's all. You code will only be disqualified if it stops producing output at some point. As always in code golf, the shortest code ...
120
votes
405
answers
30k
views
Print a 10 by 10 grid of asterisks
Background
This is a standard textbook example to demonstrate for loops.
This is one of the first programs I learnt when I started learning programming ~10 years ago.
Task
You are to print this exact ...
269
votes
145
answers
37k
views
Without using numbers, get the highest salary you can. But don't exaggerate!
As I'm applying for some jobs whose job advert doesn't state the salary, I imagined a particularly evil interviewer that would give the candidate the possibility to decide their own salary ...by "...
110
votes
328
answers
22k
views
Simple cat program
One of the most common standard tasks (especially when showcasing esoteric programming languages) is to implement a "cat program": read all of STDIN and print it to STDOUT. While this is named after ...
239
votes
115
answers
43k
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 (...
128
votes
201
answers
34k
views
Sing Happy Birthday to your favourite programming language
Your favourite programming language has just had a birthday. Be nice and sing it the Happy Birthday song.
Of course you should accomplish this by writing a program in that language.
The program takes ...
92
votes
241
answers
19k
views
"DDoouubbllee ssppeeaakk!!"
Super simple challenge today, or is it?
I feel like we've heard a fair bit about double speak recently, well let's define it in a codable way...
Double speak is when each and every character in a ...
393
votes
49
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 ...
66
votes
170
answers
16k
views
Print 0 to 100 without 1-9 characters
Print integers 0 to 100 (inclusive) without using characters 123456789 in your code.
Separator of numbers can be comma or white space (by default <blank>, <...
120
votes
98
answers
17k
views
Loading... Forever
Your challenge is to make an infinite loading screen, that looks like this:
Or, to be more specific:
Take no input.
Output Loading..., with a trailing space, but ...
59
votes
209
answers
8k
views
The Mystery String Printer (Cops)
The robbers thread can be found here: The Mystery String Printer (Robbers)
Your challenge
Write a program, function, or REPL script that prints a string to STDOUT.
The robbers will try to create a ...
91
votes
119
answers
12k
views
N(e(s(t))) a string
To "function nest" a string, you must:
Treat the first character as a function, and the following characters as the arguments to that function. For example, if the input string was ...
105
votes
90
answers
24k
views
It took me a lot of time to make this, pls like. (YouTube Comments #1)
Hold up..... this isn't trolling.
Background
These days on YouTube, comment sections are littered with such patterns:
...
65
votes
125
answers
17k
views
Duck, duck, goose!
Remember the kids game, 'Duck, Duck, Goose'? No? Me neither.
The challenge
Print the word 'duck' on individual lines an indeterminate amount of times.
Print the word 'goose'.
Your program ends.
The ...