text
stringlengths
180
608k
[Question] [ I don't like numbers, but I do like the Fibonacci sequence. I'm sure we could work something out. Please read one integer *n* from STDIN and output the *n*th Fibonacci number in base 26 (`abcdefghijklmnopqrstuvwxyz` instead of `0123456789`) to STDOUT. The first Fibonacci number is 0. The second one is...
[Question] [ A secondary number is a positive integer whose prime factors (without multiplicity) are all less than or equal to its square root. `4` is a secondary number, because its only prime factor is `2`, which equals its square root. However, `15` is not a secondary number, because it has `5` as a prime factor...
[Question] [ Create a program or function to unjumble a 9x9x9 cube of digits by rotating individual 3x3 cubes within it. This is similar to (but, I suspect, a bit harder than) my [Flippin' Squares](https://codegolf.stackexchange.com/questions/18545/flippin-squares) question. ## Input Input will be a 9x9x9 cube. I'm...
[Question] [ ### Background I like my old 8-bit 6502 chip. It's even fun to solve some of the challenges here on PPCG in 6502 machine code. But some things that should be simple (like, read in data or output to stdout) are unnecessarily cumbersome to do in machine code. So there's a rough idea in my mind: Invent my...
[Question] [ You are a medieval overlord tasked with designing a road network between three kingdoms placed on a \$9 \times 9\$ grid. A sample placement of kingdoms might look like this: [![](https://i.stack.imgur.com/3gdSB.png)](https://i.stack.imgur.com/3gdSB.png) Non-commercial use of tileset by [douteigami](htt...
[Question] [ A simple contest, inspired by [this stackoverflow question](https://stackoverflow.com/questions/11936073/can-counting-contiguous-regions-in-a-bitmap-be-solved-in-better-than-or-c/11936456): > > You are given an image of a surface photographed by a satellite.The image is a bitmap where water is marked ...
[Question] [ Disclaimer: while I have been on this site for entertainment purposes for a little while now, this is my first question, so please forgive any minor errors. # Background When assigning us homework, my teacher is really annoying and writes out *all* the problems we have to do individually. As such, it t...
[Question] [ Input will consist of the following characters: * `^`: Go up one * `v`: Go down one * `▲` or `k`: Go up two * `▼` or `j`: Go down two For example, the following input: ``` ^^▲^v▼▲^^v ``` would produce the following output: ``` ^ ^ ^ v ▲ v ▲ ^ ▼ ^ ``` Escape sequences that move the cur...
[Question] [ Given only a straightedge and compass, inscribe a rhombus inside the given rectangle, sharing two opposite points. [![rhombus-in-rectangle](https://i.stack.imgur.com/Yv2lq.png)](https://i.stack.imgur.com/Yv2lq.png) ### Input Input is the dimensions of the rectangle. In the example shown, that would be ...
[Question] [ > > [Robber's Thread here](https://codegolf.stackexchange.com/questions/140794/im-thinking-of-a-number-robbers-thread) > > > In this [cops-and-robbers](/questions/tagged/cops-and-robbers "show questions tagged 'cops-and-robbers'") challenge cops will think of a positive integer. They will then writ...
[Question] [ [Pyramid Scheme](https://github.com/ConorOBrien-Foxx/PyramidScheme) is a language being developed by [@ConorO'Brien](https://codegolf.stackexchange.com/users/31957/conor-obrien). In Pyramid Scheme, the code that you write looks like this: ``` ^ ^ / \ /3\ / \ --- /...
[Question] [ # Challenge Given a binary matrix and a binary string, determine if that binary string can be found starting at any point in the matrix and moving in any direction at any subsequent point to form the binary string. That is, can the string be found folded up however inside the matrix? The string can onl...
[Question] [ > > A [Pythagorean triple](https://en.wikipedia.org/wiki/Pythagorean_triple) consists of three positive integers a, b, and c, such that a2 + b2 = c2. Such a triple is commonly written (a, b, c), and a well-known example is (3, 4, 5). If (a, b, c) is a Pythagorean triple, then so is (ka, kb, kc) for an...
[Question] [ In this code golf challenge, you'll be computing the placement of ([open](https://en.wikipedia.org/wiki/Disk_(mathematics))) circles of areas \$\pi, 2\pi, 3\pi, \dots\$ when greedily placed along integer points in a square spiral in such a way that no two overlap. A [square spiral](https://oeis.org/plo...
[Question] [ There is a "sorting algorithm" sometimes called Stalin sort in which in order to sort a list you simply remove elements from the list until it is sorted in increasing order. For example the list ``` [1, 2, 4, 5, 3, 6, 6] ``` When "sorted" using Stalin sort becomes ``` [1, 2, 4, 5, 6, 6] ``` The three w...
[Question] [ The [happy ending problem](https://en.wikipedia.org/wiki/Happy_ending_problem) (actually a theorem) states that > > Any set of five points in the plane in general position has a subset of four points that form the vertices of a convex quadrilateral. > > > The problem was [so named by Paul Erdős](ht...
[Question] [ ## Introduction Similar to the Fibonacci Sequence, the [Padovan Sequence](https://en.wikipedia.org/wiki/Padovan_sequence) ([OEIS A000931](https://oeis.org/A000931)) is a sequence of numbers that is produced by adding previous terms in the sequence. The initial values are defined as: ``` P(0) = P(1) = P...
[Question] [ Your task is to write a [program or a function](https://codegolf.meta.stackexchange.com/a/2422/60340) that [outputs](https://codegolf.meta.stackexchange.com/q/2447/60340) `n` random numbers from interval [0,1] with fixed sum `s`. # Input `n, n≥1`, number of random numbers to generate `s, s>=0, s<=n`, s...
[Question] [ The Enigma machine is a fairly complex cipher machine used by the Germans and others to encrypt their messages. It is your job to implement this machine\*. # Step 1, Rotation Our enigma machine has 3 slots for rotors, and 5 available rotors for each of these slots. Each rotor has 26 different possible ...
[Question] [ # Input: A maze containing the characters: * `--` (horizontal wall); * `|` (vertical wall); * `+` (connection); * (walking space); * `I` (entrance); * `U` (exit). I.e. an input could look like this: ``` +--+--+--+--+--+--+--+--+--+--+ I | | | + +--+--+--+ + + + +--+ +...
[Question] [ I'm sure everyone has seen before that cups can be stacked into pyramids (and other shapes): ``` A A A A A A A A A A A A A A A A A ``` Yes, `A` is definitely an adequate character to represent a cup. New cups could be added either on the ground, to the right of the stru...
[Question] [ Last month I borrowed a plenty of books from the library. They all were good books, packed with emotions and plot-twists. Unfortunately, at some points I got very angry/sad/disappointed, so I tore some pages out. Now the library wants to know how many pages I have torn out for each book. Your goal is t...
[Question] [ Given an integer N >= 2, produce an image showing a Sierpiński knot of degree N. For example, here are knots of degree 2, 3, 4 and 5: [![Degree 2](https://i.stack.imgur.com/wURaQt.png "Degree 2 Sierpiński knot")](https://i.stack.imgur.com/wURaQ.png) [![Degree 3](https://i.stack.imgur.com/34PRpt.png "De...
[Question] [ ## Task Implement a program in minimum bytes of source or binary code that does voice recognition of a voice sample (me saying "yes", "yeah" or "no" in voice or in whisper, plainly or quirkily) based on training samples with maximum accuracy. The program should read `train/yes0.wav`, `train/no0.wav`, `...
[Question] [ Bernd is a high school student who has some problems in chemistry. In class he has to design chemical equations for some experiments they are doing, such as the combustion of heptane `C7H16`: > > C7H16 + 11O2 → 7CO2 + 8H2O > > > Since mathematics isn't exactly Bernd's strongest subject, he often ha...
[Question] [ > > **Synopsis:** Given the output of a generalised FizzBuzz program, return the list of factors and words used for the program. > > > ## Challenge Description Imagine a generalised FizzBuzz program that takes in as input a list of factors and words to use and the number to start from. For instance...
[Question] [ # Introduction Decide whether a [Hexagony](https://esolangs.org/wiki/Hexagony) program composed solely of the characters `.)_|\/><@` will halt using least bytes. # Challenge [Hexagony](https://github.com/m-ender/hexagony) is a language developed by Martin Ender in which the source code is presented in ...
[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/12056/edit). Closed 8 years ago. [Improve this question](/posts/12056/edit) ...
[Question] [ [Cops challenge](https://codegolf.stackexchange.com/questions/155018/the-programming-language-quiz-mark-ii-cops) ## The Robbers' Challenge 1. **Find a vulnerable answer.** That is, an answer which hasn't been cracked yet and which isn't *safe* yet either. 2. **Crack it by figuring out its language.** T...
[Question] [ Here's a simple challenge, so hopefully lots of languages will be able to participate. Given a positive integer \$n\$, output \$A076039(n)\$ from the [OEIS](http://oeis.org/A076039). That is, start with \$a(1)=1\$. Then for \$n>1\$: $$a(n)=\left\{ \begin{array}{ll} n\cdot a(n-1), & \text{if } n>a(n-1) ...
[Question] [ **Requirements:** * Take a single word as input with only lowercase alphabetical characters (a-z) * Output a string where every other character is repeated, with the first repeated character being the second character in the string **Example:** Input: `abcde` Output: `abbcdde` **Winning Criteria:** S...
[Question] [ Because there are not enough simple [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") challenges: Create an optionally unnamed program or function that, given (by any means) an integer 1 ≤ N ≤ 10000, outputs your language's True value with a pseudo-random probability of 1/N, ...
[Question] [ ## Introduction: I think we've all heard of it, but here a very brief summary: Noah gathered two of every species of animal on the planet, male and female, to save in his Ark during a great flood. The actual quote from the Bible is: > > *Genesis 7:2-3* > > You must take with you seven of every kind...
[Question] [ # *[All credits to Adnan for coming up with this challenge.](http://chat.stackexchange.com/transcript/message/32016426#32016426)* My last challenge, before [I go on break](http://chat.stackexchange.com/transcript/message/31944993#31944993). # Task Given positive integer `n`, if `n` is odd, repeat `/` t...
[Question] [ ### Input The input is a single positive integer `n` ### Output The output is`n` with its most significant bit set to `0`. ### Test Cases ``` 1 -> 0 2 -> 0 10 -> 2 16 -> 0 100 -> 36 267 -> 11 350 -> 94 500 -> 244 ``` For example: `350` in binary is `101011110`. Setting its most significant bit (i.e. th...
[Question] [ ## Challenge Given an integer \$Q\$ in the range \$-2^{100} ≤ Q ≤ 2^{100}\$, output the number of digits in that number (in base 10). ## Rules Yes, you may take the number as a string and find its length. All mathematical functions are allowed. You may take input in any base, but the output must be the...
[Question] [ This is a relatively quick one, but I'm sure you'll like it. Codegolf a program that will take input in the form of a sentence and then provide the output with the first letter capitalized in each word. Rules: 1. Submissions may not be in the form of a function. So no: `function x(y){z=some_kind_of_mag...
[Question] [ My boss just told me to write a cosine function. Being a good math geek, my mind immediately conjured the appropriate Taylor Series. $$\cos(x) = \frac 1 {0!} - \frac {x^2} {2!} + \frac {x^4} {4!} - \frac {x^6} {6!} + \cdots + \frac{(-1)^k \times x^{2k}} {(2k)!} + \cdots$$ However, my boss is very picky...
[Question] [ Given a positive integer n as input, output the reversed range sum of n. A reversed range sum is created by making an inclusive range up to n, starting with 1 and including n, reversing each of the numbers inside, and summing it. **Example:** Here is what would happen for an input of 10: Range: `[1,2,3...
[Question] [ # Source Code Byte Frequency --- Write a program that get a single byte character as an input and prints the frequency of that byte in the program's source code as an output. **Examples:** Assuming my program is: `ab#cd%b` then the output of the program should be (each line is a separate execution): ``...
[Question] [ We are used to the term "squaring" *n* to mean calculating *n2*. We are also used to the term "cubing" *n* to mean *n3*. That being said, why couldn't we also triangle a number? # How to triangle a number? * First off, let's pick a number, `53716`. * Position it in a parallelogram, whose side length eq...
[Question] [ **Closed**. This question needs to be more [focused](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** Update the question so it focuses on one problem only by [editing this post](/posts/19123/edit). Closed 3 years ago. [Improve this question](/p...
[Question] [ [Sandbox](https://codegolf.meta.stackexchange.com/a/20666/80214), [Codidact](https://codegolf.codidact.com/posts/280612) *A rewrite of [this question](https://codegolf.stackexchange.com/questions/16124/write-an-interactive-deadfish-interpreter) with a simpler input format and guidelines.* ## Challenge ...
[Question] [ Consider a question written in plain English whose answer involves two reasonably accurate (but potentially clever) words or phrases that can be separated by the word 'and': > > **Q:** What are the two sides of a coin? **A:** heads and tails > > > **Q:** What are the best ways to travel? **A:** airp...
[Question] [ ### Background [Adler-32](https://en.wikipedia.org/wiki/Adler-32) is a 32-bit checksum invented by Mark Adler in 1995 which is part of the widely used zlib library (also developed by Adler). Adler-32 is not as reliable as a 32-bit [cyclic redundancy check](https://en.wikipedia.org/wiki/Cyclic_redundanc...
[Question] [ # Introduction This is a very simple challenge: simply count the divisors of a number. We've had a [similar but more complicated challenge](https://codegolf.stackexchange.com/questions/11080/give-the-smallest-number-that-has-n-divisors) before, but I'm intending this one to be entry-level. # The Challe...
[Question] [ Why should you golf in Haskell? [Find out here](https://codegolf.meta.stackexchange.com/a/10668/66833). In that answer, [Zgarb](https://codegolf.meta.stackexchange.com/users/32014/zgarb) defines a task: > > Let's define a function `f` that splits a list at the second occurrence of the first element, e...
[Question] [ In calculus, the derivative of a mathematical function defines the rate at which it changes. The derivative of a function `f(x)` can be marked as `f'(x)`, and these can sometimes be abbreviated to `f` and `f'`. The derivative of the product of two functions `fg` is `f'g + g'f`. The derivative of three ...
[Question] [ ## Task Implement a kind of "some users are typing" system, which can be found in Discord and some other chat clients. * If 1 user (say, Bubbler) is typing, output `Bubbler is typing...` * If 2 users (say, Bubbler and user) are typing, output `Bubbler and user are typing...` * If 3 or more users are ty...
[Question] [ ### Introduction Let's observe the string `abc`. The substrings that can be made from this are: ``` a, ab, abc, b, bc, c ``` We now need to align them under the initial string, like this: ``` abc a b c ab bc abc ``` The order of the string doesn't matter, so this is also perfectly valid: ``` abc a ...
[Question] [ There have been a couple of challenges involving doubling source code: [here](https://codegolf.stackexchange.com/questions/132558/i-double-the-source-you-double-the-output) and [here](https://codegolf.stackexchange.com/questions/132786/double-time-is-not-double-time). The task we have here is a bit har...
[Question] [ An alphadrome is a word in which each letter in the first half of the word "reflects" its alphabetical "opposite" in the second half of the word. Write a program or function that returns truthy if the given word is an alphadrome and falsey otherwise. For example, `BEEB` is a palindrome. Its first lette...
[Question] [ Sequel of [this AWESOME challenge](https://codegolf.stackexchange.com/questions/31552/disarm-the-b-o-m-b) You, a genius tech prodigy detective, have successfully disarmed the bomb and want to break into the computer. The police found the password `67890-=yuiop[]hjkl;'\vbnm^&*()_+:"|` on a piece of pape...
[Question] [ **This question already has answers here**: [Making Squared Words](/questions/133650/making-squared-words) (32 answers) Closed 5 years ago. Sometimes when you're lying in bed and reading a message, your phone screen will pop into landscape mode right in the middle of a sentence. Only being able ...
[Question] [ This is a KOTH challenge for the [dollar bill auction](https://en.wikipedia.org/wiki/Dollar_auction) game in game theory. In it, a dollar is being sold to the highest bidder. Bids go up in increments of 5¢, and the loser also pays their bid. The idea is that both players escalate the bidding war far be...
[Question] [ # Challenge Make two programs, A and B, which are both cat programs in the same language. When concatenated, AB (also in the same language) should be a quine. For example, suppose `hello` and `world` are both cat programs in language XYZ. If `helloworld` is a quine in said language, then your solution ...
[Question] [ You will be given a positive, whole number (that will never contain a 0) as input. Your task is to check whether it is a Lynch-Bell number or not. A number is a Lynch-Bell number if all of its digits are unique and the number is divisible by each of its digits. In fact, there are actually only 548 Lync...
[Question] [ **Task:** You are an amazing programmer and Stackoverflow-answerer, and you decide to answer every question with a bounty on Stackoverflow. You are so good, that you manage to get all the bounties in all the questions. While you wait for the rep to come flooding in, you write a program that goes and fi...
[Question] [ > > [Robber's thread](https://codegolf.stackexchange.com/questions/136151/restricted-mini-challenges-robbers-thread) > > > Your task as cops is to select three things: * A programming language * An OEIS sequence * A byte set You are then to secretly write a program in that language that computes th...
[Question] [ Your task is to generate the nth term of the RATS sequence, where n is the input. The RATS sequence is also known as the Reverse Add Then Sort sequence. This sequence can also be found here: <http://oeis.org/A004000>. test cases: ``` 0 > 1 1 > 2 2 > 4 3 > 8 4 > 16 5 > 77 6 > 145 7 > 668 ``` For example...
[Question] [ Almost six years ago, fellow PPCG member steenslag [posted](https://codegolf.stackexchange.com/q/958/13486) the following challenge: > > In a standard dice (die) the numbers are arranged so that opposite > faces add to seven. Write the shortest possible program in your > preferred language which out...
[Question] [ A time in the format hhMMss is represented by six numbers in the range 0..9 (e.g.`100203` for 3 seconds after 2 minutes after 10am (10:02.03), or `155603` for three seconds after 56 minutes after 3pm (15:56.03). Treating these times as integers, these numbers are therefore in the range `000000` to `235...
[Question] [ For the non-zero digits on a standard [numpad](https://en.wikipedia.org/wiki/Numeric_keypad) ``` 789 456 123 ``` consider placing a [chess knight](https://en.wikipedia.org/wiki/Knight_(chess)) at any digit and moving it around with any number of normal L-shaped jumps, tracing out a positive decimal int...
[Question] [ ## Challenge Unlike the circumference of a circle (which is as simple as \$2\pi r\$), the [circumference (arc length) of an ellipse is hard](https://en.wikipedia.org/wiki/Ellipse#Circumference). Given the semi-major axis \$a\$ and semi-minor axis \$b\$ of an ellipse (see the image below, from Wikipedia...
[Question] [ Within the scope of this question, let us consider only strings which consist of the character `x` repeated arbitrary number of times. For example: ``` <empty> x xx xxxxxxxxxxxxxxxx ``` (Well, actually it doesn't have to be `x` - any character is fine as long as the whole string only has 1 type of char...
[Question] [ As code-golfers, we're not used to releasing (*surely*). We're gonna need a few tools to help us do that. Of course, to help marketing a new release, we need a nice and shiny Release Version. Who doesn't get excited when they hear about version 3.0.0? ### Task Your task will be to write a program/routi...
[Question] [ ## The task In this challenge, you are given a number and a list. Your task is to remove from the list all occurrences of the given number except the first (leftmost) one, and output the resulting list. The other elements of the list should be left intact. * The number will be a positive integer below ...
[Question] [ ### Introduction: A Dutch BSN (BurgerServiceNummer) is valid when it complies to the following rules: * It only contains digits. * The length should be either 8 or 9 in length. * When the digits are indexed as `A` through `I`, the result of the following sum: `9xA + 8xB + 7xC + 6xD + 5xE + 4xF + 3xG + ...
[Question] [ Create a cat program, a.k.a a program that takes an input and prints it. ...Except, the program will randomly take characters away from your input and print that instead. Each character in the input should have generally equal odds to be removed with the program, though, as it is hard to make that, the...
[Question] [ The *harmonic series* is the "infinite sum" of all the fractions of the form \$\frac1n\$ for \$n\$ positive integer. I.e. the harmonic series is $$\frac11 + \frac12 + \frac13 + \frac14 + \cdots$$ It is well-known that [this sum diverges](https://www.wolframalpha.com/input/?i=Harmonic+series), which mea...
[Question] [ Your job is to simulate a couple of keystrokes that a user types in. **Input** A string array or string with a delimiter of your choice (outside the range 32-126) containing at least one 'keystroke'. This array will only contain two types of string: passive keystrokes (single chars) and commands (cha...
[Question] [ Write the smallest program that maps strings injectively to outputs and maps itself to 2020. To be clear, your program \$p\$ must have the following properties: 1. every possible input string \$s\$ has a well-defined output \$p(s)\$, 2. for every pair of strings \$s\$ and \$t\$ with \$s\neq t\$, it hol...
[Question] [ Your objective is to take input like ``` Pie is good. I just ate a bunch of pies early this morning. Actually, it was closer to the afternoon. Mornings are good. ``` and create an array of the indexes of the string where the letters that make up the word "Llama" appear (one of each in order). For ex...
[Question] [ This challenge is inspired by [@LuisMendo's MATL answer](https://codegolf.stackexchange.com/a/200008/75323) to my "[binary multiples](https://codegolf.stackexchange.com/a/200008/75323)" challenge. # Task Pick a [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") challenge that ...
[Question] [ Rule 110 is a cellular automaton with some interesting properties. **Your goal** is to simulate a rule 110 in as few characters as possible. For those who don't know, rule 110 is simulated line by line in a grid. Each square in a line of the grid looks at the squares above, above-left and above-right ...
[Question] [ Given an integer, output five perfect cubes whose sum is that integer. Note that cubes can be positive, negative, or zero. For example, ``` -10 == -64 - 64 + 64 + 27 + 27 ``` so for input `-10` you could output `[-64, -64, 64, 27, 27]`, though other solutions are possible. Note that you should output t...
[Question] [ Your task is to write a program or a function that prints an ASCII triangle. They look like this: ``` |\ | \ | \ ---- ``` Your program will take a single numeric input `n`, with the constraints `0 <= n <= 1000`. The above triangle had a value of `n=3`. The ASCII triangle will have `n` backslashes (`\...
[Question] [ ### Introduction Let's observe the following string: ``` AABBCCDDEFFGG ``` You can see that every letter has been *duplicated*, except for the letter `E`. That means that the letter `E` has been *de-duplicated*. So, the only thing we need to do here is to reverse that process, which gives us the follow...
[Question] [ This is a simple one: print an ASCII [Gantt chart](https://en.wikipedia.org/wiki/Gantt_chart). Given tasks' ranges (start-time - end-time Tuples), print a Gantt timeline in the form of `-` characters for each task duration - each task in a new line. ### Example Say my tasks ranges are `28->35, 34->40, ...
[Question] [ The other day, our team went to an escape room. One of the puzzles involved a board of six mechanical switches where you had to find the correct combination of on and off in order to unlock a box, somewhat like this: ``` -v-v-v- -v-v-v- ``` Being developers, we decided it would be more efficient to try...
[Question] [ Given a positive integer `n`, output the smallest base `b >= 2` where the representation of `n` in base `b` with no leading zeroes does not contain a `0`. You may assume that `b <= 256` for all inputs. ## Test Cases ``` 1 -> 2 (1) 2 -> 3 (2) 3 -> 2 (11) 4 -> 3 (11) 5 -> 3 (12) 6 -> 4 (12) 7 -> 2 (111) ...
[Question] [ The three rows of the qwerty keyboard are `qwertyuiop`, `asdfghjkl` and `zxcvbnm`. Your task is to find the longest word that can be typed using only one row of the keyboard, from a given list of words. Sample input 1 ``` artist home gas writer geology marine twerp ``` Output ``` writer ``` (Of the giv...
[Question] [ I love sardines, I can't get enough of them, and so does my computer, the Omnilang 5000, which is language agnostic. To give my computer the joy of experiencing sardines, I've decided to feed him a number of programs that are capable of displaying on the screen tins of sardines in various orientations,...
[Question] [ A staircase number is a positive integer **x** such that its **n**th digit (one indexed starting with the least significant digit) is equal to **x % (n + 1)**. Thats a bit of a mouthful so lets look at an example. Take **7211311**, if we take the modular residues of **7211311** on the range 2-8 we get ...
[Question] [ This challenge was posted on the DailyProgrammer subreddit, and I figured it would be a great candidate for a code golf challenge. Determining if a letter balances is based on its distance from the point of balance, and the letter's value. The value of a letter can be determined by either taking its on...
[Question] [ Disclaimer: This challenge is inspired by a coding error I once made. --- Okay, time for a maths lesson. A normal mean average looks like this: ``` Work out the sum of all numbers in a list then divide by the size of the list. ``` But what if we don't know all the numbers at the time we're working out ...
[Question] [ ## Input: * An integer \$n\$, which is guaranteed to be \$\ge3\$. * An integer \$d\$, which is one of \$[-1,0,1]\$. ## Output: A road of size \$n\$, which will be in a north-west direction if \$d=-1\$; a north direction if \$d=0\$; or a north-east direction if \$d=1\$. The road will always be three spa...
[Question] [ Yesterday while playing with my kid I noticed the number in his toy train: [![4281](https://i.stack.imgur.com/iBozFm.jpg)](https://i.stack.imgur.com/iBozFm.jpg) So we have $$4281$$ that can be split into $$4-2-8-1$$ or $$2^2-2^1-2^3-2^0$$ So simple challenge: given a non-negative number as input, retur...
[Question] [ The three-dimensional Levi-Civita symbol is a function `f` taking triples of numbers `(i,j,k)` each in `{1,2,3}`, to `{-1,0,1}`, defined as: * `f(i,j,k) = 0` when `i,j,k` are not distinct, i.e. `i=j` or `j=k` or `k=i` * `f(i,j,k) = 1` when `(i,j,k)` is a cyclic shift of `(1,2,3)`, that is one of `(1,2,...
[Question] [ I find it fascinating how the letters "H" and "I" are very similar. "H" is a horizontal stroke surrounded by two vertical strokes; "I" is a vertical stroke surrounded by two horizontal strokes (depending on your font). I bet this could be nested... You know what that reminds me of? **Fractals**!!! Let'...
[Question] [ The [Kolmogorov complexity](http://en.wikipedia.org/wiki/Kolmogorov_complexity) of a string s is defined as the length of the *shortest program* P that outputs s. If the length of P is shorter than the length of s, then s is said to be *compressible*, otherwise s is *incompressible*. Most strings are i...
[Question] [ The "Look and say" or "Say what you see" sequence is a series of numbers where each describes the last. ``` 1 11 (one one) 21 (two ones) 1211 (one two, one one) 111221 (one one, one two, two ones) 312211 (three ones, two twos, one one) ``` and on and on... <https://oeis.org/A005150> Anyway, this is a r...
[Question] [ An ant walks along the edges (not faces) of a wireframe cube. Each vertex it encounters presents it with a fork from which two new edges branch off. The ant chooses which way to turn -- `left` or `right`. These direction are relative to the ant, who is facing the vertex and is outside the cube. Your go...
[Question] [ A [quine](/questions/tagged/quine "show questions tagged 'quine'") is a program that produces output that's identical to the program's source code. On this website, we generally only care about [proper quines](https://codegolf.meta.stackexchange.com/q/4877/62131) (at the time of writing, the current de...
[Question] [ This idea came to me when I saw my little brother playing with my calculator :D # The task Taking a integer as an input, print that many graphical square roots under each other, like this: ``` n = 1 ___ \/ 1 n = 3 _______ / _____ / / ___ \/\/\/ 3 n = 5 ___________ / _________ ...
[Question] [ Your task is to calculate the square root of 2 using Newton's Method - with a slight twist. Your program is to calculate an iteration using Newton's Method, and output the source code for the following iteration (which must be able to do the same). Newton's method is fairly exhaustively described on [W...
[Question] [ Given an [ascii-art](/questions/tagged/ascii-art "show questions tagged 'ascii-art'") road and the time it took me to cross it, tell me if I was speeding. ## Units Distance is in the arbitrary unit of `d`. Time is in the arbitrary unit of `t`. ## The road Here is a simple road: ``` 10===== ``` The `10`...
[Question] [ You deal cards labeled 0 to 9 from a deck one a time, forming stacks that start at 0 and count up by 1. * When you deal a 0, you place it on the table to start a new stack. * When you deal any other card, you stack it atop a card that's exactly one lower in value, covering it. If there's no such card, ...
[Question] [ # The Problem: You receive a (section of) a Conway's Game of Life grid. Your task is to output whether it represents a still-life (subsequent generations are identical to the current grid), a oscillator of period up to 4 (every nth generation is identical to the current grid), or something else. The re...
[Question] [ Given a list of positive integers, output whether every adjacent pair of integers in it shares a prime factor. In other words, output **truthy** if and only if **no** two neighboring integers in the list are co-prime. In yet other terms: given a list of positive integers **[a1 a2 … an]**, output whethe...