All Questions

Filter by
Sorted by
Tagged with
21 votes
58 answers
3k views

Find the occurrences of a character in an input string

Challenge Write a program that, given a string x which is 10 characters long and a character y, outputs the number of times ...
rosslyn taghoy's user avatar
20 votes
5 answers
3k 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 ...
aditsu quit because SE is EVIL's user avatar
19 votes
1 answer
719 views

Advent Challenge 1: Help Santa unlock his present vault!

Next >> Descriptive Keywords (for searching): Make Two Matrices Equivalent, Overlap, Array, Find Challenge Santa has had a history of elves stealing presents from his vault in the past, so this ...
hyper-neutrino's user avatar
  • 41.3k
18 votes
10 answers
991 views

Tips for golfing in Pip

Pip is an imperative golfing language with infix operators. It also borrows some features from functional and array programming. What general tips do you have for golfing in Pip? I'm looking for ...
DLosc's user avatar
  • 38k
13 votes
3 answers
1k views

Polynomial Interpolation

Write a program that performs Polynomial Interpolation using true arbitrary precision rational numbers. The input looks like this: f(1) = 2/3 f(2) = 4/5 f(3) = 6/7 ... You may assume that there's ...
FUZxxl's user avatar
  • 10.1k
11 votes
16 answers
3k views

Give me the Gray Code list of bit width n

The Gray Code is a sequence of binary numbers of bitwidth n where successive numbers differ only in one bit (see example output). Reference Example input: ...
ToonAlfrink's user avatar
  • 1,276
11 votes
25 answers
3k views

Cartesian product of a list with itself n times

When given a a list of values and a positive integer n, your code should output the cartesian product of the list with itself n ...
JoshM's user avatar
  • 447
430 votes
23 answers
148k views

Build a Compiler Bomb

Introduction You're probably familiar with zip bombs, XML bombs, etc. Put simply, they are (relatively) small files which produce enormous output when interpreted by naïve software. The challenge ...
Dave's user avatar
  • 8,451
390 votes
36 answers
71k views

American Gothic in the palette of Mona Lisa: Rearrange the pixels

You are given two true color images, the Source and the Palette. They do not necessarily have the same dimensions but it is guaranteed that their areas are the same, i.e. they have the same number of ...
Calvin's Hobbies's user avatar
382 votes
110 answers
89k views

Most creative way to display 42

Douglas Adams was born on March 11, 1952, and died when he was just 49. In honor of this wonderful writer, I challenge you to display 42 in the most creative way possible. You could print it in the ...
Milo's user avatar
  • 3,062
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 "...
Nicola Sap's user avatar
  • 2,711
219 votes
89 answers
39k views

Make your language unusable

Try to write some code in your language and make it not satisfying our criteria of being a programming language any more. A language satisfies our criteria (simplified version for this challenge) of ...
jimmy23013's user avatar
  • 36.9k
192 votes
175 answers
20k views

What is the smallest positive base 10 integer that can be printed by a program shorter (in characters) than itself?

I think the question as above is clear, but just in case: Write a full program (not just a function) which prints a positive base 10 integer, optionally followed by a single newline. Qualifying ...
Arandur's user avatar
  • 1,939
167 votes
70 answers
24k views

How high can you count?

Challenge: Your task is to write as many programs / functions / snippets as you can, where each one outputs / prints / returns an integer. The first program must output the integer ...
Stewie Griffin's user avatar
148 votes
245 answers
29k views

Unscramble the Source Code

Note: This challenge is now closed to new cop submissions. This is to ensure that no one can post submissions that only remain uncracked because there aren't enough robbers interested in the challenge ...
PhiNotPi's user avatar
  • 29k
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 ...
Leaky Nun's user avatar
  • 49.6k
105 votes
65 answers
12k views

Find an Illegal String

The challenge is to find a string of characters that cannot appear in any legal program in your programming language of choice. That includes comments, strings, or other "non-executable" parts. ...
nneonneo's user avatar
  • 12.3k
