instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
I came across an interesting tiling of the plane using squashed hexagons in a popular math book. All the six edges of the squashed hexagon are the same length. Two opposite corners are right angles and the rest four corners are 135 degrees each. This shape allows four squashed hexagons be arranged so that they meet at ...
stackexchange_codegolf
You want to create a square chessboard. Adjacent tiles must alternate black and white like a standard chessboard, and the bottom left corner can be either black or white. Your program will take in two positive integers, the number of black and the number of white tiles. These will always be less than 1024. You don't ha...
stackexchange_codegolf
Let's for once do something useful. Given the text from a Try It Online codegolf submission, produce the equivalent Chat Mini Challenge submission, which is of the form Language, N bytes: [`code`](URL) or (if submission is a single byte – TIO will add a trailing s on the first line only if needed) Language, 1 byte: [`...
stackexchange_codegolf
As part of a city planning project, you've gotten the assignment of creating a program or function that will display the city skyline, given some input from the architects. The project is only in the startup phase, so a very rough sketch is sufficient. The easiest approach is of course to simply draw the skyline in ASC...
stackexchange_codegolf
\$BB\$ is the busy beaver function, an uncomputable function. Write a program which when given an integer \$n\$ as input, will output \$BB(n)\$, with at least \$\frac 2 3\$ probability. You can do whatever (return something wrong, infinite loop, explode, etc.) in other cases. To help you compute it, you're given a func...
stackexchange_codegolf
What is the shortest way to see if an input is a wordinian using any programming language? A wordinian is a word that contains words of length 1 to the original word's length. For example, bin 'I' is a word 'in' is a word 'bin' is a word Or, stage 'a' is a word 'ta' is a word (yes it is) 'age' is a word 's...
stackexchange_codegolf
Write a program that fills in the paths of a grid of characters (ASCII 20-7E) according to the following rules. The path is governed by eight directional characters: -, |, /, \, &, @, %, and *, as specified in the table below. The direction of the path will change when it reaches one of the eight above characters. Note...
stackexchange_codegolf
Draw the parabolic trajectory of a thrown ball. The input is the ball's initial upward velocity, a positive integer v. Every second, the ball moves 1 space right and v spaces vertically, and then v decreases by 1 to due to gravity. So, the upward velocity eventually steps down from v to 0 and down to -v, finally falli...
stackexchange_codegolf
You are given 100 arrays/sets of 5-8 numbers between 1-20. If you combine all the arrays you will always get at least one of each number (1-20), so don't worry about an "unsolvable" case. The goal is to find the combination of arrays that minimizes duplicate numbers while still getting one of each number from 1-20. Her...
stackexchange_codegolf
Challenge: Here we have the first 100 items of a sequence: 6,5,4,3,2,1,66,65,64,63,62,61,56,55,54,53,52,51,46,45,44,43,42,41,36,35,34,33,32,31,26,25,24,23,22,21,16,15,14,13,12,11,666,665,664,663,662,661,656,655,654,653,652,651,646,645,644,643,642,641,636,635,634,633,632,631,626,625,624,623,622,621,616,615,614,613,612,6...
stackexchange_codegolf
Based on Practical Golf - US States Your task is to find the abbreviation (symbol) of an element given the element name, up to and including ununoctium (118). Use the periodic table on Wikipedia. Thanks to squeamish ossifrage, you can find a full list of elements to abbreviations at http://pastebin.com/DNZMWmuf. You ma...
stackexchange_codegolf
Introduction: I think most people will know how darts work. But since some might not, here are the rules of playing Darts in a nutshell: Amount of players: 2 Starting points: 501 Goal: Get your points to 0 first Darts per player: 3 Available numbers on the board: 1 through 20, and Bulls-eye Here is the layout of a Da...
stackexchange_codegolf
Objective Write a full program that works exactly like the flow chart below. Each output, which is an integer, shall be through stdout, followed by a line feed. Each input shall be a line of string fed through stdin, and shall be judged to a predicate you choose for branching. The same predicate must be used for all br...
stackexchange_codegolf
This was related to a program I am writing. Although the title is simple, the challenge is a lot more complicated. Your challenge You must write a program that takes an input, and your answer must match the sample outputs in this question. What the program should be is that you must output "HelloWorld" with the length ...
stackexchange_codegolf
Consider the following definitions taken from The number of runs in a string by W. Rytter. Note that word, string and substring are all roughly synonyms. A run in a string is a nonextendable (with the same minimal period) periodic segment in a string. A period p of a word w is any positive integer p such that w[i...
stackexchange_codegolf
Your challenge is to format a list of words across multiple lines that are no longer than a given number of characters, so that each line contains as many words as possible and no words are unnecessarily cut off. Input The input will be a space-separated list of words and then a number that is at least 4. Output The ou...
stackexchange_codegolf
Introduction In the prisoner's dilemma, two partners in crime are being interrogated, and have the choice to either betray their partner or stay silent. If both prisoners betray each other, they both get 2 years in prison. If neither betrays (both stay silent), they both get 1 year in prison. If only one betrays and t...
stackexchange_codegolf
Given two lists of numbers, a source and a pattern, reorder the source to match the relative ordering of the pattern. Any two entries of the reordered source should compare the same way as the entries at those same positions of the pattern. For example, the input s = [-5, 9, 4, 13, 11, -6, 0] p = [7, -4, 1, -8, 4, -3, ...
stackexchange_codegolf
Background A checkered tiling of a rectangular grid is a tiling using some polyominoes, where each region can be colored either black or white so that no two polyominoes sharing an edge has the same color. In graph-theoretic terms, the chromatic number of the adjacency graph is 2. Terminology adapted from a Fillomino v...
stackexchange_codegolf
Daylight saving time (DST), is the practice of advancing clocks (typically by one hour) during warmer months so that darkness falls at a later clock time. The typical implementation of DST is to set clocks forward by one hour in the spring ("spring forward") and set clocks back by one hour in autumn ("fall back") to re...
stackexchange_codegolf
You'll get a human-readable question matching one of the following syntaxes, and are expected to print/return the corresponding result. Finding similarities between the human-readable inputs and matching them with minimum size code is explicitly part of the task, so I won't give a formal definition. "Will October begi...
stackexchange_codegolf
Quylthulg is a language by Chris Pressey that attempts to solve the problem of infix notation using what it calls panfix: like postfix, panfix does not require the deployment of arcane contrivances such as parentheses to override a default operator precedence. At the same time, panfix allows terms to be specified in t...
stackexchange_codegolf
Task Given a string composed of ASCII printable characters, return how many strings could fit the given pattern with character literals and regex-like ranges. Pattern string The pattern string follows this grammar (the | means an option and the * means 0 or more occurrences of whatever was immediately to the left): pat...
stackexchange_codegolf
We once made a Hexagony template without actually knowing it. But after a bit of experience with Hexagony, it becomes apparent that it is not enough; sometimes the source code is too short for the given hexagon, and you get totally unexpected results. So I came up with an idea: a template that gives a hint when the cod...
stackexchange_codegolf
Challenge: With any given number that has multiple digits, every digit in the number needs to repeatedly be summed together until the sum is a single digit number. To make things interesting, if there's a 0 in the number, then it must equal 26, because zero starts with the letter z, which is the 26th and final letter o...
stackexchange_codegolf
Starting with a positive integer N, find the smallest integer N' which can be computed by repeatedly dividing N by one of its digits (in base-10). Each selected digit must be a divisor of N greater than 1. Example #1 The expected output for N = 230 is N' = 23: Example #2 The expected output for N = 129528 is N' = 257:...
stackexchange_codegolf
A string like this one: "a, 4.25, ((true, 5), 3, (false, false, false)), abc" Describes a tree with 13 nodes, 9 of which are leaf nodes. In C# the leaf nodes in this example would be of types string, float and bool, this differs between languages and depending on your implementation. The important structure forming sym...
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
Inspired by this comment. Input The number of seconds on the timer. Output Here's our basic microwave: _____________________________________________________________ | | ___________ | | | | [display] | | | ____________________...
stackexchange_codegolf
Given a string that is one of the directions on a 16-point compass rose output the two directions that are immediately adjacent to the input direction, in clockwise order. Specifically, you need to handle these (and only these) input/output pairs: Input Output N NNW NNE NNE N NE NE NNE ENE ENE NE E E ...
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
A polyglot is a program which can be run by several different language's interpreters/compilers without failing. For example, the stackoverflow 404 page contains a polyglot which runs in Python, Perl, Ruby, C, brainfuck and befunge, each time printing 404 to stdout. Now, my challenge is to create a polyglot which, whe...
stackexchange_codegolf
Background Python 3 has many types of string literals. For example, the string this 'is' an exa\\m/ple can be represented as: 'this \'is\' an exa\\\\m/ple' "this 'is' an exa\\\\m/ple" r"this 'is' an exa\\m/ple" '''this 'is' an exa\\\\m/ple''' """this 'is' an exa\\\\m/ple""" r'''this 'is' an exa\\m/ple''' r"""this 'is' ...
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
This is a code golf puzzle: shortest byte count wins. The program should do the following (standard loopholes obviously forbidden): Input a hexadecimal number Convert to octal Then interpret the digits as if in decimal (765 octal -> 765 decimal) Divide the number by two Convert to hexadecimal Example: Input: 4a3d Out...
stackexchange_codegolf
Your task, should you choose to accept it, is to take two input values \$a\$ and \$b\$, where \$a\$ and \$b\$ are in the set \$\{T, U, F\}\$, and compute and output their logical conjunction in a three-valued logic system. A three valued logical conjunction is this transformation: a b output U U U U F F F ...
stackexchange_codegolf
(Related) Given an integer n > 1, 1) Construct the range of numbers n, n-1, n-2, ... 3, 2, 1 and calculate the sum 2) Take the individual digits of that number and calculate the product 3) Take the individual digits of that number and calculate the sum 4) Repeat steps 2 and 3 until you reach a single digit. That digit ...
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
This is the robbers' thread. The cops' thread goes here. In the cops thread, the task was to create a program that outputs printable ASCII characters in ascending order. The robbers task is to unscramble the code the cops used to produce this output. The cracked code doesn't have to be identical, as long as it has the ...
stackexchange_codegolf
Challenge The challenge is to write a code that takes a positive integer 'n' as an input and displays all the possible ways in which the numbers from 1 - n can be written, with either positive or negative sign in between, such that their sum is equal to zero. Please remember that you may only use addition or subtractio...
stackexchange_codegolf
Muriel is a language where the only way to loop is to create a quine and execute it. Your job is to create your own language with this property and an implementation of it in a pre-existing language. We will define a Muriel-like language like as follows: It has a built-in command for executing code in its own language...
stackexchange_codegolf
...or "snakes but not too long". Inspired by this challenge and this comment. Task Write a program or a function that takes no input and outputs its own source code formatted as a snake according to the rules below: If your code has any whitespace, it will not be output; it will just be skipped. There will be one char...
stackexchange_codegolf
Inspired by this video by tecmath. An approximation of the square root of any number x can be found by taking the integer square root s (i.e. the largest integer such that s * s ≤ x) and then calculating s + (x - s^2) / (2 * s). Let us call this approximation S(x). (Note: this is equivalent to applying one step of the ...
stackexchange_codegolf
The Kempner series is a series that sums the inverse of all positive integers that don't contain a "9" in their base-10 representations (i.e., \$\frac{1}{1} + \frac{1}{2} + \frac{1}{3} + .. + \frac{1}{8} + \frac{1}{10} + ...\$). It can be shown that, unlike the Harmonic series, the Kempner series converges (to a value ...
stackexchange_codegolf
Inspired by this code review question, I am curious to see what happens if we turn that into a code-golf challenge! The description is easy, the input is an array or any similar data structure with only unsigned integers, the output is a boolean if the number of odd numbers is equal to the number of even numbers inside...
stackexchange_codegolf
The task is to display ascii table for a given array. Input The input is an 2D matrix. The matrix's row length is same with the length of an array. Alternatively, you can take input of an 2D matrix with the first row is a header. The outer dimension is the row. Example Input: [["License","2008-05-08","2009-03-11","2011...
stackexchange_codegolf
Given a string, like potatocarrot, break it into the smallest number of substrings possible. These substrings can consist either be a single character, or one of a list of words passed as input. For example, if [carrot, potato] was the input, the optimal way to break the string up would be [potato][carrot]. If the list...
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
Given a string s and a positive integer N, gradually duplicate each character more and more until N duplicates, and then staying at N duplicates until N characters away from the end, then step down again. For example, given abalone and 3: a we start with 1 copy bb then 2 copies aaa then 3 copies, which is our sec...
stackexchange_codegolf
The Lost Numbers are 4, 8, 15, 16, 23, 42. Your goal is to create an expression to output them all. Your allowed characters are 0123456789, ^+-*/, (), % for modulo and n as the single variable allowed. Modified PEMDAS ()^*/%+- is the precedence and / is normal division (3/2 = 1.5). 0^0 = 1 although division by 0 is und...
stackexchange_codegolf
Challenge Given an input of an integer, \$n\$ (where \$0<n<50\$), output the graph of \$y=\mathrm{Re}((-n)^x)\$ from \$x = -3\$ to \$x = 3\$ inclusive. Where \$\mathrm{Re}(p)\$ is the real part of the complex number \$p\$. Note that \$\mathrm{Re}((-n)^x) = n^x \cos{(\pi x)}\$ Output The output may be in any form you wi...
stackexchange_codegolf
This challenge is based on one proposed on the usenet group rec.games.roguelike.development a few years ago. I can't find the original newsgroup post, but you can have a look a the Github repo of solutions. It was only golfed in a couple of languages and I'd love to see some more! Objective The aim is to build a prog...
stackexchange_codegolf
This is the robbers' thread. The cops' thread goes here. In the cops thread, the task was to create a program that outputs printable ASCII characters in ascending order. The robbers task is to unscramble the code the cops used to produce this output. The cracked code doesn't have to be identical, as long as it has the ...
stackexchange_codegolf
You are given an array A of length N and an array B of length N-1. You need to output array where items alternates: A[0], B[0], A[1], B[1], ..., B[N-2], A[N-1] Restrictions: N>0 Type of items is not specified, but code should work at least for unsigned integers. Sample input: A = [1,2,3,4] B = [7,8,9] Sample output:...
stackexchange_codegolf
Given a ragged list of positive integers find the size of the largest list contained somewhere in it. For example: [1,[1,[8,2,[1,2],5,4,9]],2,[],3] Here the answer is 6 because one of the lists has 6 elements and all other lists have fewer. [1,[1,[8,2,[1,2],5,4,9]],2,[],3] ^ ^ ^ ^ ^ ^ The length doesn't ca...
stackexchange_codegolf
For the given string s, generate generate a table like below. Input:abcd Output: abcd bbcd cccd dddd Input:Hello, world! Output: Hello, world! eello, world! llllo, world! llllo, world! ooooo, world! ,,,,,, world! world! wwwwwwwworld! ooooooooorld! rrrrrrrrrrld! llllllllllld! dddddddddddd! !!!!!!!!!!!!! Trailin...
stackexchange_codegolf
I am sorry for the very long description. But i think some information of how /proc/self/cmdline works and how it can be used to get a integer input was necessary. You may skip the sections you don't need. While part of this task is related to C and Linux, it can be done in any almost language that can start other prog...
stackexchange_codegolf
Given a string of printable ASCII text (including newlines and spaces) that contains at least one character that is neither a newline nor a space, output a truthy value if the string is rectangular, and a falsey value otherwise. Additionally, the source code for your solution must be rectangular. A string is rectangula...
stackexchange_codegolf
This is my first golf contest. What you need to do Build me, in the shortest amount of bytes possible, my AC remote control system. My room is too cold right now, and I'm missing my remote. Now, I don't want you literally building it or anything, just golf this: A slow increment of temperature, starting at 40 degrees, ...
stackexchange_codegolf
Here's a very simple little problem that I don't believe has been asked before. Challenge Write a program or a function that takes in four positive integers that represents the lengths of movable but unbreakable and unbendable straight fences. Output the area of the largest rectangular yard that can be fully encompasse...
stackexchange_codegolf
If someone facing north at point A in this grid wanted directions to follow the green path (as they can only follow gridlines) to point B you might tell them: Go North, North, West, East, East, South, East, East. or equivalently Go Forward, Forward, Left, Back, Forward, Right, Left, Forward. (Where a command of Right...
stackexchange_codegolf
Background On this site, we occasionally have questions requiring programs to be "radiation hardened"; this means that the program has to be able to survive the deletion of one or more bytes, no matter which bytes are deleted. As is common for tasks that frequently get set in programming challenges, it's natural to wan...
stackexchange_codegolf
New Posts and New Sandbox Posts are chatbots that occupy CGSE's main chatroom, The Nineteenth Byte. They've been doing their jobs for almost one full year now, so I thought I'd make a challenge to honor their contributions! The challenge is simple: Draw the profile picture of either New Posts (NP) or New Sandbox Posts ...
stackexchange_codegolf
Given an input of a list of days of the week, output the shortest sorted representation of the list. The format of the input is a string consisting of one or more of the two-character substrings Su (Sunday), Mo (Monday), Tu (etc.), We, Th, Fr, and Sa. The input may not necessarily be given in sorted order. To convert t...
stackexchange_codegolf
The brilliant engineers at <enter company you love to hate> have struck again. This time they've "revolutionised" the generation of random permutations. "Every great invention is simple" they say and their magical new algorithm is as follows: Start with a list 1,2,3,...,n of numbers to permute. For each element x in t...
stackexchange_codegolf
Disclaimer While I know there is this particular related question, my question uses two garage doors, a randomizing component, and I'm also basing this on real life events, seeing my son accidentally lowered one of said garage doors whilst I was walking out of the garage last week... Nothing like a blow to the head to ...
stackexchange_codegolf
Brainfuck is an esoteric programming language that is Turing Complete, meaning you can't tell whether a given program will halt without running it. It's cell-based and has an infinite tape of cells, values containing an unsigned integer from 0 to 255, but if you give it arbitrary-size cells, just three is enough to mak...
stackexchange_codegolf
Thanks to your help in the Mark My Mail challenge, PPCG-Post has successfully stamped all of its parcels with the generated barcodes! Now, it's time to decode them. In this challenge your program will, given a barcode generated from the Mark My Mail challenge, decode it and return the encoded integer. But watch out! Th...
stackexchange_codegolf
A directed graph G is given with Vertices V and Edges E, representing train stations and unidirectional train routes respectively. Trains of different train numbers move in between pairs of Vertices in a single direction. Vertices of G are connected with one another through trains with allotted train numbers. A hop is ...
stackexchange_codegolf
For functions \$f, g: \{0,1\}^n \rightarrow \{0,1\} \$, we say \$f \sim g\$ if there's a permutation of \$1,2,3,...,n\$ called \$i_1,i_2,i_3,...,i_n\$ so that \$f(x_1,x_2,x_3,...,x_n) = g(x_{i_1},x_{i_2},x_{i_3},...,x_{i_n})\$. Therefore, all such functions are divided in several sets such that, for any two functions \...
stackexchange_codegolf
My cell phone carrier charges a cent per character in a text! I need a program to shorten the words for me, while still being understandable. I will be texting this program to my friends, so it needs to be as short as possible. Your program will take a String (a word is separated by a non-alphanumeric character) of wor...
stackexchange_codegolf
It's 22022 and the Unicode consortium is having a problem. After the writing system of the ⮧⣝Ⅲⴄ⟢⧩⋓⣠ civilization was assigned the last Unicode block, the consortium members have been scrambling to find a new encoding to replace UTF-8. Finally UTF-∞, a proposal by Bob Rike, was adopted. UTF-∞ is backwards compatible wit...
stackexchange_codegolf
Introduction Today's challenge is all about teeth. Specifically, how long it takes to brush from one tooth to another. Your challenge is, given the locations of two teeth, output the shortest amount of time possible to brush from the first to the second. Challenge For this challenge we will be using a layout of an aver...
stackexchange_codegolf
In elementary school, children learn about proper fractions, where the numerator is less than the denominator, and thus the value of the fraction is less than one. Later, they are taught about fractions where the value of the fraction is greater than one, and two different ways to express these fractions: mixed fractio...
stackexchange_codegolf
Create a program that generates a drum fill. Your program will output a pattern of L (left hand hits), 'R' (right hand hits), and K for kick drum hits. Rules The pattern must never have more than 2 of the same hits consecutively. The pattern must be loopable, so it mustn't have more than 2 of the same hits when it lo...
stackexchange_codegolf
This is an ascii-art challenge where you will draw ascii-art showing a person "jumping" off the top of a building. The building Input given will be a group of rectangular buildings. You may assume buildings are not "stacked on top of each other", hence only one row of buildings. This is the standard format of a buildi...
stackexchange_codegolf
Some of you may say that I am wasting my time, but this task does not give me peace for more than 500 days. It is required to write a program in Python 3.x that takes two numbers as input and displays their sum. The numbers are given in the following format: a b Some example test cases: 100 500 -> 600 3 4 -> 7 Th...
stackexchange_codegolf
EDIT (Jan 19, 2022, 18:00 UTC): This challenge is now over. The winner is Citty with this Pyth answer. Congratulations! This is an answer-chaining challenge where each answer must take an integer \$N\$ as input and return the 1-indexed ID of the answer which was written by the user whose ID is \$N\$. You may want to s...
stackexchange_codegolf
Given an input list of non-empty strings, output an ASCII art representation of a tournament, based on the following drawing rules: The number of strings is guaranteed to be of quantity 2,4,8,16,etc. The first two strings play each other, and the next two play each other, and so on. This is the first round. For each g...
stackexchange_codegolf
Game In this challenge you will play a made-up turn-based game. The game is made up of the following elements: A 8x8 grid with each spot containing nothing (space), a robot (*), a wall (#), or HP (@) A public stack Robots In this challenge, you will be playing as a robot. Each robot has health (starts at 10HP and ca...
stackexchange_codegolf
I found this YouTube video with a table on it showing some card suits with ampersands. You might not understand what it is about, but I still want to make a challenge about it. The input is two suits, being one of the following: heart diamond spade club You can do anything for any other input. Then the output is their...
stackexchange_codegolf
You're driving a car in an infinite city whose blocks are pentagons arranged in the order-4 pentagonal tiling. At each step, you proceed to the next intersection and choose whether to continue left, right, or straight. A sequence of choices that returns you to your initial state (street segment and direction) is called...
stackexchange_codegolf
Sound synthesizers use envelope generators to control how certain parameters of the sound (such as overall loudness) change with time. In many synthesizers an envelope is defined by four parameters, as represented in the following figure from Wikipedia: Attack time (A): time taken for the envelope to reach its maximum...
stackexchange_codegolf
This challenge is related to some of the MATL language's features, as part of the May 2018 Language of the Month event. Associated challenge: Function clipboard: copy. Introduction MATL's function clipboard stores ("copies") the inputs to the four most recent calls to normal, input-taking functions. Normal functions a...
stackexchange_codegolf
In this challenge, players need to tamper with a time bomb as late as possible without getting blasted in the face. Mechanics Let N be the number of bots plus one. Each round, each bot receives the following arguments: numbers played by all bots last round in ascending order. number of points it received last round. N...
stackexchange_codegolf
Unfortunately one of the greatest comic book writers passed away yesterday afternoon. Lots of Hollywood stars, musicians, actors, and many other people are paying tribute to this awesome writer, so we must do something as well. Challenge Print The Avengers Logo Note: You may use any other character in place of # othe...
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
Cops thread Robbers Robbers, your job is to find the slices of the corresponding cop's code. Scoring The robber with the most cracks wins. Example Take this code: iimmppoorrtt ssyymmppyy;;pprriinntt((ssyymmppyy..iisspprriimmee((iinnppuutt(()))))) The slice here is [::2], so the robber's post could look like this: Crac...
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
Related to AoC2017 Day 18, Part 2. (Anyone want to add Duet to esolangs?) Duet is an assembly-like language that involves two processes running the same program simultaneously. Each process of Duet operates with 26 registers named a to z, all initialized to zero, except for the register p which contains the process ID...
stackexchange_codegolf
Challenge : Sort the vowels (only vowels) in the given string . Note : Vowels are the following characters: A, E, I, O, U Vowel sorting is cyclic i.e. After rearrangement the first vowel of sorted string goes where the original first vowel was Input : A string line, the original line (consisting of alphabets and wh...
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
Problem Let's define a generalized Cantor set by iteratively deleting some rational length segments from the middle of all intervals that haven't yet been deleted, starting from a single continuous interval. Given the relative lengths of segments to delete or not, and the number of iterations to do, the problem is to w...
stackexchange_codegolf
Background A magic square is an n×n matrix consisting of one of each of the integers from \$1\$ to \$n^2\$ where every row, column, and diagonal sum to the same value. For example, a 3×3 magic square is as follows: 4 9 2 3 5 7 8 1 6 Here, each row, column, and diagonal sum to the magic sum of 15, which can be calculat...
stackexchange_codegolf
Challenge: Given a list of multi-line strings, overlap them (in the top-left) and output the result. Example: Input: ["aaaa\naaaa\naaaa\naaaa","bb\nbb\nbb","c"] Output: cbaa bbaa bbaa aaaa Challenge rules: Input-format is flexible. You are allowed to get the input as a 2D list of lines (i.e. [["aaaa","aaaa","aaaa","a...
stackexchange_codegolf
"nimi ale lon toki pona" is a song by YouTuber jan Misali which lists 137 common words in the constructed language Toki Pona. This challenge is not a duplicate of "How high can you count?" or "Alphabet printing challenge" because instead of numbers or single characters, it outputs random (to many programming languages)...
stackexchange_codegolf
A checkerboard program is a program where each individual character's ordinal value alternates from even to odd, excluding the line terminator (which can be any standard line-endings). A triangular program is a program where each line has one additional character than the preceding line, with the first line having one ...
stackexchange_codegolf
Introduction Given five points in the plane, your task is to compute the area of the ellipse passing through these points. You can assume that exactly one non-degenerate ellipse can be constructed with the given input values. Rules Input is 10 integers in any convenient form, corresponding to the x and y coordinates of...
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
I encountered this question in an interview and could not figure it out. I believe it has a dynamic programming solution but it eludes me. Given a number of bricks, output the total number of 2d pyramids possible, where a pyramid is defined as any structure where a row of bricks has strictly less bricks than the row be...
stackexchange_codegolf