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)
About Negabinary Negabinary means base negative two (-2). That is, the $n$th place value is determined by $(-2)^n$. Negabinary numbers can be evaluated just like any other base system. For exampl...
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 You will be given a string and an ascii art as input. The string must be placed above the ascii art, and centered based on its longest line. The text BOTTOM TEXT must be placed below...
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...
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...
Abundant numbers are numbers which are less than their proper divisor sum. For example $18$ is abundant as $1 + 2 + 3 + 6 + 9 = 21 > 18$ Deficient numbers are numbers which are greater than the...
Write the shortest program that takes no input and outputs a Sudoku solution. For reference, a Sudoku solution is a 9x9 grid of digits where each column, each row and each of the nine 3x3 grids th...
Originally from Somewhere Else. I thought I'd continue making more drawing challenges here now that I discovered it. Make the Stack Overflow logo using the following criteria: The tray: ...
Task Print the following: ABDFHJLNPRTVXZ CABDFHJLNPRTVX ECABDFHJLNPRTV GECABDFHJLNPRT IGECABDFHJLNPR KIGECABDFHJLNP MKIGECABDFHJLN OMKIGECABDFHJL QOMKIGECABDFHJ SQOMKIGECABDFH USQOMKIGE...
Definitions A binary tree is either a null (leaf), or an object (node). A node contains a value (non-negative integer) and two pointers (left and right) to two separate binary trees. A binary tre...
Given an integer n, output the smallest prime such that the difference between it and the next prime is at least n. For example, if n=5, you would output 23, since the next prime is 29, and 29-23&...
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...
Note: This challenge was underspecified and bad, and as such I would not encourage answering it in the future. Challenge You will be given a single 2D boolean array $M$. You may take its dimensi...
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 ...
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...
[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...
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...
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 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...
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...
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...
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...
Introduction The Pell(no, not Bell) Numbers are a simple, Fibonacci-like sequence, defined by the following relation: $P_n=\begin{cases}0&\mbox{if }n=0;\\1&\mbox{if }n=1;\\2P_{n-1}+P_{n-2...
The task is to generate the text of Lewis Caroll's Jabberwocky. The text, quoted from Wikipedia, is as follows (I've replaced a non-ASCII character with ASCII, otherwise it's direct copy&paste...
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 Given a date with day, month and year, calculate how old a person born on that day would be today. Input can be in any reasonable format(params, array, date object). Input will never b...
You have an army of size $n$ that you need to split up to fight $k$ battles simultaneously against an opposing army $A$. In each battle, the army with the most troops present wins - no one wins a t...
The task Given a positive integer as input, output tiled pyramids of this height. How? Let's say the inputted integer was n. From there, we output n lines of output, each having: A decreasing...
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...
Introduction What is the Caesar shift cipher (ROT$n$)? It's basically a cipher sequence that changes a letter's value from the number chosen. If we use ROT1 on "games", we get "hbnft". The basic 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 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 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...
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...
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 ...
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...
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...
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 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...
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...
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. ...
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 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...
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...
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...
Given a musical key, output its number and letter on the Camelot Wheel (shown below). Input A musical key as a string, as shown on the wheel. The words "Sharp" and "Flat" may be replaced with s...
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...
Given an array of numbers, output the length of the longest increasing (not necessarily contiguous) subsequence. It is guaranteed that there are no duplicates in the array. For example, if the inpu...
- ← Previous
- 1
- 2
- 3
- 4
- Next →