instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Task
Given a finite permutation output its inverse.
You may take input and output in any reasonable format equivalent to a list of natural numbers. You may choose to use 0 indexing or 1 indexing. Your input and output format should be the same. You may assume a permutation has at least 1 element.
This is code-golf so... | stackexchange_codegolf |
As you may know, the typical binary floating point numbers in a computer language are quite different than the typical integer numbers in a computer language. Floating point numbers can represent a much larger range, and can represent fractional amounts, however there is a trade-off that is frequently elided.
The dista... | stackexchange_codegolf |
Bob the Bowman
o
/( )\ This is Bob.
L L Bob wants to be an archer.
#############
.
/ \ <--- bow So he bought himself a
(c -)-> <--- arrow nic... | stackexchange_codegolf |
Using the following length-separated lists of words:
https://github.com/Magic Octopus Urn/wordListsByLength
Print 1 word from each list of length n from 1 all the way up to 20, here's a valid example:
a
an
and
hand
hands
handle
handles
abandons
abandoned
understand
outstanding
newfoundland
understanding
characteristic... | stackexchange_codegolf |
Task
A reverse checkers position is a chess position where every piece for one player is on one colour and every piece for the other player is on the other colour. Your task is to find if the given (valid) position meets these criteria.
For example, this position does (click for larger images). Every white piece is on ... | stackexchange_codegolf |
There is an asdfmovie video about a pie flavoured pie. Someone also made an edited version with more pies, so I created this challenge.
The input is a positive integer.
The code should first output the following string:
I baked you a pie!
Oh boy, what flavour?
Then, the next line should be PIE (input number of times)... | stackexchange_codegolf |
NDos' Numeral System
NDos' numeral system is a numeral system invented by me. It represents every nonnegative integer by a binary tree. Given a nonnegative integer \$n\$:
If \$n=0\$, it is represented as the empty tree.
Otherwise, the tree has a root. With the binary expansion of \$n\$:
The left sub-tree of the root... | stackexchange_codegolf |
Prime numbers have always fascinated people. 2300 years ago Euclid wrote in his "Elements"
A prime number is that which is measured by a unit alone.
which means that a prime is only divisible by 1 (or by itself).
People have always looked for relations between prime numbers, and have come up with some pretty weird (a... | stackexchange_codegolf |
A challenge I thought that would be very cool is to make an interpreter for a Turing-complete language of your choosing.
The rules are simple:
You may use any language to create this interpreter even if it is newer than this challenge.
You may use any Turing-complete language as long as it is not the same as the one y... | stackexchange_codegolf |
Sandbox post (deleted)
The old roman army formations are very famous around the world. In these formations roman legionaries grouped in a geometric shape (usually a rectangle) protecting the flanks and the superior part of it using their shields. The legionaries at interior positions covered the superior part placing t... | stackexchange_codegolf |
Your program has to have an year like 1957 to be the input and then output the century of that year.
For example:
In: 1946
Out: 20
In: 1705
Out: 18
In: 1900
Out: 19
In: 100
Out: 1
In: 2001
Out 21
because 1946 is in the 20th century.
Keep in mind that 2000 should be 20th century or 1900 should be in 19th century.
There... | stackexchange_codegolf |
Write a program or function that takes in a positive integer N, and outputs an N×N pixel image of Google's "G" logo according to this* construction:
For example, if N is 400, a 400×400 pixel logo should be output, with correct dimensions and colors:
It should look accurate regardless of how large or small N is. e.g... | stackexchange_codegolf |
Rolling the Dice
So, I was rolling dice a while ago and thought of a challenge.
Given the cube with a net taken from input and a list of moves, find the square on the bottom at the end.
I will use this image for the examples here.
Input
You take in a string with a list of moves. The string contains only the capital A... | stackexchange_codegolf |
Input:
A string only containing the following characters:
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.?! (space at the end) and two special characters (_ and |)
Output:
Mirror the text based on the position(s) of the _ and |.
_ mirrors horizontally and | mirrors vertically.
Mirroring process
The fir... | stackexchange_codegolf |
This challenge is inspired by a picture that often roams on Facebook that looks like this. Except our base square will look more like this:
┌─┬───┬─┐
├─┼─┬─┼─┤
├─┼─┴─┼─┤
├─┼─┬─┼─┤
└─┴─┴─┴─┘
The square is made out of n x m 1x1 square, you have to count how many sub-squares (1x1, 2x2, 3x3, 4x4, 5x5, etc.) can fit within... | stackexchange_codegolf |
Background
A maximal domino placement (MDP) on a rectangular grid is a non-overlapping placement of zero or more dominoes, so that no more dominoes can be added without overlapping some existing domino.
Alternatively, it can be thought of as a tiling using dominoes and monominoes (single square pieces) so that no two m... | stackexchange_codegolf |
This is a CMC (chat mini challenge) that I posted in our chatroom, The Ninteenth Byte, a bit ago.
The Challenge
Given a positive integer x, depending on the last 2 bits of x, do the following:
x & 3 == 0: 0
x & 3 == 1: x + x
x & 3 == 2: x * x
x & 3 == 3: x ^ x (exponentiation)
Input/Output
Single Integer -> Single Int... | stackexchange_codegolf |
Every palindrome with an even number of digits is divisible by 11, so 11 is the only [palindromic prime] with an even number of digits. - David Wasserman, OEIS
I learned this today the manual way, before I did my research, when my program skipped numbers with an even number of digits (except 11) when calculating pali... | stackexchange_codegolf |
There is a challenge Let's play tennis by Daniel. He proposes to place a court in the North-South direction. My proposal is to create a court to play tennis in the East-West direction too.
You have to print a tennis court, but you have to do it in the fewest bytes possible because of confidential reasons.
Tennis court... | stackexchange_codegolf |
Your function must accept three numbers in any order:
A signed real number (or ±Infinity) - The number (N) for which you have to generate a number from the range
A signed integer - Minimum of the range
A signed integer - Maximum of the range
Input:
The minimum of the range will always be less than the maximum of the... | stackexchange_codegolf |
Challenge: Write a piece of code that only runs when the code is not being altered. If you change anything, the code should detect this and deny running. Of course, it should not be possible to just alter the detection mechanism (since this is a change in itself).
| stackexchange_codegolf |
Introduction
I can't stand text abbreviations, mainly because for the most part I have no idea what most of them mean. Of course, cut backs need to be made, so if they are necessary to fit the text in the character limit, I'll allow them.
Challenge
You have to write a program that takes passage of text and determines w... | stackexchange_codegolf |
Your challenge: The code must print "Hello, World!" and nothing else.
Your restrictions: Your program must satisfy these requirements:
The program must be a pangram.
It must use every character in printable ASCII, or, if you chose a particularly strange language, characters which are stored as one byte.
You are allow... | stackexchange_codegolf |
For the purpose of this challenge, we'll define whitespace as only linefeeds (0x0A) and spaces (0x20). Note that most languages and regex flavours consider many other characters as whitespace as well, both inside and outside the ASCII range so you might not be able to make use of the corresponding built-ins.
The Cops' ... | stackexchange_codegolf |
Challenge
Make a triangle of numbers like below.
How to?
Let say we get a numbers in the form of ab, for example 12. We then create a triangle like below:
Sorry for my bad drawing!
First we have 12, and we take sum of the two numbers 1 and 2, which is 3. In case the sum of two numbers are greater than 9, we just take ... | stackexchange_codegolf |
Your task is to write a program that performs case conversion from plain text, and other case formats, into one of the specified formats below. Inputs will be either plain lowercase text, or one of the detailed cases below. You must remove non-alphabetic characters except (space), _ (underscore) and - (hyphen), then ... | stackexchange_codegolf |
Find a maximally profitable sequence of exchanges given an exchange rate table.
As an example consider the currencies Ariary (your home currency), Baht, Cedi, and Denar where the rate from one to another (after any transaction rate has been levied) is given by the (row, column) entry in the exchange rate table below:
... | stackexchange_codegolf |
inspired by this chat conversation
A satisfying number is a number whose decimal representation is of the form abx, with the following properties:
x is the longest trailing repeating suffix, or the last digit if there is no repetition at the end (123333 -> 3333, 545656 -> 5656, 123 -> 3)
b is the single digit prior to... | stackexchange_codegolf |
When you look at the last decimal digit of each power of a non-negative integer a repeating pattern forms. For example, 3:
3^1 = 3
3^2 = 9
3^3 = 27
3^4 = 81
3^5 = 243
3^6 = 729
3^7 = 2187
3^8 = 6561
3^9 = 19683
The last digits go 3971 which repeats indefinitely. In fact any number we choose that en... | stackexchange_codegolf |
Write a program that translates an arithmetic expression to a Brainfuck program which evaluates the expression and prints the result in decimal numbers. For example, this arithmetic expression,
2 * (3 + 4)
can be translated to Brainfuck as,
++ 2
>+++ 3
>++++ 4
[-<+>]< add
<[>[->+>+<<]>[-<+>]<<-]>[-]>>[-<<<+>>>]<<< mul... | stackexchange_codegolf |
Challenge :
Your job is to find the given number N.
Input :
You will be given a string in the following form:
dN ± Y = X
Where:
d, N, X, Y are all numbers with d , X , Y being integers (not decimals).
Output :
Solve the equation and output the value of N rounded. Round up if decimal is greater than or equal to 0.5... | stackexchange_codegolf |
Inspired by this excellent challenge (from which the bulk of this text is blatantly duct-taped) – and my highschool philosophy project...
I define the following operators:
Fuzzy Conjunction a ×F b is a × b
Fuzzy Division a ÷F b is a ÷ b
Fuzzy Negation –F b is 1 – b
Fuzzy Disjunction a +F b is –F ((–F a) ×S (–F b) which... | stackexchange_codegolf |
Numbers that are easy to remember yet theoretically not easily made
Your challenge is to make a program/function in any language that generates uniformly random numbers that fit these criteria:
Length is 5 digits
There are two separate repeated digit pairs
One set of repeated digits is at the beginning or end and th... | stackexchange_codegolf |
I came across an interesting tiling of the plane using squashed hexagons in a popular math book. All the six edges of the squashed hexagon are the same length. Two opposite corners are right angles and the rest four corners are 135 degrees each. This shape allows four squashed hexagons be arranged so that they meet at ... | stackexchange_codegolf |
Task:
Given an integer input, figure out whether or not it is a Cyclops Number.
What is a Cyclops number, you may ask? Well, it's a number whose binary representation only has one 0 in the center!
Test Cases:
Input | Output | Binary | Explanation
--------------------------------------
0 | truthy | 0 | only ... | stackexchange_codegolf |
Description
In this challenge, you need to write a function that takes in a list of strings and returns the smallest string based on their ASCII value. You should assume that the input list contains only lowercase alphabetical strings.
Test Cases
["a", "b", "c"] => "a"
["hello", "world", "code"] => "code"
["aaa", "aa",... | stackexchange_codegolf |
The goal is simple, print out each day of the twelve days of Christmas, the text should match this exactly
On the first day of Christmas my true love gave to me
A partridge in a pear tree
On the second day of Christmas my true love gave to me
Two turtle doves, and
A partridge in a pear tree
On the third day of Christ... | stackexchange_codegolf |
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 (credits to GPT Gone Wild)
Your job is to print that text exactly. More specifically,
Take no inp... | stackexchange_codegolf |
This challenge is based on the game Layerz.
Given, on stdin or as a function argument, a 2D rectangular array of cells where each cell contains either a blank (you may choose to use 0s instead of blanks at no penalty), a 1, a 2, a 3, or a 4; find a way to divide it into valid regions (as defined below) such that each n... | stackexchange_codegolf |
This challenge is inspired by the same task I read some time ago in CACM.
There are many ways to sort stuff. Most attempt to sort in as few operations as possible (= as fast as possible). However, it is also possible to consider how few resources you might require to sort stuff, which seems more fitting for a codegolf ... | stackexchange_codegolf |
Try it online! currently has 680 listed languages, all of which are searchable. For most of those languages, when searching for it, you don't have to enter the entire string. For example, entering lega results in just 05AB1E (legacy) appearing, and entering d+ results in only Add++. However, for some languages, there i... | stackexchange_codegolf |
Introduction (may be ignored)
Putting all positive numbers in its regular order (1, 2, 3, ...) is a bit boring, isn't it? So here is a series of challenges around permutations (reshuffelings) of all positive numbers. This is the fifth challenge in this series (links to the first, second, third and fourth challenge).
I... | stackexchange_codegolf |
Given an input integer n >= 10, output the average of all deduplicated rotations of the integer.
For example, for input 123, the rotations are 123 (no rotation), 231 (one rotation) and 312 (two rotations). The average of those is (123 + 231 + 312) / 3 or 222.
As another example, take 4928. The rotations are 4928, 9284,... | stackexchange_codegolf |
Task
Given one non-whitespace printable character, make a 3x3 square representation of that input. For example, if the input is #, then the output is:
###
# #
###
Rules
The output format is strict, although a trailing newline is allowed. It means that the space in the middle is required, and also that the two newline... | stackexchange_codegolf |
Write a full program or a function taking an unsigned integer number N and doing this cut out work:
Cut out a hollow hexagon 'donut' shape with side B-C equal to 2N times '/'
Translate the piece above by 3 lines.
Repeat the job N times (from the piece obtained) decrementing by 2 '/' side B-C , until smallest hexagon ... | stackexchange_codegolf |
Given a sequence of 625 32-bit unsigned integers (that is, in the range [0, 2**32)), output which of the following pseudorandom number generators generated the sequence:
Linear Congruential Generator
Xorshift
Mersenne Twister
Specifically, the C implementations of these three generators used for this challenge are as... | stackexchange_codegolf |
For our purposes, a trend is a contiguous subsequence of an array that falls into one of three categories:
increasing, e.g. [1,2,3,10,239]
decreasing, e.g. [8,5,0,-3,-50]
stable, e.g. [7,7,7,7]
Note that [1,1,2,3] is not a valid trend. It can be broken up into a stable trend [1,1] and an increasing trend [1,2,3]. In ... | stackexchange_codegolf |
I noticed a certain game had a peculiar life counter, which instead of stopping at 999, gained a new digit – the next number was crown hundred or 00. After 99 came crown hundred crownty (0) and the last number, after 9, was crown hundred crownty crown or , which would be 1110 in decimal.
Your task is to write a program... | stackexchange_codegolf |
There is a rather curious number which shows up sometimes in math problems or riddles. The pseudofactorial(N) is the least (i.e. lowest) common multiple of the numbers 1 through N; in other words, it's the lowest number which has all numbers from 1 through N as factors.
For instance pseudofactorial(7) = 3 * 4 * 5 * 7, ... | stackexchange_codegolf |
Shocking news: Dr. Mad J Scientist has released a proof of P = NP to the world. But the proof is nonconstructive, and she's keeping the algorithm to herself.
Worry not. Without even looking at her proof, we can still (almost) write a computer program that solves NP-complete problems in polynomial time.
The Problem
Inpu... | stackexchange_codegolf |
The task:
Build a calculator that takes a simple math equation in Chinese and outputs the correct answer(To the equation from the users input) in Chinese.
Scope:
Any programming language can be used.
Input must be in Chinese otherwise an error message will be displayed .
Output must be in Chinese.
Only input and outp... | stackexchange_codegolf |
Challenge
The goal is to output Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo.
Context. (Maybe another interesting challenge could be printing all of the other examples? This would probably use similar logic but involve either a function or just a for loop.)
Rule(s)
You cannot output anything other t... | stackexchange_codegolf |
Background:
For this challenge, a polynomial looks like this:
$$P(x)=a_nx^n+a_{n-1}x^{n-1}+\dots+a_2x^2+a_1x+a_0$$
The degree, \$n\$, is the highest power \$x\$ is raised to. An example of a degree 7 polynomial would be:
$$P(x)=4x^7+2x^6-7x^4+x^2-6x+17$$
All powers are integers \$n\ge0\$. This means \$x\$, \$-2\$, and ... | stackexchange_codegolf |
Input
A single hex 6-digit colour code, capital letter, without #. Can also be a 24-bit integer if you prefer.
Output
The closest HTML color name (e.g red, or dark-salmon, as defined as https://www.w3schools.com/colors/colors_names.asp or see below). Distance is defined by summing the difference in red, green and blue ... | stackexchange_codegolf |
Your task is to write a program or function. Its output/return value must follow these rules:
The program outputs 1
The program repeated n times outputs n
The program backwards outputs -1
The program backwards and repeated n times outputs -n
A mix of forward and backward programs will output number_forward - number_ba... | stackexchange_codegolf |
Challenge
Given a string of any length, write it as a triangle, spiraling out from the center. For example, abcdefghijklmnop becomes:
g
fah
edcbi
ponmlkj
Or more explicitly:
If you like, you can spiral counter-clockwise instead:
g
haf
ibcde
jklmnop
Or add spaces uniformly:
g
f a h
... | stackexchange_codegolf |
Hexcells is a game based off of Minesweeper played on hexagons. (Full disclosure: I have nothing to do with Hexcells. In fact I don't really like the game.) Most of Hexcells rules can be pretty easily expressed in Generalized Minesweeper (Minesweeper played on an arbitrary graph). The one that is most difficult is th... | stackexchange_codegolf |
I am a big fan of the game Creeper World, and especially the sequel. You don't need to know how this game works to answer the question, I just wanted to mention where my question originated from.
In the game, your objective is to destroy the Emitters that are spawning Creeper, using a weapon known as a nullifier.
Nulli... | stackexchange_codegolf |
The Problem:
Two enemy secret agents have devised a wonderful (for you) method of communication!
Here’s how the encryption process works:
1) Take the ascii equivalents of each letter. (No spaces, numbers, or punctuation are sent)
2) For each letter in the message, the ascii equivalent of it and the letter after it (If ... | stackexchange_codegolf |
Tab completion is a useful feature that auto-completes partially written commands. You're going to be implementing it.
For example, if the available commands were ['apply','apple','apple pie','eat'], then a would complete to appl, as all of the commands that start with a also start with appl.
Input/Output
You need to... | stackexchange_codegolf |
To be able to challenge the Elite-4 of top programmers, you need to show your badges first, that qualify you as a potential programmer-master. However, there's a twist. Once you show a badge, it is collected, which means you can't re-show it. So better come prepared! There are n badge collectors, each has a known list ... | stackexchange_codegolf |
Every positive integer can be expressed as the sum of at most three palindromic positive integers in any base b≥5. Cilleruelo et al., 2017
A positive integer is palindromic in a given base if its representation in that base, without leading zeros, reads the same backwards. In the following, only base b=10 will be c... | stackexchange_codegolf |
Your challenge: The code must print "Hello, World!" and nothing else.
Your restrictions: Your program must satisfy these requirements:
The program must be a pangram.
It must use every character in printable ASCII, or, if you chose a particularly strange language, characters which are stored as one byte.
You are allow... | stackexchange_codegolf |
Imagine a bunch of rectangles drawn in the plane, each rectangle with its vertices at integer coordinates and its sides parallel to the axes:
The rectangles partition the plane into a number of disjoint regions, coloured red and blue below:
Your goal is to find the number of such regions which are perfect squares. In... | stackexchange_codegolf |
Input
A bound m <= 4294967295.
Output
Consider values sampled uniformly at random from integers in the range 0 to m, inclusive.
Your output should be the expected (average) number of trailing zeros in the binary representation of the sampled value. Your answer should be exact, for example given as a fraction.
Example
... | stackexchange_codegolf |
Challenge
Robin likes having his variables declaration in the shape of an arrow. Here's how he does it:
Input any number of strings
Order them by ascending length
Output them ordered by the middle to roughly form a negative arrowhead, like this (whichever order golfs the best):
5 or 4
3 2
1 1
2 3
4 ... | stackexchange_codegolf |
Let \$ A \$ represent the alphabet, such that \$ A_1 = \$ a and \$ A_{26} = \$ z.
Let's define that a word \$ W = w_1 w_2 ... w_n \$ (where \$ w_c \in A\$) is in standard order if and only if:
\$ w_1 = A_1 \$, and
for \$ 2 \le i \le n \$, if \$ w_i = A_x \$ then \$ w_j = A_{x-1} \$ for some \$ j < i \$ and some \$x\$.... | stackexchange_codegolf |
Challenge
Your program needs to take an input of a string, where the string has only letters, no special characters, no numbers, and no accents (they look all weird).
Then, your program should output a superscript version.
Example
Input: hello world
Output: ʰᵉᶫᶫᵒ ʷᵒʳᶫᵈ
Test Cases
hello - ʰᵉᶫᶫᵒ
code - ᶜᵒᵈᵉ
golf - ᵍᵒᶫᶠ
a... | stackexchange_codegolf |
Task
Provide two programs/functions A and B (not necessarily in the same language) with the following properties:
Either program, when given its own source code as input, produces an accepting output.
Either program, when given the other program's source code as input, produces a rejecting output.
It doesn't matter w... | stackexchange_codegolf |
This is a little codegolf challenge from codingame.com. I was wondering how much Python3 code is necessary (but of course answers are not limited to Python3).
Input
The first line contains one positive integer n. The second line contains n positive integers. Each consecutive integers on the second line are separated by... | stackexchange_codegolf |
Challenge:
In the programming language of your choice, take no input and output your programming language's name.
Fair enough, right?
Restrictions:
You can't use any character that is included in your programming language's name in your code. E.g., if I use Batch, I must not use the chars 'B' 'a' t' 'c' 'h' in my code... | stackexchange_codegolf |
(Note: This is my first ever code golf question, but as far as I can tell, nobody else has done exactly this, so I should be good.)
Your task is to make a program or function that takes in a string s and an integer n, and returns or outputs that text wrapped into multiple lines. Each word must be wholly on a line; i.e.... | stackexchange_codegolf |
For this golf, you will need to use more than one language.
The task
A Rube Goldberg machine is a contraption that takes an enormous number of complicated steps in order to execute a very simple task. The goal of this golf is to output Rube Goldberg... but not directly.
The machine
Your "machine" is the source code tha... | stackexchange_codegolf |
Given a rectangular haystack of size at least 2x2 composed of all the same printable ASCII characters, output the location (counting from the top-left) of the needle which is a different character.
For example, if the following haystack is input:
#####
###N#
#####
#####
The output should be 3,1 when zero-indexed (what... | stackexchange_codegolf |
This is the exact same question I asked earlier, but without the annoying Cyrillic factor which many found superfluous. I hope this is a better puzzle!
The quaint hamlet of North Codetown in the Scottish far north has a problem: their population is low (below 52), and no new people have arrived for years. Moreover, af... | stackexchange_codegolf |
I just created a language on the spot, and it's called "interpreter". Called as such because the only valid word is "interpreter"!
A sample program in "interpreter" looks like this:
interpreter interpreterinterpreter interpreterinterpreterinterpreter interpreterinterpreterinterpreterinterpreter interpreterinterpreterin... | stackexchange_codegolf |
Suppose we define a simple program that takes an array L of natural numbers with some length N and does the following:
i=0 #start at the first element in the source array
P=[] #make an empty array
while L[i]!=0: #and while the value at the current position is not 0
P.append(L[i])... | stackexchange_codegolf |
Question
Write a program to accept one string on the console only and print back its letters arranged in alphabetical order. The string must only have the following characters:
0123456789abcdefghijklmnopqrstuvwxyz
Rules
The ascending alphabetical order is defined in the given string.
All repeated characters must be ... | stackexchange_codegolf |
Vyxal is a golfing language that has 500+ different commands (achieved through overloads), and is a known beater of Jelly, 05AB1E and most golfing languages.
Henceforth, it seems like a good idea to share some of the tips and tricks of the industry used to get terse programs in Vyxal.
One tip per answer, and no stupid ... | stackexchange_codegolf |
I was surprised to not find this asked already, though there is a great question on darts checkouts: Darts meets Codegolf
Your challenge is to calculate which scores are not possible with 'n' darts below the maximum score for 'n' darts. E.g. for n=3, the maximum possible score is 180 so you would return [163,166,169,17... | stackexchange_codegolf |
Here's a very simple little problem that I don't believe has been asked before.
Challenge
Write a program or a function that takes in four positive integers that represents the lengths of movable but unbreakable and unbendable straight fences. Output the area of the largest rectangular yard that can be fully encompasse... | stackexchange_codegolf |
Print the biggest-size subset of strings in the input that are all permutations of each other. If there are ties, any one will do. If no strings are permutations of each other (for example, only one string was given or the strings contain distinct characters), this is just one of the strings. If no strings were passed ... | stackexchange_codegolf |
The TAK function is defined as follows for integers \$x\$, \$y\$, \$z\$:
$$
t(x, y, z) = \begin{cases}
y, & \text{if $x \le y$} \\
t(t(x-1,y,z), t(y-1,z,x), t(z-1,x,y)), & \text{otherwise}
\end{cases}
$$
It can be proved that it always terminates and evaluates to the simple function below:
$$
t(x, y, z) = \begin{cases}... | stackexchange_codegolf |
The task is to write a radiation-hardened irradiator. What do I mean by that, exactly?
An irradiator is a program that, when given a string as input, will output all possible versions of the string with one character removed. For example, given the input Hello, world!, the program should output:
ello, world!
Hllo, worl... | stackexchange_codegolf |
Introduction
You are listening to a car radio. You are pressing seek up/down, moving you to the next frequency some radio station broadcasts on, to avoid all this pointless music and listen to all the ads, or vice versa. If you try to go below the lowest frequency radio can handle, it jumps to the highest (and vice ver... | stackexchange_codegolf |
Cross posted from my anagolf post (note: may contain spoilers, post mortem).
Output the following text exactly.
You may have additional trailing whitespace on each line, and trailing newlines as well.
Shortest code, in bytes, wins.
... | stackexchange_codegolf |
Background
Slowsort is an in-place, stable sorting algorithm that has worse-than-polynomial time complexity. The pseudocode for Slowsort looks like this:
procedure slowsort(A[], i, j) // Sort array range A[i ... j] in-place.
if i ≥ j then
return
m := floor( (i+j)/2 )
slowsort(A, i, m) ... | stackexchange_codegolf |
You want to draw a regular polygon but you have limited space! In this challenge, you should draw a polygon with n sides which is as big as possible for a given square container image.
I found surprisingly little information on the Internet about inscribing a polygon into a square. To save you the hassle, I verified th... | stackexchange_codegolf |
What do you get when you cross Pascal's Triangle and the Fibonacci sequence? Well, that's what you have to find out!
Task
Create a triangle that looks like this:
1
1 1
2 2 2
3 5 5 3
5 10 14 10 5
8 20 32 32 20 8
Basically, instead of each cell being the sum of the cells ... | stackexchange_codegolf |
Lists can contain lists and we have nested lists. But we don't like nested lists and want to flatten them. By flattening I mean create a list which does not contain any list, but elements of lists it contained before. I'll explain it more.
Input
An arbitrary size list which has the below properties:
it can contain int... | stackexchange_codegolf |
TL;DR: Given an array of chars and a robot in a starting position of the array, write an algorithm than can read a string with movements (F for "go forward", R for "rotate 90 degrees right" and L for "rotate 90 degrees left") and calculate the ending position of the robot. More details in the complete text.
We have a... | stackexchange_codegolf |
Goal
Write a function or a program that when given a string, for example "The quick brown fox jumps over the lazy dog", outputs:
T h e q u
i
e r t h e c
v k
o l
a b
s z r
p y o
m g o d w
u n
... | stackexchange_codegolf |
Toki Pona is a constructed language with 137ish words, designed to constrain the speaker to expressing ideas in a simple and straightforward manner, reducing ideas to more essential forms.
Often, people attempt to avoid directly expressing numeric quantities in Toki Pona, opting to express them in more practical terms.... | stackexchange_codegolf |
Introduction:
In Dutch, the words leading and suffering, being 'leiden' and 'lijden' respectively, are pronounced the same way. One is written with a "short ei", and one with a "long ij", as we Dutchman would say, but both 'ei' and 'ij' are pronounced [ɛi].
Challenge:
Given a list of numbers, determine which (if any) a... | stackexchange_codegolf |
Have you ever found a good challenge to answer, answered it and then found out somebody posted a solution with a better score in the same language?
Challenge
Write a program/function that takes a PPCG question ID and outputs a leaderboard.
A leaderboard consists of the rank, the language, the score, the author and the ... | stackexchange_codegolf |
Backstory
Meet my friend Jimmy:
/o\
Jimmy is a little character who likes to stand on platforms. Here's Jimmy safely standing on a platform:
/o\
-------------
Now, Jimmy has a good sense of balance, so he can safely stand with one leg off of the platform, like so:
/o\
-------------------
Although i... | stackexchange_codegolf |
I don't know if something like this exists already (and I'm not finding the right key words) but if not, it felt like it could be an interesting coding puzzle.
The challenge is, to take an arbitrarily nested list (no more than 2 deep), and display the content in a terminal in 2 dimensions in a 'pretty' manner. Each 'to... | stackexchange_codegolf |
Today's date is quite an interesting one. Let's take a look at why. The date 07/12/2017 (in DD/MM/YYYY date format) can be split into the year (2017) and the rest (07/12). You may notice that the digits in the year can be rearranged to match the digits in the rest of the date, which is the basis of this challenge.
The ... | stackexchange_codegolf |
The task is to find the smallest paper size on which it is possible to print a picture of the dimensions given in milimetres. The image will be printed without margins.
Input:
Two integers (bigger than zero) and a letter a, b, or c, for example:
290
200
A
Output:
Paper size, for example:
A4
Another examples:
218,297... | stackexchange_codegolf |
Here is the problem, for which I can only think of an iterative solution and have not found a closed formula:
You need to paint a house with R rooms.
For each room there are four walls and one ceiling, which all have the same dimensions and need C coats of paint.
You can't paint the next coat until the previous one ha... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.