instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
This wasn't originally intended for code-golf, just as a little debugging routine to roughly visualize something "goofy" going on in a model of some (irrelevant here) physical process. But when I saw how surprisingly short it was, compared to my expectations, I just wondered if it can be further shortened. And that's p...
stackexchange_codegolf
One of the lesser known programming paradigms which seems rather fitting for code golfing is Overlapping Oriented Programming (OOP) *. When writing partly identical code, many bytes can be saved by simply overlapping the identical parts and remembering in some way where the two original code lines start. Your task is t...
stackexchange_codegolf
In the following markup without changing it or using JS, implement the behavior to show only the ul element of div which name is clicked in the first ul (before div). Name is content of li in top ul and it matches the content of the first li in ul you want to show. Elements that have {content} are just fillers and have...
stackexchange_codegolf
The challenge Create a function which takes an array of numbers and subtract from each element the lowest element in the array that has not yet been subtracted from another. After using the lowest value, It can not be used again. Numbers in the array are decimal numbers, and not necessarily integers. Example: Input: ...
stackexchange_codegolf
Given three integers rgb, output hexadecimal representation as a string. Input: Output: 72 61 139 #483D8B 75 0 130 #4B0082 0 255 127 #00FF7F Shortest most unorthodox code wins
stackexchange_codegolf
There is a building with an infinite number of floors and you are the only passenger in an elevator which can lift an infinite number of people. You are going home, but before the elevator gets to your floor, the elevator stops at another floor to allow people to enter the elevator and input their destination floors. Y...
stackexchange_codegolf
You are working as a programmer for a bank. Your task is to write a program that handles the transactions from one bank account to another. The program should do the following: Run in an infinite loop waiting for input. The input consists of 3 numbers: Accountnumber1, Accountnumber2 and x the amount of money. e.g. 99...
stackexchange_codegolf
Background This is a follow up question to the question: Will the Hydra finally die? As before a dangerous A Medusa have released a dangerous Hydra which is revived unless the exact number of heads it have is removed. The knights can remove a certain number of heads with each type of attack, and each attack causes a sp...
stackexchange_codegolf
The new site header has some bits of source code from various questions as the background. Here are the first 3 lines: --<-<<+[+[<+>--->->->-<<<]>]<<--.<++++++.<<-..<<.<+.>>.>>.<<<.+++.>>.>>-.<<<+. Hello, World! IT'S SHOWTIME TALK TO THE HAND "Hello, World!" YOU HAVE BEEN TERMINATED "9!dlroW ,olleH"ck,@ 72a101a+7aa+3a4...
stackexchange_codegolf
Input variables: (Names are just examples, they don't need to be named like this) GrandTotal - integer to divide SplitCount - number of output integers required UpperLimit - highest valid value for any one output integer LowerLimit - lowest valid value for any one output integer Valid Output: Outout must be a random ...
stackexchange_codegolf
Background Combinatory logic is a system where a term is written using a finite set of combinators and function application between terms, and reduction rules are defined for each combinator. The well-known S and K combinators have the following reduction rules: $$ \begin{aligned} S\;x\;y\;z & \overset{S}{\implies} x\;...
stackexchange_codegolf
Your Task Given a list of words, check if they form a valid word grid. They form a valid grid if there are N words with N letters and they spell the same words vertically as they do horizontally. The words can be given in any order. [FILE, ICED, LEAD, EDDY] = True and [FILE, LEAD, EDDY, ICED] = True. Print True if it i...
stackexchange_codegolf
Powers We define an important power as a number that can be represented as \$ x^y \$ where \$ x ≥ 2 \$ and \$ y ≥ 2 \$. Palindrome We define an important palindrome as a number that is the same written forwards and backward, and is greater than 10. Thus, the last digit must not be 0. Palindromic Power We define a Palin...
stackexchange_codegolf
Introduction I have some JavaScript code that uses Array.prototype.map to map an array of functions fns to their return values: const fns = [() => 1, () => 2]; const result = fns.map( fn => fn() ); console.log(result); // => [1, 2] Challenge The argument to map above is fn => fn(). The challenge is to rewrite th...
stackexchange_codegolf
The Challenge Given a valid regex, output a regex that that matches the same set of strings, but reversed. The Task This challenge uses the most basic regex operations: ^, $, ?, +, *, [], {}, |. There's no such thing as capture groups or any of that complicated stuff. Special characters can be escaped. Sample Input/O...
stackexchange_codegolf
This is a cops-and-robbers challenge, the cops' 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 crack an answer on the cops' thread. Cops will create a series of program...
stackexchange_codegolf
As code-golfers, we're not used to releasing (surely). We're gonna need a few tools to help us do that. Of course, to help marketing a new release, we need a nice and shiny Release Version. Who doesn't get excited when they hear about version 3.0.0? Task Your task will be to write a program/routine/... to increment a v...
stackexchange_codegolf
I've been a fan of My Little Pony: Friendship Is Magic for a long time, and very early on I created a pony version of myself also called Parcly Taxel (warning: may be too cute to look at). The symbol below is her "cutie mark", which you will be drawing here: Construction All key points of the cutie mark lie on a rotat...
stackexchange_codegolf
You have given an array from which we need to remove duplicates. Rules: First or immediate duplicates gets removed first. Array contains natural numbers a[i]>0 for i>=0 no. of elements in the array is greater than 1 i.e. n>1 e.g. {1,2,3,4,5,5,4,6,6,7,8}=> {1,2,3,7,8} {1,2,3,3,4,5,6,7,7,8} => {1,2,4,5,6,8} {1,1,3,3,...
stackexchange_codegolf
Some chess variants use interesting non-standard pieces. In order to concisely describe new pieces or to describe pieces without requiring everyone to memorize a bunch of non-standard names some new notation can be invented. In this challenge we are going to look at Parlett's movement notation and convert it to nice at...
stackexchange_codegolf
Given a positive integer n, simplify the square root √n into the form a√b by extracting all square factors. The outputted a,b should be positive integers with n = a^2 * b with b as small as possible. You may output a and b in either order in any reasonable format. You may not omit outputs of 1 as implicit. The outputs...
stackexchange_codegolf
You have probably seen these signs on the doors of various shops: OPENING HOURS mon-fri 0900-1800 sat-sun 1100-1530 The task here is to generate a sign like that, grouping consecutive days with the same opening hours, from a list of opening hours for the whole week. Note that the week "wraps around" for what is con...
stackexchange_codegolf
Inspired by Cheap, Fast, Good, we're going to implement an algorithm which has exactly two of them. The Math Given two nonzero integers a and b, the GCF d is the largest integer that divides both a and b without remainder. Bézout coefficients are pairs of integers (x, y) such that ax + by = d. Bézout coefficients are n...
stackexchange_codegolf
What general tips do you have for golfing in Go? I'm new to Code Golfing and looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Go. Please keep to one tip per answer.
stackexchange_codegolf
Why a Simulator? Kids these days don't have the time nor the ambition to actually go and stack boxes on the see-saw or play around with balancing physical objects. This leaves lots of room in the software market for a Lever Simulator which will, according to my models, sell like mad! Programming Help Wanted I've filed ...
stackexchange_codegolf
Write a program or function to estimate as closely as possible the number of syllables in English words. The input list is here: 1000 basic English words. There are only 997 words because a few duplicates were removed. For each word, output a line containing the word, a comma (,), and the number of syllables and no oth...
stackexchange_codegolf
V1.1: Added criterion to help with tiebreakers, a bit overkill but still. Task: Crack the scrambled code for calculating the argument of a complex number \$z=x+iy\$ given two inputs. You must post a comment in the cops’ thread with a link to your working source, mentioning clearly that you have cracked it. In your ans...
stackexchange_codegolf
Given a positive integer n >= 1, output the first n rows of the following structure: # # # ### # # # # # ## ## ##### # # # # # # # # # # ### # ## ## ## # ## ### ### ####### The n-th 1-indexed row is the binary representation of n, mirrored without copying the last character, with # in place of 1 a...
stackexchange_codegolf
Challenge Choose any number of languages. Call this set L. Write a program so that running it in any language in L produces an interpreter for a different language in L. Each language in L must have exactly one interpreter for it. This is to prevent, for example, Nothing or Text being part of L and all interpreters be...
stackexchange_codegolf
Special thanks to Bubbler and AdmBorkBork for supplying feedback about this challenge Keta (Keyboard tacit — clever naming, I know!) is a golfing language I’ve been working on recently. One of it’s features is it’s most probably unique bracket autocompletion system, which will hopefully allow for shorter programs. The...
stackexchange_codegolf
We have a challenge to output your own score, but it seems like all the answers there just hardcode the output and that's boring1. So lets have a new challenge. Your program must output its own length in bytes followed by the string " bytes", but in order to prevent hardcoded solutions if we reduce its size by removi...
stackexchange_codegolf
I am exploring a unique approach to the classic problem of Reverse Polish Notation on code.golf. Unlike the conventional solutions, my focus lies on leveraging the eval function in GolfScript. This twist was inspired by a comment in a related thread, where the absence of eval was deemed a limitation. "It's a shame no ...
stackexchange_codegolf
ASCII art is fun. Modern text editors are very good at manipulating text. Are modern programming languages up to the task? One common task in ASCII art manipulation is to crop text to a rectangle between two characters. This is the task you must implement in this challenge. Details Your program will take 3 inputs: t...
stackexchange_codegolf
This is a simple challenge. The task is to write code that outputs a 448*448 square image with 100% transparency. The output should follow the standard image rules.
stackexchange_codegolf
I have the following code which I've written to emulate Newton's method for deriving the square root of a number: r=(x,y)=> (z=((y=y||x)*y-x)/(2*y)>1e-15)? r(x,y-(y*y-x)/(2*y)):y Where r(37) would result in 6.08276253029822 which is great given the limitations of my browser. I'd like to golf this code further seei...
stackexchange_codegolf
Background Tents and Trees (try here) is a puzzle played on a square (or rectangular) grid, where the objective is to place tents horizontally or vertically adjacent to each of the trees, so that no two tents touch each other in 8 directions (horizontally, vertically, and diagonally) and the number of tents on each row...
stackexchange_codegolf
Consider a horizontal line with vertical lines centered on the x-axis and placed at gaps of \$\sqrt{2}/2\$. For a positive integer \$n \geq 3\$, the first half of the lines have lengths \$0, \sqrt{2}, 2\sqrt{2}, 3\sqrt{2}, \dots, (n-1)\sqrt{2}\$ and then the second half have lengths \$(n-2)\sqrt{2}, (n-3)\sqrt{2}, \do...
stackexchange_codegolf
Craps is a fairly simple dice game often played in casinos. Even if you aren't a gambler (which I'm not), it's still a fairly interesting game. Here's the rules: At the start of a game of Craps there's what is called the come-out round. The player rolls two d6s (six-sided die) and the two die rolls are added. If the re...
stackexchange_codegolf
To mark the anniversary of World IPv6 day, the Internet Society has published a campaign to Turn Off IPv4 on 6 June 2014 for One Day. IPv6 addresses may be represented in their long form as eight colon-separated 16-bit hex values. Depending on the address, they may also be shortened as described in item 2 of section ...
stackexchange_codegolf
I like to pretty print multidimensional arrays, like this: [ [ [1, 2, 3], [4, 5, 6] ], [ [7, 8, 9], [6, 4, 2] ] ] But it's a pain to do by hand and it'd be nice to have a program that does this for me. Your challenge is to create a program that does this for me, taking a multidimensional array containing onl...
stackexchange_codegolf
My parents have an home theater device. The remote is broken making it incredibly difficult to navigate rightwards in a menu. Most the time it doesn't work but when it does it moves rightwards incredibly quickly. This is obviously frustrating but it is most frustrating when you want to enter a movie title which requi...
stackexchange_codegolf
Quell is a single-player grid-based puzzle game. Pearls are scattered across a 2D map and the aim is to collect them all by rolling a drop of water over them. For this challenge we will only consider basic maps containing the drop, pearls, walls, and empty spaces. (The full game includes a variety of additional objects...
stackexchange_codegolf
Based on this, but I was asked[​1​],[​2​] to do a graphical edition. Task Generate a circular display of the text EASIER COMMUNICATION MEANS FASTER CODING MEANS FEWER CODERS MEANS . Any uppercase font goes. The letter tops must face out of the circle. Either the space before FEWER must be at the bottom (6 o'clock) or ...
stackexchange_codegolf
Your task is to form an expression equaling \$ 11111111111 \text{ (11 ones)} \$ using only the following characters: 1+(). Keep in mind that the result is in base 10, and not some other base like binary. Of course, these expressions should follow the order of operations. Furthermore, the only operations which should be...
stackexchange_codegolf
Write a program that outputs the contents of the first HTML <code>...</code> block of the answer to this question that is just above yours when the answers are sorted by votes. Output Top! if you are the top answer. Ignore answers that have negative votes or no <code>...</code> tags. The source of your program must app...
stackexchange_codegolf
Your task: given an input string, determine whether the binary representation of that string does not have 4 1s or 0s in a row, anywhere. Furthermore, your code itself should not contain any such runs of four in a row. Test Cases String Binary Result U3 01010101 00110011 Truthy 48 ...
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
Write a quine which attempts to invert the case of as many ascii characters in the source code as possible. For example in javascript: (x=function(y){return ('(x='+y+')(x)').toUpperCase();})(x) Standard quine rules apply. The score is given by number of bytes in the source code - number of case inversions. For examp...
stackexchange_codegolf
The challenge is to create an iterator(/generator) which iterates (in any order so as to reach all of them... ie no set should occur at infinity) over all possible non-empty finite sets(/tuples/lists) of positive integers (hence demonstrating their countability). Since the problem of verifying the correctness of a solu...
stackexchange_codegolf
Write a program that accepts as input an emoticon and ouputs if the emoticon is happy or sad. The program accepts a string as input or parameter, and should display the string "happy" if the input is in the happy emoticon list, or "sad" if the input is in the sad emoticon list. You can assume the input is always a vali...
stackexchange_codegolf
What general tips do you have for golfing in Clean? Please post only ideas that can be applied to code golf problems in general, and are at least somewhat specific to Clean. If you've never heard of Clean, you can find out more here. Or, you can join the chat room.
stackexchange_codegolf
Introduction I recently came across an oral exam where the candidates were asked to find a logical circuit than can negate 3 inputs A,B,C using only two NOT gates. The question also specified that such a circuit is unique up to removal of useless gates and reordering inputs/outputs. The candidates were asked to prove t...
stackexchange_codegolf
Jack and Jane decided to play a game of chess to while away time. Unfortunately, Jack is rather bad at visualizing. He finds it tough to figure the moves possible for a given piece other than a pawn, of course! Your challenge is to help find Jack the possible options for a given piece (other than a pawn). In case one...
stackexchange_codegolf
Write program which finds shortest expression for big integer. Expression may consist of + - * / ^ ! ( ) operations. ! stands for factorial, ^ - exponentiation, / - rational division. Number itself should be printed when no shorter expression found. Examples: 7 - 7 120 - 5! 19683 - 3^9 191102976 - 4!^6 Code which is a...
stackexchange_codegolf
This is based off this challenge. Given an input string, check whether the string is blurry. What's a blurry string? A blurry string is a string that's contained in the set of all blurrified pure-ASCII strings. Take a non-blurrified pure-ASCII string abc as an example. You repeat every character of this twice: aabbcc ...
stackexchange_codegolf
Challenge This challenge is pretty simple: Output the total number of possible Tweets. Given the fact that \$1{,}114{,}112\$ Unicode characters exist, and Tweets can be up to \$280\$ characters long, we calculate this number like so: $$\sum_{l=1}^{280}1{,}114{,}112^l$$ Calculated, this number becomes: 13806352273767118...
stackexchange_codegolf
Lets define the process of crushing an array of numbers. In a crush we read the array left to right. If at a point we encounter two of the same element in a row we remove the first one and double the second one. For example here is the process of crushing the following array [5,2,2,3] ^ [5,2,2,3] ^ [5,2,2,3] ...
stackexchange_codegolf
I am looking for tips to code in this golfing language Seriously, and was wondering what some of the ways for golfing this language is. "Remove comments" is not a tip. Actually is also included
stackexchange_codegolf
In this challenge you must write a computer program that creates a stack of a thousand identical \$1 \times 1\$ frictionless homogeneous blocks such that each block is supported and the stack is stable under gravity when placed on the edge of a table which spans from \$x = -\infty\$ to \$0\$ horizontally, with the surf...
stackexchange_codegolf
Given an ASCII-art shape made of the characters /\|_, your challenge is to return the number of sides it has. A side is a straight line of one of those, for example: \ \ \ / / | | | | _____ Are all sides. For example, this shape: ___ / \ /_____\ Has four sides. You can assume the input will be a single va...
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
Amazingly, this is the easier of the three card tricks I know off the top of my head... The aim of this is to have your compiler perform a specific card trick. There's no slight of hand, and the compiler won't be memorizing the choice and saying "Voila, this is your card!" The code will basically manipulate a stack of ...
stackexchange_codegolf
Write a program or function that can distinguish the following 12 trigonometric functions: sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh. Your program is given one of the above functions as black box and should output the function's name either as given above or the way it is named in your lan...
stackexchange_codegolf
A narcissistic number is a natural number which is equal to the sum of its digits when each digit is taken to the power of the number digits. For example \$8208 = 8^4 + 2^4 + 0^4 + 8^4\$, so is narcissistic. We'll define a function \$f(x)\$ as the following, for a natural number \$x = d_1d_2\dots d_n\$, where \$d_i\$ i...
stackexchange_codegolf
Correct a single-letter typo in a fixed text. Input: The paragraph below but with exactly one typo, where a single letter a-zA-Z is replaced by a different letter a-zA-Z. To be clear, the letter isn't replaced everywhere it appears, but just in that one place. For example, the first word "In" might become "IZ". Non-let...
stackexchange_codegolf
Introduction I have an even number of bottles, all of different sizes. Unfortunately, I only know the size of the smallest bottle: 300ml. I also know the following: Half of the bottles are twice the size of the other half, meaning that the smallest small bottle and the smallest large bottle are in a ratio of 2:1. The...
stackexchange_codegolf
Challenge Write a program/function that accepts an "image" and outputs a picture maze formed from that image. Input Your program should accept two arguments: I, the image to form the maze from S, a boolean specifying whether or not to display the solution to the maze I is given in the following form: ....... .#####. ...
stackexchange_codegolf
Your job is to write a program to find the closest number to PI. Let me clarify. You will first choose a number type. Let us say you choose Integer (in an actual answer, you cannot). Your program would then have to generate an integer that is closed to PI. For Integers, this would be 3. Not 4; 3. For every allowed numb...
stackexchange_codegolf
A regular string looks like this: Hello,IAmAStringSnake! And a string snake looks something like this: Hel l rin o,IAmASt g S !ekan Your Task String snakes are dangerous, so you must make a program that takes a string snake as input and outputs it as a regular string. Specification...
stackexchange_codegolf
Challenge The goal of this challenge is to generate and output a \$16 \times 32\$ (height \$\times\$ width) grid where all cells contain a decoy character, except for a random single cell that contains the target character. The input will be a pair of ASCII (32-126) characters: [target,decoy], where target is the chara...
stackexchange_codegolf
Your mission today is to create a vortex given a single parameter. This parameter determines the length of each arm in characters. Each "layer" of each arm contains one more character than the last. Here's how the vortex will look, given the arm length: 0: # 1: # ### # 2: # # # ### # # # 3: ## # ...
stackexchange_codegolf
Have you been shooting gallery? We are recently. In our shooting gallery cans and aluminum cans from under various drinks hang and stand. More precisely, they hung and stood. From our shots, banks dangled from side to side on a rope, were torn off, rang, crumpled. This is not for you to shoot from your fingers. Each ...
stackexchange_codegolf
Take a string as an input, and perform addition/subtraction of all the digits in the string and output the sum of those operations as the result. Rules The digits in the string are read from left to right If a digit (n) is odd, perform addition with the next digit (n + n1) If a digit (n) is even, perform subtraction ...
stackexchange_codegolf
Background We've had challenges before on Fibonacci coding and Zeckendorf representation. These representations follow naturally from Zeckendorf's theorem, which states that every positive integer can be represented uniquely as the sum of one or more distinct, non-consecutive Fibonacci numbers. For example: $$ \begin...
stackexchange_codegolf
Degree of Unsaturation This is not a particularly hard code puzzle - but I'm interested to see your multiple ways of solving it. The Degree of Unsaturation is the number of double chemical bonds between atoms, and/or the number rings in a chemical compound. You will be given the molecular formula of a chemical compoun...
stackexchange_codegolf
I have string \$s\$ of length \$n\$ and some constant integer \$k\$ which is at most \$n\$. Give the fastest algorithm to sample a random string with Levenshtein distance \$k\$ from \$s\$ uniformly. Your algorithm should output any of the strings with edit distance exactly \$k \leq n\$ from the input string \$s\$ with ...
stackexchange_codegolf
Conways' 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 around it) lives ...
stackexchange_codegolf
This is a problem that the Hacker Cup team made for the 2018 Facebook Hacker Cup, but we ended up not using it (though Ethan struggles through a variety of other challenges). Normally code size isn't a factor in the Hacker Cup, but we thought this would make for an interesting code golf challenge. We look forward to se...
stackexchange_codegolf
A stack state diagram shows how the values on one stack are changed into the other. For example, this is a stack state diagram: 3 0 2 1 0 This means that there is a stack initially containing 3 values (the 3 part). These values are indexed from 0 to 2, with 0 at the top: 2 1 0. The next part 0 2 1 0 describes the fina...
stackexchange_codegolf
Challenge My challenge, is for you to generate a Menger Sponge based on the level/iteration given. You need to draw it in 3d, anyway you can. Examples Inputs: 0, 1, 2, 3 Outputs: Background Information What is a Menger Sponge In mathematics, the Menger sponge (also known as the Menger universal curve) is a fractal c...
stackexchange_codegolf
Starting an the origin on an infinite grid, you follow a predetermined path going up (U), down (D), left (L), or right (R). You paint every square you visit, including the square you started at and the square you finish at. Using this method, we can paint the number six using the instructions RRDDLLUUUURR: The origin ...
stackexchange_codegolf
So, last week I posted a challenge to play Duck, Duck, Goose. This lead to a number of Minnesotans commenting about their regional 'Gray duck' variation. So here's the rules: Using this list of colours: Red Orange Yellow Green Blue Indigo Violet Gray Write a program to follow these rules: Select one of these colours,...
stackexchange_codegolf
Problem You are given a binary string A of length N. You can perform the following type of operation on the string A: Choose two different indices \$i\$ and \$j\$ (\$1 \le i\$, \$j \le N\$) Change \$A_i\$ and \$A_j\$ to \$Ai \oplus Aj\$​. Here \$\oplus\$ represents the bitwise XOR operation. Input A binary string con...
stackexchange_codegolf
Inspired by this on Spiked Math: (source: spikedmath.com) In this code golf, you are going to write a numerical integrator. Instead of weighting, you first plot on a graphic canvas pixel-by-pixel or plot on a 2D array, then calculate the integral by counting the colored pixels. You are implementing a function with th...
stackexchange_codegolf
Input: An integer N which represents the polygon's vertices and a list of their x and y coordinates. Expected output: The smallest difference possible between the area of the(not necessarily convex) polygon and the triangle containing it. The triangle also has to share at least 2 vertices with the polygon. If there is ...
stackexchange_codegolf
Given one of the following inputs: Sweet Onion Chicken Teriyaki Oven Roasted Chicken Turkey Breast Italian BMT Tuna Black Forest Ham Meatball Marinara output a number from 1-7 (or 0-6) representing the day of the week that you get that deal, starting with Monday as the lowest number. Input can be all lowercase or uppe...
stackexchange_codegolf
Inspired by one of many bugs I ran into while implementing selection sort in trilangle. Given a non-empty list of non-negative integers, "sort" the list using the following procedure: Find and output the smallest value in the list. If the list only has one element, stop. Recurse on a sublist: If the last element in t...
stackexchange_codegolf
Referencing xkcd 1688: Your task is to deduct the age of a map by asking the user questions. These question must be exactly the same as in the xkcd guide, except from the capitalisation and additional newline(s). Additionally, you should give the user some options to choose from, which don't have to be in the order as...
stackexchange_codegolf
Definition According to Wikipedia: The Cooke and Wheatstone telegraph was an early electrical telegraph system dating from the 1830s invented by English inventor William Fothergill Cooke and English scientist Charles Wheatstone. It was the first telegraph system to be put into commercial service. The receiver consiste...
stackexchange_codegolf
I recently read up on graph theory, especially hypercubes and thought about interesting ways to construct paths on them. Here's what I came up with. As you might know, you can construct an n-dimensional hypercube by taking all n-tuples consisting of 1 and 0 as vertices and connect them, iff they differ in one digit. If...
stackexchange_codegolf
Introduction Just on Hacker news, John Resig contemplates transforming a query “foo=1&foo=2&foo=3&blah=a&blah=b” into one that looks like this: “foo=1,2,3&blah=a,b", https://johnresig.com/blog/search-and-dont-replace/. He claims "being 10 lines shorter than Mark’s solution". Query strings consist of sequences of name-v...
stackexchange_codegolf
Presumably everybody here knows that for the legacy BIOS, the tiniest bootable disk image is 512 bytes (the lower bound is due to the 2-byte magic at offset 510), and there is a bootsector demoscene where people try to fit the entire demo into the 510 bytes of usable space. Now that the BIOS is being superseded by UEFI...
stackexchange_codegolf
In this game, you can look inside one box at a time chosen by you. When you do that, you can see how many coins there are in that box. The wizard has one last twist for you. At any point, you can choose to give up on this set of boxes and get him to start the whole process again (with a new random \$x\$). Of course, i...
stackexchange_codegolf
Given a number N from 2 to 8, place any nonzero number of queens on a grid of any size so that every queen has exactly N queens (counting itself) in each of its row, column, and each diagonal. This challenge has a significant restricted-time runtime limit. Your code must finish all N from 2 to 8 (combined) within the 6...
stackexchange_codegolf
Monday Mini-Golf: A series of short code-golf questions, posted (hopefully!) every Monday. (Sorry I'm late again; I was away from my computer basically all of yesterday and today.) Us programmers (especially the code-golfers) sure love arbitrary integer sequences. We even have an entire site dedicated to these sequenc...
stackexchange_codegolf
Last month I borrowed a plenty of books from the library. They all were good books, packed with emotions and plot-twists. Unfortunately, at some points I got very angry/sad/disappointed, so I tore some pages out. Now the library wants to know how many pages I have torn out for each book. Your goal is to write a program...
stackexchange_codegolf
In Australian Football, goals are worth 6 points and behinds are worth 1 point. Scores may include the number of goals and behinds, as well as the total score. Given the number of goals and behinds for two different teams, determine which team won the game. Take four integers g1, b1, g2, b2 as input, and output two dis...
stackexchange_codegolf
Introduction There is a plantation defined by one big square-board like this one: The numbers inside each small square represents its area's value/cash/... The farmer needs help to find the N squares that connected (it means all N squares should have at least one shared border) give him the greatest value. For example...
stackexchange_codegolf
You probably all know the 7-segment display which can display among other things all digits from \$0\dots 9\$: Challenge We only consider the segments \$\texttt{A}\dots\texttt{G}\$, your task is to decode a single digit given which segments are turned on. This can be encoded as an 8-bit integer, here's a table of each...
stackexchange_codegolf
Define f(a,b) := a if b=1; a^f(a,b-1) if b>1 (Tetration, where ^ means power) for positive integers a and b, given four positive integers a,b,c,d, compare f(a,b) and f(c,d). Your program should output three constant values to mean "greater", "less" and "equal". Samples: a b c d f(a,b) output f(c,d) 3 2 2 3 27 > ...
stackexchange_codegolf