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)
Given a positive integer, indicate whether it is the product of its proper divisors. Integers equal to the product of their proper divisors can be found on the Online Encyclopedia of Integer Seque...
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...
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...
Given a hexomino, indicate whether it is a net of a cube. Input A 6 by 6 grid containing exactly 6 filled squares. The 6 filled squares will be in a single edge connected set (a hexomino). Th...
The challenge is to write as short a source as possible, where the English alphabet (in alphabetical order from top to bottom) "abcdefghijklmnopqrstuvwxyz" is a sub-sequence of the source code. Th...
In this challenge you will take an Irish word and a personal pronoun and create the possessive pronoun construction combining the two. For example sé, madra becomes a mhadra. Translated to English...
You work in a kitchen which has a peculiar rule. When you mix something into a pot you must always add at least one new ingredient. So you can add pasta, oil, salt then pesto, but not pasta, pesto...
Your mission for today, should you choose to accept it, is to write a simple 12-hour clock calculator. Your input will always be in the form of arg op arg, where op is either + or -, and arg is eit...
Given 3 positive integers, indicate whether they are Borromean coprimes. Definition 3 positive integers are called Borromean coprimes if both of the following are true: Their greatest common d...
Does a positive integer have a substring as a factor? Input A positive integer. Output One of 2 distinct values to indicate whether the input has a factor that is a strict substring of it...
Given an integer from 1 to 1000, indicate whether it is a centered hexagonal number[1] (also known as a hex number). What is a hex number? The hex numbers can be visualised as follows: On a he...
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...
Find the shortest representation of an integer in generalised Roman numerals. Since there is more than one way to generalise, only the following definition applies to this challenge. Definition T...
$N$ vessels initially contain $3$ stones each. What is the probability of having at least $3$ stones in the first vessel after moving a uniformly random selection from the first vessel to the secon...
DC is a reverse-Polish calculator REPL that is available on most Linux distributions. In reverse-Polish notation, you can push values to a stack and then pop those values back off to perform operat...
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...
The probability of rolling every number from 1 to 6 with $N$ six-sided dice. Input A positive integer $N$. Your code must work for inputs up to and including 10, but may crash, error, or give ...
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...
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...
At my job we have to sometimes lay out materials. Materials come in large long rolls and are cut into smaller pieces when being laid out. When we order the rolls we draw up a layout document which...
The Challenge Your job is to, given input positive non-zero integer $n$, output an ASCII representation of the tiled Fibonacci squares up to the $n$th number of the Fibonacci sequence. Rules Inp...
You work at a beach. In the afternoon, the sun gets quite hot and beachgoers want to be shaded. So you put out umbrellas. When you put out umbrellas you want to shade the entire beach, with as few ...
Given a hinged tetromino, give it a unique, consistent label independent of location, rotation, and reflection. Tetrominoes A tetromino is a connected subset of the square tiling, composed of 4 s...
Given two binary strings $A$ and $B$ such that $A$ is an anagram of $B$, output a third binary string $S$ such that both $A$ and $B$ can be created by iterated removals of the substring $10101$ fro...
Your task is to write a program $p$ which outputs a string $s$ with the same length as $p$, where $s \neq p$. If I remove the $n$th byte from your program to get program $q$, then either $q$ outpu...
You are a low-level censor working for the Ministry of Media Accuracy. Part of your job is to make sure that certain words don't appear in publications. Every morning you get a fresh stack of next...
Suggest a word from a word list, given a string. Motivation Imagine typing a word one letter at a time, and seeing a suggested word after each letter is typed. At first the suggested word is simp...
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...
Goal Print the modular multiplicative inverse with a modulus of 65536 (or a higher exponent of 2) for odd numbers 1-97. Example output Print these values (or an extension of them): 1 43691 52...
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,...
This is a language specific challenge, for HTML only. Your answer is the content of a self contained HTML file, that when opened in a web browser gives a plain black page. Requirements The HTM...
Convert a matrix or grid of digits to its antitranspose. For a square matrix , this is its reflection in its antidiagonal. More generally, for a rectangular matrix, this is its reflection in its sk...
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 withing $n$ character substitutions of $X$. Sp...
Given a number $n \geq 3$ as input output the smallest number $k$ such that the modular residues of $k$ by the first $n$ primes is exactly $\{-1,0,1\}$. That is there is a prime in the first $n$ p...
Task You are going to take three strings as input $A$, $B$ and $X$. And your goal is to determine if there exists a third string $S$ such that both $A$ and $B$ can be formed by iteratively removin...
Given a chess board with some knights on it, say how many squares are neither attacked by a knight nor containing a knight. Input An 8 by 8 grid where each square is either a knight or empty T...
Input is a number, you have to decide if it is part of the mandelbrot set or not, after at least 16 iterations. This is done by applying this formula: $z_n = z_{n-1}^2 + c$ repeatedly. $c$ is the ...
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...
import requests import json import numpy as np import base64 import cv2 Replace this with the actual image path you want to test image_path = 'H_L_.jpg' Read and preprocess the image image ...
Given a grid of numbers, mark the concentric areas around nonzero elements (beacons) decreasing from the value of the beacon till 1. For example, here are some grids with a single beacon: Size 1:...
Given a positive integer as input, indicate which base from 2 to 16 gives the most holes in the representation of the input in that base. The digits used are 0123456789ABCDEF. Note that these incl...
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 ...
Given a sequence of letters, omit those with the highest or lowest pop count. Terminology The pop count or population count of a binary string is the number of 1s in it. For this challenge, the ...
An $n$-polyomino is a connected subset of the square tiling consisting of $n$ squares. We will not require that polyominos be simply connected, that is they can have holes. We will say a $n$-polyo...
The problem Someone has created an encoding format for square bit matrices, however they have found it isn't perfect! One encoding may not decode to exactly one matrix, or it may not even be possi...
Given a string of printable ASCII characters, convert them all to lowercase, except not just the letters. ASCII characters that are letters have a bit in their binary representation that is 0 for ...
Challenge It's a bootstrapping challenge this time! Write a full program that, once run, writes the source code of another program that in turn, once run, writes the source code for another progra...
Given a sequence of letters, output only the vowels. Input A sequence of letters This may be a string or any ordered data structure of characters (provided it is consistent between inputs) Th...