All Questions

Filter by
Sorted by
Tagged with
25 votes
35 answers
2k views

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 ...
user avatar
  • 5,438
71 votes
56 answers
18k views

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 ...
user avatar
  • 1,783
38 votes
53 answers
4k views

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. ...
user avatar
  • 5,438
13 votes
1 answer
1k views

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: ...
user avatar
6 votes
3 answers
425 views

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. ...
user avatar
  • 5,906
11 votes
1 answer
718 views

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 ...
user avatar
  • 9,970
60 votes
28 answers
17k views

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 ...
user avatar
  • 12.3k
35 votes
26 answers
30k views

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.
user avatar
  • 5,906
-1 votes
1 answer
5k views

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)? ...
user avatar
12 votes
2 answers
3k views

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 ...
user avatar
  • 2,140
5 votes
5 answers
902 views

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.
user avatar
  • 5,438
33 votes
52 answers
5k views

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 ...
user avatar
  • 2,140
4 votes
3 answers
262 views

Sharing Inherited Land [closed]

You and your brother have inherited a rectanglar block of land. This block of land's corners are read in from stdio as TLX,TLY,TRX,TRY,BLX,BLY,BRX,BRY (all decimal ...
user avatar
  • 1,009
48 votes
41 answers
17k views

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 "...
user avatar
  • 1,189
146 votes
308 answers
38k views

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 ...
user avatar
  • 4,857
136 votes
67 answers
22k views

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 ...
user avatar
  • 5,906
24 votes
38 answers
4k views

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.
user avatar
  • 1,145
233 votes
415 answers
58k 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 ...
user avatar
  • 2,607
320 votes
168 answers
121k 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 ...
user avatar
  • 12.3k
14 votes
5 answers
753 views

Fast Topswops calculation

From AZSPCS: Suppose you have a deck containing n cards. Each card contains a number from 1 to n, and each number appears on exactly one card. You look at the number on the top card -- let's says it'...
user avatar
  • 5,906
11 votes
4 answers
2k views

Fast line drawing algorithm

The task is to find a way to draw a horizontal line in an array of 16-bit integers. We're assuming a 256x192 pixel array with 16 pixels per word. A line is a contiguous run of set (1) bits. Lines ...
user avatar
  • 3,262
39 votes
21 answers
7k views

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 ...
user avatar
  • 1,009
5 votes
7 answers
876 views

Find an unknown very large number [closed]

Let's suppose there is a finite unknown number n (n can be very large, does not necessarily fit 64-bits; think of ...
user avatar
  • 5,906
11 votes
5 answers
1k views

fizz buzz in TMP [closed]

The Fizz Buzz problem is a very basic problem to solve that is used by some to weed out interviewees that don't know how to program. The problem is: ...
user avatar
57 votes
57 answers
8k views

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 ...
user avatar
32 votes
31 answers
16k views

Rand5() to Rand7() [closed]

You are provided with a function Rand5(). This function returns perfectly random (equal distribution) integers between 1 and 5. Provide the function Rand7(), which uses Rand5() to produce perfectly ...
user avatar
  • 1,009
9 votes
4 answers
2k views

N-Queens problem [closed]

In chess, a queen can move as far as as the board extends horizontally, vertically, or diagonally. Given a NxN sized chessboard, print out how many possible positions N queens can be placed on the ...
user avatar
  • 1,009
26 votes
12 answers
5k views

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 ...
user avatar
  • 1,257
42 votes
60 answers
6k views

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 ...
user avatar
63 votes
117 answers
22k views

99 Bottles Of Beer [closed]

Recreate '99 bottles of beers on the wall'. The desired output is this: ...
user avatar
23 votes
5 answers
5k views

Just Another Perl Hacker [closed]

Classic code golf challenge. Write the most obscure Perl program to print "Just another Perl hacker". Here's the Wikipedia article on it. Bonus points if it fits in 3 lines / 70 characters each.
user avatar
  • 3,262
105 votes
111 answers
18k views

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? ...
user avatar

15 30 50 per page
1
261 262 263 264
265