Questions tagged [code-golf]

Code-golf is a competition to solve a particular problem in the fewest bytes of source code.

Filter by
Sorted by
Tagged with
15 votes
4 answers

Freely available books for code golfing? [closed]

Can you recommend any freely available books about code golfing in general and especially in Java and C++?
50 votes
49 answers

Tips for golfing in PowerShell

What general tips do you have for golfing in Windows PowerShell? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to PowerShell (e.g. "...
Joey's user avatar
  • 12.9k
35 votes
14 answers

Drawing a cube in ASCII art

Task description: Draw a cube in ASCII art in roughly a cabinet projection. Monospaced fonts often have characters that are about twice as high as they are wide. ...
Joey's user avatar
  • 12.9k
6 votes
33 answers

Print largest integer you can with the fewest characters [closed]

Find a way to output a large integer with few characters. Solutions will be scored based on the magnitude of the number and shortness of code. EDIT: Let's impose a time limit of a minute on sensible ...
moinudin's user avatar
  • 12.5k
27 votes
37 answers

Finding "sub-palindromes".

The shortest code that finds all unique "sub-palindromes" of a string, that is: any substring with length > 1 that is a palindrome. eg.1 ...
Eelvex's user avatar
  • 5,452
75 votes
59 answers

Tips for code-golfing in C#

What general tips do you have for golfing in C#? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to C# (e.g. "remove comments" is not an ...
jcolebrand's user avatar
  • 1,863
38 votes
55 answers

196 algorithm code golf

Write a short program for 196-algorithm. The algorithm starts from an integer, then adds its reverse to it until a palindrome is reached. e.g. ...
Eelvex's user avatar
  • 5,452
13 votes
1 answer

Shortest path in a graph

Write a program to take a graph (from either standard input or a file, your choice) and find a shortest path in the graph. Graphs are specified using the following format: ...
Keith Randall's user avatar
6 votes
3 answers

Compress programs

Write a program/script that decompresses and passes any compressed data appended at the end of the binary/file as standard input to a program specified as arguments. ...
Alexandru's user avatar
  • 6,066
11 votes
1 answer

Write a compressing util for gzip files

The task of this challenge is as following: Write a program that reads a file of reasonable size (let's say <16 MB) from stdin or anywhere else (however you like, but must not be hardcoded), and ...
FUZxxl's user avatar
  • 10.1k
62 votes
30 answers

Tips for golfing in C++

What general tips do you have for golfing in C++? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to C++ (e.g. "remove comments" is not ...
moinudin's user avatar
  • 12.5k
37 votes
26 answers

Morse code translator

Write the shortest program to transform the standard input into Morse code. Characters not in the table should be printed as they are.
Alexandru's user avatar
  • 6,066
-2 votes
1 answer

Poisson random number generator [closed]

What is the shortest function (implemented in C) that will return a random draw from a Poisson distribution (given the mean or λ parameter)? ...
Daniel Standage's user avatar
11 votes
2 answers

Test if a given number is a Vampire Number [duplicate]

EDIT: In the interest of increasing the complexity, i've added more to the challenge. In mathematics, a vampire number (or true vampire number) is a composite natural number v, with an even ...
st0le's user avatar
  • 2,208
4 votes
5 answers

Tree traversal. [closed]

Write the shortest code that traverses a tree, breadth-first. Input any way you like Output a list of "names" of the nodes in correct order.
Eelvex's user avatar
  • 5,452
36 votes
61 answers

Sum of primes between given range

Write the shortest code for finding the sum of primes between \$a\$ and \$b\$ (inclusive). Input \$a\$ and \$b\$ can be taken from command line or stdin (space seperated) Assume \$1 \le a \le b \le ...
st0le's user avatar
  • 2,208
48 votes
41 answers

Obfuscated FizzBuzz Golf [closed]

Create the shortest possible obfuscated FizzBuzz implementation. To be considered obfuscated, it should satisfy at least one of the following: Does not contain any of the words "Fizz", "Buzz", or "...
mootinator's user avatar
  • 1,199
149 votes
330 answers

Fibonacci function or sequence

The Fibonacci sequence is a sequence of numbers, where every number in the sequence is the sum of the two numbers preceding it. The first two numbers in the sequence are both 1. Here are the first ...
C. K. Young's user avatar
  • 4,917
147 votes
78 answers

Interpret brainfuck

Write the shortest program in your favourite language to interpret a brainfuck program. The program is read from a file. Input and output are standard input and standard output. Cell size: 8bit ...
Alexandru's user avatar
  • 6,066
24 votes
38 answers

Reimplementing square root [duplicate]

Define a function, s, which takes a number and returns the square root. No use of library functions, such as Java's Math.sqrt() or PHP's built in sqrt(), allowed.
jtjacques's user avatar
  • 1,145
242 votes
450 answers

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 ...
Rafe Kettler's user avatar
  • 2,697
326 votes
177 answers

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 ...
moinudin's user avatar
  • 12.5k
39 votes
21 answers

Angle between the hands on a clock [duplicate]

Given the time in 24 hour format (2359 = 11:59pm) return the angle between the minute and hour hands on a standard clock (on the ...
Dan McGrath's user avatar
  • 1,007
62 votes
64 answers

The Luhn algorithm for verifying credit card numbers, etc

Challenge Write the shortest program or function to calculate the Luhn Algorithm for verifying (credit card) numbers. Luhn algorithm explained From RosettaCode, this algorithm for the purposes of ...
Chris Laplante's user avatar
25 votes
12 answers

Hamming numbers

Hamming numbers are numbers which evenly divide a power of 60. Equivalently, their prime factors are all \$ \le 5 \$. Given a positive integer, print that many Hamming numbers, in order. Rules: Input ...
grokus's user avatar
  • 1,257
44 votes
69 answers

ROT-13 transform standard input

Task Read a string of characters and produce the ROT13 of it. All characters besides [a-zA-Z] should be output verbatim. Each letter in the output may be in any ...
MiffTheFox's user avatar
110 votes
116 answers

Code Golf Christmas Edition: How to print out a Christmas tree of height N

Given a number N, how can I print out a Christmas tree of height N using the least number of code characters? ...
TheSoftwareJedi's user avatar

233 234 235 236