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)
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...
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...
Given a string, convert all of its letters using ROT13, and all of its digits using ROT5. This is sometimes referred to as ROT13.5. Input A sequence of printable ASCII characters (character cod...
Given a sequence of lower case letters, sort them into order of height. Heights The heights of letters are dependent on font, so for this challenge the height order to be used is as defined below...
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 ...
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 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 ...
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 ...
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...
Given an integer $N$ in balanced quinary, output the first $N$ characters of your source code if $N$ is positive, or the last $-N$ characters of your source code if $N$ is negative. Terminology ...
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...
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...
This is a fixed output challenge. Output a textual representation of a chessboard hosting 8 queens, none of which are attacking each other. There are 92 ways of arranging them, 12 if rotations and...
This is a fixed output challenge. It is similar to a standard Kolmogorov complexity challenge, except you get to choose your own fixed output. Given no input, output 55 fruits. You may choose any 5...
A chequer board (also spelt "checker board" in some places) is an 8 by 8 grid of squares alternating between 2 colours. Check whether a provided pattern could be a region of a chequer board. The c...
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:...
Challenge A Niven number is a positive integer which is divisible by the sum of its digits. For example, 81 -> 8+1=9 -> 81%9=0. Your task is to find the first n Niven numbers, given n. Te...
Challenge Given an array in any suitable format, create a frequency table for it. i.e: Pair each unique element with the number of times it appears in the array. You can return the frequency tabl...
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...
This challenge is based on the i. verb from J. A range grid is basically a range of m × n numbers fit into a rectangular grid with m rows and n columns. A 2×3 range grid would be: 0 1 2 3 4 5 ...
Looping counter Create an infinite loop that outputs lines of asterisks, with each line containing one more asterisk. Instead of the asterisk, any printable, non-whitespace character can be used. ...
Challenge idea taken from: Eliseo D'Annunzio Task Provide code that evaluates to 0.5 numerically, i.e. the output must be recognized by your chosen language as a numeric value (Number, float, dou...
Many programming languages have the concept of keywords, special syntax items that are not just identifiers reserved by some library, but words reserved by the language itself. The challenge is to...
An integer is called square-free if it is not a multiple of a perfect square other than 1. For example, 42 is square-free, but 44 is not because it is a multiple of the perfect square 4 = 2². Your...
Task Given an IP address as a string, find its IP address class. For reference, here is a table: Class Leadingbits Numberof networks Addressesper network Total addressesin class Start...
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...
[Rule 110] is a Turing complete cellular automaton. It is defined as follows: Take as initial value a sequence of symbols that's infinite to both sides, which consists only of two different symbol...
Your challenge today is to golf a program to interpret something Turing-complete. You may use any Turing-complete system for this so long as it is not the source language of the challenge - even a...
Challenge Make a program that takes input of 3 non-negative integers: a result and 2 other values that once calculated results to the 3rd value. The program must figure out how to get the 2 fir...
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...
As you might know, there were elections in Germany, and now the parties have to form a government coalition. Let's help them with it! A good coalition has the strict majority of seats (that is, mo...
Imagine you have only one byte (8 bits) to store a value, but need to store values from $0$ to $4032$. Impossible, until you are also told that an error of 1/64 of the exact value does not matter. ...
Given a non-negative integer up to $999\,999\,999$, write it in English. The input number can be in any form other than English (though you'll typically want to use the native integer type of your...
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...
The Ludic Numbers are a sequence that pops up when you apply the sieve of eratosthenes to the natural numbers, completely removing the numbers every iteration. Here is how they are generated: The...
Background Check out this video on the Collatz conjecture, also known as A006577. If you don't know what this is, we're given an equation of $3x + 1$, and it is applied this way: If $x$ is odd...
Rational numbers in decimal representation can have an infinite periodic part. One common way to write this down is to repeat the periodic digits and then add three dots. Numbers without those thre...
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...
Challenge Given the roots of a polynomial (that is, the $x$ values where the polynomial evaluates to zero), as an array of real numbers, return the polynomial's coefficients. That is, given real ...
Given a string and a non-negative integer $n$, output a new string in which each character is repeated $n$ times. Test cases: "abc", 1 -> "abc" "Hello", 0 -> "" "double", 2 -> "ddo...
Background Inspired by this challenge that is also a mathematical English translator. Challenge Write a program that translates a mathematical expression using English with the following specifi...
Inspired by this challenge. If anyone has any suggestions for a song title I could use for the challenge title then please leave a comment. Definition We define f(x) for a given integer as the su...
Challenge Make a program that takes input of an integer that's $n > 1$ and print out a staircase using a specific character for stair basing (hashes (#) for demonstration; you can use spaces,...
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 ...
Background While we do have a "Hello, World!" challenge, we still don't have one regarding input. So let's do one! Challenge Create a program that takes an input (not as a function argument) the...
Challenge We all know and love the generic sort function, right? However, it only sorts based off one criterion - what if we want more? That's where you come in. Your task is to sort an array bas...
Challenge What do computers understand? That's right, binary. All files are turned into binary digits when you run them, but what if I suggest giving you an int then turn it into it's binary value...