instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
You are sick of all of the codegolf challenges. Hence you decide to write a program that will automatically golf some Python code for you. There are 3 test cases: print quickSort([0,7,3,-1,8,10,57,2]) def quickSort(arr): less = [] pivotList = [] more = [] if len(arr) <= 1: return arr else:...
stackexchange_codegolf
Background: Jack is a pumpkin that enjoys spooking the citizens of the villages near his pumpkin patch every Halloween. However, every year after someone lights the candle inside of him, he has a limited amount of time to spook everyone before the candle burns out, thus being unable to spook any more villagers because...
stackexchange_codegolf
The matrix tornado is just like any other tornado: it consists of things rotating around a center. In this case, elements of the matrix instead of air. Here is an example of a matrix tornado: First we start by sectioning the matrix into square rings, each section consists of elements that are farther away from the bor...
stackexchange_codegolf
Introduction Sometimes I get bored and there are no new questions on PPCG, so I want you to dig a random question from PPCG's past. Challenge Given a user's PPCG ID as input (e.g. my ID is 30525), output the URL of a randomly chosen PPCG question. If the question does not meet the following criteria, you must choose an...
stackexchange_codegolf
Task: Given an integer number in decimal number system, reduce it to a single decimal digit as follows: Convert the number to a list of decimal digits. Find the largest digit, D Remove D from the list. If there is more than one occurrence of D, choose the first from the left (at the most significant position), all oth...
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
Input An array that can contain arrays or positive, consecutive, ascending integers. The arrays can have any number of arrays inside of them, and so on and so forth. No arrays will be empty. Output This array simplificated How to simplificate an array We will use the array, [1, [2, 3], [[4]], [[[5, 6], 7, [[[8]]]], 9]]...
stackexchange_codegolf
John Horton Conway was a brilliant mathematician. Among his contributions were three Turing-complete esolangs: Game of Life (esolangs wiki), FRACTRAN (esolangs wiki), and Collatz function (esolangs wiki). Because we did an extremely amazing job around GoL, it is time for the challenge with the other two. Background A F...
stackexchange_codegolf
Task: Consider the problem: "given a chessboard with one square missing, cut it into 21 L-triominoes". There is a well-known constructive proof that this can be done for any square chessboard size that is a power of two. It works by splitting the chessboard into a smaller chessboard with the hole in it and one big trio...
stackexchange_codegolf
From Wikipedia: The centroid of a non-self-intersecting closed polygon defined by n vertices (x0,y0), (x1,y1), ..., (xn−1,yn−1) is the point (Cx, Cy), where and where A is the polygon's signed area, In these formulas, the vertices are assumed to be numbered in order of their occurrence along the polygon...
stackexchange_codegolf
Our new bank needs a teller transaction system but there is a problem. There is only a few hundred bytes of space left on our server, so you will have to write very compact code. Database Thankfully our database is very simple (it was built by the schoolboy son of our bank president), and we only have a few customers s...
stackexchange_codegolf
This is an alternate version of this earlier challenge with a twist that adds a significant bit of difficulty. Like last time, you are going to be given a string containing some alphabetic characters along with [ and ]. Your task is to split into sections that are enclosed in a "group" created by [...] and those that ...
stackexchange_codegolf
Introduction This question is inspired by this great question. Challenge Given a number \$N>0\$, output the largest integer \$a^b\$ that is smaller or equal to \$N\$, and the smallest integer \$c^d\$ that is greater or equal to \$N\$, where \$b>1\$ and \$d>1\$. Output should be a list of two integers, the first being s...
stackexchange_codegolf
You need to produce the word codegolf Rules: None of the characters of the word codegolf (i.e. 'c', 'o', 'd', 'e', 'g', 'o', 'l' and 'f') in either case can exist anywhere in the code. Case of the word must be one of three: All Upcase (CODEGOLF) All Downcase (codegolf) Capitalized (Codegolf) You only need to produ...
stackexchange_codegolf
Write a sorting algorithm for a list of integers that has an average performance of O(n^2). This is code-golf, so the shortest code in bytes wins. RULES: The characters wasted for the declaration of the list are not counted (e.g. var c = new List<int>() { 4, 2, 1, 3 }; is not counted) Builtins to sort a list are not ...
stackexchange_codegolf
Challenge Your goal is to write a function that puts quotes around a sequence of capital letters in a string. So some examples (everything on the left (before function) and right (after function) are STRINGS): Hello the name's John Cena -> "H"ello the name's "J"ohn "C"ena I got BIG OLD truck -> "I" got "BIG" "OLD" truc...
stackexchange_codegolf
Introduction Everyone knows that the possibility of successfully navigating an asteroid field is approximately 3,720 to 1. But despite your warning, Han Solo is still willing to try his luck. Fearing for your artificial life, you decide to code, in the ship's peculiar dialect (read: your preferred Code Golf language), ...
stackexchange_codegolf
The Meeker numbers are a 7 digit number in form of \$abcdefg\$, where \$a×b=10c+d\$ and \$d×e=10f+g\$. As an example \$6742612\$ is a meeker number, here \$6×7=10×4+2\$ and \$2×6=10×1+2\$, so it is a meeker number. Additionally, a Meeker number does not have any leading zeros (so \$a \ne 0\$) The Challenge Your program...
stackexchange_codegolf
Programs often list outcome statistics, such as this: 54% of participants received an award 69% of participants got a promotion 85% of participants increased their salary These percentages are the result of dividing a/x, where both a and x are whole numbers, and the result is rounded to the nearest hundredth. Your ta...
stackexchange_codegolf
Challenge The challenge is to implement the bottom encoding (only encoding, not decoding). There is a wide variety of existing implementations in the bottom-software-foundation org. Bottom is a text encoding where each character is separated into multiple emoji. Unicode escape(s) Character Value U+1FAC2 200 ...
stackexchange_codegolf
Given some positive integer n, design a protractor with the fewest number of marks that lets you measure all angles that are an integral multiple of 2π/n (each in a single measurement). Details As an output, you may output a list of integers in the range 0 to n-1 (or 1 to n) that represent the position of each mark. Al...
stackexchange_codegolf
In the arcade version of the game, Pac-Man eats pac-dots. However, in this challenge, he's hungry for alphanumeric characters and punctuation in a string. Your task is to create a function that feeds Pac-Man a string, evaluates if he can eat it or not, and returns the string with Pac-Man's location in it. Pac-Man (<) e...
stackexchange_codegolf
Overview The sharpness of a word is the sum of the sharpness of each of its letters, using the following rules: Sharp letters A, and V each have a sharpness of 1 N and Z each have a sharpness of 2 M and W each have a sharpness of 3 Dull letters C and U each have a sharpness of -1 S has a sharpness of -2 O has a shar...
stackexchange_codegolf
Sometimes to fall asleep, I'll count as high as I can, whilst skipping numbers that are not square-free. I get a little thrill when I get to skip over several numbers in a row - for example, 48,49,50 are all NOT square-free (48 is divisible by 2^2, 49 by 7^2, and 50 by 5^2). This led me to wondering about the earliest ...
stackexchange_codegolf
Challenge Write a program or function that takes in 4 non-negative integers, A, B, C, and D, that represent two fractions, A/B and C/D, where B and D are non-zero and A <= B and C <= D. Output an ASCII art depiction of the fractions made of |x- characters on two lines as follows: The lines will always be the same, min...
stackexchange_codegolf
The formula Take for instance the number 300 The prime factors of 300 are [2, 3, 5] (unique numbers that are factors of 300 and prime) Squaring each of those numbers will give you [4, 9, 25] Summing that list will give you 4 + 9 + 25 = 38 Finally subtract that sum (38) from your original number 300-38 = 262 (this is ...
stackexchange_codegolf
Part of Advent of Code Golf 2021 event. See the linked meta post for details. Related to AoC2017 Day 9. Weekends are Bubbler's days off from posting these lol A large stream blocks your path. According to the locals, it's not safe to cross the stream at the moment because it's full of garbage. You look down at the str...
stackexchange_codegolf
Challenge Write a program that takes as input a text and output "That's me!" if the input is equal to the program own source code, and "That's not me!" otherwise. Notes This is codegolf, in each programming language the shortest program wins. The input can be taken from program arguments or function argument, and the ...
stackexchange_codegolf
Your challenge is to take input as a line of text and output it like this. Input / output The input will be a string that contains only printable ASCII characters. The first or last characters will never be spaces, and there will never be two spaces in a row. It will always be at least two characters long. Your output...
stackexchange_codegolf
Background You have again, again been given the task of calculating the number of landmines in a field. But this time, the field is foggy. You must calculate the landmine score given a list/string of numbers, the landmine number, and the land distance (all are numbers). The landmine number tells you where landmines are...
stackexchange_codegolf
Write a program or function which takes a string of text as input and outputs the number of non-alphabetical characters in it (standard I/O rules apply). A non-alphabetical character is any character not appearing in this string: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ In terms of ASCII character codes, t...
stackexchange_codegolf
Since the first weekend of October is drawing near, let's have our own Oktoberfest! Background You and some other programmers have been hired by the local sausage guys in Munich, Germany. The sausage guys provide Oktoberfest with all the sausages the giant Volksfest needs. You manage to overhear your boss speaking to t...
stackexchange_codegolf
Given a string s composed of lowercase letters, such as aabaaababbbbaaba and a positive integer n, such as 4, output a length-n string t such that when t is repeated to the length of s, they have as many chars in common as possible. For the given example, the optimal output would be aaba, because it has thirteen chars...
stackexchange_codegolf
Getting the average of a list (e.g [2,6,7]) Get the length of the list: [2,6,7] -> 3 Sum the numbers in the list: 2 + 6 + 7 = 15. Divide the sum by their count: 15 / 3 = 5. You should compare the averages of two lists of positive integers N and M, by returning a value if N has a higher average, another value if M ha...
stackexchange_codegolf
A natural number (written in the decimal base) is qualified as digisible if and only if it fulfills the following 3 conditions: none of its digits is zero, all the digits that compose it are different, the number is divisible by all the digits that compose it. The challenge is to output all the digisibles (there are ...
stackexchange_codegolf
Implement a simple digital Stopwatch, which will display the time elapsed in seconds and minutes, as described below. Important Please read both Display and Controls sections ! Display Time elapsed, should be displayed in the MM:SS format, by replacing the previously displayed time string "in-place" (clearing the who...
stackexchange_codegolf
Introduction: Inspired by both Perfect License Plates and How many points does my license plate give? Just like in the challenges above, me and my little brother had a game of our own with license plates as kids. We tried to create (random/funny) sentences with the (numbers and) letters of the license plates. For examp...
stackexchange_codegolf
Challenge: Inputs: A string containing printable ASCII (excluding spaces, tabs and new-lines) A boolean † Output: The parts of the String are divided into four groups: Lowercase letters Uppercase letters Digits Other Based on the boolean, we either output the highest occurrence of one (or multiple) of these four gr...
stackexchange_codegolf
Given a string s, return the smallest contiguous substring you can remove to create a palindrome. Examples: 800233008 -> 2 racecarFOOL -> FOOL abcdedcba -> (empty string) ngryL Myrgn -> "L " (or " M") 123456789 -> 12345678 (or 23456789) aabcdbaa -> c (or d) [[]] -> [[ (or ]]) a -> (empty stri...
stackexchange_codegolf
Playing tetris is fun. Watching an AI play tetris is also fun. Some tetris AIs will always ignore the possibility of maneuvering a piece under an overhang, which makes me sad. It means that the programmer said to himself, "What are all the possible places the tile could be at the top of the board, and from each place,...
stackexchange_codegolf
You want to send an ASCII letter to someone, but you need an envelope to put it in. Your task is to output an envelope given a size as input. Rules: Given positive integer input i, your envelope will be i characters tall (not counting the top row), and i*2 characters wide (not counting the side columns). In other word...
stackexchange_codegolf
We shall soon have a new logo & site design, let us use this last breath of the simple times and golf this ASCII version of the speech bubble beta logo: +-------------------------------------------+ | .---------------------------------. | | .EPEpEpBPEpEGCXCgCgCGJgCgP&PWP&P&P&Y` | | .RSRsRWRSRsRsHoNoNONxNONON...
stackexchange_codegolf
The Challenge Given a list of words and a grid of letters, your job is to determine which of the given words can be found on the grid in all 8 directions (forward, backward, up, down, and the 4 diagonal directions), much like a word search. The grid is toroidal, so the grid wraps around on the edges. Letters can be reu...
stackexchange_codegolf
Given an \$n \times n\$ matrix of integers, The task is to find the optimal dividing line that maximizes the sum of the integers on the same side as the top left corner. The dividing line should be connected and made up of only vertical and horizontal lines. For an example with a non-optimal dividing line: [[ 3, 0,...
stackexchange_codegolf
The point of this challenge is to find the smallest positive integer that uses up at least all of the digits supplied in the input after it is squared and cubed. So, when provided an input such as 0123456789 (i.e. a number that finds the result): 69² = 4761 69³ = 328509 It means that 69 is the result of such an input....
stackexchange_codegolf
This is a cops-and-robbers challenge, the robbers' thread is here You can change the word code into golf by changing a letter at a time in four steps: CODE COLE COLD GOLD GOLF Today, we’ll be doing the same thing with programs. Your challenge is to: choose a programming language write two programs / functions, one th...
stackexchange_codegolf
It's one of these again :D Your task, if you wish to accept it, is to write a program/function (without any uppercase letters) that outputs/returns its string input/argument. The tricky part is that if I convert your source code to uppercase, the output must be reversed. For simplicity, you can assume that the input is...
stackexchange_codegolf
Write a program or function that takes in a positive integer and prints or returns an ASCII art depiction of an archery arrow, scaled according to the input. If the input is 1 the output is /\ / \ \__/ || || || || || || || || /||\ / || \ / || \ // \\ / \ If the input is 2 the output is /...
stackexchange_codegolf
Imagine you have two boxes B(x) and B(y), each containing an unknown bit - 0 or 1, and a machine F that can X-ray them and produce a third box for B(x^y) (xor). F can also compute B(x*y) (and). In fact, those are just special cases of the the single operation the machine can perform - inner product each, denoted with F...
stackexchange_codegolf
Premise: Your reputation is in Stack-Exchange Form if it can be represented by decomposing your medal counts (gold, silver, and bronze counted separately) into their base-10 digits and joining them in any given order, with a few caveats. While decomposing, each Gold medal digit is worth three digits. Silver is worth...
stackexchange_codegolf
A numeronym (also known as a "numerical contraction") is when a word is shortened using numbers. A common contraction method is to use the length of the replaced substring to replace all but the first and last characters. For example, use i18n instead of internationalization, or L10n instead of localization. (The L is ...
stackexchange_codegolf
Your task is simple: tell me who wins the battle of the letters. The troops There are three different "troops" in this battle, summarized by this table. name | health | damage A 25 25 B 100 5 C 10 50 You may use any three unique characters to represent the the troops, but m...
stackexchange_codegolf
Introduciton Some of you might have realised that I am a sloppy typer when using my phone. That's why I want you to write a program which corrects my typos. Chalkrnge Given a misspelled word, output all of the possible words which I meant to write. Typso The main cause of my typos is down to the fact that I hit the wro...
stackexchange_codegolf
The McGill Billboard Project annotates various audio features of songs from a random sample of the Billboard charts. I scraped this data to produce the following file of chord progressions: chords.txt Write the shortest code that outputs the above file (or its contents). Edit: Here's a quick description of the notation...
stackexchange_codegolf
For the context of this challenge, a matched group is a digit \$n\$, followed by \$n\$ more matched groups. In the case of \$n = 0\$, that's the whole matched group. Digits only go up to 9. For example, 3010200 is a valid matched group, as: 3 # 3, capturing three elements... 0 # a 0 (group 1) 1 # a 1 ...
stackexchange_codegolf
Related to, but not a duplicate of, this challenge. Basics This is a clock: ****** ** | ** ** | ** * | * * | * * | * * | * * | * * ...
stackexchange_codegolf
All variables in this question are integer valued. Input 4 integers w, x, y, z. They can be positive or negative and will be less than 1048576 in absolute value. Output The general solution to the equation. \$ aw+bx+cy+dz = 0 \$. The variables \$a, b, c, d\$ must all be integer values. Output format Your output should ...
stackexchange_codegolf
Well... there are 59 (now 60) questions tagged sorting, but no simple quicksorts. That must be fixed. For those unfamiliar with quicksort, here is a breakdown, courtesy of Wikipedia- Pick an element, called a pivot, from the array. Reorder the array so that all elements with values less than the pivot come before the...
stackexchange_codegolf
This challenge is about building a chessboard in which the square size, instead of being constant across the board, follows a certain non-decreasing sequence, as described below. The board is defined iteratively. A board of size \$n \times n\$ is enlarged to size \$(n+k)\times(n+k)\$ by extending it down and to the rig...
stackexchange_codegolf
In an attempt to “liberate” their fellow birds, a group of highly intelligent hens are attempting to compromise the zoo’s security system. To get access to the zoo’s mainframe, the hens first need to guess the administrative password. The hens know that the password is a string built from up to 62 possible characters: ...
stackexchange_codegolf
This challenge takes place on a grid. +----------+ | | | | | | | | | | | | | | | | | | +----------+ This one's 10 x 10, but it can be any rectangular shape. There are four directions on this grid. Up, down, left and right. The task is to ...
stackexchange_codegolf
Inspired by this challenge, which got closed. This is meant to be an easier, but no less interesting version of that. This is the robbers thread of a cops-and-robbers challenge. For the cops thread, see here. Cops will provide a program/function and a flag. Robbers will guess a password. When the password is given to t...
stackexchange_codegolf
Write a program that accesses Project Gutenberg's KJV Bible, either from a file called pg10.txt in the working directory or in any other way that is typical for the language, takes a Bible verse reference as input, and prints the corresponding verse, with no newlines except optionally one at the end, as output. The sta...
stackexchange_codegolf
Implement a function \$f\$ (as a function or complete program), such that \$ \displaystyle\lim_{n\rightarrow \infty} f(n) \$ converges to a number which is not a computable number. Answers will be scored in bytes with fewer bytes being better. IO formats Your answer may be in any of the following formats A program or ...
stackexchange_codegolf
Make a program that takes a length and list of intervals and outputs a ruler of that length with longer ticks for each interval using the line drawing characters ┌ ┬ ┐ │ ╵ The first row of the output should begin with the tick for 0 with ┌ and end with a tick for the length with ┐, with a ┬ being used for every charac...
stackexchange_codegolf
Introduction Arrays are usually used with for-loops or iterators. One different task might be the use as a cheap way to rotate through a set of items, so after reaching the last index, the next item would be the first item of the array. This is useful for cases like menus and physical controls. Challenge Given the size...
stackexchange_codegolf
Background In C, there is a function to help parse command-line arguments: getopt. Getopt takes the argument count (argc), the argument list (argv), and a string representing the options the program should take (optstring). The option string (optstring) is a series of option characters each followed by one colon (for a...
stackexchange_codegolf
Draw the Biohazard symbol in an arbitrary colour on a distinctly coloured background. The specific proportions were published in the June 27th 1974 issue of the Federal Register of the US Government. Details As output, writing to a file (raster and vector formats are permitted) or displaying on the screen are both all...
stackexchange_codegolf
In this challenge, submissions will be programs or function which, when given an emoticon such as :-), :(, or :D, will rate their happiness from 0 to 3. An emoticon will be one of the following: :(: 0 :|: 1 :): 2 :D: 3 Emoticons may also have noses (a - after the :). Test cases: :( -> 0 :-| -> 1 :D -> 3 :-) -> 2 :|...
stackexchange_codegolf
You will be given as input a non-empty list of positive integers. For example: [1,2,2,2,1] You want to produce a ragged list as output which has this as its "depth map". This list should have the same elements in the same order but each element n should be at the depth equal to its value. [1,[2,2,2],1] This is a li...
stackexchange_codegolf
Given a variable a (non array) or (any[]) convert to (any[]) function example(s: string | string[]) { const e = Array.isArray(s) ? s: [s] return e } Is Array.isArray(s) ? s: [s] the shortest way?
stackexchange_codegolf
;# 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 $ outputs the accumulator modulo 127. H...
stackexchange_codegolf
We've had a lot of alphabet challenges. For this challenge, you are passed the output of an alphabet challenge, and you need to output the pattern scaled to size N. For example, if N=5 and you were passed the L-phabet: ABCDEFGHIJKLMNOPQRSTUVWXYZ BBCDEFGHIJKLMNOPQRSTUVWXYZ CCCDEFGHIJKLMNOPQRSTUVWXYZ DDDDEFGHIJKLMNOPQR...
stackexchange_codegolf
Write code that outputs the smallest integer \$n > 5\$ such that \$\frac{\sqrt{\log_2{n}}}{(\log_2 {\log_2 n})^2} > 1\$. Your code may have at most one digit in its source code. You can use your chosen digit more than once however. By digits we are only counting the ASCII characters between 0x30 and 0x39 (inclusive).
stackexchange_codegolf
In CSS, colours can be specified by a "hex triplet" - a three byte (six digit) hexadecimal number where each byte represents the red, green, or blue components of the colour. For instance, #FF0000 is completely red, and is equivalent to rgb(255, 0, 0). Colours can also be represented by the shorthand notation which use...
stackexchange_codegolf
Introduction Let's define a ternary function as a function from the three-element set S = {0,1,2} to itself: it associates to each element of S another element of S. One example of a ternary function f is f(0) = 0; f(1) = 2; f(2) = 0 There are exactly 27 different ternary functions, and we represent them with integers...
stackexchange_codegolf
This challenge will be based on an R language trivia: every release is named and it's a reference to Peanuts comic strips (see here and here). Task Given a release name, output its number. For reference, use the below list: Great Pumpkin 2.14.0 December Snowflakes 2.14.1 Gift-Getting Season 2.14....
stackexchange_codegolf
The divisors of a natural number form a poset under the relation of "a divides b?", \$a | b\$. This challenge is to produce the number, \$C\$, of non-empty chains of such posets for natural numbers, \$N\$. This is A253249 in the Online Encyclopedia of Integer Sequences. That may sound complicated, but it's not really, ...
stackexchange_codegolf
Intro Reverse and add is as simple as it sounds, take n and add it to its digits in reverse order. (e.g. 234 + 432 = 666). If you apply this process repeatedly some numbers will eventually hit a prime number, and some will never reach a prime. Example I currently have 11431 rep. 11431 is not prime 11431 + 13411 = 2484...
stackexchange_codegolf
Background Two strings s and t are called k-Abelian equivalent (shortened to k-equivalent in the following) for a positive integer k if the following conditions hold: The length-k-1 prefixes of s and t are equal. The length-k-1 suffixes of s and t are equal. The strings s and t have the same multisets of length-k cont...
stackexchange_codegolf
Today, November 11, 2015, is Veterans Day in the United States. "Taps" is the bugle call played at U.S. military funerals: ("Taps" on SoundCloud from vtmiller) It is a simple melody, only twenty-four notes long and using only four different notes. Here is the sheet music: (source) Challenge Write a program or funct...
stackexchange_codegolf
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. As we all know, Santa comes down the chimney to deliver presents to good kids. But chimneys are normally full of smoke, and the Elves are worried about Santa's health. So they decide to blow the smoke out using an electronic air blower...
stackexchange_codegolf
Intro: You accidentally corrupted the flow of time with a device you made for fun, that turned out to be a time machine. As a result, you got pushed to the far future. You realized that computing, processing power, and computers in general have been evolved by a huge amount, an infinite amount to be precise. So you g...
stackexchange_codegolf
As most of you probably know, (byte-addressable) hardware memories can be divided into two categories - little-endian and big-endian. In little-endian memories the bytes are numbered starting with 0 at the little (least significant) end and in big-endian ones the other way round. Fun fact: These terms are based on Jon...
stackexchange_codegolf
Inspired by Hyperprogramming: N+N, N×N, N^N all in one. Thanks to @MartinEnder and @trichoplax for their help in the sandbox. Definitions Hyperquines Define a hyperquine of order n as a quine-like full program or function P that satisfies all rules that apply to proper quines and, in addition, has the following struct...
stackexchange_codegolf
For robbers' post, Cheapo Enigma machine (Robbers) A cop's submission will consist of a program/function that accepts a single byte of data and return a single byte of data. Every possible input must produce a unique output. (In the other words, your function must be bijective) Robbers will attempt to create the invers...
stackexchange_codegolf
This question is heavily based off this question, but should pose a number of additional difficulties. Your Task You must write a program or function that, when receiving a string, prints out all possible anagrams of it. For the purpose of this question, an anagram is a string that contains the same character as the o...
stackexchange_codegolf
For the purposes of this challenge, a polyphthong is defined as a contiguous slice of a String, that only contains vowels, and has length at least 2. Given a non-empty String as input, your task is to output all the polyphthongs it contains. For example, "abeoic" has the following contiguous slices (space-separated): a...
stackexchange_codegolf
The challenge today is to write a program that outputs a known proverb, Where there is a will, there is a way., that means if someone is determined to do something, he will find a way to accomplish it regardless of obstacles. Output It has to be exactly the same, including the space bar and punctuation and excluding th...
stackexchange_codegolf
A donut distribution (for lack of a better term) is a random distribution of points in a 2-dimensional plane, forming a donut-like shape. The distribution is defined by two parameters: the radius r and spread s, in which the distance to the origin follows a normal (Gaussian) distribution around r, with a standard devia...
stackexchange_codegolf
As you most probably now, there are 2339 solutions to pentomino puzzle in a 6x10 grid. There are different labeling schemes for the 12 pentominoes, two of them are shown on the image below: Image credit: Wikipedia For the purposes of the current task we will say that a normalized pentomino solution is a solution that ...
stackexchange_codegolf
Implement the Discrete Cosine Transform (DCT). This may implemented as either a function or a program and the sequence can be given as either an argument or using standard input. Your program must be able to handle sequences of any length (assuming a hypothetical version of your language which has no limits on things l...
stackexchange_codegolf
We all know about the Fibonacci sequence. We start with two 1s and keep getting the next element with the sum of previous two elements. n-bonacci sequence can be defined in similar way, we start with n 1s and take the sum of previous n elements to get the next element. Challenge Given a positive integer m > 1, output t...
stackexchange_codegolf
For a 2 dimensional array we will define the elements in either the first row or the last column to be the largest "J-Bracket" of the array. For example in the following array elements in the J-bracket are highlighted: \$ \begin{bmatrix} \color{red}{\underline 1} & \color{red}{\underline 2} & \color{red}{\underline 4}...
stackexchange_codegolf
The sci-fi shooter Destiny 2 contains guns which have the ability to regenerate ammunition directly into the magazine if, and only if x (precision) shots are landed (in a fixed amount of time), returning y bullets to the magazine. For example, the perk (ability) "Triple Tap" will return 1 bullet to the magazine if 3 pr...
stackexchange_codegolf
Convert a number to a sum of digits Not any sum: we need the shortest sum Not any digits: you can use only digits of the number Example You will be given as input an integer n>0 Let's say n=27. You have to express 27 as a sum, using only the digits [2,7], in the shortest way possible. You don't have to use all the digi...
stackexchange_codegolf
Left and right Riemann sums are approximations to definite integrals. Of course, in mathematics we need to be very accurate, so we aim to calculate them with a number of subdivisions that approaches infinity, but that's not needed for the purposes of this challenge. You should instead try to write the shortest program,...
stackexchange_codegolf
Two or more positive integers are said to be "friendly" if they have the same "abundancy". The abundancy of an positive integer \$n\$ is defined as $$\frac {\sigma(n)} n,$$ where \$\sigma(n)\$ is the sum of \$n\$'s divsors. For example, the abundancy of \$30\$ is \$\frac {12} 5\$ as $$\frac {\sigma(30)} {30} = \frac {1...
stackexchange_codegolf
Explanation ¡Hola! For those of you who don't take Spanish, a verb is conjugated based on the person who does the action. Here's a chart: English Spanish I Yo You Tú He Él She Ella You (formal) Uste...
stackexchange_codegolf
Introduction Right now I'm participating a chess tournament. I got inspired by the tournament schedule. Right now, I'm in a competition with three other players. That means with the four of us, we are playing 3 rounds. The schedule goes as following: Round 1: 1-4 3-2 Round 2: 3-4 2-1 Round 3: 1-3 4-2 This is also know...
stackexchange_codegolf