All Questions

Filter by
Sorted by
Tagged with
71
votes
184answers
12k views

Count up forever

Write a program that counts up forever, starting from one. Rules: Your program must log to STDOUT or an acceptable alternative, if ...
62
votes
105answers
9k views

Make a ;# interpreter

I recently created a new language called ;# (pronounced "Semicolon Hash") which only has two commands: ; add one to the ...
41
votes
43answers
7k views

Reverse Polish notation

You must evaluate a string written in Reverse Polish notation and output the result. The program must accept an input and return the output. For programming languages that do not have functions to ...
37
votes
8answers
4k views

Shortest terminating program whose output size exceeds Graham's number

Write the shortest possible program (length measured in bytes) satisfying the following requirements: no input output is to stdout execution eventually terminates total number of output bytes exceeds ...
19
votes
16answers
1k views

Tips for golfing in sed

What general tips do you have for golfing in sed? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to sed (e.g. "remove comments" is not ...
65
votes
111answers
7k views

Print/Output the L-phabet

Inspired by George Gibson's Print a Tabula Recta. You are to print/output this exact text: ...
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: ...
41
votes
68answers
6k views

Is it a leap year?

This challenge is quite simple. You will take an input which will be a year from 1801 to 2400, and output if it is a leap year or not. Your input will have no newlines or trailing spaces: ...
36
votes
47answers
6k views

Catalan Numbers

The Catalan numbers (OEIS) are a sequence of natural numbers often appearing in combinatorics. The nth Catalan number is the number of Dyck words (balanced strings of parenthesis or brackets such as ...
25
votes
8answers
1k views

All your bijective base are belong to us

Background A bijective base b numeration, where b is a positive integer, is a bijective positional notation that makes use of b symbols with associated values of 1 to b. Unlike its non-bijective ...
20
votes
49answers
3k views

Run Length Decoding

Write the shortest code in the language of your choice to perform run length decoding of the given string. The string will be supplied as input on stdin in the form ...
16
votes
28answers
1k views

Spell out the Revu'a

Actually not inspired neither by Atbash Self Palindromes nor by Generalized Gematria Calculator. Given a string s of length n, output the Revu'a sequence, which is the first character of s, the first ...
9
votes
5answers
2k views

Words from periodic table of elements [closed]

Back when I was a freshman in highschool taking chemistry, I'd look at the periodic table of elements and spell dirty words out with the number of the elements (HeCK would be 2619, 2-6-19). I was ...
27
votes
23answers
2k views

Case Permutation

Who needs to compare things case insensitively when you're able to generate every permutation of uppercase and lowercase? No one! That's the answer. No one does. Your task is to achieve this feat; ...
14
votes
49answers
7k views

Sum of positive integers. [closed]

Problem: Given a set of integers, find the sum of all positive integers in it. Input: t – number of test cases [t < 1000] On each of next t lines, an integer N [-1000 ≤ N ≤ 1000] Output The ...
226
votes
180answers
35k views

Evolution of “Hello World!”

This contest is officially over, the winner is jimmy23013. Congratulations! The challenge is to make a program that prints Hello World! to stdout. The catch is ...
121
votes
269answers
26k 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 ...
43
votes
37answers
15k views

Draw A Sierpinski Triangle

The Sierpinsky Triangle is a fractal created by taking a triangle, decreasing the height and width by 1/2, creating 3 copies of the resulting triangle, and place them such each triangle touches the ...
85
votes
260answers
15k views

Create output twice the length of the code

The Challenge Write a complete program that writes twice as many bytes to standard output as the length of the program. Rules The program must write ASCII characters to the standard output. The ...
104
votes
99answers
12k views

Make an error quine!

Your challenge: write a "program", for a language of your choice, that causes the compiler/interpreter/runtime to produce error output when compiling/running your program which is identical to your ...
65
votes
14answers
5k views

Write a polyglot that prints the language's name

Your task is to write a program that executes in as many languages as possible, with as few characters as you can. To avoid trivial solutions, the program must print the name of the language it was ...
63
votes
150answers
13k views

Sum of all integers from 1 to n

I'm honestly surprised that this hasn't been done already. If you can find an existing thread, by all means mark this as a duplicate or let me know. Input Your input is in the form of any positive ...
56
votes
80answers
11k views

Play the “bzzt” game

Winner: Aditsu's CJam answer! A whopping 25 bytes! Nice! You may continue to submit your answer, however you can no longer win. Original post kept for posterity: The "Bzzt" game is a game where you ...
50
votes
10answers
9k views

Build a random number generator that passes the Diehard tests

While there are many code golf questions on here involving randomness, I haven't seen one yet that actually asks for building an algorithmic pseudorandom number generator. There's this one that asks ...
88
votes
23answers
11k views

Programming a Pristine World

Let's define a pristine program as a program that does not have any errors itself but will error if you modify it by removing any contiguous substring of N characters, where ...
28
votes
17answers
9k views

Transform number into 7-segment display pattern

Given two arbitrary numbers A,B. Print number B as a Digital LED Pattern where A is the scale. input: 1 2320451640799518 ouput: ...
25
votes
7answers
3k views

Self-Interpreting Interpreter

Based on a comment by George Edison to this question, write the smallest self-interpreting interpreter. You may use the language of your choosing. Empty languages do not count. Your program must be ...
31
votes
12answers
2k views

Tips for golfing in vim

I've recently realized how vim works great for golfing, especially for kolmogorov-complexity. Also, according to meta vim is a perfectly acceptable 'programming language' at least, for the scope of ...
27
votes
21answers
33k views

List of first n prime numbers most efficiently and in shortest code [closed]

Rules are simple: First n primes (not primes below n), should be printed to standard output separated by newlines (primes should be generated within the code) primes cannot be generated by an inbuilt ...
64
votes
36answers
11k views

Enlarge ASCII art

In this challenge, you must take multiline ASCII art as input, such as: ...
28
votes
5answers
2k views

Advanced Calculator

You must write a program that evaluates a string that would be entered into an advanced calculator. The program must accept input using stdin and output the correct answer. For languages that do no ...
43
votes
20answers
2k views

Tips for golfing in The Shakespeare Programming Language

What general tips do you have for golfing in The Shakespeare Programming Language? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to SPL ...
40
votes
65answers
5k views

Greatest Common Divisor

Your task is to compute the greatest common divisor (GCD) of two given integers in as few bytes of code as possible. You may write a program or function, taking input and returning output via any of ...
28
votes
37answers
4k views

Implement hyperexponentiation/tetration without the use of '^'

The Challenge Implement tetration (aka Power Tower or Hyperexponentiation) with the least amount of characters. The Conditions Don't use the 'power' operator or its equivalents (such as ...
55
votes
35answers
6k views

Print the N-bonacci sequence

This isn't very widely known, but what we call the Fibonacci sequence, AKA 1, 1, 2, 3, 5, 8, 13, 21, 34... is actually called the Duonacci sequence. This is ...
45
votes
18answers
5k views

Sᴍᴀʟʟ Cᴀᴘꜱ Cᴏɴᴠᴇʀᴛᴇʀ

Portable Spec. Iɴꜱᴘɪʀᴇᴅ ʙʏ @ConorO'Brien's ᴜꜱᴇʀɴᴀᴍᴇ. Aʟꜱᴏ ᴛʜᴀɴᴋꜱ ᴛᴏ @Dᴏᴏʀᴋɴᴏʙ ꜰᴏʀ ꜱʜᴏᴡɪɴɢ ᴍᴇ ᴛʜᴇ ᴇxɪꜱᴛᴇɴᴄᴇ ᴏꜰ ǫ ᴀɴᴅ x. Sᴍᴀʟʟ ...
33
votes
76answers
7k views

Notcalc (Calculate the wrong answer)

Goal: Given two natural numbers (integers from 0 to infinity), output a number that is not the sum of those numbers, but is a natural number. Example solutions (TI-Basic): ...
29
votes
41answers
9k views

Will Jimmy fall off his platform?

Backstory Meet my friend Jimmy: /o\ Jimmy is a little character who likes to stand on platforms. Here's Jimmy safely standing on a platform: ...
22
votes
11answers
4k views

Generate a Kolakoski sequence [duplicate]

Definition1 A Kolakoski sequence is a self-describing infinite sequence {kn} of alternating blocks of 1's and 2's, given by the following rules: k0 = 1 kn = the length of the (n+1)'th ...
21
votes
10answers
2k views

Tips for golfing in Lua

What general tips do you have for golfing in Lua? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Lua (e.g. "remove comments" is not ...
21
votes
54answers
6k views

Display number of occurrences for every character in an input string

The code should take a string as input from keyboard: The definition of insanity is quoting the same phrase again and again and not expect despair. The output ...
62
votes
47answers
6k views

N-dimensional N^N array filled with N

In: Enough memory and a positive integer N Out: N-dimensional N^N array filled with N, where N^N means N terms of N-by-N-by-N-by... Examples: 1: [1] ...
29
votes
8answers
3k views

Are you in the biggest room?

Introduction You have recently accepted a job offer at a Pretty Good Software Company. You're pretty content with the size of your office, but do you have the biggest office? Its kinda hard to tell ...
20
votes
5answers
2k views

Calculate π with quadratic convergence

Write a function or complete program that takes a positive number n and performs n steps of an iterative algorithm for ...
16
votes
7answers
657 views

Tips for golfing in Prolog

What general tips do you have for golfing in Prolog? I am looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Prolog (e.g. one letter ...
32
votes
16answers
5k views

Balanced Ternary Converter

Credits for the challenge idea go to @AndrewPiliser. His original proposal in the sandbox was abandoned and since he has not been active here for several months, I have taken over the challenge. ...
21
votes
25answers
2k views

Code-Golf: Permutations

Write a function that takes as input a set of integers (can be a list, array or any other container with distinct numbers), and outputs the list of all its permutations. Python (95 chars): ...
13
votes
6answers
1k views

Golf me an ASCII Alphabet

Don't you find that reading simple text isn't appealing enough? Try our ...
51
votes
24answers
7k views

Minecraft Mirrored

This is Calvin. Just trying to get 20 rep so this user can chat in the PPCG Minecraft Server chatroom. Write a program or function that takes in a positive integer. If the integer is even (2, 4, 6, ....
26
votes
3answers
1k views

Create a rotating quine

A rotation of a string is made by splitting a string into two pieces and reversing their order, for example "world! Hello," is a rotation of ...

15 30 50 per page