Code challenges of all types. For questions about golfing, bowling, etc, use Q&A. For questions about this community, use Meta. To get feedback on a challenge before posting it, use Sandbox.
Filters (None)
Let's imagine a point in three dimensional space. We will start it located at $(0,0,0)$. Then we will receive a series of instructions. x, y, and z indicate moving unit distance in the positive $x$...
Given a string of Roman numerals, decide whether it forms a valid Roman number. If not, output the substring that proves this, from the list of 50 strings described below. Relevant fact This chal...
Recently I asked for tips on improving some code-golf of mine. The code was supposed to output every third value of the Fibonacci sequence starting with 2: 2,8,34,144,610,2584,10946,46368,196418,...
Convert a number in words to digits. Input A number in words from one to ninety-nine. Output The corresponding number in digits from 1 to 99. This may be a string of digits or a number o...
Input The name of a polygon. You are only required to handle inputs listed in the test cases. Output The number of edges the polygon has. Test cases Test cases are in the format input...
Output the Nth number in the list of Fibonacci numbers that have no consecutive digits. Input A non-negative integer (if you treat the Fibonacci numbers as zero-indexed) or a positive integer (...
Given a list of non-negative integers the function $f$ replaces every integer with the number of identical integers preceding it (not necessarily contiguously). So f [1,1,2,2,1,3,3] = [1,2,1,2,3,1...
Given a single character, which is a valid Roman numeral, output its value. Values There are 7 valid single character Roman numerals, with the following values: Character Value I...
Simple challenge: Read a byte, swap bit 7 with 0, 6 with 1, 5 with 2 and 4 with 3 and then output the byte. For example the byte 0b1001'1100 would turn into 0b0011'1001. Rules: Shortest code wi...
You roll $N$ six-sided dice simultaneously. Your score is the highest number rolled. If you play this game many times, what is the expected value (mean) of your score? Input A positive integer ...
The task is to create a program which displays a golf score as text. It takes 2 numbers as input, separated by space or new line: The first number is the par of the specific hole. The second nu...
Run-length encoding is a simple compression technique which compresses sequences of repeating identical bytes. The encoding rules for this task are as follows: Any sequence of $n$ identical bytes...
Challenge Write a program that prints its reversed self. For example, if your code is foo() Then it'll output: )(oof Make sure that the quine is a valid one, as defined here: No cheatin...
Challenge Make a program that takes input of a string and abbreviate it. All letters of an abbreviation are capitalized, so keep that in mind. Whitespace, numbers and non-English characters ar...
Inspired by this Rosetta Code article. Introduction Balanced Ternary is a method of representing integers using -1, 0 and 1 in base 3. Decimal 11 = (1 * 32) + (1 * 31) + (−1 * 30) = [1,1,-1] or ...
Challenge This is a simple randomness challenge: Given a non-negative integer $n$, and positive integer $m$, simulate rolling and summing the results of $n$ fair dice, each of which have $m$ sides...
The squares of a 5 by 5 chessboard are labelled with the letters A to Y in English reading order: A B C D E F G H I J K L M N O P Q R S T U V W X Y Determine whether a string is a knight's ...
Indicate whether a letter is an HTML element. Input A single lowercase letter. Output An indication of whether the input is a standard HTML element. This could be one of 2 distinct value...
Define a cool number as a number whose proper divisors (all except for the number itself) have an integral mean. Define a really cool number as a number whose divisors (including itself) are all co...
A Juggler sequence is a sequence that begins with a positive integer $a_0$ and each subsequent term is calculated as: $$a_{k+1} = \begin{cases} \left \lfloor a_k ^ \frac 1 2 \right \rfloor, &...
Definition $F_{n}\left(0\right)=0$ $F_{n}\left(1\right)=1$ $F_{n}\left(x\right)=n\cdot F_{n}\left(x-1\right)+F_{n}\left(x-2\right)$ For example: $F_{1}=\left[0,1,1,2,3,5,8,13,21,34,55,89...\ri...
Two words are anagrams of each other if the letters of one can be reordered to spell the other; e.g. ADOBE and ABODE are anagrams. An alternate way of describing it is that both words contain the s...
Task Given a list of numbers $X$ produce a second list of numbers $Y$ such that $Y_i$ is the length of the longest common prefix of $X$ and $X$ with the first $i$ elements removed. For example if...
Goldbach's Conjecture states that every even whole number greater than 2 is the sum of 2 prime numbers. Your task is to return those 2 prime numbers, given an even whole number as input. There are ...
A Sturmian sequence is an infinite binary sequence satisfying two properties: It is balanced. This can be stated a number of equivalent ways: There is no pair of equal length subwords whose d...
The Universal Crossword has a set of guidelines for crossword puzzle submissions. In this challenge we are going to be concerned with their rules for hidden word themes. A hidden word clue consis...
A finite binary string is "Sturmian" if for every two contiguous substrings $x$ and $y$ of the same length, the number of $0$s in $x$ and $y$ differs by at most 1. Your program should take a finit...
Get ready for a comparatively dry question - this is intended to be one of the "the"s of the code-golfing dictionary. Create a program which inputs a base 10 non-negative whole number (without lea...
Indicate whether the 1s and 0s in an 8 by 8 grid are connected. The grid Connectedness is by orthogonal adjacency (up, down, left, right). Diagonal adjacency does not count. If all of the 1s ...
Challenge Given two strings a and b, return the shortest string s so that s starts with a and ends with b. (Inspired by https://chat.stackexchange.com/transcript/message/57816868#57816868 ) Exam...
Given an integer, output the number of lone 1s in its binary representation. Input An integer from $0$ to $4294967295$ (that is, $2^{32}-1$). In binary that's from 00000000000000000000000000000...
Print or return this exact text: 0 0 0 0 1 0 0 1 1 0 0 1 2 1 0 ...
Challenge Output the following text: A ABA ABCBA ABCDCBA ABCDEDCBA ...
How many digits of $\pi$ can you fit into a square root? Rules Your answer is a non-negative integer $N$. Highest score wins. Your score is the number of initial digits after the decimal poin...
Jelly has an atom called untruth, which when given indices, creates an array with 1s at those places: [2,4] → [0,1,0,1]. You are required to perform the inverse of this. Given a 2D boolean array, ...
In Google Docs, the word count tool looks like this: Pages would not make sense, but your goal is to implement every other count. Definitions Words are strings of text separated by any amount ...
Multiply complex numbers. 2 space-seperated ones will be input, as follows: (update: you can replace i with j or some other symbol if needed) a+bi -a+bi a-bi -a-bi where a and b are integers ...
Idea shamelessly stolen from caird and rak1507 Shuffle a subset of a list of unique, positive integers with uniform randomness, given the indices of that subset. For example, given the list $[A, B...
Create a program P1 which takes as input a base 10 number N1 (the numbers for the variables are important). Given N1, P1 will print a program P2. P2 will take as input a base 10 number N2 and outpu...
Challenge Given a list of integers >= 0 , check if all of them are equal. Tests [1,1,1,1,1] -> true [0,1,1,6,7] -> false [1] -> true [] -> undefined(you do n...
Challenge Given a list of unique colour names as input, sort them in the order that they first appear in Joseph's Amazing Technicolour Dreamcoat. Example Input: green, blue, red, brown Outpu...
Create a program that gets all perfect squares starting from 0 or 1 without using any methods of multiplication (repetitive addition) and exponentiation (repetitive multiplication). Output them for...
Connect opposite corners of a rectangle of characters without putting 4 characters in a row. Input Two numbers, W and H, representing the width and height of the rectangle Each number will be ...
In this challenge you will take a number $n$ and a string $X$ of length $\geq n$, and produce a regular expression which matches all strings that are within $n$ character substitutions of $X$. Spe...
Your answer is a string containing 255 fishes as subsequences, and your score is the length of that string in bytes (lowest score wins). Rules Your string must include at least 255 fishes from ...
Given a radius R, output a text representation of a circle. Input A positive integer R (strictly greater than zero) You do not need to handle values of R greater than 32 Output A square ...
Given a word that can be rotated by 180 degrees (a half turn) about at least one of its 3 axes and continue to be composed of English alphabet letters, output one of its rotated forms. The 3 rotat...
Given 3 points, output one that is separated from its nearest neighbour by the largest distance. Input 3 distinct points (that is, no 2 points are in the same position). Each point is a pair o...
Does a number have balanced numbers of distinct digits? That is, do the number's digits appear with equal frequency? Input A positive integer N. N will have no leading zeroes. Output An ...
Given a positive integer, count its odd digits. Input An integer from 1 to 999,999,999, inclusive, in any of the following formats: A number (such as an integer or floating point number), li...
