instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Palindromes are fun, but some of the other strings are starting to feel left out. We can turn those strings into chunky palindromes by splitting them up into palindromic arrays of chunks. For example, the string "abcabca" isn't a palindrome if we read it character by character, but we have three different ways of makin...
stackexchange_codegolf
In this challenge, you'll print out the SBCS of Jelly, a popular golfing language. Its code page looks like this: _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F 0_ ¡ ¢ £ ¤ ¥ ¦ © ¬ ® µ ½ ¿ € Æ Ç Ð 1_ Ñ × Ø Œ Þ ß æ ç ð ı ȷ ñ ÷ ø œ þ 2_   ! " # $ % & ' ( ) * + , - . / 3_ 0 1 2 3 4 5 6 7 8 9 : ; < = > ? 4...
stackexchange_codegolf
Let's assume that $$ f(x) = \frac{Ax+B}{Cx+D} $$ Where, \$x\$ is a variable and \$A\$,\$B\$,\$C\$,\$D\$ are constants. Now we have to find out the inverse function of \$f(x)\$, mathematically \$f^{-1}(x)\$, To do this first we assume, $$ y = f(x) \\\rightarrow y=\frac{Ax+B}{Cx+D} \\\rightarrow Cxy+Dy=Ax+B \\\rightarrow...
stackexchange_codegolf
Let me know if this task has already been posed. I haven't found it when I looked. Input master sequence \$\ X = x_1\dots x_n\$: sequence of characters, eg. \$\rm international\$ subsequence \$\ Y = y_1\dots y_m\$: sequence of characters, eg. \$\rm intl\$ Output Number of possible mappings \$\mu: [1\dots m] \righta...
stackexchange_codegolf
Challenge A simple challenge: given two or more strings, output all of the substrings that are in each string. Rules Input is always a comma separated list of strings Strings should be outputted from longest to shortest length without duplicates Strings should preserve whitespace Examples Input: aaa,aa Output: aa a ...
stackexchange_codegolf
Introduction A polyglot is a program that is valid in multiple languages at once. An iterative quine is a program that outputs another program that outputs another program that outputs the source of the original program. Note that the number of chained programs does not have to be 3; it could be 2, 4, or 97384. Challen...
stackexchange_codegolf
When you leave, my challenges fade to grey, 0A0AE16, 0A0A0AE16... A while ago, I made this programming language (https://esolangs.org/wiki/Dragostea_din_tei) which uses an interesting number system. It is base two for integers, but for decimals it divides a base two integer by a power of ten. The input should be a floa...
stackexchange_codegolf
What is Crazyhouse Chess? Crazyhouse Chess is a chess variant that is basically normal chess except you can place a piece you previously captured back on the board instead of a regular turn. Bot interface Only JavaScript bots are allowed. A bot is a JavaScript function that takes 3 arguments (board, side, bank) and ret...
stackexchange_codegolf
Background Consider an \$n\times n\$ grid, where each cell is either empty (denoted by .) or a wall (denoted by #). We say that two cells are adjacent if they share an edge (a corner is not enough). A path is a sequence of distinct empty cells \$s_0,s_1,\ldots,s_k\$ such that cells \$s_i\$ and \$s_{i+1}\$ are adjacent ...
stackexchange_codegolf
Do you know Icy Tower ? Here is a gameplay example of what i'm talking about The game concept is simple : you play as Harold the Homeboy, and your goal is to jump from floors to floors to go as high as possible without falling and getting off-screen ( the camera goes higher following you or at a speed that gets faster ...
stackexchange_codegolf
Given a non-empty list of digits 0 though 9, output the smallest number that can be produced by an expression formed by reordering these digits and introducing exponentiation signs ^, with adjacent digits getting concatenated as multi-digit numbers. Exponentiation is evaluated as right-associative. For example, [4, 2, ...
stackexchange_codegolf
For the purposes of this challenge a substring \$B\$ of some string \$A\$ is string such that it can be obtained by removing some number of characters (possibly zero) from the front and back of \$A\$. For example \$face\$ is a substring of \$defaced\$ \$ de\color{red}{face}d \$ This is also called a contiguous substri...
stackexchange_codegolf
It seems we've managed to go all this time without a plain vanilla Number-To-Binary challenge! Whilst this will inevitably be only one element in many languages, it should put a few esolangs through their paces. I truly looked for this challenge to no avail. If it already exists, comment as such and I'll delete this po...
stackexchange_codegolf
A binary multiple of a positive integer k is a positive integer n such that n is written only with 0s and 1s in base 10 and n is a multiple of k. For example, 111111 is a binary multiple of 3. It is easy to show that a positive integer has infinitely many binary multiples. See here for a construction proof of one binar...
stackexchange_codegolf
Curry is the Language of the Month this month and some users are starting to get into it, so let's get some tips together. Haskell and Curry are similar in a lot of ways and a lot of tips for Haskell work well in Curry and vice versa. So I'd like in this question to gather tips for code-golf in Curry, that would be use...
stackexchange_codegolf
This challenge, while probably trivial in most "standard" languages, is addressed to those languages which are so esoteric, low-level, and/or difficult to use that are very rarely seen on this site. It should provide an interesting problem to solve, so this is your occasion to try that weird language you've read about!...
stackexchange_codegolf
Print all the numbers from 0-100 in the right order using the Danish way of counting How they count Like English, they have dedicated words for 0-20, 30, 40 and 100 Instead of saying twenty-one and twenty-two, they say one and twenty and two and twenty Starting with fifty they say multiples of 10 as n*20 50 = half thi...
stackexchange_codegolf
A drug comes in 5mg, 2.5mg, and 1mg sized pills. The drug is taken once a day. The total daily dose will be only one of the following (all in mg): 1, 2, 3, ... 20, 22.5, 25, 27.5, 30, 32.5, 35, 37.5, 40, 42.5, 45, 47.5, 50 In words: any whole number less or equal to 20, then at 2.5mg increments up to 50. Your task is t...
stackexchange_codegolf
The Corpus are a fictional faction from the popular video game Warframe who have a somewhat interesting language. Whilst other factions in the game such as the Grineer have some logic behind their language, the Corpus is simply a lossy substitution of the English language. All Corpus words are the same as their English...
stackexchange_codegolf
The Riemann series theorem states that the terms of a conditionally convergent series can be permutated such that the resulting series converges to an arbitrary value. The Challenge Write a program or function that takes in three parameters via stdin (or equivalent) or as parameters: The expression for the sequence x_...
stackexchange_codegolf
Consider this file path: C:/Users/Martin/Desktop/BackupFiles/PC1/images/cars/new.png Your goal is to write a program that will return the file path starting from the folder after the last folder that contains a number till the filename. So, for the above file path, the program should return images/cars/new.png. One or...
stackexchange_codegolf
Challenge Let's have a list L of n elements. The task is to swap every two elements in this list. Constrains the list L has at least two elements size of the list L is a multiple of two (i.e. number of elements is even) Example input: [1,2,3,4,5,6] output: [2,1,4,3,6,5] input: [0,1,0,1] output: [1,0,1,0] Rules ...
stackexchange_codegolf
Gimbap(김밥) is Korean food, somewhat looks like sushi roll. Here is Korean emoticon represent Gimbap : @)))))))))) Your quest is make ASCII Gimbap cutter. Rule Input is string made with only @ and ). Output cuts every valid Gimbap with ), and then add @ between them. So for example @)) to @) @). Valid Gimbap starts wi...
stackexchange_codegolf
Program your robots to deliver packages in a warehouse infested with destroyer drones. Avoid the drones and get your packages to the right place as fast as you can. Delivery Robots There are packages labeled a-z in a warehouse. Packages must be delivered to a matching chute A-Z. A robot cannot move to a square that co...
stackexchange_codegolf
Definitions Two numbers are co-prime if their only positive common divisor is 1. A list of numbers is mutually co-prime if every pair of numbers within that list are co-prime with each other. A factorization of number n is a list of numbers whose product is n. Task Given a positive number n, output the mutually co-pr...
stackexchange_codegolf
Write functions \$x(a)\$, \$y(a)\$ and \$z(a)\$ such that for any rational \$a\$ all functions return rational numbers and $$x(a) \times y(a) \times z(a) \times (x(a) + y(a) + z(a)) = a$$ You may assume \$a \ge 0\$ You do not need to use rational types or operations in your program, as long as your program is mathemati...
stackexchange_codegolf
Make a Number Expression is related : actually, it is also about Aheui. But it just made number expression, but this made real Aheui code. Aheui is esolang written in only Korean character. Because of its nature, Aheui can't use Arabic numbers. But, of course, there is way to generate number. Brief introduction to Ahe...
stackexchange_codegolf
You are given a polynomial function, in the following format: \$x = (c_0 * y^0) + (c_1 * y^1) + (c_2 * y^2) + ... + (c_n * y^n)\$ where \$c_n\$ stands for the coefficient of the \$n^{th}\$ power of \$y\$ You have to plot the equation on a \$10 * 10\$ ASCII matrix. The value must be floored to an integer before plotting...
stackexchange_codegolf
See Hole #1 if you are confused. What does every kid do after he/she collects buckets of candy over Halloween? Sort it by type and size, of course1! The Challenge Given a dumped-out bag of candy of varying shapes and sizes, sort the candy from left to right based on: First: The amount of candy (so 5 of one will be mor...
stackexchange_codegolf
A barcode of EAN-13 symbology consists of 13 digits (0-9). The last digit of this barcode is its check digit. It is calculated by the following means (the barcode 8923642469559 is used as an example): Starting from the second digit, sum up all alternating digits and multiply the sum by 3: 8 9 2 3 6 4 2 4 6 9 5 5 9 |...
stackexchange_codegolf
You know those stackable shelves that are basically just wooden boxes that can be stacked together? We're going to simulate building some bookshelves out of those with some ASCII art. Our books are all conveniently uniform in size, and all look like the following: |X| |X| |X| The bookshelves are individual boxes, alwa...
stackexchange_codegolf
The task is the following: Program the shortest fully functional program that checks, if an 8-bit value contains a consecutive sequence of 2 or more ones in its binary form. If it does contain such a sequence, the output shall be 0. If not: 1. Examples: Input: 1 Output: 1 Input: 3 Output: 0 Input: 72 Output: 1 Input: 7...
stackexchange_codegolf
Subleq is a Turing-complete esolang with only one instruction, SUBLEQ. This instruction takes in three parameters, A, B, and C, all of which are memory addresses. The instruction subtracts the value in memory address A from that in memory address B, storing it in address B. If the value at B is now less than or equal t...
stackexchange_codegolf
You have been given the charge to calculate the current balance as of the day that you perform the calculation for 330,000 individuals who worked for an average of 30 years spanning 300 years where the initial principal was 1 with an addition of 1 per day and interest rate set at 3%. You initially tried to use online ...
stackexchange_codegolf
Challenge Your task is to encode an integer as a string of ASCII characters, then successfully decode it after said string has been randomly shuffled. You will write two programs/functions, which will be referred to as Encoder and Decoder. Encoder Input: an integer \$n\$ in the range \$[0,2^{31}-1]\$. Output: a string...
stackexchange_codegolf
The Cashier's Algorithm is an algorithm for making change in the minimal number of coins that works quite well for most currency systems. However like most greedy algorithms it is not without its flaws. If a currency system is set up just right (or just wrong) there are certain values in which the Cashier's Algorithm...
stackexchange_codegolf
Given two positive integers, 'a' and 'b', output an ascii-art "box" that is a characters wide and b characters tall. For example, with '4' and '6': **** * * * * * * * * **** Simple right? Here's the twist: The border of the box must be the characters of "a" and "b" alternating. This starts at the top left corner, ...
stackexchange_codegolf
The text of the children's book Polar Bear, Polar Bear, What Do You Hear? has a very simple pattern. You might use the text to teach introductory programming concepts. My son was quickly bored by this idea, so I decided to play some golf with it instead. The Challenge In your programming language of choice, write the...
stackexchange_codegolf
Your task Given a numerical string or integer \$\ge 0\$ (which may have leading zeros), convert it to letters using the below rules. Rules Loop through the digits: If the digit is 0 or 1, combine it with the next digit and output that letter of the alphabet (0-indexed). If the digit is 2, combine with the next digit O...
stackexchange_codegolf
A001057 is one way to represent an integer as a natural number. It lists them according to the following pattern: 0, 1, -1, 2, -2, 3, -3, 4, -4, ... In this challenge, you'll take two distinct integers as input and return which is at a higher index in this enumeration. Take -2 and 1 as an example: -2 comes after 1, so...
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
For each node in a balanced binary tree, the maximum difference in the heights of the left child subtree and the right child subtree are at most 1. The height of a binary tree is the distance from the root node to the node child that is farthest from the root. Below is an example: 2 <-- root: Height 1 ...
stackexchange_codegolf
Commentscript is a variant on Javascript that I made up for the purpose of this question. Only commented-out code is evaluated. Javascript has two types of comments: // this is a single line comment, which starts with `//` and ends on a newline. /* This is a multiline comment. It starts with /* and ends with */ Examp...
stackexchange_codegolf
As the title says, I was thinking to contest in which one must detect edges of an ASCII art. The code should accept a B/W ASCII art as input. A B/W ASCII art is defined as (by me) an ASCII art with only one kind of non-white-spaces character (in our case: an asteriks *). And as output produce a standard ASCII art (all...
stackexchange_codegolf
Preamble A common pain-point when working with rational numbers and decimals is how infrequently one can represent their rational number as a clean, non-repeating decimal. Let's solve this by writing a program to decimalize (not to be confused with decimate) them for us! The Challenge Given a fraction, check if it can ...
stackexchange_codegolf
Given an integer N >= 2, produce an image showing a Sierpiński knot of degree N. For example, here are knots of degree 2, 3, 4 and 5: Click on the images to view full size (the higher the degree the larger the image). Specification A Sierpiński knot of degree N is drawn using the vertices of a Sierpiński triangle ...
stackexchange_codegolf
Your task is to write a program that outputs its own source code in reverse. However, when the reversed code is run, it should output the source code, facing the correct direction. Example Say your program is abc. When run, it should output cba. cba, when run, should output abc. Rules Your program should follow all the...
stackexchange_codegolf
I honestly don't know what the point of this sort of calculation would be, but it should make fun golfing. Shortest code wins. Input (in no particular order) An array of integers, a (All elements will be integers less than the length of the array.) An index therein, i An iteration count, n Processing Store a number ...
stackexchange_codegolf
Imagine a countable infinite amount of empty rooms. When an infinite amount of guests come, they occupy the 1st, 3rd, 5th...(all odd) empty rooms. Therefore there's always an infinite amount of empty rooms, and occupied guests needn't move when new guests come. - - - - - - - - - - - - - - - - - 1 - 1 - 1 - 1 - 1 - 1 - ...
stackexchange_codegolf
It is very hard to remember my password, so I came up with a way to generate a password. The way I generate my password is from a word or a sentence, following these steps: Start from left to right Find the count of each letter Put letter with its count in an order Letters with higher repetition will be in the end ...
stackexchange_codegolf
Definition Given some number, x calculate the smallest number i such that 2i≥x. This is not a duplicate of this question. It is slightly different in that an input of 16 should yield an output of 4 whereas 16 returns 5 in the linked question. Input Input will be an unsigned 32-bit integer. Output Output will be an unsi...
stackexchange_codegolf
Inspiration Conway's Game of Life is a well known cellular automaton "played" on an infinite grid, filled with cells that are either alive or dead. Once given an initial state, the board evolves according to rules indefinitely. Those rules are: Any live cell with 2 or 3 living neighbours (the 8 cells immediately aroun...
stackexchange_codegolf
The objective Given the non-negative integer \$n\$, output the value of the hyperfactorial \$H(n)\$. You don't have to worry about outputs exceeding your language's integer limit. Background The hyperfactorial is a variant of the factorial function. is defined as $$ H(n) = 1^{1} \cdot 2^{2} \cdot 3^{3} \cdot \: \cdots ...
stackexchange_codegolf
Challenge We all know about normal Christmas trees - but how about an upside-down Christmas tree! This is a fairly easy, Christmas themed challenge. The objective of this challenge is to make me an ASCII upside-down Christmas tree. Here are the rules for this challenge: Accept an odd, positive integer. You can assume ...
stackexchange_codegolf
Background A Hamiltonian path is a path on a graph that steps through its vertices exactly once. On a grid, this means stepping through every cell exactly once. On a square grid, a Chess King can move to a horizontally, vertically, or diagonally adjacent cell in one step. Challenge Count the number of Hamiltonian paths...
stackexchange_codegolf
For Gregorian calendars, the date format varies from a country to another. There are three main formats recognized: YY-MM-DD (big-endian) DD-MM-YY (little-endian) MM-DD-YY (middle-endian) Your task is to write a program which, given an input string representing a date, output all the possible date formats by which th...
stackexchange_codegolf
Magic: the Gathering is a trading card game where, among other things, players play cards representing creatures, which can then attack the other player, or defend against the other player's attacks by blocking. In this code-golf challenge, your program will be in the place of a Magic player deciding how to block in co...
stackexchange_codegolf
We have 40 sticks of same widths but different heights. How many arrangements are there possible to put them next to each other so that when we look from right we see 10 sticks and when we look from left we again see exactly 10 sticks? For example such an ordering is: Black sticks are hidden, red sticks are the ones y...
stackexchange_codegolf
Your task is to display the below letter "E" shaped ASCII art, given five inputs. Examples: Input: 7,2,+,|,- (Note: You don't have to follow this exact input format, and if you don't use it, then you must explain how your own input format works) Explanation: 7 total width, including the left and right edge characters....
stackexchange_codegolf
The problem #6 of IMO 2009 reads: Let a 1, a 2, a 3, ..., a n, be distinct positive integers and let T be a set of n-1positive integers not containing a 1+a 2+a 3+...+a n, A grasshopper is to jump along the real axis, starting at the point 0 and making n jumps to the right with lengths a 1, a 2, a 3, ..., a n in so...
stackexchange_codegolf
Intro Imagine a list of elements and their outcomes when some non-commutative function is applied to them. For example, we will use the elements Rock, Paper, and Scissors, the outcomes Win, Lose, and Tie, and an operator * such that X*Y = what would happen if you played X against Y As a list, you might write it this wa...
stackexchange_codegolf
Your task will be to write a Haskell function that takes a list of integers and returns a sorted version of the same list. You are to do this without the use of builtins What are builtins? To keep ourselves from having to navigate edge case hell we are going to limit answers to Haskell (sorry if Haskell is not your fa...
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
There is a job which can be decomposed into x equally-sized smaller tasks. You have a team of size y <= x, where every member works equally fast on any task. The goal for this challenge is to divide the work as evenly as possible such that every member of your team has at least 1 task to perform. As evenly as possible ...
stackexchange_codegolf
Simply put, your goal is to create a complete program that modifies its own source code until every character of the source is different than what it started as. Please include the beginning source as well as the ending source in your post, as well as a description. E.g. Describe what (else) your program does, the lang...
stackexchange_codegolf
Too bad! I had such a beautiful equation, but I lost all my =+-*, so there is nothing left but a chain of digits, looking like a number: 7512. But was it 7+5=12 or 7-5=1*2 or 7=5*1+2 or 7=5+1*2? Or are there even more valid possibilities? Your task: For a given positive integer number, return the number of true equatio...
stackexchange_codegolf
Challenge closed, the shortest answer has been acccepted. A military projection is a projection where all lengths and the angles in the X-Z plane remain unattuned. Your task is to print a cube in military projection using /, |, \, -, and any whitespaces you want, given any integer greater than zero as it's side length....
stackexchange_codegolf
United States senators are sorted into three classes, based on what year their six-year term starts. Since each state has two senators, each state has a senator in two of the three classes. Given a full state name and a class number (1, 2, or 3), output truthy if that state has a senator of that class, and falsey if th...
stackexchange_codegolf
You work in a kitchen which has a peculiar rule. When you mix something into a pot you must always add at least one new ingredient. So you can add pasta, oil, salt then pesto, but not pasta, pesto, salt and oil since pesto already contains salt and oil. You only have one pot per dish, so you can't mix ingredients in on...
stackexchange_codegolf
You are on a plane filled with boxes, and you get a sequence of movements, say "up right right down left": You move up, pushing all boxes in front of you away: You move right, right and down, getting and finally left. This time you only push one box rather than infinite boxes: At the end, there are 4 spaces. Given ...
stackexchange_codegolf
This is the robbers' challenge. The cops' one is here. In Fewest (distinct) characters for Turing Completeness, the goal is to find the minimum number of characters which make a language Turing Complete...in other words, allow it to do any computation possible with any other language. In this challenge, we'll be doing ...
stackexchange_codegolf
Write a program or function that takes in a quadratic equation and prints its factorized roots. The input can be taken in from any reasonable source, such as a function parameter, stdin, or a command line argument. Edit: This is not intended to be a duplicate of other quadratic equation questions. While others simply p...
stackexchange_codegolf
"All roads lead to Rome" is a saying that essentially means there are plenty of different ways of achieving an objective. Task Your task is to write a program that finds a set of link connections from one Wikipedia page to the Wikipedia page about Rome. Notice that it is not enough to find the word Rome with a hyperlin...
stackexchange_codegolf
Introduction On 30 May 2020, NASA and SpaceX launched a crewed rocket to the international space station on the SpaceX Demo 2 mission. This is the first time humans have been launched into orbit from American soil since the retiring of the Space Shuttle in 2011, and the first time ever that a private company has launch...
stackexchange_codegolf
The famous game of Qwirkle has simple but intricate rules (See part 2 of this question for a summary of the rules!) The Challenge You are somehow (text input, function parameter, whatever) given a board of a Qwirkle game, like a snapshot from any current timeframe within a game. This board can be anything from complet...
stackexchange_codegolf
Inspired by this default for IO. The Task Write a program that, given an input integer x between 0 and 255, crashes with exit code x. Restrictions You may not call anything which is intended directly for exit code output (System.exit(x), returning from main, etc.). Instead, your program must cause an error or crash wh...
stackexchange_codegolf
In this challenge, you implement an interpreter for a simple stack-based programming language. Your language must provide the following instructions: push a positive number pop two numbers and push their sum pop two numbers and push their difference (second number - first number) pop a number and push it twice (dup) p...
stackexchange_codegolf
Peano numbers represent nonnegative integers as zero or successors of other Peano numbers. For example, 1 would be represented as Succ(Zero) and 3 would be Succ(Succ(Succ(Zero))). Task Implement the following operations on Peano numbers, at compile time: Addition Subtraction - You will never be required to subtract a ...
stackexchange_codegolf
Your task is to write a non-empty computer program comprised of some sequence of bytes. If we choose a particular byte in the program and remove all instances of it from the program, the modified program should output the removed byte. For example if our program were aabacba Then bcb would output a, aaaca would need ...
stackexchange_codegolf
plorcly borglar is a "mod" created by jan Misali for the constructed language toki pona that makes words sound funny. It involves substituting the 14 toki pona letters for funnier versions plus 2 extra rules. The substitutions are: toki pona letter plorcly borglar letter m bl n gl p b t pl k cl s scr...
stackexchange_codegolf
Introduction This challenge was originally the "Among Us" challenge in the "Misc" category of YASCON CTF 2020. (The link includes an answer to that challenge. Click at your own risk.) You're given a lot of files, 1 of which is different from every other files. Your job is to find that 1 different file. Challenge Input...
stackexchange_codegolf
Inspired by both the challenge "Unique is Cheap" by @Laikoni, where the score is based on the challenge itself, as well as the JavaScript (ES6) answer of @ETHproductions for the "Palindrome Compression" challenge, where he uses a pretty cool compression method for the palindrome-flag, upper/lower case indication, and l...
stackexchange_codegolf
Exposition Your mathematics teacher is a big fan of Vieta's formulas, and he believes that you should use them to solve quadratic equations. Given the equation ax^2 + bx + c = 0 the product of its roots is c/a, and their sum is -b/a. When all of a, b and c are nonzero integers, assuming the roots are rational numbers,...
stackexchange_codegolf
We all know what a quine is. An inverted quine is a non-empty program that prints the inverse of its source code without reading its source code, and consists solely of printable-ASCII characters (space through ~). Here, “inverse of the source code” means the following: the output of your program must contain each pri...
stackexchange_codegolf
Your task is to compile regexes... by specifying a substitution for each character in a regex. Regexes The regexes support these REGEX = (LITERAL REGEX / GROUP REGEX / STAR REGEX / ALTERNATIVE) LITERAL = 1 / 0 GROUP = '(' REGEX ')' STAR = (LITERAL / GROUP) '*' ALTERNATIVE = '('REGEX ('|' REGEX)*'...
stackexchange_codegolf
I like making dank memes out of my own images. But all those so called "quick meme" sites just have too much code. I realized that the only way to make the dankest meme generator is to ask you guys at PPCG to golf one for me. So let me give you the low down on what you have to do. Specs Take an image as input as a fil...
stackexchange_codegolf
Let's build a simulation for an aspect in the card game, which I personally know by the Dutch name 'Oorlog' (translates to 'War'). How does 'Oorlog' work? Two decks of cards (each including two Jokers) are equally divided between the amount of players playing. Each player shuffles their own stock, put it upside down in...
stackexchange_codegolf
I'm currently working with a branchless language which does not have native Less-Than, Greater-Than or Equal-To functions. I do however have min, max and abs functions and standard arithmetic (+, -, / and *) available to me. I'd like to create these three functions (as L(a, b), G(a, b) and E(a, b) respectively, which w...
stackexchange_codegolf
Today while playing with my kids I noticed that an apparently simple toy in the park hid a challenge. The wheel has a triangle that points to a number, but also has three circles that point to the numbers every 90 degrees from the first one. So: Challenge (really simple) Given an integer between 1 and 12 (the one poi...
stackexchange_codegolf
Task You should write a program that when a button is pressed, it outputs a different sound for each key. The keys that you will use are: 1!2"34$5%6^78*9(0qQwWeErtTyYuiIoOpPasSdDfgGhHjJklLzZxcCvVbBnm The notes begin at C and each key above adds one semitone. Lets make it slightly easier for you though. You can choose ...
stackexchange_codegolf
This is the cops thread of this cops and robbers challenge. The robbers thread is here. Related, but hashes numbers instead of strings and uses a different scoring system. Definitions A hash collision is when two different strings produce the same hash. Summary In this challenge, the cops will make a hash function, wit...
stackexchange_codegolf
The following problem is taken from the real world — but indubitably code-golf! In this puzzle, the programming language is fixed, and your job is to write the most efficient program in this fixed language. The language has no loops; a program is a straight-line sequence of instructions. Each instruction consists of ex...
stackexchange_codegolf
A tower is made out of layers, each one being one unit shorter than the one below it. Every layer is completely on top of the previous layer. For example, here is a tower along with it's height map: # ## ### #### ##### 14532 Because the lengths of the layers are the integers from 1 to n, and because the layers ar...
stackexchange_codegolf
There are a few questions on this site about balancing brackets, and checking whether brackets are balanced. I propose it's now time to use those balanced brackets for something! In mathematics and programming, brackets are like bubbles, isolating everything inside form everything outside so that whatever's inside can ...
stackexchange_codegolf
I'm posting my code for a LeetCode problem copied here. If you have time and would like to golf for a short solution, please do so. Requirement It has to only pass the LeetCode's Online Judge, if the language would be available. If the language is not available, simply we should possibly keep the class Solution as we...
stackexchange_codegolf
The way points are assigned on a dice follows a regular pattern, the center dot is present if and only if the number is odd. To represent the even numbers, pairs of dots on opposite sides of the center are added, which will stay present for all successive numbers. 1: O 2: 3: 4: 5: 6: O O O O O O ...
stackexchange_codegolf
So, I have an array ['a', 42, 'b', 42, 'a'] I want to alert users to the fact that 42 and 'a' appear in it twice. some_function(['a', 42, 'b', 42, 'a']) should return ['a', 42] Write some code to extract the duplicates from an array. It should accept an array as input. The array can have multiple types of object. ...
stackexchange_codegolf
Draw an "apartment" building according to the specifications below. Basic Rules Take, as input, the number of floors of the building. Return a building with that many floors meeting the following specifications: The building will be eight characters wide, with eight underscore characters (_) on top and eight dashes (-)...
stackexchange_codegolf
Let's have a list of positive integers [6,1,9,3,7,4,6,3,2,7,6,6] this will represent a river. We would like to skip a stone across this river. We can throw the stone as far as we want and whatever number it lands on it will skip that many places. So if we start by throwing it 2 spaces, it will land on the 1 skip fo...
stackexchange_codegolf
Your program will control a mining robot searching underground for valuable minerals. Your robot will tell the controller where you want to move and dig, and the controller will provide feedback on your robot status. Initially your robot will be given an image map of the mine with some mining shafts already present, an...
stackexchange_codegolf