text
stringlengths
26
126k
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] []
[Question] [ # Binary to decimal converter As far as I can see, we don't have a simple binary to decimal conversion challenge. --- Write a program or function that takes a positive binary integer and outputs its decimal value. You are not allowed to use any builtin base conversion functions. Integer-to-decimal fu...
[Question] [ A brace string is defined as a string consisting of the characters `*()[]` in which braces match correctly: ``` [brace-string] ::= [unit] || [unit] [brace-string] [unit] ::= "" || "*" || "(" [brace-string] ")" || "[" [brace-string] "]" ``` This is a valid brace-string: ``` ((())***[]**)****[(...
[Question] [ Many old [**Game Boy**](https://en.wikipedia.org/wiki/Game_Boy_line) games often required string input from the user. However, there was no keyboard. This was handled by presenting the user with a "keyboard screen" like so: [![Pokemon Ruby Keyboard](https://i.stack.imgur.com/glQuY.png)](https://i.sta...
[Question] [ ## Problem The goal is as the title says to find the \$n\$th prime such that \$\text{the prime}-1\$ is divisible by \$n\$. ## Explanation Here is an example so you understand the question, *this is not necessarily the way it ought to be solved. It merely as a way to explain the question* given \$3\$ ...
[Question] [ Your challenge is to write a program or function that, when given two strings of equal length, swaps every other character and outputs/returns the resulting strings in either order. ## Examples ``` "Hello," "world!" --> "Hollo!" "werld," "code" "golf" --> "codf" "gole" "happy" "angry" --> "hnpry" "aa...
[Question] [ ### Background When I was in elementary school, we used to play a game in math class that goes as follows. All kids sit in a big circle and take turns counting, starting from **1**. However, the following numbers must be skipped while counting: * Numbers that are multiples of **3**. * Numbers that h...
[Question] [ Since Halloween is coming up I thought I might start a fun little code golf challenge! The challenge is quite simple. You have to write a program that outputs either `trick` or `treat`. "The twist?" you may ask. Well let me explain: Your program has to do the following: * Be compilable/runnable in ...
[Question] [ **This question already has answers here**: [Palindromic palindrome generator](/questions/47827/palindromic-palindrome-generator) (39 answers) Closed 7 years ago. Your task is to palindromize a string as follows: Take the string. ``` abcde ``` Reverse it. ``` edcba ``` Remove the first letter....
[Question] [ A string is *pairable* if it can be split into subtrings, each of which is a string repeated twice consecutively. For example, `aabaaababbbaba` is pairable as: ``` aaba aaba b b ba ba ``` Given a non-empty string of `a`'s and `b`'s, output a Truthy value if it's pairable and a Falsey value if it isn'...
[Question] [ Using your language of choice, golf a [quine](http://en.wikipedia.org/wiki/Quine_%28computing%29). > > A **quine** is a non-empty computer program which takes no input and produces a copy of its own source code as its only output. > > > No cheating -- that means that you can't just read the sourc...
[Question] []
[Question] [ Given an array of any depth, draw its contents with borders of `+-|` around each subarray. Those are the ASCII characters for plus, minus, and vertical pipe. For example, if the array is `[1, 2, 3]`, draw ``` +-----+ |1 2 3| +-----+ ``` For a nested array such as `[[1, 2, 3], [4, 5], [6, 7, 8]]`, dra...
[Question] [ # ...counted! You will pass your program a variable which represents a quantity of money in dollars and/or cents and an array of coin values. Your challenge is to output the number of possible combinations of the given array of coin values that would add up to the amount passed to the code. If it is ...
[Question] [ One of the most common standard tasks (especially when showcasing esoteric programming languages) is to implement a ["cat program"](http://esolangs.org/wiki/Cat): read all of STDIN and print it to STDOUT. While this is named after the Unix shell utility `cat` it is of course much less powerful than t...
[Question] [ An 'Even string' is any string where the [parity](https://en.wikipedia.org/wiki/Parity_(mathematics)) of the ASCII values of the characters is always alternating. For example, the string `EvenSt-ring$!` is an even-string because the ASCII values of the characters are: ``` 69 118 101 110 83 116 45 114...
[Question] [ Inspired by a task for Programming 101, here's a challenge that hopefully isn't too easy (or a duplicate). ## Input: * A positive integer `n >= 1`. ## Output: * `n` lines of asterisks, where every new line has one asterisk more than the line before, and starting with one asterisk in the first line. #...
[Question] [ Inspired by a task for Programming 101, here's a challenge that hopefully isn't too easy (or a duplicate). ## Input: * A positive integer `n >= 1`. ## Output: * `n` lines of asterisks, where every new line has one asterisk more than the line before, and starting with one asterisk in the first line. #...
[Question] [ ### Introduction The [Atari ST](https://en.wikipedia.org/wiki/Atari_ST) was a rather popular personal computer from the mid 80's to early 90's era, powered by a Motorola 68000 microprocessor. On this machine, the default behavior of the operating system for uncaught CPU exceptions was to display a ro...
[Question] [ PPCG user and elected mod, [@Dennis](https://codegolf.stackexchange.com/users/12012/dennis) just became the second ever user to earn over 100k rep! [![enter image description here](https://i.stack.imgur.com/5ME5N.png)](https://i.stack.imgur.com/5ME5N.png) This is a totally original idea, that I [did ...
[Question] [ Notice the pattern in the below sequence: ``` 0.1, 0.01, 0.001, 0.0001, 0.00001 and so on, until reaching 0.{one hundred zeros}1 ``` Then, continued: ``` 0.2, 0.02, 0.002, 0.0002, 0.00002 and so on, until reaching 0.{two hundred zeros}2 ``` Continued: ``` 0.3, 0.03, etc, until 0.{three hundred zeros}...
[Question] [ Write a program or function that prints or outputs this exact text (consisting of 142 characters): ``` ()()()()()() |\3.1415926| |:\53589793| \::\2384626| \::\433832| \::\79502| \::\8841| \::\971| \::\69| \::\3| \__\| ``` Your program must take no input (except in language...
[Question] [ # Challenge Given an input of an all-lowercase string `[a-z]`, output the total distance between the letters. ## Example ``` Input: golf Distance from g to o : 8 Distance from o to l : 3 Distance from l to f : 6 Output: 17 ``` ## Rules * Standard loopholes forbidden * This is [code-golf](/questions/t...
[Question] [ I remember people saying that code size should be measured in bytes, and not in characters, because it's possible to store information with weird Unicode characters, which have no visual meaning. How bad can it be? In this challenge, you should output the following Lorem Ipsum text, taken from [Wikip...
[Question] [ # Description Subtract the next P numbers from a N number. The next number of N is N + 1. Look at the examples to get what I mean. # Examples: ``` Input: N=2,P=3 Calculate: n - (n+1) - (n+2) - (n+3) //Ending with 3, because P=3 Calculate: 2 - 2+1 - 2+2 - 2+3 //Replacing N with 2 from In...
[Question] []
[Question] [ Write a program or function that takes in a single-line string. You can assume it only contains [printable ASCII](https://en.wikipedia.org/wiki/ASCII#Printable_characters). Print or return a string of an ASCII art rocket such as ``` | /_\ |E| |a| |r| |t| |h| |_| /___\ VvV ``` with the inpu...
[Question] [ Don't you love those [exploded-view diagrams](https://en.wikipedia.org/wiki/Exploded-view_drawing) in which a machine or object is taken apart into its smallest pieces? [![enter image description here](https://i.stack.imgur.com/6lcse.jpg)](https://i.stack.imgur.com/6lcse.jpg) Let's do that to a stri...
[Question] [ Tired of always wondering how many more Pokémon you need to catch to get those high-tier evolutions? Wonder no more! Now you will write a complete program or function to calculate it for you! ## The Challenge: As input, your program will receive a list of the costs in candy to evolve a Pokémon to the...
[Question] [ Consider the standard equilateral triangle, with nodes labeled using [barycentric coordinates](https://en.wikipedia.org/wiki/Barycentric_coordinate_system): ![](https://i.stack.imgur.com/URM7b.png) We can turn this 3 node triangle into a 6 node triangle by adding a new line of 3 vertices (one more th...
[Question] [ Here's a nice easy challenge: > > Given a string that represents a number in an unknown base, determine the lowest possible base that number might be in. The string will only contain `0-9, a-z`. If you like, you may choose to take uppercase letters instead of lowercase, but please specify this. You ...
[Question] [ # Enterprise Quality Code! ### TL;DR * Answers will consist of a full program (**of length < 30k**) prints the the first N Prime numbers (as a base 10 representation without leading zeros unless the chosen language only supports unary or other based output) separated by newlines (optional trailing li...
[Question] [ The goal here is to simply reverse a string, with one twist: Keep the capitalization in the same places. Example Input 1: `Hello, Midnightas` Example Output 1: `SathginDim ,olleh` Example Input 2: `.Q` Exmaple Output 2: `q.` **Rules**: * Output to STDOUT, input from STDIN * The winner will be...
[Question] [ Given two positive integers, 'a' and 'b', output an ascii-art "box" that is *a* characters wide and *b* characters tall. For example, with '4' and '6': ``` **** * * * * * * * * **** ``` Simple right? Here's the twist: The border of the box must be the characters of "a" and "b" alternating. This s...
[Question] [ The purpose of this challenge is to produce an ASCII version of the cover of [this great album](https://en.wikipedia.org/wiki/The_Wall) by the rock band Pink Floyd. The brick junctions are made of characters `_` and `|`. Bricks have width 7 and height 2 characters, excluding junctions. So the basic u...
[Question] []
[Question] []
[Question] []
[Question] [ ## Background I have a collection of "weekday socks", which are seven pairs of socks labeled by the days of the week. When I wash my socks, they end up in a pile, and I must arrange them into the correct pairs before putting them into the closet. My strategy is to pull one random sock from the pile a...
[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 smal...
[Question] [ Write a program or function that outputs an `L` if run on a little endian architecture or a `B` if run on a big endian architecture. Lower case output `l` or `b` is also acceptable. There is no input. Scoring is code golf, so the code with the fewest bytes wins. **Edit:** *As per the comments below, ...
[Question] [ In the popular (and essential) computer science book, *An Introduction to Formal Languages and Automata* by Peter Linz, the following formal language is frequently stated: $$\large{L=\{a^n b^n:n\in\mathbb{Z}^+\}}$$ mainly because this language can not be processed with finite-state automata. This exp...
[Question] [ A binary recurrence sequence is a recursively-defined sequence of the following form: $$F(1) = a\_1 \\ \vdots \\ F(y) = a\_y \\ F(n) = \alpha F(n-x) + \beta F(n-y), n > y$$ This is a generalization of the Fibonacci (\$x = 1, y = 2, a = [1, 1], \alpha = 1, \beta = 1\$) sequence and the Lucas (\$x = 1,...