104 votes
131 answers
20k views

Shortest code to produce non-deterministic output

You need to produce output that is non-deterministic. In this case, this will be defined to mean that the output will not always be the same result. Rules: A pseudo-random number generator that ...
mbomb007's user avatar
  • 23.3k
101 votes
79 answers
17k views

The Rock, Paper, Scissors, Lizard, Spock Tournament of Epicness

Most Recent Leaderboard @ 2014-08-02 12:00 ...
Eoin Campbell's user avatar
83 votes
192 answers
10k views

Output the sign

Given a number N, output the sign of N: If N is positive, output 1 If N is negative, output -1 If N is 0, output 0 N will be an integer within the representable range of integers in your chosen ...
user avatar
73 votes
155 answers
13k views

Print X without X (cop's thread)

This is the cop's thread of a cops-and-robbers challenge. You can view the robber's thread here A pretty common beginner style question is to print some string, but there's a catch! You need to do it ...
Wheat Wizard's user avatar
  • 96.5k
67 votes
62 answers
4k views

Count trailing truths

Inspired by, and in memory of, my dear friend and colleague, Dan Baronet, 1956 – 2016. R.I.P. He found the shortest possible APL solution to this task: Task Given a Boolean list, count the number of ...
Adám's user avatar
  • 29.9k
67 votes
20 answers
7k views

Just repeat yourself

Write a program that outputs Do not repeat yourself! Your program code must respect the following constraints : its length must be an even number each ...
Arnaud's user avatar
  • 8,503
66 votes
47 answers
5k views

User Appreciation Challenge #1: Dennis ♦

I got the spontaneous idea of making a series of challenges of users that have helped and continue to help the PPCG community be an enjoyable place for everyone, or maybe just specifically for me. :P ...
hyper-neutrino's user avatar
  • 41.3k
59 votes
100 answers
8k views

Find the smallest number that doesn't divide N

This challenge is simple enough that it's basically all in the title: you're given a positive integer N and you should return the smallest positive integer which is not a divisor of N. An example: the ...
Martin Ender's user avatar
56 votes
16 answers
8k views

Extreme Fibonacci

There have been a billion iterations of Fibonacci challenges on this website, so lets spice things up with a Fibonacci challenge of a billion iterations! Your challenge is to output the first 1000 ...
user1502040's user avatar
  • 3,599
55 votes
9 answers
11k views

Golf a number bigger than TREE(3)

The function TREE(k) gives the length of the longest sequence of trees T1, T2, ... where each vertex is labelled with one of k colours, the tree Ti has at most i vertices, and no tree is a minor of ...
PyRulez's user avatar
  • 7,207
54 votes
49 answers
26k views

Outputting ordinal numbers (1st, 2nd, 3rd)

I would like to generate (as a return result of a function, or simply as the output of a program) the ordinal suffix of a positive integer concatenated to the number. Samples: ...
Nicole's user avatar
  • 643
53 votes
11 answers
4k views

Unfolding the Hexagony source code

Introduction If you're not familiar with Hexagony, it's an esoteric language created by Martin Büttner. The thing is that this language accepts multiple forms for the program. The following programs ...
Adnan's user avatar
  • 44.3k
51 votes
48 answers
4k views

Count sums of two squares

Given a non-negative number n, output the number of ways to express n as the sum of two squares of integers ...
xnor's user avatar
  • 144k
49 votes
97 answers
5k 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. ...
Leo's user avatar
  • 12.4k
49 votes
50 answers
19k views

Display random colored pixels

I've always liked screens full of randomly colored pixels. They're interesting to look at and the programs that draw them are fun to watch. The challenge Fill your screen, or a graphical window, ...
MD XF's user avatar
  • 13.8k
49 votes
48 answers
10k 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 ...
user avatar
48 votes
83 answers
4k views

Type uniqchars!

Given a string consisting of printable ASCII chars, produce an output consisting of its unique chars in the original order. In other words, the output is the same as the input except that a char is ...
Luis Mendo's user avatar
  • 104k
46 votes
10 answers
2k views

Zigzagify a String

Write a program (or function) that takes in a non-empty string of any printable ASCII characters. Print (or return) a zigzagging chain of the characters in the string with every neighboring pair of ...
Calvin's Hobbies's user avatar
46 votes
3 answers
7k views

Radiation Hardened Quine

As you should (hopefully) know, a radiation hardened quine is a quine that you can remove any one character from and still print its original, pre-modified source. The thing is, with most of these you ...
takra's user avatar
  • 843
44 votes
90 answers
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): ...
Julian Lachniet's user avatar
44 votes
68 answers
8k views

