text
stringlengths
180
608k
[Question] [ Something I found while looking through some old files. It seemed like a neat idea for a code golf challenge. ## The intro One of the most popular events at the annual Cyclist's Grand Competition for Charity (CGCC) is the rocket bike parcours. The rules are simple: Inspect the parcours and place a be...
[Question] [ [Robbers thread](https://codegolf.stackexchange.com/questions/242618/slice-the-source-code-robbers) # Cops ## Understanding slicing Remember, slices are zero-indexed. Take this slice: [2:]. If the string is "abcde", the result is "cde" because the slice basically means "get all elements with an index...
[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 [AoC2020 Day 20](https://adventofcode.com/2020/day/20), Part 1. (This day is a dreaded one for many of you, I know :P) *[Obligatory final "but you're n...
[Question] [ Consider the following 9 "row patterns", using 0s to represent empty cells and 1s to represent a full cell. Each pattern is associated with an integer \$n\$, such that \$0 \le n \le 8\$ (multiple `[1,1,1,1,1,1]`s exist as there's some difference that we don't care about): | \$n\$ | Pattern | | --- | ...
[Question] [ ## Background Consider the shape \$T(n)\$ consisting of a triangular array of \$\frac{n(n+1)}{2}\$ unit regular hexagons: [![enter image description here](https://i.stack.imgur.com/oUzDh.jpg)](https://i.stack.imgur.com/oUzDh.jpg) John Conway proved that \$n = 12k + 0,2,9,11\$ if and only if \$T(n)\$ ...
[Question] [ Here are the annual returns for a hypothetical S&P 500 stock index fund for each calendar year from 1928 to 2017, expressed as a multiplier. So in 1928 you might say "the index went up by 37.88%" which I've represented here by 1.3788. ``` 1.3788, 0.8809, 0.7152, 0.5293, 0.8485, 1.4659, 0.9406, 1.4137...
[Question] [ I have a series of binary switches, which I can represent as a bit string. The last person who used my switches left them in some arbitrary state without cleaning up, and it bugs me. I always keep the switches in one of four possible "tidy" configurations: * All `1`: e.g., `111111111` * All `0`: e.g....
[Question] [ Pig-latin is a made-up language that is translated into by moving the first letter of a word to the end and adding `ay` to the end. For example: `hello` translates into pig-latin as `ellohay`. Therefore, translating pig-latin back into English is dropping the `ay` at the end and moving the last lette...
[Question] [ **Note:** I have accepted an answer, but I'm willing to accept a better answer if it comes. Write a program that computes operations on sets. You may take input either from standard input or from command line arguments. Your program must be able to compute unions, intersections, relative complements,...
[Question] [ The answer to [this question](https://stackoverflow.com/q/12850950/174728) is much too long Your challenge is to write a **partitioning function** in the smallest number of characters. Input example ``` ['a', 'b', 'c'] ``` Output example ``` [(('a'),('b'),('c')), (('a', 'b'), ('c')), (('a', 'c'), (...
[Question] [ Given a number N, write the shortest complete program to find the number of [square-free integers](http://en.wikipedia.org/wiki/Square-free_integer) below N. ``` Sample Input 100000 Sample Output 60794 ``` Constraints: 1. Should work for all positive N below 1,000,000 2. Should not take more than 10...
[Question] [ I'm trying to shorten a bash solution to a Code Golf challenge, which requires an output of `true` or `false`. I've managed to condense the key piece of the code down to a substring check, to determine if the provided argument, `$1`, is a substring of a particular hard-coded fixed string, of the form...
[Question] [ ## Introduction: Some times using a 24-hour clock are formatted in a nice pattern. For these patterns, we'll have four different categories: ``` All the same (pattern A:AA or AA:AA): 0:00 1:11 2:22 3:33 4:44 5:55 11:11 22:22 ``` ``` Increasing (pattern B:CD or AB:CD, where D==C+1==B+2==A+3): 0...
[Question] [ This challenge will be based on an [R language](https://www.r-project.org/) trivia: every release is named and it's a reference to Peanuts comic strips (see [here](https://bookdown.org/martin_monkman/DataScienceResources_book/r-release-names.html) and [here](https://stackoverflow.com/questions/134783...
[Question] [ Given \$n, m\ge 1\$. There are \$n\$ balls. Do \$m\$ moves, each choose a ball (maybe also the first one), and exchange with the one currently on the first place. At the end, the order of balls should be the same as the initial state. You can either output all possibilities, or a random one provided ...
[Question] [ Consider the integer set \$S = \{3, 5, 6, 7\}\$. If we list all \$2^n\$ subsets of \$S\$ (its powerset) and calculate their sums, we get $$ \mathcal{P}(S) = \{\emptyset, \{3\}, \{5\}, \{6\}, \{7\}, \{3, 5\}, \{3, 6\}, \{3, 7\}, \{5, 6\}, \{5, 7\}, \{6, 7\}, \{3, 5, 6\}, \{3, 5, 7\}, \{3, 6, 7\}, \{5,...
[Question] [ There are 4 regular polygons that we can construct using ASCII art: ``` . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...
[Question] [ ### Challenge: Your program will take two integers `n` and `k` as input, and output the smallest integer greater than (but not equal to) `n` that contains at least `k` occurrences of the digit `5`. You can assume `1 ≤ k ≤ 15` and `1 ≤ n < 10**15`. This is a [restricted-time](/questions/tagged/restri...
[Question] [ In this task you are given an odd number of white balls and the same number of black balls. The task is to count all the ways of putting the balls into bins so that in each bin there is an odd number of each color. For example, say we have 3 white balls. The different ways are: ``` (wwwbbb) (wb)(wb)(...
[Question] [ [<< Prev](https://codegolf.stackexchange.com/questions/149746/advent-challenge-2-the-present-vault-raid) [Next >>](https://codegolf.stackexchange.com/questions/149861/advent-challenge-4-present-assembly-line) Unfortunately, Santa was not able to catch the elves in time! He has to go back to manufactu...
[Question] [ For this challenge you are going to make a function (your function may be a complete program) that takes a list as input and returns a permutation of that list. Your function must obey the following requirements. * It must be deterministic. * Composing your function with itself a variable number of t...
[Question] [ The Goldbach conjecture states that: > > [every even number that is greater than 2 is the sum of two primes.](http://mathworld.wolfram.com/GoldbachConjecture.html) > > > We will consider a Goldbach partition of a number **n** to be a pair of two primes adding to **n**. We are concerned with numbe...
[Question] [ ### Background The [convex hull](https://en.wikipedia.org/wiki/Convex_hull) of a finite number of points is the smallest convex polygon that contains all of the points, either as vertices or on the interior. For more information, see this [question on PGM which defines it very well](https://codegolf....
[Question] [ A [numeronym](https://en.wikipedia.org/wiki/Numeronym) (also known as a "numerical contraction") is when a word is shortened using numbers. A common contraction method is to use the length of the replaced substring to replace all but the first and last characters. For example, use [`i18n` instead of ...
[Question] [ This question will feature a mechanic from the game "Path Of Exile" in this game there are things called **MAPS** they are items that you can use to open high level areas, you can also combine 3 of them to get a upgraded one which will be the task of this challenge. The upgrade combinations are as fo...
[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/37435/edit). Closed 3 years ago. [Improve this question](/posts/37435/edit)...
[Question] [ A certain children's game, often called "Huckle Buckle Beanstalk", is played with two players. Here is a brief description of how the game is played: 1. One player is designated the "hider", and the other the "seeker". 2. The seeker goes out of the room while the hider hides a small, pre-selected obj...
[Question] [ The Haskell function [`biSp`](http://haddocks.fpcomplete.com/fp/7.4.2/20130829-168/concatenative/Control-Concatenative.html#v%3abiSp) has type signature ``` biSp :: (a -> c) -> (b -> d) -> (c -> d -> e) -> a -> b -> e ``` and (for those who prefer [combinator calculus](http://en.wikipedia.org/wiki/Co...
[Question] [ Your objective is to take multiline ASCII like ``` | v | * * * * * * * ``` and have an array that includes everything that isn't a star changed to a star (except for [any-width] spaces) and the number of stars it included and the number of stars it now includes. So the output of my example would b...
[Question] [ The challenge is rather simple: 1. Take a positive whole number \$n\$ as input. 2. Output the \$n\$th Fibonacci prime number, i.e. the \$n\$th Fibonacci number that is also prime. Input can be as an parameter to a function (and the output will be the return value), or can be taken from the command li...
[Question] [ It can be proven that there's exactly one string of infinite length that remain same after `base64` encoding [`Vm0wd2QyUXlVWGxWV0d4V1YwZ...`](https://tio.run/##Ncy/DsIgEMfx3ae4DUixafzTBVl8BUfjcFZoDppioLoYnx1tQ9fv537n8I2pi/SctmN4mJxtiMBJNwrotDu2CqqKxAZg6W7ubu1u7kX8LH4VL@CzGACChvPLWhP5laST/iZUIbLAsZ7CZ...
[Question] [ *Alternatively: Now you're checking with portals!* *[Inspired this challenge](https://codegolf.stackexchange.com/questions/256814/knight-to-fork)* I am somewhat of a self-declared [Chess Anarchist](https://www.reddit.com/r/AnarchyChess/). That means that when I play chess, en passant is forced (else ...
[Question] [ ## Introduction The \$RADD(n)\$ operation is defined as the sum of \$n + [\$ the number whose decimal representation are the decimal digits of \$n\$ in reverse order \$]\$, see [A004086](https://oeis.org/A004086). After reversal, trailing zeros are lost. See [Reverse-Then-Add Sequence](https://mathwo...
[Question] [ Part of [**Code Golf Advent Calendar 2022**](https://codegolf.meta.stackexchange.com/questions/25251/announcing-code-golf-advent-calendar-2022-event-challenge-sandbox) event. See the linked meta post for details. --- *challenge idea by [emanresu A](https://chat.stackexchange.com/transcript/message/62...
[Question] [ Part of [**Code Golf Advent Calendar 2022**](https://codegolf.meta.stackexchange.com/questions/25251/announcing-code-golf-advent-calendar-2022-event-challenge-sandbox) event. See the linked meta post for details. --- As we all know, Santa comes down the chimney to deliver presents to good kids. But c...
[Question] [ > > **Note:** This is a more limited version of a [challenge from 2014](https://codegolf.stackexchange.com/questions/40150/find-a-representative-submatrix) that only received one answer. That challenge required participants write two programs; this challenge is essentially one half of that. The text...
[Question] [ What is the shortest way to convert a string containing integers separated by spaces to a list of integers? * input : "-3 1 5 8 10" * output : [-3, 1, 5, 8, 10] I regularly face this situation and I wanted to know if there is a better way than (24 bytes): ``` list(map(int,s.split())) ``` [Answ...
[Question] [ ## Introduction: In Dutch, the words leading and suffering, being 'leiden' and 'lijden' respectively, are pronounced the same way. One is written with a "short ei", and one with a ["long ij"](https://en.wikipedia.org/wiki/IJ_(digraph)), as we Dutchman would say, but both 'ei' and 'ij' are pronounced ...
[Question] [ # An Séimhiú agus an tUrú In Irish Gaelic (Gaeilge) there are a number of ways that the start of a word can be changed. The most common of these are lenition (an séimhiú) and eclipsis (an t-urú) Lenition involves adding the letter *h* as the second letter. For example, the word "bean" (woman) would b...
[Question] [ In [Map inputted ASCII characters](https://codegolf.stackexchange.com/q/124306/61563), I asked you to .. map inputted ASCII characters. This time, you will do the opposite, by immediately mapping all ASCII characters, and then mapping spaces over them. This program will have practical uses, such as s...
[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/105753/edit). Closed 7 years ago. [Improve this question](/posts/105753/edi...
[Question] [ Let's parse and process Key-Language! Given the input of a sequence of keyboard keypresses and/or special keys, write a program, function, etc. that outputs the product when all the actions are processed based on the following keyboard: ``` +-------------------------------------------------------+ | ...
[Question] [ My preferred way to approximate a derivative is the central difference, its more accurate than forward difference or backward difference, and I'm too lazy to go higher-order. But the central difference requires a data point on either side of point you are evaluating. Normally this means you end up no...
[Question] [ This is based on this challenge and Geobits's/CarpetPython's idea to improve it: [Keep your distance!](https://codegolf.stackexchange.com/questions/44781/keep-your-distance) For this challenge, the distance between two numbers is measured on a loop, so, for example, the distance between 0 and 999 is ...
[Question] [ # Background In this challenge, a *base-`b` representation* of an integer `n` is an expression of `n` as a sum of powers of `b`, where each term occurs at most `b-1` times. For example, the base-`4` representation of `2015` is ``` 4^5 + 3*4^4 + 3*4^3 + 4^2 + 3*4 + 3 ``` Now, the *hereditary* base-`b`...
[Question] [ Your goal is to implement [Möbius inversion](http://en.wikipedia.org/wiki/M%C3%B6bius_inversion_formula), a linear operation on a sequence of numbers that is [used in combinatorics and number theory](https://www.maa.org/sites/default/files/pdf/upload_library/22/Ford/BenderGoldman.pdf). Fewest bytes w...
[Question] [ The [edit (or Levenshtein) distance](https://en.wikipedia.org/wiki/Edit_distance) between two strings is the minimal number of single character insertions, deletions and substitutions needed to transform one string into the other. If the two strings have length n each, it is well known that this can ...
[Question] [ # Input The code should take an integer \$n\$ between 1 and 1000. # Output The code should output positive integers with \$n\$ bits. Accompanying each integer should be its full factorization. Each integer should be a uniformly random \$n\$ bit number. # Score The score for your code will be the numb...
[Question] [ # Context After ["Computing a specific coefficient in a product of polynomials"](https://codegolf.stackexchange.com/q/198779/75323), asking you to compute a specific coefficient of polynomial multiplication, I wish to create a "mirror" challenge, asking you to compute a specific coefficient from poly...
[Question] [ Given a string that is potentially boxed in, toggle the box. This becomes clearer in the test cases and explanation. # Input / Output ### Input Format The input will be either a single string separated by CR, LF, or CRLF, or a list of strings. The input format is up to you to decide. ### Output Forma...
[Question] [ I recently listed to the song [I'm a Textpert](https://m.youtube.com/watch?v=FWj42BxDXCU) about texting while driving and one particular line in the song inspired this challenge. > > I never stoop so low as to text photos / Instead I text the correct combo of ones and zeros > > > Now obviously, t...
[Question] [ Given two lists that contain no duplicate elements `a` and `b`, find the crossover between the two lists and output an ASCII-Art Venn Diagram. The Venn Diagram will use a squarified version of the traditional circles for simplicity. # Example **Given:** ``` a = [1, 11, 'Fox', 'Bear', 333, 'Bee'] b = ...
[Question] [ `tinylisp` is, in its essence, a very stripped-down version of Lisp, as the name suggests. It was made by @DLosc for an "interpret this language" challenge, which can be found [here](https://codegolf.stackexchange.com/questions/62886/tiny-lisp-tiny-interpreter). It features a small amount of builtins...
[Question] [ Tamagotchi and Giga Pets were small electronic devices which simulated a little virtual pet. This pet had several stats, like health, hunger, etc. I recently wrote this example: ``` import msvcrt,os,sys;d=m=100;h=s=t=p=0;f=10 while 1: os.system('cls'if os.name=='nt'else'clear');print("health:",d,"...
[Question] [ In the examples below, `A` and `B` will be 2-by-2 matrices, and the matrices are one-indexed. A [Kronecker *product*](http://mathworld.wolfram.com/KroneckerProduct.html) has the following properties: ``` A⊗B = A(1,1)*B A(1,2)*B A(2,1)*B A(2,2)*B = A(1,1)*B(1,1) A(1,1)*B(1,2) A...
[Question] [ Given a string of letters and a set of words, output an ordering of the words so that they can be found in the string by dropping letters that are not needed. Words may occur more than once in the word set. The input string and all words will consist of 1 to 1000 lower case letters each. The letters ...
[Question] [ # Introduction [Doppelkopf](https://en.wikipedia.org/wiki/Doppelkopf) is a traditional German card game for 4 players. The deck consists of 48 cards (9, 10, Jack, Queen, King, Ace of each suit while every card is in the game twice), so each player gets 12 at the start of a round. There are always 2 t...
[Question] [ Two rows of a matrix are *orthogonal* if their inner product equals zero. Call a matrix with all rows pairwise orthogonal an *orthogonal matrix*. A [circulant matrix](https://en.wikipedia.org/wiki/Circulant_matrix) is one where each row vector is rotated one element to the right relative to the prece...
[Question] [ In this challenge, you need to parse morgue files from the roguelike game [Dungeon Crawl Stone Soup](http://crawl.develz.org) and output it to STDOUT. ## What are these morgue files?? When you die, a text file is generated with that character's data inside. You can see what equipment the character ha...
[Question] [ The [*Ship of Theseus*](http://en.wikipedia.org/wiki/Ship_of_Theseus) is an old question that goes something like: > > If a ship has had all of its original parts replaced, is it still the same ship? > > > For this golf, we're going to slowly replace "parts" on a "ship", and see how long it takes...
[Question] [ # Introduction You are a friend of a curator for an art museum, who has had the recent delight of getting modern art from four artists (*some of which may give the curator zero pieces of art, young scoundrels*). As this is modern art, all of any given artist's pieces look exactly the same. Your frien...
[Question] [ After your [disastrous canoe ride](https://codegolf.stackexchange.com/questions/36337/extreme-whitewater-canoeing), you ended up falling off a waterfall at the end of the river rapids. Your canoe exploded, but you managed to survive the explosion. However, your river journey went completely off the m...
[Question] [ Your mission is to write a program that accepts a date in the formats `2014-02-27` (calendar date) and `2014-W09-4` (week date) from standard input and outputs the date in the format it wasn't entered in (to standard output with a trailing newline). The dates must conform to the standard ISO 8601, i....
[Question] [ Assuming A=1, B=2... Z=26, and the value of a word is the sum of these letter values, it is possible to split some words into two pieces such that they have equal values. For example, "wordsplit" can be broken into two pieces like so: ordsl wpit, because o+r+d+s+l = w+p+i+t. This was a challenge give...
[Question] [ [The Universal Crossword](https://www.puzzlesociety.com/crosswords) has a set of [guidelines](https://docs.google.com/document/d/1ORNpKwGG7RedypfnYwgOfkTUc0jNZ7FKRRTVWDmTfl8/edit) for crossword puzzle submissions. In this challenge we are going to be concerned with their rules for hidden word themes....
[Question] [ A [fixed-point combinator](https://en.wikipedia.org/wiki/Fixed-point_combinator) is a higher order function \$\mathrm{fix}\$ that returns the fixed point of its argument function. If the function \$f\$ has one or more fixed points, then $$\mathrm{fix} f=f(\mathrm{fix} f).$$ The combinator \$Y\$ has s...
[Question] [ There have already been challenges about computing the [exponential](https://codegolf.stackexchange.com/questions/230784/to-raise-e-to-the-power-of-a-matrix) of a matrix , as well as computing the [natural logarithm](https://codegolf.stackexchange.com/questions/262711/vanilla-natural-logarithm-challe...
[Question] [ A twin of [this](https://codegolf.stackexchange.com/questions/249186/fix-my-fizzbuzz). FizzBuzz is where a range of positive integers is taken, and numbers divisible by 3 are replaced with "Fizz", divisible by 5 with "Buzz" and divisible by 15 with "FizzBuzz". For example, FizzBuzz from 1 to 10 is `1...
[Question] [ Lean is a theorem prover and programming language. It's also as of writing the [Language of the Month](https://codegolf.meta.stackexchange.com/q/23916/56656)! What tips do people have for golfing in Lean? As always, tips should be specific to to Lean (e.g. "Remove comments" is not an answer), and sti...
[Question] [ ## Background The [fixed-point combinator](https://en.wikipedia.org/wiki/Fixed-point_combinator) \$\textsf{fix}\$ is a higher-order function that computes the fixed point of the given function. $$\textsf{fix}\ f = f\ (\textsf{fix}\ f)$$ In terms of programming, it is used to implement recursion in la...
[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/216576/edit). Closed 3 years ago. [Improve this question](/posts/216576/edi...
[Question] [ I often have to take character data and categorize it numerically at work. A common thing I do is to take character type variables and convert them to numeric type characters, keeping same categories according to the level of work I'm doing. (The longer the substring, the more in depth and specific, ...
[Question] [ Flip flop is a memory / arithmetic game that I played in high school. Some number of players stand in a circle. The players take turns. On the `n`th turn, the current player checks: 1. What is the largest power of 7 dividing n? 2. How many instances of the digit 7 does the decimal representation of n...
[Question] [ **This question already has answers here**: [Coding Convention Conversion](/questions/70180/coding-convention-conversion) (19 answers) Closed 4 years ago. ## Story In an unnamed company, some people use Java and some use C++. This was always a nuisance, and they kept on arguing which single la...
[Question] [ ## Background Though this is a bit late for Pi Day, I saw an article about [Pilish](https://en.wikipedia.org/wiki/Pilish) and thought it would make a great challenge. Pilish is created by using a sequence of words where each word's length corresponds to a digit of pi. Example from Wikipedia: > > The...
[Question] [ I guess I'm not the only one who have seen this kind of image on Facebook (and other sites). [![Solve it!!!!](https://i.stack.imgur.com/vgvsh.png)](https://i.stack.imgur.com/vgvsh.png) The picture above was posted 16 days ago, and has accumulated 51 k comments. Some answers: 0, 4, 8, 48, 88, 120, 12...
[Question] [ Your geologist buddy nearly kicked down your office door as he burst in, eyes wide in excitement, and asked you to come with him to a site he just discovered. On the way he explains that he thinks he literally just struck gold. Only problem is, it's buried deep underground in a cavern with a very uns...
[Question] [ Let \$n > 0\$. Let \$X = 1, 2,...,n\$ and \$Y = n+1, n+2, ..., 2n\$. Define \$a(n)\$ as the number of permutations \$p\$ of \$Y\$ such that every element of \$X + p(Y)\$ is prime. For example: ``` n = 2 X = [1,2] Y = [3,4] p_0(Y) = [3,4] => X + p0(Y) = [4,6] => No p_1(Y) = [4,3] => X + p1(Y) = [5,5] ...
[Question] [ Your task is to build a vim script or provide a sequence of keystrokes that will operate on a single line of text with up to 140 printable ASCII characters (anywhere in a file, with the cursor starting anywhere in the line) and reverse every space-separated string in the sentence while keeping the st...
[Question] [ Your task is to write a program in x86 machine language (any version you like) that will run through as many instructions as possible and then halt, using a maximum of 32 bytes of code and starting with zeroed-out registers. You can assume anything about the random-access memory you like, as long as ...
[Question] [ Given two strings containing only `0` and `1`, decide the probability that first appears earlier as a consecutive substring in an infinite random 0/1 stream. You can assume that neither string is suffix of the other string, so `01, 1`, `00, 0` are invalid. (\*) IO format flexible. Your answer should ...
[Question] [ This challenge is from a game, [Keep Talking And Nobody Explodes](https://keeptalkinggame.com/). *This is like one of those toys you played with as a kid where you have to match the pattern that appears, except this one is a knockoff that was probably purchased at a dollar store.* – From the [manual]...
[Question] [ ## Background This is Post's lattice: [![Post's lattice](https://i.stack.imgur.com/flzRU.png)](https://i.stack.imgur.com/flzRU.png) Credit: [EmilJ](https://commons.wikimedia.org/wiki/File:Post-lattice.svg) It denotes the lattice of all clones on a two-element set `{0, 1}`, ordered by inclusion (from ...
[Question] [ # Universal Command Sequence ## Definition An \$n\$-maze is a \$n\times n\$ chessboard which has "walls" on some edges, and a "king" on the board that can move to the 4 adjacent cells, which cannot pass through any walls. Starting from any cell the king should be able to reach every cell on the board...
[Question] [ The title is an homage of the [Natural Number Game](https://wwwf.imperial.ac.uk/%7Ebuzzard/xena/natural_number_game/), which is a nice interactive tutorial into proving certain properties of natural numbers in Lean. --- The definitions used in [Lv1](https://codegolf.stackexchange.com/q/236182/78410) ...
[Question] [ Inspired by [This answer to a Puzzling question](https://puzzling.stackexchange.com/a/97195/42642) **Background - exponentiation by squaring** *If you don't want to read the background, or don't understand it, there's a worked example in Java, linked at the bottom of the post.* \$a^{2^{x+1}} = a^{2...
[Question] [ For more MtG-goodness: [Magic: The Gathering Combat with Abilities](https://codegolf.stackexchange.com/questions/171158/magic-the-gathering-combat-with-abilities?rq=1) # Premise: In Magic: the Gathering, you cast spells by paying their mana cost by tapping lands for the required amount. These lands c...
[Question] [ We have a floating point number `r` between 0 and 1, and an integer `p`. Find the fraction of integers with the smallest denominator, which approximates `r` with at least `p`-digit precision. * Inputs: `r` (a floating point number) and `p` (integer). * Outputs: `a` and `b` integers, where + `a/b` (a...
[Question] [ First, a few definitions: * Given `n` and `k`, consider the sorted list of [**multisets**](https://en.wikipedia.org/wiki/Multiset), where for each multiset we choose `k` numbers from `{0, 1, ..., n-1}` with repetitions. For example, for `n=5` and `k=3`, we have: > > [(0, 0, 0), (0, 0, 1), (0, 0, 2),...
[Question] [ Write a program or function with the following functionality: * The program/function first attempts to write the string `Hello, world!` to the standard output stream. (No other forms of output are acceptable for this challenge, as the focus is very much on the I/O rather than the trivial behaviour of...
[Question] [ # Challenge Write a function or program that accepts a line of input, performs a very specific and oddly familiar shuffle on its characters, and outputs the result. The required shuffling can be described using the following algorithm: 1. Label each character in the input with a 1 based index. 2. Wri...
[Question] [ Keeping with a festive theme, print a carol singing angel with the shortest possible code. The angel is raising money for the homeless, so must be able to sing all three of the below songs available at request. To illustrate she can sing them, the title of the song must be placed within the speech bu...
[Question] [ A Diagonal [Sudoku](https://en.wikipedia.org/wiki/Sudoku) board is a special case of [Latin squares](https://en.wikipedia.org/wiki/Latin_square). It has the following properties: * The board is a 9-by-9 matrix * Each row contains the numbers `1-9` * Each column contains the numbers `1-9` * Each 3-by-...
[Question] [ Some trading cards have real value and can be sold for money. Bending the cards is frowned upon because it takes away their value and makes them look less new. Say you have a deck of trading cards (Pokemon, Magic, etc.) and you want to shuffle them. Instead of doing the bridge that bends all of the c...
[Question] [ A subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. A strictly increasing subsequence is a subsequence in which every element is bigger than the preceding one. The heaviest increasing subsequence of a se...
[Question] [ An *acyclical grid* is a mapping of an acyclical graph (that is, a tree) where each node has no more than four edges onto a toroidal rectangular grid such that each cell of the grid is occupied by a node. Here is an example of an acyclical grid: ``` ┴─┐╵╵│└┘└╴╶┴┬ ╴╷╵┌┐│╷┌┬┐╶┐├ ╷│╷╵│├┘│╵└╴│╵ ┘└┴┐│└┬┤┌...
[Question] [ In Conway's Game of Life, a cell is in a state of either on or off, depending on the on-and-off state of the eight cells surrounding it. We can simulate this using a logic gate network with some sort of clock signal that updates every cell all at once. Your task in this problem is to build the logic ...
[Question] [ # The Challenge For a given set of n integers, write a program which will output its lexicographic index. # The Rules * The input must only be a set of unique non-negative integers separated by spaces. * You should output the lexicographic index (range 0 to n!-1 inclusive) of the permutation. * No pe...
[Question] [ **Problem:** You must make a program that does the following: * takes a large string of lowercase text, and counts all the occurrences of each letter. * then you put the letters in order from greatest to least occurences. * then you take that list and turns it into an encoder/decoder for the text. * ...
[Question] [ **This question already has answers here**: [Get the decimal!](/questions/117440/get-the-decimal) (28 answers) Closed 6 years ago. Given three integers N,D,R write a program to output Rth digit after the decimal point in the decimal expansion for a given proper fraction N/D. [Answer] ##...