text
stringlengths
180
608k
[Question] [ Somehow, we don't yet have a challenge for finding the inverse of an arbitrarily-sized square matrix, despite having ones for [3x3](https://codegolf.stackexchange.com/questions/168828/find-the-inverse-of-a-3-by-3-matrix) and [4x4](https://codegolf.stackexchange.com/questions/45369/find-the-inverse-of-a...
[Question] [ My father who [was a really good APLer](https://youtu.be/pL8OQIR5cB4?t=3m16s) and taught me all the basics of APL (and much more), passed away on this day, five years ago. In preparation for [50 Years of APL](http://www.dyalog.com/50-years-of-apl.htm), I found [this patent letter](https://tidsskrift.dk...
[Question] [ Lower level languages, such as C and C++ actually have no concept of multidimensional arrays. (Other than vectors and dynamic arrays) When you create a multidimensional array with ``` int foo[5][10]; ``` This is actually just [syntactic sugar](https://en.wikipedia.org/wiki/Syntactic_sugar). What C real...
[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/23860/edit). Closed 4 years ago. [Improve this question](/posts/23860/edit) ...
[Question] [ **This question already has answers here**: [Fibonacci function or sequence](/questions/85/fibonacci-function-or-sequence) (334 answers) Closed 6 years ago. The Fibtraction sequence (as I call it) is similar to the Fibonacci sequence except, instead of adding numbers, you subtract them. **The fi...
[Question] [ Dither a grayscale image into pure black and white with your own algorithm. Guidelines: You must come up with your own new algorithm. You cannot use pre-existing algorithms (ex. Floyd-Steinburg) but you can use the general technique. Your program must be able to read an image and produce an image the s...
[Question] [ ## The Challenge The challenge is simple: given an input list `a` and another list `b`, repeat `a` until it is longer than `b`. As an example, call the repeated list `ra`. Then the following condition must hold true: `len(b) < len(ra) <= len(b) + len(a)`. That is, `a` must not be repeated more than is ...
[Question] [ ## *Back*ground A **[backronym](https://en.wikipedia.org/wiki/Backronym)** is an acronym that was formed from an existing word. For example, *spam* is actually named after the canned meat product as used in the [Monty Python sketch](https://en.wikipedia.org/wiki/Spam_(Monty_Python)), but can be interpr...
[Question] [ # Introduction I don't *particularly* know where the fizz buzz trend came from. It might just be a meme or something, but it is somewhat popular. # Challenge Your job today is to convert Fizz Buzz into binary (0, 1) respectively, and convert that binary to text. Pretty standard stuff. # How does that w...
[Question] [ The sum of the squares of the first ten natural numbers is, \$1^2 + 2^2 + \dots + 10^2 = 385\$ The square of the sum of the first ten natural numbers is, \$(1 + 2 + ... + 10)^2 = 55^2 = 3025\$ Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum...
[Question] [ There are two forms of nouns, singular and plural. The conversion between these two is quite easy. 1. Normally, you end it with `s`. ex. `car` => `cars`. 2. If it ends with `s`,`x`,`z`,`ch` or `sh`, end it with `es`. ex. `bus`=>`buses`. 3. If it ends with `y` with a consonant just before it, change the...
[Question] [ # Background When I was younger, I was taught a method of drawing a weird "S" shape, that I (along with my classmates) found fascinating. Today, I rediscovered it, and due to its formulaic approach to drawing it, thought it could lead to an interesting challenge :P # Drawing the "S" The S can be drawn ...
[Question] [ # Introduction Long ago, when I used to code card games with usual playing cards, I used to specify a number for each card and call a function with some number to get a card. This somewhat inspired me to make this challenge. So for the people unaware of the playing cards, a deck of cards consist of 52...
[Question] [ The [On-Line Encyclopedia of Integer Sequences](https://en.wikipedia.org/wiki/On-Line_Encyclopedia_of_Integer_Sequences) (OEIS) is an online database of integer sequences. It contains nearly 280000 sequences of mathematical interest. Examples of sequences: * positive integers ([A000027](https://oeis....
[Question] [ Taken straight from the ACM Winter Programming Contest 2013. You are a person who likes to take things literally. Therefore, for you, the end of The World is ed; the last letters of "The" and "World" concatenated. Make a program which takes a sentence, and output the last letter of each word in that se...
[Question] [ We are all familiar with the famous [Fibonacci sequence](https://en.wikipedia.org/wiki/Fibonacci_number), that starts with `0` and `1`, and each element is the sum of the previous two. Here are the first few terms (OEIS [A000045](http://oeis.org/A000045)): ``` 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 1...
[Question] [ **A simple one:** Take a list of positive integers as input and output the numbers modulus their 1-based index in the list. If the input integers are `{a, b, c, d, e, f, g}` then the output should be `{a%1, b%2, c%3, d%4, e%5, f%6, g%7}` where `%` is the modulus operator. --- **Test cases:** ``` 10 9 ...
[Question] [ **Problem:** You are making a new phone where people can type in specialized phone numbers, for example, `1-800-program`, and they would be converted automatically to a usable phone number, like `1-800-7764726` (for the previous example). Your program will recieve a string if any length with numbers, ...
[Question] [ # Challenge : Given an integer `n` as input. Create a diamond that is 2x the given number `n`. # Input : Input is integer `n` and 2 < n ≤ 3000. # Output : Output will be a string and it will be in form of a diamond consisting of `+` with an addition line at the start showing `n` using `+` # Examples : ...
[Question] [ > > Well, although this challenge turned out to be a huge success, it also turned out to be very trivial to solve. Therefore, for those of looking for more of a challenge, I created a sequel to this challenge in which you must now count the number of *unique* rectangles. [Check it out!](https://codego...
[Question] [ ### Task Given a UTF-8 string (by any means) answer (by any means) an equivalent list where every element is the number of bytes used to encode the corresponding input character. ### Examples `!` → `1` `Ciao` → `1 1 1 1` `tʃaʊ` → `1 2 1 2` `Adám` → `1 1 2 1` `ĉaŭ` → `2 1 2` (single chara...
[Question] [ Monday, October 31st, is Halloween. And it got me thinking -- I wonder what other months have the last day of the month *also* be a Monday? ### Input * A positive integer [in any convenient format](http://meta.codegolf.stackexchange.com/q/2447/42963) representing a year, `10000 > y > 0`. * The input ca...
[Question] [ # Challenge In this challenge you have to take a number as input and output the corresponding letter of the alphabet, and vice versa. (1 <=> A, 2 <=> B) etc. ``` 1 -> A 2 -> B ... 26 -> Z A -> 1 B -> 2 ... Z -> 26 ``` # Rules * This is [code-golf](/questions/tagged/code-golf "show questions tagged 'cod...
[Question] [ ## Story Have you seen [this](https://9gag.com/gag/aE2y7MO) post from [9gag](https://9gag.com/)? Maybe you got the feeling to make your own sentences. But then you realize that you could just golf a script in half an hour, and you will never have to deal time with that. ## The submission Your program w...
[Question] [ To *normalize* a vector is to scale it to a length of 1 ([a unit vector](https://en.wikipedia.org/wiki/Unit_vector)), whilst keeping the direction consistent. For example, if we wanted to normalize a vector with 3 components, **u**, we would first find its length: > > **|u| = sqrt(ux2 + uy2 + uz2)** >...
[Question] [ The **subfactorial** or **rencontres numbers** ([A000166](https://oeis.org/A000166)) are a sequence of numbers similar to the factorial numbers which show up in the combinatorics of permutations. In particular the **n**th subfactorial **!n** gives the number of [derangements](https://en.wikipedia.org/w...
[Question] [ The natural numbers including 0 are formally defined as sets, in the [following way](https://en.wikipedia.org/wiki/Set-theoretic_definition_of_natural_numbers#Contemporary_standard): * Number 0 is defined as the empty set, {} * For *n* ≥ 0, number *n*+1 is defined as *n* ∪ {*n*}. As a consequence, *n* ...
[Question] [ ### Introduction This is how a chessboard looks like. [![enter image description here](https://i.stack.imgur.com/YxP53.gif)](https://i.stack.imgur.com/YxP53.gif) You can see that `a1` is a **dark** square. However, `b1` is a **light square**. ### The Task The challenge is, given `dark`, `light` or `bot...
[Question] [ ### Introduction [As ToonAlfrink says](https://codegolf.stackexchange.com/questions/30361/the-shortest-code-to-invert-a-binary-string): "Me thinks there aren't enough easy questions on here that beginners can attempt!". So the task is very simple. Given a string, output a truthy or falsy value whether ...
[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/17456/edit). Closed 6 years ago. [Improve this question](/posts/17456/edit) ...
[Question] [ A matrix is [antisymmetric](https://en.wikipedia.org/wiki/Skew-symmetric_matrix), or skew-symmetric, if its transpose equals its negative. The transpose of a matrix can be obtained by reflecting its elements across the main diagonal. Examples of transpositions can be seen here: \$\begin{pmatrix}11&12&1...
[Question] [ ## Challenge Weirdly, this hasn't been done yet: output the current date. ## Rules The date format you should follow is as follows: ``` YYYY-MM-DD ``` Where the month and day should be padded by zeroes if they are less than 10. For example, if the program is run on the 24th May 2017, it should output `...
[Question] [ mbomb007 asked us to make a [self mutilating program](https://codegolf.stackexchange.com/questions/60003/self-mutilating-program). Its an interesting challenge, but I personally don't like to encourage my programs to be self-mutilating. I like to think that, at the heart of every program is a beautiful...
[Question] [ # Introduction The *[telephone numbers](https://en.wikipedia.org/wiki/Telephone_number_(mathematics))* or *involution numbers* are a sequence of integers that count the ways \$n\$ telephone lines can be connected to each other, where each line can be connected to at most one other line. These were firs...
[Question] [ ## Challenge: Take input of two black and white (monochrome) images and xor each pixel of the first, with each pixel of the second, add them to a new image and output the new image. ## Some clarifications: Size of pictures does not matter. Extension/Image format doesn't matter. You can make it take inp...
[Question] [ The [dragon curve sequence](http://oeis.org/A014577) (or the regular paper folding sequence) is a binary sequence. `a(n)` is given by negation of the bit left of the least significant 1 of `n`. For example to calculate `a(2136)` we first convert to binary: ``` 100001011000 ``` We find our least signifi...
[Question] [ Write a program or function that takes a character as input and outputs a character. Also, choose a list of 13 distinct ASCII printable characters (32-126). When a character from this list is passed into the program or function, it should output the character at the corresponding position in `Hello, wo...
[Question] [ Upon the rumor that Codegolf will have a *Rock-Paper-Scissors tournament* you look into the topic of **square-free words**. A word made of the letters `R`, `P`, `S` is *square-free* if it does not contain a sequence that repeats twice. That is to say, the word can not be written as ``` a x x b ``` wher...
[Question] [ # 0xUsernames There's so many people using a messaging service that they're running out of space to store all the usernames! To fix this, they are going to start storing usernames as hexadecimal, where possible. If a username consists of only the characters `0123456789ABCDEF` (case insensitive), it ca...
[Question] [ Every phone needs a calculator app. Because of the limited screen real estate, the developer of mine has decided to save some buttons. Instead of having two dedicated bracket buttons - one for open `(` and one for close `)` - there is just a single bracket button `()`. It looks something like this: [![...
[Question] [ # Definition 1. a(1) = 1 2. a(2) = 1 3. a(n) = a(n-a(n-1)) + a(n-a(n-2)) for n > 2 where n is an integer # Task Given positive integer `n`, generate `a(n)`. # Testcases ``` n a(n) 1 1 2 1 3 2 4 3 5 3 6 4 7 5 8 5 9 6 10 6 11 6 12 8 13 8 14 8 15 10 16 9 17 10 18 11 19 11 20 12 ``` # Reference *...
[Question] [ What general tips do you have for golfing in Julia? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Julia (e.g. "remove comments" is not an answer). [Answer] NOTE: The below are correct as of Julia 1.4.1 A few tricks to save a few c...
[Question] [ *(related/inspired by: [Draw a bowling formation](https://codegolf.stackexchange.com/q/42645/42963))* A fun pastime in the winter months here is to perform snowman bowling, using a large ball (like a basketball) and tiny snowman figures. Let's recreate this in ASCII. Each snowman consists of the follow...
[Question] [ There are a lot™ of pokemon. One of the defining characteristics of pokemon is their type, of which every1 pokemon has up to two types, a primary type and an optional secondary type. There are mechanical implications to each type, and so it is very useful to know what type a given pokemon is during bat...
[Question] [ There are a bunch of different casing conventions, like `camelCase`, `PascalCase`, `snake_case` etc. It's annoying juggling all of these, so instead of choosing one like a sensible person, why not cursedly mix all of them together? Your challenge is to, given a list of words (only containing lowercase ...
[Question] [ Take a square matrix containing positive integers as input, and calculate the "rotated sum" of the matrix. **Rotated sum:** Take the sum of the original matrix and the same matrix rotated 90, 180 and 270 degrees. Suppose the matrix is: ``` 2 5 8 3 12 8 6 6 10 ``` then the rotated sum...
[Question] [ [Inspired/mostly copied but I don't think it's a dupe](https://codegolf.stackexchange.com/questions/171884/overlapping-polyglots). [Also Inspired](https://codegolf.stackexchange.com/questions/102370/add-a-language-to-a-polyglot). In this challenge, you will create polyglots that include all languages f...
[Question] [ ### Note this is a question primarily focusing on [data-structures](/questions/tagged/data-structures "show questions tagged 'data-structures'") ## Introduction Bacefook wants people to be friendlier! As such, they are implementing a new system to suggest friends! Your task is to help Bacefook to imple...
[Question] [ In math, one way to figure out what the type of a given relation (linear, quadratic, etc) is to calculate the differences. To do so you take a list of y values for which the gap between the correspondent x values is the same, and subtract each one from the number above it, creating a list of numbers on...
[Question] [ Given a binary message, and the number of parity bits, generate the associated parity bits. A parity bit is a simple form of error detection. It's generated by counting the number of `1`'s in the message, if it's even attach a `0` to the end, if it's odd attach `1`. That way, if there's a 1-bit error...
[Question] [ As you probably know, there have been [multiple](https://codegolf.stackexchange.com/questions/187586/will-jimmy-fall-off-his-platform) [lovely](https://codegolf.stackexchange.com/questions/187682/how-many-jimmys-can-fit) [Jimmy](https://codegolf.stackexchange.com/questions/187731/jimmy-needs-your-help)...
[Question] [ Your challenge is to write a program which, given a year, outputs the number of "Friday 13ths" in it. **Rules & Details:** * You can take input via `STDIN`, or as an argument passed to your program. * You should output the result to `STDOUT`. * You may assume that input will be a valid year, and does n...
[Question] [ # Challenge You are given an array \$a\$ of integers. With a ***move*** you can **increase or decrease** an element of the array **by 1**. Your task is to ***equalize*** the array, that is make all the elements of the array equal by performing some *moves*. But that's not enough! You also want to make ...
[Question] [ # The plus-minus sequence The plus-minus sequence is one that starts with two seeds, `a(0)` and `b(0)`. Each iteration of this sequence is the addition and subtraction of the previous two members of the sequence. That is, `a(N) = a(N-1) + b(N-1)` and `b(N) = a(N-1) - b(N-1)`. **Objective** Produce the ...
[Question] [ In the fewest bytes possible, determine whether the two values given each match one of the following: **First value** ``` 2 string or integer - whichever you prefer to case insensitive too case insensitive two case insensitive t0 case insensitive (t zero) ``` **Second value** ``` b ...
[Question] [ Here's an easy one, with just enough complexity to make golfing non-trivial. ## Input 1. A list of non-negative numbers representing people waiting in line for Thanksgiving dessert. The first (leftmost) number is first in line, and the list can contain repeats (think of each number as a person's first ...
[Question] [ The challenge is simply; output the following six 2D integer arrays: ``` [[ 1, 11, 21, 31, 41, 51], [ 3, 13, 23, 33, 43, 53], [ 5, 15, 25, 35, 45, 55], [ 7, 17, 27, 37, 47, 57], [ 9, 19, 29, 39, 49, 59]] [[ 2, 11, 22, 31, 42, 51], [ 3, 14, 23, 34, 43, 54], [ 6, 15, 26, 35, 46, 55], [ 7, 18, 27, ...
[Question] [ Inspired by [this post](https://codegolf.stackexchange.com/questions/125117/diagonal-alphabet). For those marking this question as a duplicate I urge you to actually read the question to see that mine is a modification of the one linked. The one linked does not ask for an input and is to just print the...
[Question] [ Special [Independence Day (USA)](https://en.wikipedia.org/wiki/Independence_Day_(United_States)) themed challenge for you today. You must write a program that prints this ascii-art representation of The American Flag. ``` 0 |--------------------------------------------------------- | * * * * * ...
[Question] [ In [Fewest (distinct) characters for Turing Completeness](https://codegolf.stackexchange.com/questions/110648/fewest-distinct-characters-for-turing-completeness), the goal is to find the minimum number of characters which make a language [Turing Complete](https://en.wikipedia.org/wiki/Turing_completene...
[Question] [ Nepal’s flag ([Wikipedia](https://en.wikipedia.org/wiki/Nepalese_Flag), [Numberphile](http://www.numberphile.com/videos/nepal_flag.html)) looks very different from any other. It also has specific drawing instructions (included in the Wikipedia article). I want you guys to make a program which will draw...
[Question] [ **The [bounty](https://codegolf.stackexchange.com/help/bounty) expires in 5 days**. Answers to this question are eligible for a +100 reputation bounty. [Adám](/users/43319/ad%c3%a1m) wants to **reward an existing answer**: > > [This](https://codegolf.stackexchange.com/a/270066/43319) well-explained...
[Question] [ Given an integer *k* and either a block of text, or a 2d array that the inner arrays may have unequal lengths (that resembles a block of text), rotate every character or element in the *k*-th column up or down to the next position that exists. ### Example Rotate the 20th column of the following text (1...
[Question] [ Non-metals typically\* have a fixed number of covalent bonds in every chemical they are part of. Given the number of bonds every element requires, output whether it's possible to construct a *single* molecule from the given chemicals, such that every atom has it's desired number of bonds. In other word...
[Question] [ Write a program/function that takes two integers in the range \$0\$ to \$255\$ inclusive, and returns whether the binary forms of the numbers are exactly one bit different. For example, \$1\$ and \$0\$ have binary forms `00000001` and `00000000`, which are one bit apart. Similarly, \$152\$ and \$24\$ ...
[Question] [ A positive integer N is *K*-sparse if there are at least *K* 0s between any two consecutive 1s in its binary representation. So, the number 1010101 is 1-sparse whereas 101101 is not. Your task is to find the next 1-sparse number for the given input number. For example, if the input is 12 (`0b1100`) out...
[Question] [ We've all been told at some point in our lives that dividing by 0 is impossible. And for the most part, that statement is true. But what if there *was* a way to perform the forbidden operation? Welcome to my newest creation: `b`-numbers. `b`-numbers are a little bit like imaginary numbers: the main pro...
[Question] [ Given a list of `1`s and `-1`s, determine whether or not it is a valid [OVSF code](https://en.wikipedia.org/wiki/Chip_(CDMA)#Orthogonal_variable_spreading_factor) (by outputting a truthy or falsey value). OVSF codes are defined as follows: * `[1]` is an OVSF code. * If `X` is an OVSF code, then `X ++ X...
[Question] [ Given some positive integer \$n\$ that is not a square, find the fundamental solution \$(x,y)\$ of the associated [Pell equation](https://en.wikipedia.org/wiki/Pell%27s_equation) $$x^2 - n\cdot y^2 = 1$$ ### Details * The fundamental \$(x,y)\$ is a pair of integers \$x,y\$ satisfying the equation where...
[Question] [ Consider a grammar over the alphabet **{**`0`**,** `1`**,** `?`**,** `:`**}** defined by the [production rule](https://en.wikipedia.org/wiki/Production_(computer_science)#Grammar_generation) > > s → `0` ┃ `1` ┃ `0` `?` s `:` s ┃ `1` `?` s `:` s > > > Given a string generated from *s*, parse it as a...
[Question] [ Given a number > 0, output the sum with all digits (1 .. n) concatenated and reversed and add them up. For example, with n = 6: The numbers 1 to 6 concatenated: ``` 123456 ``` Reversed: ``` 654321 ``` Adding them up together will result in: 777777. Another example is n = 11: ``` 1 2 3 4 5 6 7 8 9 10 11...
[Question] [ Imagine that a list of integers describes the heights of some two-dimensional terrain as seen from the side. ``` Stamina: [ 4 4 4 4 4 4 3 3 3 3 2 2 2 - ] O /|\ / \ +---+ +---+ | | | ...
[Question] [ **EDIT** I modified the wording of the rules to make some things which were implicit more explicit. I also added some emphasis to clear up some points of apparent confusion, and explicitly defined the option of making a standalone program instead of a function. The goal here is to make a function that ...
[Question] [ Your goal is to write a program that prints the following poem exactly as it appears here: ``` There was an old lady who swallowed a fly. I don't know why she swallowed that fly, Perhaps she'll die. There was an old lady who swallowed a spider, That wriggled and iggled and jiggled inside her. She swall...
[Question] [ Very heavily inspired by this challenge [Code Golf: Your own pet ASCII snake](https://codegolf.stackexchange.com/questions/156245/code-golf-your-own-pet-ascii-snake) - I thought making it horizontal would add an extra layer of complexity. An example horizontal snake: ``` 0 0 ...
[Question] [ The [Vigenère cipher](http://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher) was a simple polyalphabetic cipher that basically applied one of several Caesar ciphers, according to a key. Basically the letters in the key indicate which shifted alphabet to use. To that end there was a simple tool, called the...
[Question] [ In convolutional neural networks, one of the main types of layers usually implemented is called the **Pooling Layer**. Sometimes, the input image is big (and therefore time consuming especially if you have a big input set) or there is sparse data. In these cases, the objective of the Pooling Layers is ...
[Question] [ ## What is the Ultraradical? The [ultraradical](https://en.wikipedia.org/wiki/Bring_radical), or the Bring radical, of a real number \$a\$ is defined as the only real root of the quintic equation \$x^5+x+a=0\$. Here we use \$\text{UR}(\cdot)\$ to denote the ultraradical function. For example, \$\text{U...
[Question] [ There are an abundance of questions involving drawing shapes using asterisks - so I thought, with so many asterisks out there, we should draw one, using the ASCII table. ## Challenge Your task is to write a program or function which takes no input, and outputs this exact text: ``` ! ...
[Question] [ Given a vector of \$n\$ values \$(x\_1,x\_2,x\_3,\ldots,x\_n)\$ return the determinant of the corresponding [Vandermonde matrix](https://en.wikipedia.org/wiki/Vandermonde_matrix) \$V(x\_1, x\_2, \ldots, x\_n) = \begin{bmatrix}1 & x\_1 & x\_1^2 & x\_1^3 & \ldots &x\_1^{n-1} \\1 & x\_2 & x\_2^2 & x\_2^3 ...
[Question] [ ## Background I have a ladder leaning on a wall, and a remote-controlled robot that can climb it. I can send three different commands to the robot: * `UP`: the robot takes one step upwards. If it was on the highest step, it trips over, falls down and explodes. * `DOWN`: the robot takes one step downwar...
[Question] [ When writing a message with fridge magnets, you'll often find yourself substituting a `1` for an `I`. In this challenge, your goal is to find out if a message can be written using the letters of another message. The allowed substitutions are: ``` A = 4 B = 8 C = U E = M = W = 3 G = 6 = 9 I = 1 L = 7 N ...
[Question] [ *The shortest code to pass all possibilities wins.* In mathematics, the [persistence of a number](http://en.wikipedia.org/wiki/Persistence_of_a_number) measures how many times a certain operation must be applied to its digits until some certain fixed condition is reached. You can determine the additive...
[Question] [ Given an integer \$n \geq 2\$, print a triangle of height \$n\$ of (triangles of height \$n\$ of asterisks), as in [this SO question](https://stackoverflow.com/q/69796358/257418). For \$n=2\$, print: ``` * *** * * * ********* ``` For \$n=3\$, print: ``` * *** ...
[Question] [ Given a string of N, S, E and W, output a bearing (angle clockwise from North in degrees), correct to 5 decimal places. In [traditional compass notation](https://en.wikipedia.org/wiki/Points_of_the_compass#16-wind_compass_rose "Wikipedia article on points of the compass"), a string is made up of only 2...
[Question] [ **This question already has answers here**: [Numbers with Rotational Symmetry](/questions/77866/numbers-with-rotational-symmetry) (43 answers) Closed 1 year ago. ## Background You are working for some board-game manufacturer and need to produce wooden tiles with the numbers from 0 to *n* engrave...
[Question] [ Given a nonnegative integer, return whether it is a three digit number ending in one, in any consistent integer base. In other words, the number needs to be represented in base-N, N being an integer greater than zero. ## Rules * This is [code-golf](/questions/tagged/code-golf "show questions tagged 'co...
[Question] [ Your goal is to create a function or a program to reverse the bits in a range of integers given an integer \$n\$. In other words, you want to find the [bit-reversal permutation](https://en.wikipedia.org/wiki/Bit-reversal_permutation) of a range of \$2^n\$ items, zero-indexed. This is also the OEIS sequ...
[Question] [ # The Objective Build a random number generator whose range is \$\left[0,1\right) \cap \mathbb{Q} .\$ This is, build a random number generator that can produce any value that's: 1. at least \$0 \,;\$ 2. not \$1\$ or greater; and 3. expressible as the ratio of two integers. --- # What's the fuss? This R...
[Question] [ In this challenge you and your friends are debating on which case is better, uppercase or lowercase? To find out, you write a program to do this for you. Because esolangs scare your friends, and verbose code scares you, your code will need to be as short as possible. --- ## Examples ``` PrOgRaMiNgPuZzL...
[Question] [ Given a list of integers, group the elements which occur most first, then group the next most and so on until each unique element in the list has been grouped once. --- # Examples: **Input:** `[1,2,3]` **Output:** `[[1,2,3]]` --- **Input:** `[1,1,1,2,2,3,3,4,5,6]` **Output:** `[[1],[2,3],[4,5,6]]` --- ...
[Question] [ If you don't know what the [Tower of Hanoi](https://en.wikipedia.org/wiki/Tower_of_Hanoi) is, I'll explain it briefly: There are three rods and some discs each of which has a different size. In the beginning all discs are on the first tower, in sorted order: The biggest one is at the bottom, the smalle...
[Question] [ It is often said, that all programmers should be able to write a "hello world" program in any programming language after a few glances on that language (And [quicksort](https://codegolf.stackexchange.com/questions/2445/implement-quicksort-in-brainf) after a few more glances). As the [Conway's Game of L...
[Question] [ Given a list of integers, your task is to output the second largest value in the first *k* elements, for each *k* between 2 and the length of the input list. In other words, output the second largest value for each prefix of the input. You can output an arbitrary value for the first element (where *k* ...
[Question] [ [Suzhou numerals](https://en.wikipedia.org/wiki/Suzhou_numerals) (蘇州碼子; also 花碼) are Chinese decimal numerals: ``` 0 〇 1 〡 一 2 〢 二 3 〣 三 4 〤 5 〥 6 〦 7 〧 8 〨 9 〩 ``` They pretty much work like Arabic numerals, except that when there are consecutive digits belonging to the set `{1, 2, 3}`, the digits alt...
[Question] [ We've recently reached the threshold of 10,000 questions on PPCG. Hooray! Let's celebrate this with a simple challenge. ## Input Two integers \$A\$ and \$B\$, both in \$[1..9999]\$, such that \$A+B<10000\$. ## Task Your task is to add one single digit to one of these integers or one single digit to bot...
[Question] [ Given a string of the characters `+=-` where there is at least one `=`, insert positive integers between all the symbols and at the start and the end such that the math equations are satisfied. For example, given the input ``` +-=-= ``` you need to insert positive integers A through F like this ``` A+B...
[Question] [ Since Euclid, we have known that there are infinitely many primes. The argument is by contradiction: If there are only finitely many, let's say \$p\_1,p\_2,...,p\_n\$, then surely \$m:=p\_1\cdot p\_2\cdot...\cdot p\_n+1\$ is not divisible by any of these primes, so its prime factorization must yield a ...
[Question] [ Let's define a sequence: The **n digit summing sequence** (n-DSS) is a sequence that starts with **n**. If the last number was **k**, then the next number is **k + digit-sum(k)**. Here are the first few n-DSS: ``` 1-DSS: 1, 2, 4, 8, 16, 23, 28, 38, 49, 62, 70... 2-DSS: 2, 4, 8, 16, 23, 28, 38, 49, 62, ...
[Question] [ Your task is to write a program which prints following four verses extracted from the lyrics from The Beatles' song "Hey Jude" (© Sony/ATV Music Publishing LLC): ``` Hey Jude, don't make it bad\n Take a sad song and make it better\n Remember to let her into your heart\n Then you can start to make it be...