I reverse the source code, you negate the input!

Blatant rip-off of a rip-off. Go upvote those! Your task, if you wish to accept it, is to write a program/function that outputs/returns its integer input/argument. The tricky part is that if I ...
Adám's user avatar
  • 29.9k
43 votes
9 answers
6k views

Text compression and decompression — "Nevermore."

With the recent discussion about the use of compression tools in code golf, I thought it would be a nice challenge to write your own text compressor and decompressor. Challenge: Write two programs: ...
Ilmari Karonen's user avatar
40 votes
89 answers
11k views

Add without addition (or any of the 4 basic arithmetic operators)

Problem: Your goal is to add two input numbers without using any of the following math operators: +,-,*,/. Additionally, you can't use any built-in functions that ...
TheDoctor's user avatar
  • 7,989
40 votes
87 answers
6k views

Generate ;# code

Related to: Make a ;# interpreter In the above linked challenge the task was to create an interpreter for the esoteric language ;#. The ...
kalsowerus's user avatar
  • 2,014
39 votes
62 answers
6k views

Zeroes at the end of a factorial

Write a program or function that finds the number of zeroes at the end of n! in base 10, where n is an input number (in any ...
Arcturus's user avatar
  • 7,349
37 votes
29 answers
6k views

Find the number in the Champernowne constant

Introduction In base 10, the Champernowne constant is defined by concatenating representations of successive integers. In base 10: 0.1234567891011121314151617... ...
Adnan's user avatar
  • 44.3k
36 votes
49 answers
5k views

Generate Monday Numbers

Monday numbers, as defined by Gamow in this question over on Puzzling, are positive integers N with the following three properties: The decimal representation of N does not contain the digit 0 The ...
AdmBorkBork's user avatar
  • 43.3k
35 votes
38 answers
4k views

Is it Christmas?

Challenge Given that Christmas is: December Month 12 Day 25 Every year, determine today's date, and whether or not today is Christmas. If it is Christmas, you must print ...
Patrick Perini's user avatar
34 votes
9 answers
3k views

Who's that Pokémon? [closed]

Input: an integer N between 1 and 151 Output: the Nth Pokemon. Rules You may use one data file. You may not use any already made data decompression algorithms. This includes libraries and other ...
cardboard_box's user avatar
34 votes
40 answers
6k views

Render "Digital Clock Style" Numbers

Write the shortest program which will take a string of numbers (of up to at least 20 length) as input, and display the output using the standard digital clock style numbers. For instance for input 81,...
mootinator's user avatar
  • 1,199
33 votes
5 answers
2k views

Chain reaction of bombs

Introduction: Before the task, here is what every element does on the map: Plain land (X): This does nothing. Destroyed land (...
Adnan's user avatar
  • 44.3k
32 votes
46 answers
8k views

Mode (most common element) of a list

Write a snippet to calculate the mode (most common number) of a list of positive integers. For example, the mode of d = [4,3,1,0,6,1,6,4,4,0,3,1,7,7,3,4,1,1,2,8] ...
garg10may's user avatar
  • 709
31 votes
15 answers
3k views

List all multiplicative partitions of n

Given a positive number n, output all distinct multiplicative partitions of n in any convenient format. A multiplicative partition of n is a set of integers, all greater than one, such that their ...
orlp's user avatar
  • 39k

15 30 50 per page
1
3 4
5
6 7
93