text
stringlengths
180
608k
[Question] [ We do seem to have a [fastest square root](https://codegolf.stackexchange.com/q/85555/66833) challenge, but it's very restrictive. In this challenge, your program (or function) will be given an arbitrarily sized nonnegative integer, which is the square of an integer. **Input** You may take input in any...
[Question] [ # Contest permanently opened - Updated August 10th 2017 Even though on June 5th 2017 I declared a winner (who will be kept as the best answer) I'll be rnning new bots and updating the results. # June 5th Results Congratulations [user1502040](https://codegolf.stackexchange.com/users/18957/user1502040) S...
[Question] [ ## Description All cubic equations can be solved, and every cubic has at least one solution. The goal of this challenge is to find the real solutions to a given cubic using inputs, and (obviously) the smallest program size. ## Rules The solution must find the real solutions of a cubic correctly, using ...
[Question] [ Part of [**Advent of Code Golf 2021**](https://codegolf.meta.stackexchange.com/q/24068/78410) event. See the linked meta post for details. Related to [AoC2017 Day 6](https://adventofcode.com/2017/day/6). --- A debugger program here is having an issue: it is trying to repair a memory reallocation routin...
[Question] [ Your task, if you wish to accept it, is to write a program that outputs its own source code in the binary **UTF-8** representation. # Rules * The source must be at least 1 byte long. * Your program must *not* take input (or have an unused, empty input). * The output may be in any convient format. * Op...
[Question] [ ## Introduction: [![enter image description here](https://i.stack.imgur.com/SnMxA.jpg)](https://i.stack.imgur.com/SnMxA.jpg) (Source: [Wikipedia](https://en.wikipedia.org/wiki/Rainbow)) When we look at a rainbow it will always have the colors from top to bottom: Red; orange; yellow; green; blue; in...
[Question] [ The task in this challenge is to put elements of an array into time bins. The input will be a non-decreasing array of positive integers representing the time of events, and an integer which represents the size of each bin. Let us start with an example. We call the input array `A` and the output array `...
[Question] [ Given the following Python 3 script: ``` def greet(): print("Hello, world!") greet() ``` ***Prepend*** some lines to this text file so that it can be both executed as a Python program as well as compiled and run as a C++ program producing the same output **Hello, world!** (including the newline at ...
[Question] [ **Closed.** This question is [off-topic](/help/closed-questions). It is not currently accepting answers. --- Questions without an **objective primary winning criterion** are off-topic, as they make it impossible to indisputably decide which entry should win. Closed 6 years ago. [Improve this quest...
[Question] [ # Task Write a function/full program that will be able to produce two different sequences of integers in `[0, ..., 9]`. You will take an input `seed` to decide whether to output your `s`pecific sequence or the `c`ommon one. For that matter, you must choose one non-negative integer, let us call it `k`. ...
[Question] [ # Challenge For a given positive integers range, find the first and last prime number entirely composed of prime number digits, exceptionally including 0 (for the **digits**, a range of 0-2 should output 2-2). The range is inclusive. If no number is found, the expected output is 0. If there is only one...
[Question] [ # Goal Given an input number, round it off to the nearest number with one significant figure. # Requirements ## Input * A floating point number. * Assume the input number results in an output within the data type's limits (ie. ignore overflow errors.) * 0 is an invalid input. * Numbers that cannot be a...
[Question] [ Alright, my second attempt at a code golf, let's see how this goes. Pretend you have a 3x3 grid of digits, from 0 to 8: ``` 0 | 1 | 2 ---+---+--- 3 | 4 | 5 ---+---+--- 6 | 7 | 8 ``` Return the neighbors the input has as indexes of the array. **Rules:** * It's code golf, so shortest answer wins. * Th...
[Question] [ ## Introduction Alphabet challenges are in our DNA, so let's show it. ## Challenge Print the following the text exactly: ``` AaBbCc cCbBaA BbCcDd dDcCbB EeFfGg gGfFeE HhIiJj jJiIhH KkLlMm mMlLkK NnOoPp pPoOnN QqRrSs sSrRqQ TtUuVv vVuUtT WwXx ...
[Question] [ The goal of this Code Golf is to create a program that sorts a list of strings (in ascending order), **without using any built-in sort method** (such as `Array.Sort()` in .NET, `sort()` in PHP, ...). Note that this restriction excludes using a built-in method that sorts an array descending, and then re...
[Question] [ **Closed**. This question needs [details or clarity](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** Add details and clarify the problem by [editing this post](/posts/5131/edit). Closed 7 years ago. [Improve this question](/posts/5131/edit) ##...
[Question] [ Make a program that outputs a sequence of integers so that every finite sequence of positive integers is a substring (continuous subsequence) of the output. For example, the following sequence satisfies the rules: `1,1,1,2,1,1,1,1,2,2,1,3,1,1,1,1,1,1,2,1,2,1,1,3,2,1,1,3,1,4,...` To see the underlying p...
[Question] [ The challenge is to write the fastest code possible for computing the [Hafnian of a matrix](https://en.wikipedia.org/wiki/Hafnian). The Hafnian of a symmetric `2n`-by-`2n` matrix `A` is defined as: $$\operatorname{haf}(A)=\frac{1}{n ! 2^n} \sum\_{\sigma \in S\_{2 n}} \prod\_{j=1}^n A\_{\sigma(2 j-1), \...
[Question] [ # Task Given two integers \$d\$ and \$n\$, find the number of ways to express \$n\$ as a sum of \$d\$ squares. That is, \$n = r\_1^2 + r\_2^2 + ... + r\_d^2\$, such that \$r\_m\$ is an integer for all integers \$1 ≤ m ≤ d\$. Note that swapping two **different** values (e.g. \$r\_1\$ and \$r\_2\$) is co...
[Question] [ How many of you that still use your own knuckle to determine whether a month is having a full 31 days or less? You job is to write a program to count how many months, in a month range, are having a full 31 days and how many are having less than 31 days by "counting the knuckles". [![Counting days of mo...
[Question] [ ## The Challenge Implement a function which accepts two integers whose values range from 0 - 255 and returns the sum of those integers mod 256. You may only use bitwise negation (~), bitwise or (|), bit shifting operators (>>,<<), and assignment (=). Things you cannot use include (but are not limited t...
[Question] [ Create a BCD [binary clock](http://www.thinkgeek.com/homeoffice/lights/59e0/) in ASCII. As implied, it shall display time in six columns of dots: [![Binary Clock](https://upload.wikimedia.org/wikipedia/commons/thumb/2/27/Binary_clock.svg/480px-Binary_clock.svg.png)](https://upload.wikimedia.org/wikiped...
[Question] [ [Robbers thread](https://codegolf.stackexchange.com/questions/241381/find-my-other-token-robbers) Cops, Choose two strings of code, one public and one secret. We will call them P and S. You will be writing a program using only repetitions of these strings. For example: if you choose P=`hello`and S=`wor...
[Question] [ ## Challenge You are given three integers as input - `min_value, max_value, sample_size`, that you can pass to your answer as either array or several parameters. Your task is to **output a diagram in any convenient format**, that shows the frequency of numbers in the `(min_value, max_value)` range show...
[Question] [ # The Challenge Given a grid of numbers (10 <= N <= 99) Return number with the highest sum of the four numbers adjacent to it; that is the numbers above, below, right, and left of the number, but not itself. 1. The number itself does not count, only its four neighbors. 2. A number on the edge *should* ...
[Question] [ > > This is a [cops-and-robbers](/questions/tagged/cops-and-robbers "show questions tagged 'cops-and-robbers'") challenge, the cops thread can be found [here](https://codegolf.stackexchange.com/questions/137379/seeking-secret-swapping-sequences). > > > This is the robbers thread, your job here is t...
[Question] [ Given a string `s` and a positive integer `N`, gradually duplicate each character more and more until `N` duplicates, and then staying at `N` duplicates until `N` characters away from the end, then step down again. For example, given `abalone` and `3`: ``` a we start with 1 copy bb then 2 copies a...
[Question] [ Given two strings \$ A \$ and \$ B \$ and a positive integer \$ n \$, determine whether \$ B \$ is composed entirely of (possibly overlapping) strict substrings of \$ A \$ of a length of at least \$ n \$. ## Test cases ``` n A B Output --------------------------------------...
[Question] [ [*sandbox*](https://codegolf.meta.stackexchange.com/a/18737/9481) **Story** Similar to a newspaper route you have been tasked with delivering bits to the residents of Bin City. Just as certain people like certain newspapers, the citizens of Bin City prefer either \$1\$s or \$0\$s delivered to their doo...
[Question] [ **This is a [cops-and-robbers](/questions/tagged/cops-and-robbers "show questions tagged 'cops-and-robbers'") challenge. The Cops' thread to this challenge is [here](https://codegolf.stackexchange.com/questions/167596/hardcoding-the-cops-and-robbers-cops)** An interesting question to think about is the...
[Question] [ This king-of-the-hill game is a strategy game in which you must throw around a water balloon and avoid getting splashed by water. The goal is to obtain the most points. You will be given a map of the field and the location of the water balloon. You can either return that you want to hit the water ballo...
[Question] [ Your function must accept two [strings](https://codegolf.meta.stackexchange.com/questions/2214/whats-a-string/8964#8964) and return new string where are UTF-16 code of all symbols is the sum of UTF-16 codes of inputs symbols * If the resulting sum is greater than `65535` (maximum UTF-16 codepoint), tak...
[Question] [ # Introduction Many old chess books use [descriptive notation](https://en.wikipedia.org/wiki/Descriptive_notation) to notate squares on a chessboard, naming the file (column) of the square based on the starting piece positions of White or Black, depending on whose move it is. The ranks (rows) are numbe...
[Question] [ ## Challenge Given a list of bases for [positional numeral systems](https://en.wikipedia.org/wiki/Numeral_system#Positional_systems_in_detail) as input, output the lowest positive integer that when represented in those bases they have no common digits. The input list can be assumed to have two or more ...
[Question] [ An [addition-subtraction chain](https://en.wikipedia.org/wiki/Addition-subtraction_chain), is a sequence \$a\_1, a\_2, a\_3, ... ,a\_n\$, such that \$a\_1=1\$ and for all \$i > 1\$, there exist \$j,k<i\$ such that \$a\_i = a\_j \pm a\_k\$. Your task, is given a number \$x\$, find the shortest addition-...
[Question] [ The skip-pure numbers are defined with this rule: ``` A(0) = 1 A(1) = 1 A(n) = the smallest positive number not in the sequence such that A(x) + A(x-2) for any x never appears ``` For example, the term A(2) is 2, because 1 has already appeared. The term A(3) is 4, as A(2) + A(0) = 3 and 3 is disallowed...
[Question] [ # Objective Take \$a \in ℤ\_{>1}\$ and \$b \in ℤ\_+\$ as inputs. Write a function \$f\$ such that: $$ f(a,b) = \left\{ \begin{array}{ll} \log\_ab & \quad \text{if} \space \log\_ab \in ℚ \\ -1 & \quad \text{otherwise} \end{array} \right. $$ # Rules * Types and formats of the inputs doesn't matter. *...
[Question] [ [Another brilliant question from Stack Overflow](https://stackoverflow.com/q/20696011/764357) turned into a [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") challenge! Write a program that: 1. Accepts a **string** as user input (not *piped in* or a command line argument). Th...
[Question] [ **Context** > > Chess960 (or Fischer Random Chess) is a variant of chess invented and advocated by former World Chess Champion Bobby Fischer, publicly announced on June 19, 1996 in Buenos Aires, Argentina. It employs the same board and pieces as standard chess; however, the starting position of the pi...
[Question] [ Your mission, should you choose to accept it, is to input a series of point pairs that form a graph, like this: > > A,B C,A B,A A,D A,E F,G C,G > > > You must then output an ASCII visualization of the graph. For example, `A,B C,A C,D` could be: ``` A-----------------B \ \ ...
[Question] [ There are 18 primes with distinct prime digits ([A124674](https://oeis.org/A124674)). Namely, they are: \$2, 3, 5, 7, 23, 37, 53, 73, 257, 523, 2357, 2753, 3257, 3527, 5237, 5273, 7253, 7523\$ Your task is to output this sequence. # Rules * [sequence](/questions/tagged/sequence "show questions tagged '...
[Question] [ ## Introduction Our goal is to efficiently find the maximum of a large amount of (redundant) data. We define the outer product of vectors \$A\$ and \$B\$ as a matrix containing the products of all entries of \$A\$ with each entry of \$B\$. (see [outer Product](https://en.wikipedia.org/wiki/Outer_produc...
[Question] [ Part of [**Advent of Code Golf 2021**](https://codegolf.meta.stackexchange.com/q/24068/78410) event. See the linked meta post for details. Related to [AoC2016 Day 1](https://adventofcode.com/2016/day/1), Part 1. --- You're airdropped near Easter Bunny Headquarters in a city somewhere. "Near", unfortuna...
[Question] [ ## Background The recurrence of the Fibonacci sequence is defined as $$ f(n+2) = f(n+1) + f(n) $$ From this recurrence alone, the following *gap formulae* (recurrences relating three terms with certain amount of gaps) can be derived: $$ f(n+4) = 3f(n+2) - f(n) \\ f(n+6) = 4f(n+3) + f(n) \\ f(n+8) = 7f(...
[Question] [ # The Problem: Two enemy secret agents have devised a wonderful (for you) method of communication! Here’s how the encryption process works: 1) Take the ascii equivalents of each letter. (No spaces, numbers, or punctuation are sent) 2) For each letter in the message, the ascii equivalent of it and the l...
[Question] [ Given an array of numbers, find out how many iterations of averaging\* it takes for the average of every element to be no more than 1 higher or lower than the first element (absolute difference between the array's average and the first element is less than or equal to 1). # \*Array averaging To "averag...
[Question] [ Given a list of math expressions that all hold true and consist of [modulo remainder](https://en.wikipedia.org/wiki/Modulo_operation) calculations with two numbers and a result, your task is to yield the first `n` numbers that hold true for all the statements in the list. For example: `[m % 3 = 0, m % ...
[Question] [ Your task is to make a program that will take an input of a **word** of any length, in the Calibri font. This word will be made out of letter characters that are found on a normal QWERTY keyboard. There will be no accents or any other characters (i.e punctuation, numbers etc). So, the original characte...
[Question] [ ## Challenge > > In this task you have to write a program that will take input > an integer N **(-1e9 <= N < 0 && 0 < N > <= +1e9)**, then compute **T = (abs(N) % > M+1)**,if N is positive then output > the T-th character from the > beginning else output the T-th > character from the end of your...
[Question] [ [Hertzprung's Problem (OEIS A002464)](https://oeis.org/A002464) is the number of solutions to a variant of the [Eight Queens Puzzle](https://en.wikipedia.org/wiki/Eight_queens_puzzle), where instead of placing \$n\$ queens, you place \$n\$ rook-king fairy pieces (can attack like both a rook and a king)...
[Question] [ The Prisoner's Dilemma, but with 3 choices, and the payoffs are random! Each round, your bot recieves a 3x3 grid and chooses a row to play. The grid might be this: ``` 4 5 7 3 1 9 9 9 0 ``` Each number in the grid is between 0 and 10 (inclusive). Your score for the round is `grid[your_play][their...
[Question] [ Given an odd integer *N* (5 <= *N* <= 51), generate a maze with side length *N* that follows the following requirements: The maze must be composed of the characters `|` `-` and `+`. It must use the `|` character as a vertical wall, the `-` character as a horizontal wall, and if that wall turns, the ch...
[Question] [ Using one programming language write 5 single-line programs, each of which outputs a different line of the first verse to Harry Nilsson's 1972 song "[Coconut](http://youtu.be/aA9OqUuA6a0)" when run individually: > > Brother bought a coconut, he bought it for a dime > > His sister had another one, s...
[Question] [ The program plays white. Example stdin: ``` 8 ║♜ ♞ ♝ ♛ ♚ ♝ ♞ ♜ 7 ║♟ ♟ ♟ ♟ … ♟ ♟ ♟ 6 ║… … … … … … … … 5 ║… … … … ♟ … … … 4 ║… … … … … … … … 3 ║… … ♘ … … … … … 2 ║♙ ♙ ♙ ♙ ♙ ♙ ♙ ♙ 1 ║♖ … ♗ ♕ ♔ ♗ ♘ ♖ ——╚═══════════════ —— a b c d e f g h ``` Example stdout: ``` 8 ║♜ ♞ ♝ ♛ ♚ ♝ ♞ ♜ 7 ║♟ ♟ ♟ ♟ … ♟ ♟ ♟ 6 ║… … ...
[Question] [ **Given a 24 hour time, e.g. 20:48, output the nearest time where each adjacent pair of digits has an absolute difference of 1, e.g. 21:01.** That is, each number in the output must differ from the numbers next to it by 1, and the output must be the closest time, forwards or backwards, for which this i...
[Question] [ **Challenge** Given a sequence of non-negative integers, create a function that output a descendant pyramid where the children are the sum of both parent numbers. The result is outputted as an string using tab `\t`. *Note: trailing tabs on each line are not required* ``` 1\t\t2\t\t3\n\t3\t\t5\t\n\t\t8\...
[Question] [ ### Introduction Note: this is not some kind of method to encourage cheating. As [Cᴏɴᴏʀ O'Bʀɪᴇɴ](https://codegolf.stackexchange.com/questions/69770/cheating-a-multiple-choice-test#comment170320_69770) already said, studying is the best solution for passing a test :3. Consider the following answers to t...
[Question] [ The task is to compute the divisor sum of a number given its prime factorisation. ### Input Two arrays (or something equivalent) of length *n*, one containing the prime factor and the other containing the corresponding exponent. ### Output The sum of all divisors (including the number itself). ### Exam...
[Question] [ A [magic square](http://mathworld.wolfram.com/MagicSquare.html) is a square array of numbers with side n consisting of the distinct positive integers 1, 2, ..., *n*² arranged such that the sum of the *n* numbers in any horizontal, vertical, or main diagonal line is always the same number, which is know...
[Question] [ **Background:** I often find that, when browsing a Stackexchange site, I begin to wonder how people get the amount of reputation that they have. I know I can always count on codegolf SE to solve my problems, so here it is: Create a program that will accept a positive integer which represents a person's...
[Question] [ A composition of an integer \$n\$ is a representation of \$n\$ as a sum of positive integers. For example the eight compositions of 4 are as follows: ``` 4, 3 + 1, 1 + 3, 2 + 2, 2 + 1 + 1, 1 + 2 + 1, 1 + 1 + 2, 1 + 1 + 1 + 1. ``` The challenge is to output the number of compositions of \$n\$ in which t...
[Question] [ Let's say we have a 2-D list, like the following one: \$ \begin{bmatrix} \color{red}{1} & \color{red}{2} & \color{red}{3} & \color{red}{4} \\ \color{blue}{5} & \color{blue}{6} & \color{blue}{7} & \color{red}{8} \\ \color{green}{9} & \color{green}{10} & \color{blue}{11} & \color{red}{12} \end{bmatrix} \...
[Question] [ To quote <http://brainfuck.org/utm.b>: > > A tag-system transforms strings over an alphabet `A = {a[1], a[2], ... a[n], a[n+1]}` as follows: a positive integer `m` is chosen, and so is a function `P` that maps each `a[i]` for `1<=i<=n` to a string `P(a[i])` over the alphabet `A`. Now: > > > 1. if th...
[Question] [ Though there is a prime factorization challenge [and it's here](https://codegolf.meta.stackexchange.com/a/22382/100887), this, I feel, will be a bit more interesting than that one. To understand this, let's have an example; I will use 5,184 for this. \$5184 = 2^6 \times 3^4\$. However, for this challen...
[Question] [ Given an positive integer `n` (including 0 if you decide to support it), output all numbers in the *generated* sequence up to the index `n`. For the current test cases of the current challenge numbers are one-indexed. Feel free to submit 0-indexed answers though. ## Base sequence We start from this seq...
[Question] [ [This question](https://codereview.stackexchange.com/questions/229152/algorithm-for-competing-cells-of-0s-and-1s) just trended over on code-review and I figured you might like it adapted as a codegolf challenge: You are given a non-empty list of x houses represented as booleans. Each day, the houses co...
[Question] [ Look at these photographs of natural scenes, with one of the RGB channels taken out of them: [![an idyllic forest with no red](https://i.stack.imgur.com/7eurk.jpg)](https://i.stack.imgur.com/7eurk.jpg) Source (with red): <https://en.wikipedia.org/wiki/File:Altja_j%C3%B5gi_Lahemaal.jpg> [![an Antarctic ...
[Question] [ In statistics, sometimes it's useful to know whether two data samples come from the same underlying distribution. One way to do this is to use the two-sample [Kolmogorov-Smirnov test](https://en.wikipedia.org/wiki/Kolmogorov%E2%80%93Smirnov_test). Your task will be to write a program that reads in two ...
[Question] [ The Challenge is to write the **shortest** implementation to find the [Longest increasing subsequence](http://en.wikipedia.org/wiki/Longest_increasing_subsequence) . **Example** : Let S be the sequence 1 5 7 1 8 4 3 5 [length of S = 8 ] * We have 1 sub-sequence of length 0 [will consider it increasin...
[Question] [ **Closed**. This question needs [details or clarity](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** Add details and clarify the problem by [editing this post](/posts/25343/edit). Closed 1 year ago. [Improve this question](/posts/25343/edit) Y...
[Question] [ Write a program that's as short as possible (as measured by byte-count), takes no input, contains no comments, and outputs a character string/sequence, such that concatenated program+output is exactly 95 characters long and **contains every [printable ASCII character](https://en.wikipedia.org/wiki/ASCI...
[Question] [ ## Challenge Given some JSON data, calculate the maximum depth reached. (Both arrays and dictionaries increase the depth) ## Input/Output The program is expected to read a JSON string from stdin and as soon as the program receives a \n start calculating the max depth, printing it to stdout and terminat...
[Question] [ Every odd degree polynomial has at least one real root. However this root does not have to be a rational number so your task is to output a sequence of rational numbers that approximates it. ## Rules * Your input is an odd degree polynomial \$f\$ with integer coefficients in any reasonable format. * Yo...
[Question] [ As some of you may remember, Peter, who was a [picky eater](https://codegolf.stackexchange.com/questions/225962/peter-is-a-picky-eater) is now puzzled Peter. This time Peter got some puzzles as a present from his Aunt. He has tried a lot, but has failed to solve the puzzles. Peter needs your help to so...
[Question] [ Modern British number plates (a.k.a. registration marks or license plates) use the format `AANNXXX` where `AA` is a "DVLA memory tag" (basically a location code), `NN` is the age identifier, and `XXX` is three random letters. Your task is to, given a date, generate a random valid number plate with a da...
[Question] [ A polygonal number is the number of dots in a `k`-gon of size `n`. You will be given `n` and `k`, and your task is to write a program/function that outputs/prints the corresponding number. # Scoring This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"). Shortest solution ...
[Question] [ Given a decimal in the form of `<float>, <precision>`, you draw the graphical representation of the decimal part (i.e. fraction) of the float. Examples: 1. Input: `6.75, 4`, output: ``` 6||| 7 ---- ``` `6.75` (first number from the input) is the number to explain, `4` (the second number from the inpu...
[Question] [ **Closed.** This question is [off-topic](/help/closed-questions). It is not currently accepting answers. --- This question does not appear to be about code golf or coding challenges within the scope defined in the [help center](https://codegolf.stackexchange.com/help/on-topic). Closed 7 years ago....
[Question] [ ## Skolem sequences A *Skolem sequence* is a sequence of `2n` numbers where every number `i` between `1` and `n` occurs exactly twice, and the distance between the two occurrences of `i` is exactly `i` steps. Here are some examples of Skolem sequences: ``` 1 1 1 1 4 2 3 2 4 3 16 13 15 12 14 4 7 3 11 4 ...
[Question] [ Problem source: <https://oj.vnoi.info/problem/backtrack_j> We have these two shapes: ``` #. ## ``` and ``` .# ## ``` Let's call the first shape the L and the second shape the flipped L. On a 4x4 board, there are 16 cells. Each cell can be either free or occupied. In all the illustrations, `#` represent...
[Question] [ Given a matrix of non-negative numbers (of arbitrary dimension) and a number, get all multi-dimensional indices of the number in that list. For example, let's say we have the list `[[0,1,0],[1,0,0]]` and the number `1`. In the first list, we see one `1` at the second index. If we were using one-based i...
[Question] [ Create a program which prints itself, followed by an additional program. This additional program should print the first program, itself, and then a third program. This continues until the nth program, which prints every program in order up to itself, but fails to print a successor. All programs output ...
[Question] [ In this simple challenge you are given an input array `L` of non-negative integers and a number of bins `b` greater than 0 but no more than the length of `L`. Your code must return a new array `M` whose length is `b` and which has binned the array `L`. This is easiest explained with examples. `L = [1,0...
[Question] [ Your input will be a string consisting of small english letters. Your task is to determine the number of distinct permutations of the original string that are a palindrome. The input string has up to 100 letters. In the case of a longer string the result might be very big so the output should be the nu...
[Question] [ As we know, a quine is a program that outputs its own source code. However, it's also possible to write a program that outputs another, different program, that outputs the first program again. For example, the Python 2 program ``` x = '''x = {} print 'print '+'"'*3+x.format("'"*3+x+"'"*3)+'"'*3''' prin...
[Question] [ The goal of this challenge is to determine the angle of a line in a image. Rules on the image: * The image background will be white (`#FFFFFF`) * The stroke of the line will be black (`#000000`) * The line will NOT be anti-aliased * The image will be 100x100 pixels * The line will start at the center o...
[Question] [ Consider the following standard 15×15 [crossword puzzle](https://en.wikipedia.org/wiki/Crossword) grid. ![Crossword grid](https://i.stack.imgur.com/a6IR4.png) We can represent this in ASCII art by using `#` for blocks and (space) for white squares. ``` # # # # # ...
[Question] [ Let's create a N×N grid of spaces and underscores that can be used to visually determine if a number is prime. (N may be any positive integer.) This grid has three simple rules: 1. The nth column contains the repeated pattern of n - 1 underscores followed by one space. This pattern starts at the first ...
[Question] [ **Task:** Create a program that will take an acronym as input, for example `dftba`, and generate some possible phrases that the acronym could stand for. You can use wordlist as word input. Inspired by <https://www.youtube.com/watch?v=oPUxnpIWt6E> **Example:** ``` input: dftba output: don't forget to be...
[Question] [ The story continues from [AoC2017 Day 22](https://adventofcode.com/2017/day/22), Part 2. --- The damn virus that was infecting a grid computing cluster now has jumped to a *hexagonal* computing cluster! In this cluster, the computers are connected in the honeycomb-like shape, and each computer has thre...
[Question] [ ### Task: Consider the problem: "given a chessboard with one square missing, cut it into 21 L-triominoes". There is a well-known constructive proof that this can be done for any square chessboard size that is a power of two. It works by splitting the chessboard into a smaller chessboard with the hole i...
[Question] [ *(Follow-up to my question about [swapping bits with their neighbours](https://codegolf.stackexchange.com/questions/81212/swap-bits-with-their-neighbours).)* # Task Given a positive integer **x = (2a · 3b) · (5c · 7d) · (11e · 13f) · …**, print the integer obtained by swapping the exponents in this fac...
[Question] [ > > Damn, that's a lot of carrots. > > > ## [The Inspiration](http://meta.codegolf.stackexchange.com/a/7330/44713) [![inspiration](https://i.stack.imgur.com/QV5vM.png)](https://i.stack.imgur.com/QV5vM.png) ## The Task You must create a program, that, in as many languages as possible, replaces ever...
[Question] [ As you may know, in **DNA** there are four bases — adenine (`A`), cytosine (`C`), guanine (`G`) and thymine (`T`). Typically `A` bonds with `T` and `C` bonds with `G`, forming the "rungs" of the [DNA double helix structure](https://en.wikipedia.org/wiki/Nucleic_acid_double_helix). We define the **compl...
[Question] [ **Task** The task is to tile polygons, given a vertex configuration. **Scoring** Your score is equal to the "complexity level" your submission reaches. Complexity levels are cumulative, meaning that to reach #3 you must also support #1 & #2. Submissions at an equal complexity level are distinguished b...
[Question] [ *This is a [cops-and-robbers](/questions/tagged/cops-and-robbers "show questions tagged 'cops-and-robbers'") challenge, the robbers' thread is [here](https://codegolf.stackexchange.com/questions/241486/from-code-to-golf-robbers-thread)* You can change the word `code` into `golf` by changing a letter at...
[Question] [ This challenge is inspired by the [High throughput Fizz Buzz](https://codegolf.stackexchange.com/questions/215216/high-throughput-fizz-buzz) challenge. ## The goal Generate a list of prime numbers up to **10,000,000,000,000,000**. The output of primes should be in decimal digits followed by a newline c...
[Question] [ ## Introduction: [I collect twisty puzzles.](http://twistypuzzles.com/forum/viewtopic.php?f=14&t=26889) Most twisty puzzles are produced and sold by Chinese companies. Most well-known companies ask permission from puzzle designers to produce their designs and work together towards a product on the mark...
[Question] [ ## Introduction / Background In a [recent discussion](https://chat.stackexchange.com/transcript/message/40318730#40318730) in [the crypto chat](https://chat.stackexchange.com/rooms/784/the-side-channel) I was challenged to discuss / help with the [Fermat primality test](https://en.wikipedia.org/wiki/Fe...
[Question] [ ### The Challenge Given the number of items, `n`, in a non-empty, sorted list output the index, `i(n)`, at which its "*Back-To-Front Permutation*" would reside in a list of all permutations if said permutations were sorted lexicographically. Results may be 0 or 1-based, just say which (that is `i`,...