text
stringlengths
180
608k
[Question] [ The esoteric programming language [evil](http://esolangs.org/wiki/Evil) has an interesting operation on byte values which it calls "weaving". It is essentially a permutation of the eight bits of the byte (it doesn't matter which end we start counting from, as the pattern is symmetric): * Bit 0 is moved...
[Question] [ ...at least for some definition of "self-modification". # The Task In this challenge, your task is to write three strings `A`, `B` and `C` that satisfy the following properties. * The string `B` has length at least 1. * For every `n ≥ 0`, the string `ABnC` is a valid program (meaning full runnable prog...
[Question] [ Say you list the positive integers in a triangle, then flip it left-to-right. Given a number, output the number it's sent to. This is a self-inverse mapping. ``` 1 1 2 3 3 2 4 5 6 <---> 6 5 4 7 8 9...
[Question] [ Imagine you place a knight chess piece on a phone dial pad. This chess piece moves from keys to keys in an uppercase "L" shape: two steps horizontally followed by one vertically, or one step horizontally then two vertically: ``` +-+ |1| 2 3 +-+ `-------v | +-+ 4 | 5 |6| ...
[Question] [ Around the year 1637, Pierre de Fermat wrote in the margins of his copy of the Arithmetica: ``` It is impossible to separate a cube into two cubes, or a fourth power into two fourth powers, or in general, any power higher than the second, into two like powers. I have discovered a truly marvelous pr...
[Question] [ # Introduction Apparently, this question has been asked [here](https://codegolf.stackexchange.com/questions/117838/shortest-possible-xkcd-password-generator) and it unfortunately closed. I thought it was a good idea to try again with it, but done right. [XKCD](http://www.xkcd.com/936) looks at the how ...
[Question] [ Sometimes, when I'm really bored I like to take the sum of an array of non-negative integers. I only take the sum of arrays of lengths that are powers of two. Unfortunately I often make mistakes. Fortunately I keep track of my work as I go along in the following way: I add pairs of adjacent numbers unt...
[Question] [ The task at hand is, given a number `n`, find the smallest prime that starts with ***AT LEAST*** `n` of the number `2` at the beginning of the number. This is a sequence I found on OEIS ([A068103](http://oeis.org/A068103)). The first 17 numbers in the sequence are given below, if you want more I'll ha...
[Question] [ The [Cornu Spiral](https://en.wikipedia.org/wiki/Euler_spiral) can be calculated using Feynman's method for path integrals of light propagation. We will approximate this integral using the following discretisation. Consider a mirror as in this image, where `S` is the light source and `P` the point wher...
[Question] [ Pythagoras had his leg blown up in the war. It had to be amputated, and though he nearly died, he pulled through and made a full recovery. Now, after a year of walking with crutches, he gets the privilege of getting a prosthetic leg! Thing is, though, there are several that fit, but which ones? ## The ...
[Question] [ The problem with the Caesar cipher is the resulting words are often unpronounceable. The problem with Pig Latin is that it is easy to decode. Why not combine them? **Input** A word consisting of the 26 english letters. **Output** First, change every consonant in the word to the next consonant in the...
[Question] [ Platforms are stretches of `-` characters separated by one or more characters. For example: ``` ------ -- ------ - ``` The above has 4 platforms sizes 6, 2, 6 and 1. Platforms that are not supported will fall. To be supported platforms need Jimmies. Jimmies look like this: ``` \o/ ``` They are thre...
[Question] [ The challenge is simple: write a program or function that, when given a finite non-negative integer, outputs a nested array. ## The rules * Your code must produce a **unique** valid nested array for *every* integer 0 ‌≤ n ‌< 231. * **Every** possible nested array with up to 16 open brackets must be out...
[Question] [ You place a standard die at the origin of a 2D grid that stretches infinitely in every direction. You place the die such that the 1 is facing upwards, the 2 is facing in the negative y direction, and the 3 is facing in the positive x direction, as shown in the figure below: ![](https://i.stack.imgur.co...
[Question] [ Today's Google doodle is about [Celebrating 50 years of Kids Coding](https://www.google.com/doodles/celebrating-50-years-of-kids-coding): The goal is program the path of a little bunny so that it can eat all the carrots. There are 4 types of blocks (see pictures below): [![block description](https://i....
[Question] [ Write a program or function that draws a mountain range, where each subsequent larger mountain peak is "behind" the ones in front, and alternates which side is visible. This is a mountain range of size `1` ``` /\ ``` This is a mountain range of size `2` ``` /\ /\ \ ``` This is a mountain range of size...
[Question] [ [We're getting markdown tables!](https://meta.stackexchange.com/questions/356997/feature-preview-table-support?cb=1) I assume this is what they look like: ``` data data data data --------------------- | | | | | | | | ``` Your ...
[Question] [ Tonight, 31 January 2020, Brexit will happen and the United Kingdom will leave the European Union, the first time that the number of EU member states will decrease. Your job is to take a date and output the number of EU1 members on that date, according to the following table: ``` | Start | End ...
[Question] [ Your task is to model the effects of batter on pieces of food. Please add three layers of crust. ``` [[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0], // in [0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,1,1,1,0,0,0,0,0,0,0,1,1,0,0,0], [0,0,0,0,1,0,0,0,0,0,0,0,1,1,0,1,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,...
[Question] [ I've compiled a mosaic of 2025 headshots from the avatars of the [top Stack Overflow users](https://stackoverflow.com/users?page=1&tab=reputation&filter=all). *(Click the image to view it full-size.)* [![StackOverflow headshots mosaic](https://i.stack.imgur.com/GY1es.jpg)](http://www.pictureshack.us/...
[Question] [ # Introduction We -- especially the geeks among us, who tend to be fans -- all remember this old *Far Side* cartoon: [![Hey! Hey! Hey!](https://i.stack.imgur.com/L3GcY.jpg)](https://i.stack.imgur.com/L3GcY.jpg) Clearly, Professor Schwartzman could have brushed up on his programming skills just a wee bi...
[Question] [ [Minesweeper](https://en.wikipedia.org/wiki/Minesweeper_(video_game)) is a popular computer game that you have probably wasted time playing where you try to reveal the cells that are mines in a rectangular grid based on hints of how many neighboring mines each non-mine cell has. And in case you haven't...
[Question] [ [![](https://i.stack.imgur.com/BN6hG.png "colors.rgb(\"blue\") yields \"#0000FF\". colors.rgb(\"yellowish blue\") yields NaN. colors.sort() yields \"rainbow\"")](https://xkcd.com/1537/) > > colors.rgb("blue") yields "#0000FF". colors.rgb("yellowish blue") yields NaN. colors.sort() yields "rainbow" > ...
[Question] [ It is ancient knowledge that every non-negative integer can be rewritten as the sum of four squared integers. For example the number 1 can be expressed as \$0^2+0^2+0^2+1^2\$. Or, in general, for any non-negative integer \$n\$, there exist integers \$a,b,c,d\$ such that $$n = a^2+b^2+c^2+d^2$$ [Joseph-...
[Question] [ # Mölkky [Mölkky](https://en.wikipedia.org/wiki/M%C3%B6lkky) is a Finnish throwing game. The players use a wooden pin (also called "mölkky") to try to knock over wooden pins of almost similar dimensions with the throwing pin, marked with numbers from 1 to 12. The initial position of the pins is as foll...
[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\$ as...
[Question] [ # The task Given any array of integers, e.g.: ``` [-1,476,578,27,0,1,-1,1,2] ``` and an index of that array (this example uses **0 based indexing**, though you can use **1 based indexing** as well.): ``` index = 5 v [-1,476,578,27,0,1,-1,1,2] ``` Then **return the nearest numb...
[Question] [ Create a program or function to unjumble a square of digits by flipping (reversing around the centre point) only rows and columns. **Input** Input will be a 9x9 grid of digits in the form of a 9 line string like the following: ``` 986553229 264564891 759176443 643982153 567891234 526917874 685328912 89...
[Question] [ A traveler needs to stay for *n* days in a hotel outside town. He is out of cash and his credit card is expired. But he has a gold chain with *n* links. The rule in this hotel is that residents should pay their rent every morning. The traveler comes to an agreement with the manager to pay one link of t...
[Question] [ One of the lesser known programming paradigms which seems rather fitting for code golfing is *Overlapping Oriented Programming (OOP)* \*. When writing partly identical code, many bytes can be saved by simply overlapping the identical parts and remembering in some way where the two original code lines s...
[Question] [ This is Pascal's Braid: ``` 1 4 15 56 209 780 2911 10864 40545 151316 564719 1 3 11 41 153 571 2131 7953 29681 110771 413403 1542841 1 4 15 56 209 780 2911 10864 40545 151316 564719 ``` I totally made that up. Blaise Pasca...
[Question] [ A [standard domino set](https://en.wikipedia.org/wiki/Dominoes) has 28 unique pieces: [![enter image description here](https://i.stack.imgur.com/7LxZh.png)](https://i.stack.imgur.com/7LxZh.png) Given a list of 28 or fewer unique dominoes, output the list required to make a complete set. Input and outpu...
[Question] [ Given the 95 printable characters in ASCII plus newline, break it apart into two *equal, 48 character* groups (hereafter called group A and group B). Create a one-to-one mapping *of your choice* (you have total discretion) between the two groups. In other words, `A` might map to `a`, and vice versa, bu...
[Question] [ One of my favorite definitions of the prime numbers goes as follows: * 2 is the smallest prime. * Numbers larger than 2 are prime if they are not divisible by a smaller prime. However this definition seems arbitrary, why 2? Why not some other number? Well lets try some other numbers will define n-prime...
[Question] [ ## [Sandbox](https://codegolf.meta.stackexchange.com/a/17644/75681) For the purposes of the current task, a cube of unit length is rendered in oblique projection with ASCII symbols as follows: ``` +-----+ / /| +-----+ | | | + | |/ +-----+ ``` * `+` for the vertices. * `-` for the X edges...
[Question] [ Apparently yes! In three easy steps. ### Step 1 Let *f*(*n*) denote the prime-counting function (number of primes less than or equal to *n*). Define the integer **sequence** *s*(*n*) as follows. For each positive integer *n*, * Initiallize *t* to *n*. * As long as *t* is neither prime nor 1, replace *t...
[Question] [ Duodyadic tiles are kinds of square [function blocks](http://en.wikipedia.org/wiki/Function_block_diagram) that take two inputs, one from their top side and one from their left side, and have two outputs, one on their right side and one on their bottom side. Each of their outputs is a separate function...
[Question] [ # Perfect License Plates Starting a few years ago, I made myself a little game while driving around: checking if nearby license plates are "perfect". It's relatively rare, but exciting when you find one. To check if a license plate is perfect: 1. Sum up the characters, with A = 1, B = 2, ... Z = 26. 2...
[Question] [ Your task is to pit each side of the keyboard against each other and build two programs, in the same language, one using only keys on the left-hand side of a standard keyboard that outputs `Pollinium milk; plump pumpkin; lollipop?`, and one using the keys on the right that outputs `Weatherheaded sweeth...
[Question] [ ## Introduction: Before the task, here is what every element does on the map: **Plain land** (`X`): This does nothing. **Destroyed land** (`-`): This is the same as plain land, but destroyed by a bomb. **The active bomb** (`!`): On a map, this will destroy everything in a 3x3 square: ``` XXXXX ...
[Question] [ [![enter image description here](https://i.stack.imgur.com/rCqky.png)](https://i.stack.imgur.com/rCqky.png) While doodling around on square-ruled paper the other day, I came up with the above negative-space font for digits. In case you haven't spotted it yet, the spaces between the above shapes yield t...
[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] [ # Background In 1870 Émile Baudot invented [Baudot Code](https://en.wikipedia.org/wiki/Baudot_code), a fixed-length character encoding for telegraphy. He designed the code to be entered from a manual keyboard with just five keys; two operated with the left hand and three with the right: ![Baudot 5-key...
[Question] [ A **[portmanteau word](https://en.wikipedia.org/wiki/Portmanteau)** is a combination of two words that takes part of each word and makes them into a single new word. For example, **lion** + **tiger** => **liger**. Let's write a program to generate portmanteaus from a pair of input words. Computers aren...
[Question] [ In this challenge, you must design a species of single-celled organisms to fight to the death in the petri-dish arena. The arena is represented as a rectangular grid, where each cell occupies one space: ``` .....x.... ...x...o.. ...x.c..o. .......o.. ``` ## Attributes Every cell has three attributes. W...
[Question] [ *This is a tips question for golfing in Python.* In Python golfing, it's common for a submission to be a function defined as a lambda. For example, ``` f=lambda x:0**x or x*f(x-1) ``` [computes the factorial](https://codegolf.stackexchange.com/a/3133/20260) of x. The lambda format has two [big advanta...
[Question] [ In the spirit of [this xkcd](http://xkcd.com/1313) ![enter link description here](https://imgs.xkcd.com/comics/regex_golf.png) Write a program that plays regex golf with arbitrary pairs of lists. The program should at least attempt to make the regex short, a program that just outputs `/^(item1|item2|it...
[Question] [ You are on an advanced intergalactic space station. A friend of yours who is minoring in the Study of Gravity just created a game that involves using microgravity as a way to move a ball around. She hands you a small controller with four directional arrows on it and a maze like structure with a ball s...
[Question] [ There seems to be this ongoing craze about people tediously learning new keyboard layouts like Dvorak or Neo because it supposedly makes them more productive. I argue that switching keyboard layouts is a bad idea, because it can take you months to get up to speed, and when you're finially 5% faster tha...
[Question] [ ## Background Most people on here should be familiar with a few integer base systems: decimal, binary, hexadecimal, octal. E.g. in the hexadecimal system, a number \$abc.de\_{16}\$ would represent $$a\times16^2 + b\times16^1 + c\times16^0 + d\times16^{-1} + e\times16^{-2}$$ However, one can also use no...
[Question] [ # Task Given a non-negative number, check if it's odd or even. In case it's even, output that number. Otherwise, throw any exception/error that your language supports, and stop the program. # Example with Python Input: `1` Output: ``` Traceback (most recent call last): File ".code.tio", line 1, in ...
[Question] [ Write a snippet to calculate the mode (most common number) of a list of positive integers. For example, the mode of ``` d = [4,3,1,0,6,1,6,4,4,0,3,1,7,7,3,4,1,1,2,8] ``` is `1`, because it occurs the maximum of 5 times. You may assume that the list is stored in a variable such as `d` and has a unique ...
[Question] [ It seems we've managed to go all this time without a plain vanilla Number-To-Binary challenge! Whilst this will inevitably be only one element in many languages, it should put a few esolangs through their paces. I truly looked for this challenge to no avail. If it already exists, comment as such and I'...
[Question] [ Write the shortest program that takes one input (n) from STDIN (or equivalent) and outputs a simple incrementing function with one argument (x) that returns x + n but the function must be in a different language. Pretty simple! **This is code-golf, normal rules apply, shortest program wins.** Example: ...
[Question] [ # Challenge You will be given a string that can contain lowercase letters, uppercase letters, or spaces. You have to turn the vowels (a, e, i, o, u) in the string to upper case and consonants to lower case. This applies whether or not the letter was originally upper case or lower case. Spaces remain as...
[Question] [ Let's start by defining a Two Bit Number™: * It is a positive integer * When expressed as a binary string it has exactly 2 true bits OR * When expressed as a decimal number, it has exactly 2 of the numeral one, and all other numerals are zero. Or as a sentence A Two Bit Number™ is a number which contai...
[Question] [ It's a [normal truth machine](https://esolangs.org/wiki/Truth-machine) but instead of taking input, it uses the first character of the program. Thus, internal. The 0 and 1 are plain characters, i.e. ASCII code 0x30 and 0x31 respectively. Example: `0abcd` prints 0 and halts, and `1abcd` prints 1 infinit...
[Question] [ The task is to display *n* characters of the [ASCII table](http://www.asciitable.com/). You may write a function (or a program that takes the argument as a parameter, STDIN is allowed as well) that takes a parameter *n*, which will be the index of the last character to print. The task is quite simple, ...
[Question] [ # Task Given a positive integer `n`, output `n+1` if `n` is odd, and output `n-1` if `n` is even. # Input A positive integer. You may assume that the integer is within the handling capability of the language. # Output A positive integer, specified above. # Testcases ``` input output 1 2 2 ...
[Question] [ Wouldn't it be neat if programming functions could be inverted, just like the mathematical function they implement? Write a function (or program) that takes one input `x` in any form, that outputs `ln(x)`. When the bytes of the program are reordered/reversed so that the first byte now is the last by...
[Question] [ One element of the list `aa, ab, ba, bb, c` has been removed, and the remainder shuffled and joined with no separator. Find the missing element. For example, if the input was `aaabbac`, this is made by concatenating `aa ab ba c`, so the output would be `bb`. ## Rules * Standard I/O rules apply. * You m...
[Question] [ # Final Result The competition is over. Congratulations to `hard_coded`! Some interesting facts: * In 31600 out of 40920 auctions (77.2%), the winner of the first round won the most rounds in that auction. * If example bots are included in the competition, the top nine places won't change except that `...
[Question] [ # How many petals around the rose How many petals around the rose is a dice game you can play with your friends. Similar to ["can I join the music box"](https://codegolf.stackexchange.com/q/199153/75323), there is a person that knows how the game works and the others have to discover the rule. In this ...
[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/4944/edit). Closed 7 years ago. [Improve this question](/posts/4944/edit) Yo...
[Question] [ Write some statement(s) which will count the number of ones in an unsigned sixteen-bit integer. For example, if the input is `1337`, then the result is `6` because `1337` as a sixteen bit binary number is `0000010100111001`, which contains six ones. [Answer] # 80386 Machine Code, 4 bytes ``` F3 0F...
[Question] [ Let's say I have this string: ``` s = "Code Golf! I love Code Golf. It is the best." ``` I want to replace all the [vowels](https://en.wikipedia.org/wiki/Vowel) with repeated "aeiou". Notes: * Uppercase vowels should be replaced by an uppercase letter, and lowercase vowels should be replaced by a lower...
[Question] [ **Task:** Given an array of numbers as input (you can choose what subset, such as integers or natural numbers), replace all items with the number of times they appear within the array. As an example, `[1, 2, 2, 1, 4, 8, 1]` would become `[3, 2, 2, 3, 1, 1, 3]`. You can take input/produce output as arra...
[Question] [ # Challenge Write the shortest snippet of code possible such that, when N copies of it are concatenated together, the number of characters output is N2. N will be a positive integer. For example if the snippet was `soln();`, then running `soln();` would print exactly 1 character, and running `soln();so...
[Question] [ Suppose a new [fairy chess piece](https://en.wikipedia.org/wiki/Fairy_chess_piece) named the Wazir is introduced to chess. Wazirs can move from a position (*x*, *y*) to:  (*x*+1, *y*)  (*x*, *y*+1)  (*x*-1, *y*)  (*x*, *y*-1) That is, they move orthogonally like the rook, but only one step at a...
[Question] [ **Locked**. This question and its answers are [locked](/help/locked-posts) because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions. The challenge: > > Make a function that finds the longest palindrome inside a string. > > > No...
[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/5562/edit). Closed 1 year ago. [Improve this question](/posts/5562/edit) ## ...
[Question] [ Print or return the following string: ``` R******* *R****** **R***** ***R**** ****R*** *****R** ******R* *******R *....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......* *....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......* *....... .*...... ..*..... ...*.... ....*... ...
[Question] [ Surprisingly, I don't think we have a [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") question for determining if a number is [semiprime](https://en.wikipedia.org/wiki/Semiprime). > > A semiprime is a natural number that is the product of two (not necessarily distinct) pr...
[Question] [ Shortest answer wins. It must be sorted, and in 24hr time. The final line does not have a comma. Output should be as follows: ``` '00:00', '00:30', '01:00', '01:30', '02:00', '02:30', '03:00', '03:30', '04:00', '04:30', '05:00', '05:30', '06:00', '06:30', '07:00', '07:30', '08:00', '08:30', '09:00', '0...
[Question] [ If you express some positive integer in binary with no leading zeros and replace every `1` with a `(` and every `0` with a `)`, then will all the parentheses match? In most cases they won't. For example, 9 is `1001` in binary, which becomes `())(`, where only the first two parentheses match. But someti...
[Question] [ Your challenge is to, given a positive integer n, count up to each digit of it, giving the effect of converging on it. Basically, count up to the first digit of n by its place value (\$‚åä\log\_{10}\left(x\right)‚åã\$). Then do the same for each subsequent digit, but with the values of the previous dig...
[Question] [ Implement a function diff that takes as input three integers x, y, and z. It should return whether subtracting one of these numbers from another gives the third. ``` Test cases: diff(5, 3, 2) yields True because 5 - 3 = 2 diff(2, 3, 5) yields True because 5 - 3 = 2 diff(2, 5, 3) yields True because 5 -...
[Question] [ You will be given as **input** an integer `k` in the range from `-4503599627370496` (−252) to `4503599627370496` (252). As is [well known](https://stackoverflow.com/questions/3793838/which-is-the-first-integer-that-an-ieee-754-float-is-incapable-of-representing-e), integers in this range can be represe...
[Question] [ Take a positive integer **n** as input, and output a **n-by-n** checkerboard matrix consisting of **1** and **0**. The top left digit should always be **1**. **Test cases:** ``` n = 1 1 n = 2 1 0 0 1 n = 3 1 0 1 0 1 0 1 0 1 n = 4 1 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1 ``` Input and output formats are optiona...
[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 mu...
[Question] [ Given an integer array and two numbers as input, remove a certain amount of the first and last elements, specified by the numbers. The input can be in any order you want. You should remove the first *x* elements, where *x* is the first numerical input, and also remove the last *y* elements, where *y* i...
[Question] [ Sona is in her house with her 10 year old daughter. She needs to go to school to bring back another child from school, as school is over at 2 pm. It's hot outside, so she wants to leave her younger child at home. She gave a bunch of strings to her child to keep her busy while she is gone. She asked her...
[Question] [ The task here is pretty simple. You should write a program that takes a string as input and outputs it (that is a cat program). Additionally when the \$n\$th byte of your program is removed (without replacement) the augmented program should take a string as input and remove the \$n\$th character. If th...
[Question] [ [Powerball](http://www.powerball.com/) is an American lottery that has recently gained attention because the current jackpot (as of January 11, 2016) is the [largest lotto prize in history](http://money.cnn.com/2016/01/06/luxury/largest-lottery-jackpots/), at about $1.5 billion ([USD](http://www.x-rate...
[Question] [ The [van der Corput sequence](https://en.wikipedia.org/wiki/Van_der_Corput_sequence) is one of the simplest example of [low-discrepancy sequence](https://en.wikipedia.org/wiki/Low-discrepancy_sequence). Its `n`-th term is just `0.(n written in base 10 and mirrored)`, so its first terms are : `0.1`, `0....
[Question] [ On the Mathematica Stack Exchange, [100xln2 asks](https://mathematica.stackexchange.com/questions/288024/how-can-i-define-a-sequence-of-integers-which-only-contains-the-first-k-integers): > > I need a list of integers […] The list contains integers and is characterized by [three] parameters, lets ca...
[Question] [ ![figure and ground](https://upload.wikimedia.org/wikipedia/commons/thumb/7/74/Cup_or_faces_paradox.svg/300px-Cup_or_faces_paradox.svg.png) Source: [Wikipedia](https://commons.wikimedia.org/wiki/File:Cup_or_faces_paradox.svg) For this challenge, you should write two programs which resemble the [figur...
[Question] [ #### The Collatz Conjecture The famous [Collatz Conjecture](https://en.wikipedia.org/wiki/Collatz_conjecture) (which we will assume to be true for the challenge) defines a sequence for each natural number, and hypothesizes that every such sequence will ultimately reach 1. For a given starting number N,...
[Question] [ I once had a beautiful rectangular array. It was very symmetrical, but unfortunately it has fallen apart and now I only have the top left corner. Your task will be to rebuild the original array. Your program will receive a 2 dimensional array of integers. For ease of parsing, you may assume they are al...
[Question] [ Take a look at this chamomile flower: [![](https://i.stack.imgur.com/VuneQ.png)](https://i.stack.imgur.com/VuneQ.png) Pretty, isn't it? Well, what if I told you that this wasn't actually one flower? A lot of flowers (including sunflowers, chamomiles, daisies and others) actually consist of many very sm...
[Question] [ I figured an "arch" was the best way to describe this pattern of numbers: ``` 1234567887654321 1234567 7654321 123456 654321 12345 54321 1234 4321 123 321 12 21 1 1 ``` Formally defined, each line consists of the numbers 1 through `9-n`, `(n-1)*2` spaces...
[Question] [ [Related](https://codegolf.stackexchange.com/questions/204969/write-a-microwave-timer) Sometimes when I use my microwave, I do a little trolling and enter times such as `2:90` instead of `3:30` because they end up being the same time anyway. The microwave happily accepts this and starts counting down f...
[Question] [ What tips do people have for golfing in TeX/LaTeX? Please post one tip per answer, each at least somewhat specific to TeX/LaTeX. --- Context: I noticed [this answer](https://codegolf.stackexchange.com/a/123693/3845) and that there is no tips question for TeX/LaTeX, so I'm creating this one. There's som...
[Question] [ Given a two dimensional matrix of 0 and 1s. Find the number of island for 1s and 0s where neighbours are only in the horizontal and vertical. ``` Given input: 1 1 1 0 1 1 1 0 output = 1 1 Number of 1s island = 1 xxx- xxx- Number of 0s island = 1 ---x ---x ------------------------------ Given input: 0...
[Question] [ **This question already has answers here**: [Swap Two Values in a List](/questions/236301/swap-two-values-in-a-list) (49 answers) Closed 1 year ago. Given an array of positive integers and two distinct valid indices, return the array with the two elements corresponding to the two indices swapped...
[Question] [ I haven't. :P So I decided to define one: A **tralindrome** is a string which contains three equal-length sections X, Y, Z such that * all characters in the string are included in at least one of the three sections, * X starts at the first character, Y starts at or right after the last character of X, ...
[Question] [ You probably all know the fibonacci sequence: ``` fibonacci(n)=fibonacci(n-1)+fibonacci(n-2) fibonacci(0)=0 fibonacci(1)=1 ``` Your task is as simple as it could be: * Given integer `N` compute `fibonacci(n)` but here is the twist: * Also do negative `N` Wait. What? ``` fibonacci(1)=fibonacci(0)+fibona...
[Question] [ *Disclaimer:* This challenge inspired by me trying to find pairs in a large pile of socks. *Disclaimer:* This is looking for a very different process and output to [Help me sort my socks!](https://codegolf.stackexchange.com/questions/77031/help-me-sort-my-socks). Please don't claim it as a duplicate u...
[Question] [ I know there have been a lot of challenges about "the two best code-golfers in the world", but this one is a bit more unique, being *Round 1* in a series of (future) challenges involving the two of them. --- Your task is to write a program or function that returns two different non-whitespace ASCII str...
[Question] [ If you sort a string you'll typically get something like: ``` ':Iaaceeefggghiiiiklllllmnnooooprrssstttttuuyyyy ``` Yes, that was the first sentence sorted. As you can see, there are a lot of repeated characters, `aa`, `eee`, `ttttt`, 9 spaces and so on. If we add `128` to the ASCII-value of th...