Linked Questions
75 questions linked to/from Tips for golfing in PowerShell
393
votes
156answers
261k views
Write a program that makes 2 + 2 = 5 [closed]
Write a program that seemingly adds the numbers 2 and 2 and outputs 5. This is an underhanded contest.
Your program cannot output any errors. Watch out for memory holes! Input is optional.
...
166
votes
304answers
50k 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 ...
283
votes
150answers
96k 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 ...
131
votes
290answers
27k 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 ...
222
votes
107answers
40k 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 (...
205
votes
59answers
17k 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 ...
71
votes
107answers
10k views
Collatz Conjecture (OEIS A006577)
This is the Collatz Conjecture (OEIS A006577):
Start with an integer n > 1.
Repeat the following steps:
If n is even, divide it by 2.
If n is odd, multiply it by 3 and add 1.
It is proven that ...
42
votes
120answers
9k views
Print invisible text
Given a string as input, output a number of whitespace characters (0x0A and 0x20) equal to the length of the string.
For example, given the string Hello, World! ...
53
votes
73answers
7k views
Test a number for narcissism
A Narcissistic Number is a number which is the sum of its own digits, each raised to the power of the number of digits.
For example, take 153 (3 digits):
13 + 53 + 33 = 1 + 125 + 27 = 153
1634:
...
56
votes
71answers
7k views
How to randomize letters in a word
According to some controversial story, the odrer of ltteres in a wrod deos not mttaer much for raednig, as lnog as the frist and lsat lteter macth with the orignial wrod.
So, for fun, what would be ...
44
votes
87answers
12k views
Draw an ASCII chess board!
Here is a simple challenge for you: You must produce this ASCII representation of a chess board. White is represented by uppercase characters, and black is represented by lowercase. Empty tiles are ...
49
votes
67answers
6k views
Output the alphabet, the ALPHABET, or just a character
The challenge is simple:
Write a function or program that takes an input x, and outputs the lower case alphabet if x is part of ...
36
votes
75answers
4k views
Division and remainder
This challenge, while probably trivial in most "standard" languages, is addressed to those languages which are so esoteric, low-level, and/or difficult to use that are very rarely seen on this site. ...
31
votes
75answers
11k views
Clearing the most significant bit from an integer
Input
The input is a single positive integer n
Output
The output isn with its most significant bit set to ...
40
votes
59answers
8k views
List of possible birth years of living humans
The Challenge
Output a list of years that starts with the current year and ends 120 years ago. The birth year of every living human would be included in this list.
Details
The list should be in ...