text
stringlengths
180
608k
[Question] [ Smallfuck is a brainfuck-like language with 1-bit cells. It has the following instructions: ``` > Increment the pointer < Decrement the pointer * Flip the current bit [ If the current bit is not set, jump to the instruction after the matching ] ] If the current bit is set, jump to the instruction aft...
[Question] [ Thinking about various quine puzzles here, I got an idea for another one: **Compose a program that outputs its own *compiled* code to a file** (or multiple files, if the compiled code is). (This means that only compiled languages are eligible.) # Rules Standard quine rules - no cheating allowed. In p...
[Question] [ A [Friedman number](http://en.wikipedia.org/wiki/Friedman_number) is a number that can be expressed by applying basic mathematical operations(^,/,\*,+,-) to all it's digits. The operations need not be applied to each individual digit, but all the digits must be involved. That is, 121= 11^2 --> all di...
[Question] [ The idea is based on [this interactive game](https://hyperjumps.quantamagazine.org). Given a set of eight decimal digits which are not necessarily distinct, your task is to find a hyperjump trip with the specified length. ### But what is a hyperjump? I ain't got time to click on HOW TO PLAY Ok, you h...
[Question] [ Consider all arrays of \$\ell\$ non-negative integers in the range \$0,\dots,m\$. Consider all such arrays whose sum is exactly \$s\$. We can list those in lexicographic order and assign an integer to each one which is simply its rank in the list. For example, take \$\ell=7, s=5, m=4\$, the list coul...
[Question] [ Al wanted to use my computer to do some simple calculations, so I lent him the use of my R terminal for a bit. He complained though, saying it wasn't set up how he liked it. I said "No problem Al, set it up how you like and I'll just revert it later." This suited Al, and I left him to it. Al isn't a ...
[Question] [ The challenge: compute the day of the week from a `MM-DD` representation of a day in this year (2021). However, you have to write your program in the following subset of Python: (*I chose Python because it's popular and easy to understand even to the people who doesn't know the language. Obviously yo...
[Question] [ # Objective Given a nonempty multiset of `Rock`, `Paper`, and `Scissors`, output the winning figure according to the special rule. # Background For a multiplayer RPS, if all three figures come out, usually it's considered a draw. But by that rule, the probability to draw would dramatically increase w...
[Question] [ [Sandbox post](https://codegolf.meta.stackexchange.com/a/18310/42248) In this [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") challenge, you are provided with a series of y values at even x-values as well as a console width and height. The desired output is an ASCII-art r...
[Question] [ You’re given two \$r×c\$ grids. Each cell contains either 0 or 1. What are the minimum number of swaps (between horizontally and vertically adjacent cell elements, no wrapping i.e no swapping between last and first element of a row) are required in the first grid for it to match the second. If the ma...
[Question] [ Your task is to take a 24 BPP sRGB image and output the same image upscaled 3x into red, green, and blue subpixels. The resulting image will be made entirely of pure black, red, green, and blue pixels. Each pixel from the source image, when zoomed, produces an arrangement of 9 sub-pixels that can be ...
[Question] [ Notwen wants to study the kinematics of bodies thrown from big heights in a uniform gravitational field but unfortunately he doesn't have the technical possibility to go to sufficiently high places and observe the objects while falling. But who doesn't want to see advances in science so... Let's help...
[Question] [ [September 1993 is known on Usenet as the September that never ended.](http://www.catb.org/jargon/html/S/September-that-never-ended.html) Thus, for example, the day this question is being posted is Saturday, September 8740, 1993. Your program or function should take any Gregorian date (with positive ...
[Question] [ Write a program that adds or removes whitespace to format code nicely. Rules for what the code should look like when you're done: * No line should contain more than one of `{` and `}`. * A `{` should always be the last thing on a line. * A `}` should always be the *only* thing on a line (besides whit...
[Question] [ Write a program that outputs all possible Tic Tac Toe positions including the corresponding game outcome. Avoid duplicate output of equal positions. The program takes no input. ### Rules: * A position output must consist of 9 characters, using `X` and `O` for the taken squares, and an arbitrary non-w...
[Question] [ In the wake of the many (two?) FizzBuzz-related challenges posted recently on PPCG, I've been tempted to come up with my own. Behold... # Fizz Buzz Lightyear Write a program or function that takes an integer `n` and prints out `FizzBuzz` for any number divisible by 15, `Fizz` for any number divisible...
[Question] [ # Task Your task is to convert a text into medieval orthography. # Details 1. `j` is converted to `i` and `J` to `I`. 2. `u` and `U` at the beginning of words are converted to `v` and `V` respectively. 3. `v` and `V` at anywhere except the beginning of words are converted to `u` and `U` respectively....
[Question] [ ## Challenge Given the roots of a polynomial separated by spaces as input, output the expanded form of the polynomial. For example, the input ``` 1 2 ``` represents this equation: ``` (x-1)(x-2) ``` And should output: ``` x^2-3x+2 ``` The exact format of output is not important, it can be: ``` 1x^2+-...
[Question] [ This is my first question, so I hope it goes well. ## Background: It's not the rivers that you might be thinking about. The question revolves around the concept of digital rivers. A digital river is a sequence of numbers where the number following `n` is `n` plus the sum of its digits. **Explanation:...
[Question] [ ### Background I have a string in Python which I want to convert to an integer. Normally, I would just use `int`: ``` >>> int("123") 123 ``` Unfortunately, this method is not very robust, as it only accepts strings that match `-?[0-9]+` (after removing any leading or trailing whitespace). For example...
[Question] [ # Challenge Write a function that implements C `printf`-style string formatting. # Rules 1. You **must** implement at least `%%`, `%c`, `%s`, `%d` and `%f`. 2. You **must not** use a built-in string formatting method. 3. You **must not** run external programs or connect to the Internet from your prog...
[Question] [ Create a program which takes one command-line argument, `n`, which will be an integer less than 2147483648 (2^31), and then reads a file `input.txt` and prints the lines of `input.txt` which contain any substring which is a positive (non-zero) multiple of `n`. You may choose to ignore multiples great...
[Question] [ Cyclic Words > > Problem Statement > > > We can think of a cyclic word as a word written in a circle. To > represent a cyclic word, we choose an arbitrary starting position and > read the characters in clockwise order. So, "picture" and "turepic" > are representations for the same cyclic word. ...
[Question] [ [Othello/Reversi](http://en.wikipedia.org/wiki/Reversi) is a board game in which players take turn placing pieces of a color (dark or light) on the 8x8 board. The possible moves are positions where there are one or more pieces of the opponent's color in a straight (horizontal, vertical, or diagonal) ...
[Question] [ # Validate a codice fiscale Every Italian resident/citizen is given a 16-character alphanumeric [*codice fiscale*](https://en.wikipedia.org/wiki/Italian_fiscal_code) ## Challenge The final letter is a check code, which is calculated as follows : * Characters of the code are split up into even and odd...
[Question] [ Problem author: <https://stats.ioinformatics.org/people/5815> You are given a system with a hidden permutation of the numbers \$1, 2, 3, \ldots, n\$. Your task is to guess this permutation by asking the system a series of questions. Each question consists of providing the system with a permutation of...
[Question] [ Take as input two strings \$A\$ and \$B\$. Output a string \$C\$ that is \$A\$ but with two characters swapped such that the [Levenshtein distance](https://codegolf.stackexchange.com/q/67474) \$d(C,B)\$ is as small as possible. You must swap two characters and you cannot swap a character with itself,...
[Question] [ ### the goal Build an optimizing Brainfuck implementation. Whether it is a compiler, an interpreter, a JIT compiler, or whatever else is up to you. ### scoring A reference implementation (`bfi`) will be given. Each implementation will run the same program (`mb.b`) also given at the end. Your score is...
[Question] [ Typescript is a typed superset of Javascript. For this challenge, we'll consider the following classic [basic types](https://www.typescriptlang.org/docs/handbook/basic-types.html): * `string` * `number` * `boolean` * `undefined` * `null` And two "meta" types: * `any` * `never` The type `any` annotate...
[Question] [ Sequel to [Verify Tents and Trees solution](https://codegolf.stackexchange.com/q/206786/78410). ## Background **Tents and Trees** (try [here](https://www.brainbashers.com/tents.asp)) is a puzzle played on a square (or rectangular) grid, where the objective is to place tents horizontally or vertically...
[Question] [ Inspired by [Find the largest fragile prime](https://codegolf.stackexchange.com/questions/41648/find-the-largest-fragile-prime) A recurring prime (or whatever you choose to call it) is a prime that, when removing leading digits, always remain prime regardless of how many digits are removed. ``` for e...
[Question] [ # Challenge Design a compression algorithm specialized for compressing ASCII mazes. You will need to create both a compression algorithm and a decompression algorithm. Your score will be based on the size of your compressed mazes. # Mazes These mazes are made primarily of the characters (floors), `+...
[Question] [ The question: Given an a number `n` ≥ 2, how many distinct pairs of points on an `n`-dimensional `n x n x n x n x n x n ... x n` lattice, where the coordinates range from `0` to `n - 1`, are a distance **at least** `n` apart? The pairs `{(2,1,3,1), (3,2,1,3)}` and `{(3,2,1,3), (2,1,3,1)}` are not con...
[Question] [ # Description Given a length `n`, and an alphabet size `k>0`, your program must determine the number of strings with those parameters which have a maximal number of unique substrings. In the case of `k=2`, this generates OEIS [A134457](https://oeis.org/A134457). # Example For example, `2210` has the ...
[Question] [ Eyeballing the binary values printed as ovals and sticks is not so easy... To help with that, you must write a function (or a program) that prints numbers in custom binary representation. So I want to take a number, say 3 (`00000011`) and output the bits in user-defined format, for example with spa...
[Question] [ I though this would be a good challenge : <http://adventofcode.com/2016/day/1> # Task description Given a sequence of rotations and distances following the pattern (L|R)[1-9][0-9]\*, give the manhattan distance between the start and the ending points, that is the minimal number of vertical and horizo...
[Question] [ **The challenge** Simply write a program that outputs its own source code. Nothing more than a regular quine. **The problem** We don't have a computer so we have to run the program on a programmable logic device (such as an FPGA, a CPLD, a gate array ...). **The rules** * Any device available on the ...
[Question] [ # Background ### Visualizing λ-calculus terms Famous lambda-juggler (and [code golfer](https://codegolf.stackexchange.com/users/5241/john-tromp)) John Tromp devised an [interesting visualization](https://tromp.github.io/cl/diagrams.html) of terms in the λ-calculus. In his words: > > abstractions (la...
[Question] [ Inspired by the *C*-directive `#define`. ### Challenge Given one phrase with some alias, and one array with each alias text. Output the initial phrase replacing each alias with its respective text. An alias is defined by one sharp `#` followed by its index in the array (the index may start at zero or...
[Question] [ Recently I've been having [some trouble](https://github.com/vihanb/TeaScript/issues/16) with the new [TeaScript](https://github.com/vihanb/teascript) interpreter. The biggest problem is identifying whether or not a string contains any special characters. --- # Challenge A special character is defined...
[Question] [ NB : Everything presented in the situation is totally fake and had just been put here to make the challenge a little more fun ;) ... Or maybe not ;) --- === === BEGINNING TRANSMISSION === === Hello, I recently had a disk failure. I hopefully had backups and I now want my photos back. However, EVERY...
[Question] [ The idea here is to produce an *almost* repeating pattern. That is, the sequence being constructed changes at the last moment to avoid a repetition of some subsequence. Subsequences of the type AA and ABA are to be avoided (where B is no longer than A). ## Examples: I'll go ahead and start by listing...
[Question] [ # The Challenge Consider the 3x3 king grid, as shown in the following ASCII graphic: ``` A--B--C |\/|\/| |/\|/\| D--E--F |\/|\/| |/\|/\| G--H--I ``` You are given as input a length-9 list of integers that represent a labeling of the nodes. For example, the input `[0,1,1,2,1,0,5,5,1]` represents the f...
[Question] [ # Sequences You are given four number sequences, numbered `1` through `4`. 1. [OEIS](https://oeis.org/A003607) The location of `0`'s when the natural numbers are listed in binary. Here's an example of how to calculate the sequence: ``` 0,1,10,11,100,101,110,111 ^ ^ ^^ ^ ^ 0 3 78 ...
[Question] [ Find the greatest gcd of the numbers \$n^m + k\$ and \$(n+1)^m + k\$ for given `m` and `k`. For example, for `m=3, k=1` we have: * \$n = 1\$: \$\gcd(1^3 + 1, 2^3 + 1) = 1\$ * \$n = 2\$: \$\gcd(2^3 + 1, 3^3 + 1) = 1\$ \$\vdots\$ * \$n = 5\$: \$\gcd(5^3 + 1, 6^3 + 1) = 7\$ (max) \$\vdots\$ * \$n \to \i...
[Question] [ I encountered some silly code from a game and I figured this would actually turn into a fun golfing problem, so: Given any ASCII string in the limited char range specified below. Append as few characters as possible such that, given: ``` i = 1 sum = 0 for char in string sum += char.intval * i++ end...
[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. --- Santa has a bunch of presents wrapped in cuboid boxes of various sizes. As his sled ...
[Question] [ Given a base type `T`, this can be augmented with `*` or `[]`, each meaning pointer and array. For example, `[]*T` means "array of pointer to `T`" and `*[]T` means "pointer to array of `T`". Let's call `*` and `[]` type *modifiers*. C has a way of ordering these modifiers tied to the evaluation order...
[Question] [ ## Background In [Scrabble](https://en.wikipedia.org/wiki/Scrabble), players take turns placing tiles on a grid so that each contiguous set of (more than one) tiles in every row and column makes a word. In one play, tiles can be placed anywhere in a single row or column as long as there is a contiguo...
[Question] [ ## Background A polyomino of size \$n\$ is a contiguous shape made from joining \$n\$ unit squares side by side. A domino is a size-2 polyomino. A **polydomino** of size \$2n\$ is defined as a polyomino of size \$2n\$ which can be tiled with \$n\$ dominoes. The following are some examples of polydomi...
[Question] [ ## Background *Match Land* is a mobile game that falls into the Match-3 genre (think Bejeweled or Candy Crush Saga series): swap two orthogonally adjacent pieces to make a 3-in-a-row or longer. However, Match Land has an additional rule that makes the game much more interesting. Once you make a valid...
[Question] [ Do you know the game Battleship? Well, I want to play with my little brother, but before we can begin we need to set up our ships on the board. This is your input. Now, we need to check that the ships that we set up are valid. This is where you come in to help. Your task is to write a program or func...
[Question] [ This challenge is about the following variant of [edit distance](https://en.wikipedia.org/wiki/Levenshtein_distance#:%7E:text=Informally%2C%20the%20Levenshtein%20distance%20between,considered%20this%20distance%20in%201965.). Say we have a cost of 1 for inserts, deletes and substitutions as usual with...
[Question] [ Given a grid of directions and a start and end position, determine the minimum number of substitutions in the direction grid that needs to be made to complete the path between the two points. The grid is doubly-cylindrical. This is clearer given an example. ## Example Let's take the following grid as...
[Question] [ Take the numbers `0, 1, 2, 3, 4, ...` and arrange them in a clockwise spiral, starting downward, writing ***each digit*** in its own separate square. Then, given one of four distinct and consistent ASCII characters (your choice) representing an axis, and an input integer `n`, output the first `n` ter...
[Question] [ ## Challenge: Create a program or function that takes an integer input, which outputs a new program/function as specified below. ### Input: Integer `n`: Time in seconds before the Time Bomb explodes. ### Output: The original program which had the time in seconds `n` as input, will output a new progra...
[Question] [ Oh no, I am lost on the way to finding the great treasures of Marakov! And all I have are these useless instructions that look like `S10R10D30`... I have no idea what they mean! Can you help me? ## Challenge Given directions consisting of `N E S W U D L R 1 2 3 4 5 6 7 8 9 0`, output how far I will b...
[Question] [ # Inspiration: Heavily inspired by [Smallest chess board compression](https://codegolf.stackexchange.com/questions/19397/smallest-chess-board-compression) I decided to make a similar but distinctly different competition. # tl;dr Take the file [Chess\_Games.txt](https://pastebin.com/raw/4q0tt98y) and ...
[Question] [ [Choi Hong Hi](https://en.wikipedia.org/wiki/Choi_Hong_Hi) died on the 15th June 2002 at the honorable age of 83. He founded [Taekwondo](https://en.wikipedia.org/wiki/Taekwondo). 15 years after his death, I would like to be a Taekwondo master. This is my time to shine ! # Task Given a string you sho...
[Question] [ This challenge was greatly inspired by [this Stack Overflow post](https://stackoverflow.com/questions/43831137/how-to-determine-the-most-busy-period-of-time). # Challenge Given a bunch of clients in terms of when they enter a room and when they exit it, determine the period(s) of time when the room h...
[Question] [ [AWG (American Wire Gauge)](https://en.wikipedia.org/wiki/American_wire_gauge) is a common way of specifying wire sizes. Your task in this challenge is to convert from a given gauge to the diameter of the wire in inches. The size in inches for the gauges from `4/0` to `40` are shown in the table belo...
[Question] [ I have a counter. It's a small device that looks like this: [![counter](https://i.stack.imgur.com/ZwQRk.jpg)](https://i.stack.imgur.com/ZwQRk.jpg) The display goes from `0000` to `9999`. It has a little push-button at the top that increases the count by 1, and a little knob at the right whose purpos...
[Question] [ Your challenge is to determine whether the given input is an integer, a string, or a decimal. # Rules * A string is any input that is not an integer or a float * An integer must contain only numeric characters and must not start with a zero * A decimal is any input that contains the period (`.`) and ...
[Question] [ Output coordinates of the vertices of a cube. Then, output a list of twelve triangles that will cover the cube, each triangle being a list of three vertex-indexes, consistently oriented. Output must be an ASCII string of distinct decimal numbers. This golf has no input. Winner is the fewest character...
[Question] [ # Input Two lists `A` and `B` of nonnegative integers. # Output Either `1`, `0`, or `-1`, depending on whether `A` is larger than, equal to, or smaller than `B` with respect to the *twisted lexicographical ordering* as defined below. If you want, you can replace `1`, `0` and `-1` with any other three...
[Question] [ Repdigits are numbers of the form `a * (10^n - 1)/9` with `a in [-9,9]\{0}` (in other words 111, -3333, 66, numbers which are made by repeating only one digit) **Goal:** Write a program or function which takes a single positive integer `N` and prints `N = s_1 + s_2 + ... + s_k`. There should be one n...
[Question] [ # Emulate the Professor's typing **Background** Unfortunately, the Professor is not able to use his keyboard properly: whenever he is meant to use the `Shift` key, he presses `Caps Lock` **once** before typing, and doesn't bother to correct himself. If there are two or more keys in a row that require...
[Question] [ ## Challenge Given a list a notes, you must return the corresponding tablature. ## Notes The notes must be in the range of A to G inclusive and the octave range being 2 to 6 inclusive. The format is note-octave with `#` representing a sharp and `b` representing a flat. E.g: `A7` or `F#3`. ## Tabs Tab...
[Question] [ What you need to do to win this challenge is to write the shortest "timeago" script that outputs the number of decades, years, weeks, days, hours, minutes, and seconds between a given [Unix timestamp](http://en.wikipedia.org/wiki/Unix_time) and the time the script is run. You must give the time diffe...
[Question] [ ## Challenge > > In this task you would be given an > integer N you have to output the > nearest prime to the integer. > > > If the number is prime itself output the number. The input N is given in a single line,the inputs are terminated by EOF.The number of inputs would not exceed 10000 values...
[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/647/edit). Closed 6 years ago. [Improve this question](/posts/647/edit) Yo...
[Question] [ Code-Golf caddy Eddie Brackets was getting tired of quine challenges, which appeared to be much too easy for the grand poobahs. He has this idea to spice up things and is sending quines to the car crusher. **Challenge**: Write a quine that prints itself "squeezed" for output purposes into an n x n sq...
[Question] [ Given a ASCII string containing control characters, compute what it should look like when printed to a terminal. Imagining the behaviour of a cursor, this is how to treat each character in the input: * 0x08 backspace (`\b`): go left one (if already at the start of a line, do not go up) * 0x09 horizon...
[Question] [ # Follow the Path I got directions to my friend's house, but it looks like his map might have some mistakes. He's expecting me soon, so I need some short code to figure out if I can get there. # The Challenge The code should, when given an ASCII representation of a path as input, traverse from the st...
[Question] [ What general tips do you have for golfing in [Grass](http://www.blue.sky.or.jp/grass/)? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Grass (e.g. "remove no-op characters" is not an answer). Please post one tip per answer. [An...
[Question] [ **Contest Finished! Read comments on blobs to view their score.** This KoTH is loosely inspired by [Primer's Natural Selection Simulation](https://www.youtube.com/channel/UCKzJFdi57J53Vr_BkTfN3uQ). Your bot is a blob. In order to survive, you must eat pellets to regain energy, which is used to move. ...
[Question] [ **This question already has answers here**: [The lowest initial numbers in a Fibonacci-like sequence](/questions/147836/the-lowest-initial-numbers-in-a-fibonacci-like-sequence) (10 answers) Closed 5 years ago. Consider a sequence `F` of positive integers where `F(n) = F(n-1) + F(n-2)` for `n >...
[Question] [ [<< Prev](https://codegolf.stackexchange.com/questions/149950/advent-challenge-5-move-the-presents-to-the-transport-docks) [Next >>](https://codegolf.stackexchange.com/questions/150150/advent-challenge-7-balance-the-storage-carts) Thanks to the PPCG community, Santa managed to sort his presents into ...
[Question] [ Let's say you have a 20-sided die. You start rolling that die and have to roll it a few dozen times before you finally roll all 20 values. You wonder, how many rolls do I need before I get a 50% chance of seeing all 20 values? And how many rolls of an `n`-sided die do I need to roll before I roll all...
[Question] [ `;#` is a very simple language. It has 2 commands: * `;` will increment the accumulator * `#` outputs the accumulator modulo 127, and then resets the accumulator `;$` is also very simple and is very similar (and also does not yet exist). It has 2 commands: * `;` will increment the accumulator * `$` o...
[Question] [ The ECMAScript 6 standard added many new features to the JavaScript language, including a new [arrow function notation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions). Your task is to write a basic ES6-to-ES5 transpiler. Given only an ES6 arrow function a...
[Question] [ ## Introduction According to the [Riemann Hypothesis](https://en.wikipedia.org/wiki/Riemann_hypothesis), all zeroes of the [Riemann zeta function](https://en.wikipedia.org/wiki/Riemann_zeta_function) are either negative even integers (called *trivial zeroes*) or complex numbers of the form `1/2 ± i*t...
[Question] [ # Introduction There is a tax collector that has some trouble managing the taxes of his kingdom: the historical records have burnt down in a great fire. He wants to find out how many possible pasts there could be in terms of where the current money was inherited from. Luckily, his kingdom is very sim...
[Question] [ Given a positive integer `n`, output the `2^n` binary sequences of length `n` sorted in the following precise ordering. Test cases: 0: ``` 0 or 1 (defining this is a matter of debate) ``` 1: ``` 0 1 ``` 2: ``` 00 01 10 11 ``` 3: ``` 000 001 010 100 011 101 110 111 ``` 4: ``` 0000 0001 0010 0100 1000 ...
[Question] [ *Koronkorko* is the Finnish word for *compound interest*. We don't want compound interest in our strings, so let's find the shortest possible regular expression to exclude it. Given a string consisting only of the uppercase alphabetic characters A-Z, determine the shortest possible regular expression...
[Question] [ ## Introduction You are probably familiar with the ["puts on sunglasses"](http://knowyourmeme.com/memes/puts-on-sunglasses-yeeeeaaahhh) emoticon-meme: ``` (•_•) ( •_•)>⌐■-■ (⌐■_■) ``` In this challenge, your task is to take the first line as input, and output the last one, effectively putting sunglas...
[Question] [ While we're on a [triangular grids kick](https://codegolf.stackexchange.com/questions/68996/alignment-on-triangular-grids), I'd like to point out that there is an equivalent to [polyominoes](https://en.wikipedia.org/wiki/Polyomino) on a triangular grid. They are called [polyiamonds](https://en.wikipe...
[Question] [ When you round a number, if the next digit is `>= 5` you add 1. For example: ``` 3.1415926535 rounded to 1dp is 3.1 3.1415926535 rounded to 4dp is 3.1416 <-- Note the 5 changed to 6 3.1415926535 rounded to 5dp is 3.14159 3.1415926535 rounded to 9dp is 3.141592654 <-- Note the 3 changed to 4 ``` Y...
[Question] [ `dog` is a command-line utility that takes in an arbitrary number of arguments, the first of which is the text to be written and the others are arbitrarily many files. The `dog` utility will split the text in equal portions over these files. If there is a remainder `n`, the first `n` files get an add...
[Question] [ Any binary floating point can be formatted exactly in decimal. The resulting string might be somewhat long, but it is possible. In [my article on floating point](http://mortoray.com/2015/07/06/essential-facts-about-floating-point-calculations/) I cover the importance of precision, and now I want this...
[Question] [ A *musical string* is any string that can be played on a piano keyboard. For those of us who weren't forced to learn the piano as kids, here is what the keyboard looks like. ![piano](https://i.stack.imgur.com/QEXqc.gif) So the string `feed a dead cabbage` is a musical string because every single lett...
[Question] [ In some cases, often in physics, you have to sum graphs. Your challenge is to write, in a language of your choice, a program or function that takes multiple graphs as images, calculates all possible sums, and outputs the result. ## Graphs The graphs are images that contain a white (`rgb(255, 255, 255...
[Question] [ A downhill maze is given as a series of rows of space separated digits from 0 to 9 inclusive, plus one "S" and one "X", where the S denotes the start and the X denotes the finish. In a downhill maze, you may only go to a space that is adjacent to you to the north, south, east, or west (no diagonals),...
[Question] [ Find Hole 1 [here](https://codegolf.stackexchange.com/questions/39748/9-holes-of-code-golf-kickoff). Make a quine that, when run, outputs its own source code block multiple times. In fact, it must output it n times, where n in the next prime number. I think an example shows it best. ``` [MY QUINE][MY...
[Question] [ Yesterday, I bought a harmonica: ![my harmonica](https://i.stack.imgur.com/wV9kO.jpg) *Figure 1: The harmonica.* However, my dreams of being able to play soulful blues harmonica that moves people and causes a grown man to cry were quickly dashed by two problems: 1. The harmonica can only play certain...
[Question] [ ## Some background [Counting rods](http://en.wikipedia.org/wiki/Counting_rods) are small bars (3-14 cm long) that were used by mathematicians from many asian cultures for more than 2000 years to represent any whole number or fraction. (In this chqllenge we'l focus on unsigned integers though) There w...
[Question] [ Just like jQuery's `$.fn.text`, write one or two functions that can get and set the text on an element. You can't use `textContent` or `innerText`, and even less `innerHTML`. Plain javascript. No DOM library. It has to work on major browsers. (No need to care about old IE.) Shortest code wins. Enjoy!...
[Question] [ # Objective Requirements * A main 'parent' file and a 'child' file. * The parent file creates a new child file that contains code that must execute after creation. * The child file that is created must delete the existing sibling file. It wants all the attention, afterall. * No matter how many times ...
[Question] [ **This question already has answers here**: [Spoonerise words](/questions/69385/spoonerise-words) (44 answers) Closed 8 years ago. A spoonerisation is swapping the first letter/pronounceable syllable of two or more words. **Example**: A lack of pies = A pack of lies. Bad salad = Sad ballad (is...
[Question] [ Given two numbers \$N\$ and \$x\$, find the number of \$x\$-digit numbers whose product of digits is \$N\$ \$N <10^6\$ and \$x <12\$ ``` Sample Input (N x): 8 3 Sample Output: 10 ``` [Answer] ### Golfscript ~~42~~ 31 ``` ~10\?.10/\,>{10base{*}*1$=},,\; ``` **Input:** Expects the numbers `N` an...