text
stringlengths
180
608k
[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/22640/edit). Closed 6 years ago. [Improve this question](/posts/22640/edit)...
[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/192803/edit). Closed 4 years ago. [Improve this question](/posts/192803/edi...
[Question] [ You are chained to a chair. Underneath you is a huge volcano. A 12-hour clock next to you ticks ominously, and you see that it has wires leading from the back up to a chain, which will drop you into the center of the earth. Taped to the clock is a note: > > Each clock hand has an electrode. When bot...
[Question] [ In the musical rendition of Les Miserables, a song appears called "Red and Black." Here is part of that song: > > Red - the blood of angry men! > > > Black - the dark of ages past! > > > Red - a world about to dawn! > > > Black - the night that ends at last! > > > [Source.](http://lesmisera...
[Question] [ **Your Task** Given a list of words, check if they form a valid word grid. They form a valid grid if there are **N** words with **N** letters and they spell the same words vertically as they do horizontally. The words can be given in any order. `[FILE, ICED, LEAD, EDDY]` = `True` and `[FILE, LEAD, ED...
[Question] [ Imagine you are working on a 3D adaptation of the classical video game [Asteroids](http://en.wikipedia.org/wiki/Asteroids_%28video_game%29). Your task is to write an algorithm that can create a random 3D asteroid. This is a popularity contest, not code golf. Write nice code and create interesting res...
[Question] [ The task is to calculate the average "funniness" of a given number given the following scoring system: * 1 point for each "420" in it * 2 points for each "69" in it * 3 points if its a palindrome (doesn't count if it's just a single digit) * 4 points if it has (not for each) "800813" * 5 points for e...
[Question] [ Generative AI is here! It's great for certain things, but it has a few problems. Not only has it broken our Stack Exchange community, it also makes mistakes. For example, when you ask Bing AI if it is sentient, Bing says [![Bing](https://i.stack.imgur.com/djtZG.jpg)](https://i.stack.imgur.com/djtZG.j...
[Question] [ Print this tree: ``` 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 15 20 15 7 21 35 35 21 7 8 28 56 70 56 28 8 9 36 84 126 126 84 36 9 252 462 462 924 ...
[Question] [ Your task is to write some code that outputs an OEIS sequence, and contains the name of the sequence in the code (`A______`). Easy enough right? Well here's the catch, your code must also output a second separate sequence when the name of the sequence in the code is changed to the name of the second ...
[Question] [ A rotation ["is made by splitting a string into two pieces and reversing their order"](https://codegolf.stackexchange.com/q/121522/48934). An object is symmetrical under an operation if the object is unchanged after applying said operation. So, a "rotational symmetry" is the fact that a string remain...
[Question] [ We define a map as a set of key-value pairs. For this challenge, you need to take each of the values and assign them to a randomly chosen key. * You must *randomly* shuffle the values, and output the resulting map. This means that each time we run your program, we have a chance of getting a different...
[Question] [ ## Brief description of the game In the game [Otteretto Classic](https://otteretto.app/) (which you can test directly in your browser; try it!) the player has to form palindromic sequences using adjacent cells on a square grid. Each cell has one of five possible colours, which we will denote by the l...
[Question] [ ## Background You have again x4 been given the task of calculating the number of landmines in a field. But this time, the field is not a number field... it's a field of letters. Our landmine letter operator is sick and requires you to cover for them. They left you the following note: > > Things work...
[Question] [ Output the **current time of day** as [Swatch Internet Time](https://en.wikipedia.org/wiki/Swatch_Internet_Time). Specifically, output a three-digit (zero-padded) number of "[.beats](https://en.wikipedia.org/wiki/Swatch_Internet_Time#Beats)" (1000ths of a day) which represent the current time of day ...
[Question] [ Your mission, if you choose to accept it, is to construct a simple truth evaluator for the following logical operators: ``` ---------------------------------------------------------------------------------- Logical Name | Gate Name | Symbol | Symbol Name | Truth Table -------------...
[Question] [ I've been a fan of *My Little Pony: Friendship Is Magic* for a long time, and very early on I created a pony version of myself also called [Parcly Taxel](https://derpibooru.org/images/2775280) (warning: may be too cute to look at). The symbol below is her "[cutie mark](https://mlp.fandom.com/wiki/Cut...
[Question] [ I'm writing a program that takes a number from input (call it x), loops from 0 to (x - 1) (let's call our iterator y) and prints \$y^x+x\$ for each y. After the loop, it then prints "SUM: N" (without a newline) where the N is the sum of the all of the previously printed values. How can I make the cod...
[Question] [ # Premise: For those in networking, you've most likely sent a ping to or from some device to make sure everything's properly connected. Cisco, a popular company in networking[citation needed], has a command for it in their IOS that looks like this: [![Capture](https://i.stack.imgur.com/W8uAL.jpg)](h...
[Question] [ **Problem** Given a value n, imagine a mountain landscape inscribed in a reference (0, 0) to (2n, 0). There musn't be white spaces between slopes and also the mountain musn't descend below the x axis. The problem to be solved is: given n (which defines the size of the landscape) and the number k of p...
[Question] [ There are 8 Australian states and territories, each with a 2 or 3 letter abbreviation: * ACT: Australian Capital Territory * NSW: New South Wales * NT: Northern Territory * QLD: Queensland * SA: South Australia * TAS: Tasmania * VIC: Victoria * WA: Western Australia > > Your task is to write a funct...
[Question] [ `{}`is the empty set. You may use `()` or `[]` if you choose. We aren't going to rigorously define "set", but sets all satisfy the following properties: Sets follow the usual mathematical structure. Here are some important points: * Sets are not ordered. * No set contains itself. * Elements are eith...
[Question] [ This task is about writing code to compute a probability exactly. The output should be a precise probability written as a fraction in its most reduced form. That is it should never output `4/8` but rather `1/2`. For some positive integer `n`, consider a uniformly random string of 1s and -1s of length...
[Question] [ Let us define the Fibonacci sequence as ``` F(1) = 1 F(2) = 2 F(n) = F(n - 2) + F(n - 1) ``` So we have the infinite sequence `1,2,3,5,8,13,`... It is well known that any positive integer can be written as a sum of some Fibonacci numbers. The only caveat is that this summation might not be unique. T...
[Question] [ For each character in your program, the program with that character removed must produce a number smaller than the program with the next character removed. Your base program isn't required to do anything, and may be invalid. An example submission could be `abcd`, where `bcd` outputs 1, `acd` outputs ...
[Question] [ Given an integer `n >= 1` as input, output a sample from the discrete triangular distribution over the integers `k`, for `1 <= k <= n` (`1 <= k < n` is also acceptable), defined by `p(k) ∝ k`. E.g. if `n = 3`, then `p(1) = 1/6`, `p(2) = 2/6`, and `p(3) = 3/6`. Your code should take **constant expecte...
[Question] [ Based on the ["Pretty Ugly"](https://i.pinimg.com/originals/87/ef/ec/87efecc2e9b48e35b1b9943760ac23b6.jpg) poem. Input consists of a number of stanzas (positive integer), and four arrays/lists of strings, called the "negatives", "negations", "positives", and "filler" sentences. You must output a "pre...
[Question] [ **This question already has answers here**: [Is this number a prime?](/questions/57617/is-this-number-a-prime) (367 answers) Closed 6 years ago. [Bertrand's postulate](https://en.wikipedia.org/wiki/Bertrand%27s_postulate) states that there is always at least 1 prime number between **n** and **...
[Question] [ I was trying to find the shortest code possible that given a number n, returns the next prime palindrome number (limited to below 100000). If the number itself is a prime palindrome, the code should return the next one. Write the shortest program/function that, when given an input `n` (less than `100...
[Question] [ [Cops' challenge](https://codegolf.stackexchange.com/q/248188/66833) This [cops-and-robbers](/questions/tagged/cops-and-robbers "show questions tagged 'cops-and-robbers'") challenge challenges the Cop to write a non-empty program that, when run, produces some non-empty output in language A, and, when...
[Question] [ Peano numbers represent nonnegative integers as zero or successors of other Peano numbers. For example, 1 would be represented as `Succ(Zero)` and 3 would be `Succ(Succ(Succ(Zero)))`. # Task Implement the following operations on Peano numbers, at compile time: * Addition * Subtraction - You will neve...
[Question] [ ## Story Martians have been observing [Aussie rules football](https://en.wikipedia.org/wiki/Australian_rules_football) matches from space with great curiosity. Having totally fallen in love with the game, they have been inspired to start their very own football league. However, being dim-witted creat...
[Question] [ ## Background There's a terrible problem in my console - the quotes never get included inside the arguments! So, when given this argument: ``` ["abc","def","ghi","jkl"] ``` it says that the argument is like this: ``` [abc,def,ghi,jkl] ``` It would be very nice if you can fix this problem! ## Challeng...
[Question] [ Not to be confused with [this question](https://codegolf.stackexchange.com/questions/103403/print-the-f-%C3%97-f-times-table). You need to draw a times table (also known as [Cremona's method for cardioid generation](https://en.wikipedia.org/wiki/Cardioid#Cardioid_as_envelope_of_a_pencil_of_lines)) as...
[Question] [ Take two inputs, a non-empty vector/list containing digits `1` and `2` and a string (no, you may not take `0/1` instead). The string will be one of the following (in lowercase, exactly as written below: ``` increasing decreasing ones twos all none ``` If the string is \_\_\_\_ then you shall return t...
[Question] [ Given a the name of a state of the United States as a string (with case), return the number of votes the state has in the [Electoral College](https://en.wikipedia.org/wiki/Electoral_College_(United_States)). Write a full program or function, and take input and output through any default I/O method. A...
[Question] [ ### Input: **Any** Brainfuck program. This includes brainfuck programs with comments such as `+++COMMENT[>+++<-].`. ### Output: A program in one of the below languages that produces the same output as the Brainfuck program on **all inputs**. It should produce the same output exactly as the [interepre...
[Question] [ The [Collatz sequence](http://en.wikipedia.org/wiki/Collatz_conjecture) starting from a positive integer n is defined in this way: * if n is even then divide it by 2 (`n' = n / 2`) * if n is odd then multiply it by 3 and add 1 (`n' = 3n + 1`) Repeat the above iteration until n reaches 1. It is not kn...
[Question] [ You are given a directed graph in an adjacency dictionary format. This can be whatever format is most natural for your language. For instance, in python, this would be a dictionary with keys of nodes and values which are lists of nodes which that node has an edge to. For instance: ``` G={1: [2, 3], 2...
[Question] [ I am referring to Project Euler #12. Write the solution in any language you want, but consume the least amount of memory while executing. Running time is not measure in this case. > > The sequence of triangle numbers is > generated by adding the natural > numbers. So the 7th triangle number > wo...
[Question] [ The sequence discussed in this challenge is a variant of the Descending Dungeons sequence family. Specifically, the sequence generation rules: ``` (A_b = A's base 10 representation read as a base b number, A = A_10) A(0) = 10 A(n) = 10_(11_(12_(...(n+9)_(n+10)))) ``` Your goal is to make a program wh...
[Question] [ Your task is to determine the length of the longest descent down a "mountain" represented as a grid of integer heights. A "descent" is any path from a starting cell to orthogonally adjacent cells with strictly decreasing heights (i.e. not diagonal and not to the same height). For instance, you can mo...
[Question] [ Almost all digital camera sensors are organized in a grid of photosensors. Each photo sensor is sensitive for one of the [primary colors](https://en.wikipedia.org/wiki/Primary_color): red, green and blue. The way those photo sensors are organized is called the [Bayer filter](https://en.wikipedia.org/...
[Question] [ Continuation of [this challenge](https://codegolf.stackexchange.com/questions/77254/create-a-boolean-parser) because the author is gone and the question is closed. --- What you need to do is create a Boolean parser. --- Boolean expressions, in case you haven't heard of them yet, have two inputs and o...
[Question] [ ## Problem statement The task is to write the shortest R statement to count the cells (rows \* cols) in an instance of the R type `numeric data.frame`. For example, the `data.frame` which would be displayed as ``` a b c 1 1 2000 NA 2 2 2000 NA 3 3 2000 1 4 4 2000 Inf ``` has 12 cells. ## Input ...
[Question] [ Your challenge (if you choose to accept it) is to implement big integer multiplication in the shortest code possible. Rules: * Take two integers (decimal form) as ASCII strings from the command line parameters of your program. If your language doesn't support command line parameters, I'll accept stdi...
[Question] [ An even distribution number is a number such that if you select any of it's digits at random the probability of it being any particular value (e.g. `0` or `6`) is the same, \$\frac1{10}\$. A precise definition is given later on. Here are a few examples: * \$\frac{137174210}{1111111111} =0.\overline{1...
[Question] [ Part of the [**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 a Christmas gift, you were given a toy solar system. In this toy, all the orb...
[Question] [ *This is the robbers' thread. For the main rules to this challenge see the [cops' thread](https://codegolf.stackexchange.com/questions/251450/polyglot-quiz-cops-thread)* In this challenge, robbers will choose a cop's *vulnerable* or *safe* post and try to figure out a pair of languages such that they...
[Question] [ Draw the following in the fewest bytes possible: ``` ------------------------- | | ABC | DEF | | 1 | 2 | 3 | ------------------------- | GHI | JKL | MNO | | 4 | 5 | 6 | ------------------------- | PQRS | TUV | WXYZ | | 7 | 8 | 9 | --------------...
[Question] [ # Privileged Strings The set of *privileged strings* is defined recursively as follows. * All strings of length 0 or 1 are privileged. * A string `s` of length at least 2 is privileged, if there exists a shorter privileged string `t` that occurs in `s` exactly twice, once as a prefix and once as a su...
[Question] [ The task is to count the number of distinct substrings of length k, for k = 1,2,3,4,..... **Output** You should output one line per `k` you manage to complete with one number per output line. Your output should be in order of increasing `k` until you run out of time. **Score** Your score is the highe...
[Question] [ Inspired by Greg Martin's "[Shiny cryptarithm](https://puzzling.stackexchange.com/q/122716/65757)" puzzle. A [cryptarithm](https://en.wikipedia.org/wiki/Cryptarithm) is a game consisting of a mathematical equation among unknown numbers, whose digits are represented by letters of the alphabet. The goa...
[Question] [ I have previously posted a challenge, [smallest number of steps for a knight in chess](https://codegolf.stackexchange.com/q/251050/113952). Now I would like to go a step further by adding the possibility to choose your piece. If you place a piece on any square of a chessboard, what is the smallest nu...
[Question] [ Given a `MM/DD` date (`12/24`) and a start/end date range (`11/01 - 06/24`), figure out if the date is within the listed date span. Date ranges can be sequential (`05/01 - 11/01`) or wrap around to the next year (`11/01 - 05/01`). Examples: * `12/24` is in `11/01 - 06/24` = True * `06/24` is in `11/0...
[Question] [ The goal of this challenge is to use [Euler's method](https://en.wikipedia.org/wiki/Euler_method#Derivation) to approximate the solution of a differential equation of the form f(n)(x) = c.† The input will be a list of integers in which the *n*th value represents the value of f(n)(0). The first intege...
[Question] [ It is December 2014, and 2015 has almost started. However, it appears not everyone has realized this. [![Jon: “2009 has sure been a long year” | Garfield looks at calendar | Garfield: “We gotta get a new calendar”](https://assets.amuniversal.com/7c0935604b6f0132acd5005056a9545d)](http://www.gocomics....
[Question] [ I work a standard nine to five. Monday through Friday. I take a half hour for lunch from 12:30 to 13:00. Write me a program which, when run, calculates the percentage of the working week that I have completed at the current moment. Rules * Only count time actually spent working. I am punctual and do ...
[Question] [ Some numbers can be represented as perfect powers of other numbers. A number x can be represented as x = base^power for some integer base and power. Given an integer x you have to find the largest value of power, such that base is also an integer. ``` Sample Input: 9 Sample Output: 2 ``` [Answ...
[Question] [ ## Challenge: Given a list of nonempty lists of integers, return a list of tuples of the following form: First list tuples starting with each element of the first list followed by the first element of every subsequent list, so the ith tuple should be `[ith element of first list, first element of seco...
[Question] [ Given Color codes in CMYK, convert it to RGB value. **Input:** *string of 4 integers(ranging from 0-100) separated by space* ``` 86 86 0 43 28 14 0 6 0 41 73 4 ``` **Output:** ``` #141592 #ABCDEF #F49043 ``` Shortest code wins! > > ***HINT:** For converting CMYK to RGB you may use formula such as...
[Question] [ Let's assign the numbers 0 through 94 to the 95 [printable ASCII characters](http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters): ``` !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ``` Space is 0, `!` is 1, and so on until `~` is 94. We'll a...
[Question] [ ## Input/Output: **Input**: A uniformly random, infinitely long, string of '0's and '1's, taken from stdin. The string is assumed to be truly random, not pseudo-random. It is uniform in that each character is equally likely to be a '0' or '1'. Careful! The input is infinitely long, so you can't store...
[Question] [ # Backstory [which is not true] A piano is set up like this: [![![http://www.piano-lessons-made-simple.com/images/2-Octave-Labled.gif](https://i.stack.imgur.com/JidN0.gif)](https://i.stack.imgur.com/JidN0.gif) However, on my piano, all of the black keys are broken! I still want to be able to play som...
[Question] [ *This challenge is inspired by [Blink the CAPS LOCK](https://codegolf.stackexchange.com/questions/110974/blink-the-caps-lock) by [zeppelin](https://codegolf.stackexchange.com/users/61904/zeppelin).* Most webcams feature a small integrated LED light, indicating if the webcam is in use, as controlled b...
[Question] [ Here is a tic-tac-toe board: ``` a b c | | 1 - | - | - _____|_____|_____ | | 2 - | - | - _____|_____|_____ | | 3 - | - | - | | ``` Given a set of moves, print the board with the tokens on. Input will be take...
[Question] [ # Background This is a continuation of my [earlier challenge](https://codegolf.stackexchange.com/questions/42997/magnetic-sculptures), where the task was to compute the shape of a sculpture obtained by dropping magnets into a huge pile. Good news: the eccentric artist liked your work, and has another...
[Question] [ Seem like GolfScript wins all of these. So you can't beat them, join them. **Write an Self-Contained Golfscript Interpreter** I'm using the definition of self-contained to mean, a single program:- So no passing the buck to some external program to do the work for you. **Test Cases:** Strings and...
[Question] [ ## inputs / outputs your program/function/routine/... will be a predicate on two tuple sequences; call it relation `≡`. for the purpose of simplicity we use natural numbers: * the input will be two list of pairs of numbers from ℕ (including 0); call them `Xs` and `Ys` * the output will be a "truthy" ...
[Question] [ **Definitions:** A palindrome is a string which reads the same backward or forward (not counting spaces or special characters), such as "madam" or "Sorel Eros". A date is said to be a palindrome when its dd-mm-yyyy format is a palindrome (or any other local representation). Two strings are said to ...
[Question] [ Given a positive integer *N* ("virality"), your program should create an ASCII-art drawing of a tree with two branches of length *N* extending downwards and/or rightwards from the top-left corner. The direction taken by each branch *after the first asterisk* can be either rightwards or downwards, and...
[Question] [ A collection of N dimensional coordinates are provided. An example is below: ``` {2,3,4} ``` This can be thought of as a 3 dimensional array with 2x's, 3y's and 4z's; there may be any number of dimensions. In the example, there are 24 total nodes. Each node can be indexed using {x,y,z}. To access the...
[Question] [ The challenge is to detect missing integer sequences of files or directories. You have a directory filled with files/directories that are named as integers. The files/directories are generated from multiple threads yet the job did not complete - there are therefore gaps in the sequence. The input is...
[Question] [ # THE TASK ### DEFINITIONS Consider the points {1,2,3,4,5} and all their permutations. We can find the total number of possible permutations of these 5 points by a simple trick: Imaging filling 5 slots with these points, the first slot will have 5 possible numbers, the second 4 (as one has been used ...
[Question] [ Thank you guys so much for your help with [calculus](https://codegolf.stackexchange.com/questions/31930/help-me-with-differential-calculus). Now I need some help with my upcoming trigonometry test. On the test, I'll need to simplify expressions. I’ll be given input like `4sin(x)/(2cos(x))` and will h...
[Question] [ ## Info The numbers 1 to 9 each represent a cell in the [Moore's Neighbourhood](http://en.wikipedia.org/wiki/Moore_neighborhood), with 5 being the central cell. So: ``` 123 456 789 1={-1,-1} 2={-1, 0} 3={-1, 1} 4={ 0,-1} 5={ 0, 0} 6={ 0, 1} 7={ 1,-1} 8={ 1, 0} 9={ 1, 1} ``` ## The Challenge You may ...
[Question] [ A *2-way universal logic processor* (2ULP) is a network of logic gates that takes two input wires `A` and `B`, as well as four other inputs `L_`, `L_a`, `L_b`, and `L_ab`, and produces a single output `L(a, b)` using the four `L` inputs as a truth table function: * The 2ULP returns `L_` if `A` and `B...
[Question] [ [Related](https://codegolf.stackexchange.com/questions/255460/) Now you have some dice which you may roll several times. You need a uniform random integer between 1 and \$n\$, inclusive. Show a method that rolls the fewest times and behaves as an \$n\$-sided dice. Alternative question: Given a set \$...
[Question] [ Part of [**Advent of Code Golf 2021**](https://codegolf.meta.stackexchange.com/q/24068/78410) event. See the linked meta post for details. The story continues from [AoC2018 Day 7](https://adventofcode.com/2018/day/7), Part 2. [Why I'm pxeger, not Bubbler](https://chat.stackexchange.com/transcript/mes...
[Question] [ Much harder than [Can this pattern be made with dominoes?](https://codegolf.stackexchange.com/q/221167/78410) ## Challenge A grid of width \$w\$ and height \$h\$ is given, filled with 1s and 0s. You can place a domino somewhere on the grid only if both cells are 1. You cannot overlap dominoes. What i...
[Question] [ Let's say we have some arbitrary number: For example 25. We also have some "tokens" (poker chips, money, something similar) with different values. Values of tokens are `2; 3; 4; 5.` "Tokens" are limitless You need to achieve number 25 using exactly n tokens (for example, 8) and to output all possibl...
[Question] [ 99 Varieties of Dosa is a popular chain of roadside dosa stalls across South India. This is inspired by a combination of this chain and the classic CodeGolf challenge "99 Bottles of Beer". Recreate the variant of the menu of the popular '99 Varieties of Dosa' listed below. *(Note: Despite the name, ...
[Question] [ Consider a bridge of length **B** formed by tiles labeled with the digits of the positive integers concatenated. For example, if **B** was 41, then it would look like this: ``` ----------------------------------------- 12345678910111213141516171819202122232425 ``` Now imagine a train of length **T** ...
[Question] [ # Introduction [Alice](https://github.com/m-ender/alice) is a 2-d language by [Martin Ender](https://codegolf.stackexchange.com/users/8478/martin-ender) which has two different execution modes, *cardinal* and *ordinal*. When the instruction pointer passes *through* a mirror (either `/` or `\`), it sw...
[Question] [ You must make a polyglot that outputs its source code in one language and its source code *backward* in another. Unlike the normal rules, you are allowed to read the current file or use a builtin to get the source code of your submission and reverse that in one language. **Your source code cannot be ...
[Question] [ The [Hamming distance](https://en.wikipedia.org/wiki/Hamming_distance) between two strings of equal length is the number of positions at which the corresponding symbols are different. Let `P` be a binary string of length `n` and `T` be a binary string of length `2n-1`. We can compute the `n` Hamming ...
[Question] [ For this challenge, you will be writing a program or function which outputs (or prints) (in a reasonable format, i.e single string or an array of lines) a chess board which indicates all the possible moves of a piece given an empty board. --- There are 5 chess pieces (for this challenge a pawn may be...
[Question] [ Given two strings, a parent string and a query string respectively, your task is to determine how many times the query string, *or an anagram of the query string*; appears in the parent string, in a case-sensitive search. Examples of Behaviour **Input 1** ``` AdnBndAndBdaBn dAn ``` **Output 1** ``` 4...
[Question] [ [Bulgarian Solitaire](http://en.wikipedia.org/wiki/Bulgarian_solitaire) is a single-player game made popular by Martin Gardner in his [mathematical column in *Scientific American*](http://en.wikipedia.org/wiki/Metamagical_Themas). You have `N` identical cards, split into piles. You take a card from e...
[Question] [ Write a program that takes a binary tree as input, and outputs the deepest node and its depth. If there is a tie, print all involved nodes as well as their depths. Each node is represented as: `T(x,x)` `T(x)` `T` where `T` is the identifier of one or more alphanumeric characters and each `x` is anoth...
[Question] [ There are multiple ways to represent a [3D rotation](https://en.wikipedia.org/wiki/Rotation_formalisms_in_three_dimensions). The most intuitive way is the [rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix) – $$A=\begin{bmatrix}A\_{11}&A\_{12}&A\_{13}\\A\_{21}&A\_{22}&A\_{23}\\A\_{31}&A\...
[Question] [ *Note: This challenge has nothing to do with actual assembly language.* --- As the head of **Code-Golf Factory Inc.**, you must create an assembly line to generate a specific piece of code. Today, the foreman has asked you to produce quines. # Specification: In this challenge, the goal is to write a ...
[Question] [ ### Intro More complex than [A square of text](https://codegolf.stackexchange.com/q/88926/43319) since this requires padding and input has unknown data type. Every year, [Dyalog Ltd.](http://www.dyalog.com/) holds a student competition. [The challenge there](http://www.dyalog.com/student-competition....
[Question] [ There exists an equation, assuming `n` and `x` are positive, ![equation](https://i.stack.imgur.com/NSUJB.png) that expresses the relationship between two monomials, one being a common misrepresentation of the other. Many people make the simple mistake of equating these (i.e. `3x^2` and `(3x)^2`). ###...
[Question] [ ## Introduction A while back I stumbled across the *tiny encryption algorithm* ([TEA](https://en.wikipedia.org/wiki/Tiny_Encryption_Algorithm)) and since then I have recommended it whenever special cryptographic security properties were un-needed and a self-implementation was a requirement. Now tod...
[Question] [ ## Index sum and strip my matrix Given a matrix/2d array in your preferable language **Input:** * The matrix will always have an odd length * The matrix will always be perfectly square * The matrix values can be any integer in your language (positive or negative) --- **Example:** ``` 1 2 3 4 5 6...
[Question] [ Create program that counts the total number of letters common to two names, and finds the product of their lengths, to function as a "love tester." Conditions: you may not get a 1:1 answer (being 3 out of 3, etc.) output. ## Input Two names from STDIN or closest alternative. ## Output Compute `x` as ...
[Question] [ Write a program that converts a decimal to a mixed, simplified fraction. Sample input: ``` 5.2 ``` Sample output: ``` 5 + (1/5) ``` The code with the shortest length in bytes wins. [Answer] # Ruby, 43 ``` y=gets.to_r;puts"#{y.to_i} + (#{y-y.to_i})" ``` Pretty straightforward. [Answer] ## pytho...
[Question] [ Taken from [Google Code Jam 2013 Qualification Round Problem B](https://code.google.com/codejam/contest/2270488/dashboard#s=p1): > > Alice and Bob have a lawn in front of their house, shaped like an N metre by M metre rectangle. Each year, they try to cut the lawn in some interesting pattern. They u...
[Question] [ Produce a program to correctly number a crossword grid. ## Input The input will be the name of a file representing the crossword grid. The input filename may be passed as an argument, on the standard input, or by other conventional means other than hardcoding. **Grid file format:** A text file. The f...