instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
The computational parity of an integer is defined as 1 if the integer has an odd number of set bits, and 0 otherwise. (src). Input You will receive one nonnegative integer that you will take the parity of. Optionally, you may take the size of the integer in bytes or bits as an argument, but you must specify this in yo...
stackexchange_codegolf
Challenge: Inputs: A string containing printable ASCII (excluding spaces, tabs and new-lines) A boolean † Output: The parts of the String are divided into four groups: Lowercase letters Uppercase letters Digits Other Based on the boolean, we either output the highest occurrence of one (or multiple) of these four gr...
stackexchange_codegolf
Golunar/Unary is a way to encode all valid Brainfuck programs, but it is not an enumeration, since most natural numbers do not correspond to a valid program. For the purpose of this challenge, assume a doubly infinite tape and no comments, i.e., a Brainfuck program is valid if and only if it consists solely of the char...
stackexchange_codegolf
Write a program that outputs the exact string: jan ale o, toki! ("Hello, world" but in toki pona to prevent builtins.) with an optional trailing newline. Additionally when all copies of any one byte present in your program are removed the program must fail to produce a correct output no matter what byte is selected. T...
stackexchange_codegolf
Given a map from arrays of integers of same size to single integers, determine if there is a set of indices such that the output is equal to the maximum of the elements at those indices for every corresponding pair. You can take the input as a map if your language support, arrays of pairs, separated 2D array of input a...
stackexchange_codegolf
Tic-Tac-Latin! This is a true story, so names have been altered. My latin teacher, Mr. Latin, created his own proprietary (no joke) tic tac toe variant. Let's call it tic-tac-latin. The game is simple, it is essentially tic tac toe played on a four by four grid. Formal rule declaration A line is either a row, column o...
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
Now that I'm thoroughly addicted to Code Golf, it's probably about time that I try to pick up a few golfing languages. Given that I play almost exclusively in JavaScript, Japt seems like the logical language to start with. I'll be diving into the documentation at the next opportunity I get but, in the meantime, please ...
stackexchange_codegolf
The majority function is a boolean function which takes three boolean inputs and returns the most common. For instance if maj(x,y,z) is the majority function and T denotes true and F denotes false then: maj(T,T,T) = T maj(T,T,F) = T maj(T,F,F) = F maj(F,F,F) = F This question concerns writing boolean functions as comp...
stackexchange_codegolf
Make a snake fill any maze (until it gets stuck). The snake The snake starts at a given starting point, pointing EAST. It moves by always having a wall or a part of its body immediately to the LEFT of its head ("left-hand rule wall follower"), until it gets stuck because all four directions around its head are occupied...
stackexchange_codegolf
At a party, I was introduced to the game LCR. Now it's not a great game as there's no skill but only random chance. But it got me thinking, I could code this, and I made a quick program in R to model the game. Rules of the game modified from Wikipedia to match how we played: Each player receives at least 3 chips. Pla...
stackexchange_codegolf
Rotonyms 1 ROT13 ("rotate by 13 places") is a simple letter substitution cipher that replaces a letter with the 13th letter after it, in the alphabet. So, A becomes N, N becomes A, B <-> O, and so on to M <-> Z. ROT13('abcdefghijklmnopqrstuvwxyz') == 'nopqrstuvwxyzabcdefghijklm' A "Rotonym" is a word (pair) that ROT...
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
Background A polyhex of size \$n\$ is a contiguous shape made from joining \$n\$ unit regular hexagons side-by-side. As an example, the following image (from Wikipedia) contains all 7 distinct tetrahexes (polyhexes of size 4): A dihex is a polyhex of size 2. Now, let's define a sticky polyhex as follows: A single dih...
stackexchange_codegolf
Task: Given the area of a triangle, find a Heronian triangle with that area. Any Heronian triangle with the specified area is allowed. A Heronian triangle is a triangle with integer sides and integer area. By Heron's formula, a triangle with sides lengths a,b,c has area sqrt(s*(s-a)*(s-b)*(s-c)) where s=(a+b+c)/2 is ...
stackexchange_codegolf
Write a function or program that, when given a list of names, outputs or returns a list where duplicates of given names have a unique shortened version of their surname. Input: A list of names, where a name is defined by a given name and a last name separated by a space. Names are non-empty strings containing only upp...
stackexchange_codegolf
A triangular number is a number that can be expressed as the sum of consecutive positive integers, starting at 1. They can also be expressed with the formula n(n + 1) / 2, where n is some positive integer. A number's digitangular counterpart is calculated in the following way: Split a number into an array of its digit...
stackexchange_codegolf
Given some raw HTML, sanitize it by formatting the spaces, as defined below. Output rules: Like many challenges, this one is inspired by XKCD. First, "untag" all tags with nothing but spaces in them. (<i>te<b> </b>xt</i> becomes <i>te xt</i>). If a tag has nothing in it (like <b></b>, simply delete it and move o...
stackexchange_codegolf
Given an input of a string, output the partial fraction in string form. The partial fraction decomposition of a rational fraction of the form \$\frac{f(x)}{g(x)}\$, where \$f\$ and \$g\$ are polynomials, is its expression as: $$\frac{f(x)}{g(x)}=p(x)+\sum_j\frac{f_j(x)}{g_j(x)}$$ In this case \$p\$ is 0, because we ass...
stackexchange_codegolf
Your challenge is simple: write as long of a pristine program as possible in the language of your choice using only unique bytes. (The full definition of a pristine program, copied from that link, is at the bottom of this question.) That's right, no strings attached. Your code doesn't have to do anything at all, just r...
stackexchange_codegolf
The Jaccard index / similarity coefficient, also known as the Tanimoto index / coefficient, is a statistic used for gauging the similarity and diversity of finite sample sets. It was developed by Grove Karl Gilbert in 1884 for the field of weather forecasting [1] and later independently developed by Paul Jaccard [2] wh...
stackexchange_codegolf
Getting the average of a list (e.g [2,6,7]) Get the length of the list: [2,6,7] -> 3 Sum the numbers in the list: 2 + 6 + 7 = 15. Divide the sum by their count: 15 / 3 = 5. You should compare the averages of two lists of positive integers N and M, by returning a value if N has a higher average, another value if M ha...
stackexchange_codegolf
Consider a non-empty binary matrix M and a natural number n. For the purposes of this challenge, M is said to have blockiness n if it can be built using adjacent square blocks of size n, where each block has equal entries; and it cannot be formed using square blocks of any larger size. Intuitively, n can be thought of ...
stackexchange_codegolf
Given an ASCII art with simple closed paths using | and - (pipes and dashes), output a random point inside the boundary. Eg. given: ---- ---- | |- --- => |12|- --- | | | | |345| |6| ----- --- ----- --- Any point 1-6 should have an equal probability of being printed. Specs T...
stackexchange_codegolf
Given a string as an input (which can be any acceptable/convenient format in your language), implement pendulum encoding. The test cases are split into individual items (which aren't quoted) for a visually appealing explanation. How do I do that? The current iteration index starts at 0. If the iteration index is even,...
stackexchange_codegolf
You are a traveller crossing the desert between two towns. You cannot carry enough water to get across without stopping. This is a variation of a classic puzzle. The Rules A desert looks like this: a WxH grid of mostly empty space. The space marked S is where you start, E is where you want to end, and a square marked w...
stackexchange_codegolf
The challenge Find the smallest feedforward neural network such that, given any 3-dimensional input vector \$(a,b,c)\$ with integer entries in \$[-10,10]\$, the network outputs the largest (i.e., "most positive") root of the polynomial \$x^3+ax^2+bx+c\$ with error strictly smaller than \$0.1\$. Admissibility The notion...
stackexchange_codegolf
As we saw in this question complex logical statements can be expressed in terms of the simple connectives of generalized Minesweeper. However Generalized minesweeper still has redundancies. In order to avoid these redundancies we define a new game called "Generalized-1 Minesweeper". Generalized-1 Minesweeper is a vers...
stackexchange_codegolf
Note: This challenge only allows answers in compiled languages Task Your task is pretty simple, make two different programs that when compiled result in the same output. Scoring Here is where the fun comes in. Your score will be the number of unique bytes present in exactly one program. For example if your two progra...
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
This is a code-shuffleboard answer-chaining challenge, where the answers will aim to, together, output the lyrics to this beloved 80s song. This is the full lyrics of the song, line by line. The first answer will contain a program that will output the first line of the song (We're no strangers to love). The second wil...
stackexchange_codegolf
Given an integer greater than 1, output the number of ways it can be expressed as the sum of one or more consecutive primes. Order of summands doesn't matter. A sum can consist of a single number (so the output for any prime will be at least 1.) This is code-golf. Standard rules apply. See this OEIS wiki for related i...
stackexchange_codegolf
(no, not those ones) The Challenge You'll be given two inputs. The first is a positive integer n > 0, which is used to output an n x n right triangle of the numbers 1, 2, 3, ... n. This triangle starts in a corner and increases horizontally and vertically by one and diagonally by two. See examples below for clarificati...
stackexchange_codegolf
User inputs an integer. Print out proper fractions using all positive integers up to the user's input, in ascending order. Rule 1: Eliminate equal fractions. Rule 2: Fractions should be in their simplest form. Rule 3: Use "/" as a fraction symbol and next line (\n or \r as convenient) as a separator between fractions. ...
stackexchange_codegolf
As a little kid, I liked to play with these toys a lot: They probably intended for these to be used for art, but I always used them for math! Fractals, patterns, etc. One time, I was given this challenge: Build a triangle without using any of the green triangle tiles. This challenge stumped me for the longest time, ...
stackexchange_codegolf
Given an array of positive integers in base 10, where n > 0, output their representation of a binary wall. How does this work? Convert each number to its binary representation. Pad the representation with leading zeroes to the length of the longest one i.e. 1, 2 -> 1, 10 -> 01, 10. Create a wall where the 1s are brick...
stackexchange_codegolf
Task Given an array of positive integers, replace each element with the parity of the sum of the other elements. The array is guaranteed to have at least 2 elements. Definition Parity: whether a number is odd or even. Example For the array [1,2,3,1]: Replace 1 with the parity of 2+3+1, i.e. even. Replace 2 with the ...
stackexchange_codegolf
A screen consists of some LED segments like such: The screen can be split into several(maybe one) component. Each component is a segment like above, with varying lengths. These components can be used to display any amount, including 0, of digits, as long as the component is large enough. Every digit except 1 needs two...
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
Find a bijective function which maps integers to arbitrarily large tuples of integers. Given the input \$n\$, output the tuple it matches to. Edit: The empty tuple is included in the mapping.
stackexchange_codegolf
Input: binary string Output: binary string that represents the binary input + 1 Example: Given 10111 as an input, output 11000 Limitations: Can't use arithmetic operators or functions (like + - * /) Criterion: code-golf, the shortest code wins the big imaginary award.
stackexchange_codegolf
Create a program that can create a randomly arranged maze (The path of the maze changes each time) with exactly 1 exit and one enterance and a minimum size of 8x4 and max size of 32x32, with the exact dimensions x and y as input Submissions can be original code, but to score higher add onto a submission with another la...
stackexchange_codegolf
Introduction Each Unicode codepoint can be represented as a sequence of up to 4 bytes. Because of this, it is possible to interpret some 2, 3, or 4-byte characters as multiple 1-byte characters. (See here for a UTF-8 to bytes converter). Challenge Given a UTF-8 character, output it split into a sequence of 1-byte chara...
stackexchange_codegolf
Introduction: Apparently I keep coming up with word search related challenges lately. :) When I do the word search in the Dutch news paper, some words are very easy to find because they contain letters that aren't too common in Dutch words, like x or q. So although I usually look for the first letter or prefix of a wor...
stackexchange_codegolf
Lost is a 2-Dimensional programming language where the instruction pointer starts at a random location, moving in a random direction. A description of the language can be found at the bottom of the post for completeness' sake and a tutorial for the language can be found in the above link. The task here is simple to de...
stackexchange_codegolf
Create a function which takes in a input integer and then returns the number of factors it has, like if you pass 25 then it will return 3 since it has 3 factors i.e. 1,5,25. Challenge: Make the fastest and the smallest code!
stackexchange_codegolf
Create a Markov Chain generator, which generates (and outputs) an Order 4 text chain. It must be able to support all plain text formatting used on this question, so be sure to check for punctuation (parentheses count for example, but HTML doesn't need to be accounted for fortunately)! You could even use this question i...
stackexchange_codegolf
Consider a word/string of length \$n\$, only including the letters A-Z, a-z. A word/string is a double prime word if and only if n is prime and the sum of the letters, s, is also prime, using their numeric position in the alphabet (a=1, B=2, c=3, etc.). Input can be any combination of upper or lower case alphabetic cha...
stackexchange_codegolf
Challenge: To take two points on the plane and figure out the position of the point that's a) on the line that connects them, and b) equally distant from each of the original points. Example: (0,0), (3,3) -> (1.5,1.5) (-1,-1), (1,1) -> (0,0) (-7,3), (2,-2) -> (-2.5,0.5) (3, 1), (-5,9) -> (-1,5) Rules: The input an...
stackexchange_codegolf
Task: Return an array with all possible pairs between the elements of an array. Example From a=["a", "b", "c", "d"]; return b=[["a","b"],["a","c"],["a","d"],["b","c"],["b","d"],["c","d"]]. Pairs can be in any order as long as all possible combinations are included and obviously ["b","d"] is the same to ["d","b"]. Inpu...
stackexchange_codegolf
Background A super-prime is a prime number whose index in the list of all primes is also prime. The sequence looks like this: 3, 5, 11, 17, 31, 41, 59, 67, 83, 109, 127, 157, 179, 191, ... This is sequence A006450 in the OEIS. Challenge Given a positive integer, determine whether it is a super-prime. Test Cases 2: f...
stackexchange_codegolf
The challenge The plastic number is a number related to the golden ratio, with many interesting mathematical properties. As such, there are many approaches that can be used to calculate the number. In order to precisely specify the number for the purposes of this challenge, we'll use the following definition (although ...
stackexchange_codegolf
Challenge Winter is fast approaching with many places receiving the first layers of snow for the 15/16 season, so why don't we break out the snow machines and code ourselves some snow? Given a integer n via STDIN, output an ASCII representation Beta's snowflake (as described below) at level n. Beta's Snowflake The snow...
stackexchange_codegolf
Write a program or function that, when given n, will print a spiral n characters long made up of the Latin alphabet ABCDEFGHIJKLMNOPQRSTUVWXYZ repeated as needed. This spiral should run through the alphabet only forwards. Related to Alphabet Spiral, though the spiral runs through the alphabet forwards and backwards, an...
stackexchange_codegolf
Given some raw HTML, sanitize it by formatting the spaces, as defined below. Output rules: Like many challenges, this one is inspired by XKCD. First, "untag" all tags with nothing but spaces in them. (<i>te<b> </b>xt</i> becomes <i>te xt</i>). If a tag has nothing in it (like <b></b>, simply delete it and move o...
stackexchange_codegolf
Introduction You have gotten a job as the minister of finance in your made-up country in your back yard. You have decided to make your own bank in your country for you and your less trustworthy friends. Since you don't trust your friends, you have decided to write a program to validate all transactions to stop your fri...
stackexchange_codegolf
The subfactorial or rencontres numbers (A000166) are a sequence of numbers similar to the factorial numbers which show up in the combinatorics of permutations. In particular the nth subfactorial !n gives the number of derangements of a set of n elements. A derangement is a permutation in which no element remains in the...
stackexchange_codegolf
This is the robbers' thread to a cops-and-robbers challenge. Click the link to find the cops' thread. In the cops' thread of this challenge, answerers will be writing programs which output two numbers, \$x\$ and \$y\$. As robbers, your goal will be to crack their submissions. To do this, you find a program in the ...
stackexchange_codegolf
Code-Golf caddy Eddie Brackets was getting tired of quine challenges, which appeared to be much too easy for the grand poobahs. He has this idea to spice up things and is sending quines to the car crusher. Challenge: Write a quine that prints itself "squeezed" for output purposes into an n x n square followed by that s...
stackexchange_codegolf
Based on How high can you count? let us give an advantage to the polyglot people. Challenge: Your task is to write as many programs / functions / snippets as you can, where each one outputs / prints / returns an integer. The first program must output the integer 1, the second one 2 and so on. You can not reuse any char...
stackexchange_codegolf
The purpose of this challenge is to graphically depict a walk on the plane, where the direction of each step \$k\$ is determined by the primality of \$k\$ and the parity of its binary expansion. Specifically, Initial direction is fixed, say North. All steps have the same length. The direction of step \$k\$ can be Nort...
stackexchange_codegolf
Task Take the (integer) number of human years that the dog has lived, \$n\$, as input and return its age in dog years, \$d\$, to two decimal places. The number of human years, \$n\$, will be between \$1\$ and \$122\$ inclusive: \$n \in [1,122], n \in \Bbb{N}\$. According to BBC's Science Focus Magazine, the correct fun...
stackexchange_codegolf
A sequel to What dice do I need to display every integer up to X? Numbers are great, but let's take it to the next level. I'd like to have a set of dice that can be arranged and rotated to display any words I want. Think Boggle: And not just that; I want to specify the number of sides those dice have. The set should c...
stackexchange_codegolf
Sum of squares Goal: Write a given natural number as sum of squares. Thanks to Lagrange, Fermat and Legendre we know that you can write any positive integer as sum of (one), two, three, or maximal four squares of integers. Your task is to write a program/function which takes a natural number via stdin/argument and outp...
stackexchange_codegolf
As of ECMAScript 2015, JavaScript has 33 reserved keywords, such as break, const and new, as well as 10 future reserved keywords, such as let and await. Your task is to chain together the largest number of consecutive1 distinct reserved keywords2 while writing functional JavaScript code3. Consecutive reserved keywor...
stackexchange_codegolf
Given two positive integer fractions \$x\$ and \$y\$ such that \$x < y\$, give the fraction \$z\$ with the smallest positive integer denominator such that it is between \$x\$ and \$y\$. For example \$x=2/5\$, \$y=4/5\$, the answer is \$1/2\$. Other fractions such as \$3/5\$ are also in between the two, but \$1/2\$ has...
stackexchange_codegolf
Background From Wikipedia: An Egyptian fraction is the sum of distinct unit fractions. That is, each fraction in the expression has a numerator equal to 1 and a denominator that is a positive integer, and all the denominators differ from each other. The value of an expression of this type is a positive rational number ...
stackexchange_codegolf
In Dungeons & Dragons 5th edition (as well as most other editions), there exists a magic item called the Deck of Many Things. It is an incredibly powerful item, as the cards all have very strong positive or negative effects. To use the deck, a character declares a number, and then draws up to that number of cards, with...
stackexchange_codegolf
An Abecedarian Word is a word whose letters are in alphabetical order. Your goal is to write a program that outputs all abecedarian words from a given lexicon. Rules: Standard Loopholes are forbidden. If a word contains punctuation, diacritical marks, or any characters other than ASCII alphabet characters (A-Za-z), r...
stackexchange_codegolf
There is a 3x3 square block made of 1x1 square blocks, with coins in each 1x1 block, starting from top left block you want to collect all the coins and return to top left block again, if possible provide instructions to achieve this. Rules From block \$(x,y)\$ in one step you can move right(R) to \$(x,y+1)\$ ,left(L) ...
stackexchange_codegolf
...so this is a challenge to make me a tree. Produce a program or function called tree which takes a single integer argument, N and draws a Pythagorean Tree N levels deep, where level 0 is just the trunk. Each junction of the tree should place the vertex of the triangle at a random point on the perimeter (this point sh...
stackexchange_codegolf
You are a secret agent trying to communicate with your fatherland. Of course the information needs to be hidden so no one eaves drops your message. What would be better suited than a cat? Everyone loves funny pictures of cats [citation needed], so they won't suspect secret information hiding in there! Inspired by the ...
stackexchange_codegolf
Your challenge is to implement a cyclic Program Sequence Generator (PSG) in a language of your choice. Given a language, L, a PSG in L is a program in L that outputs a PSG in L. Some properties of a PSG are: Repeated execution of a PSG in L generates a sequence of programs in L. A PSG is said to be cyclic if the seque...
stackexchange_codegolf
I noticed a certain game had a peculiar life counter, which instead of stopping at 999, gained a new digit – the next number was crown hundred or 00. After 99 came crown hundred crownty (0) and the last number, after 9, was crown hundred crownty crown or , which would be 1110 in decimal. Your task is to write a program...
stackexchange_codegolf
Challenge Given a number, x where -1 ≤ x ≤ 1, and the integers a and b, where b > a, solve the equation sin(θ) = x for θ, giving all solutions in the range a° ≤ θ ≤ b°. Rules x will have a maximum of three decimal places of precision. The output, θ, must also be to three decimal places, no more, no less. Your output ma...
stackexchange_codegolf
Given: a width, a height, and a set of sets of points. Output: An image where each set of points is connected and colored in (like a shape). Each shape must be a different color from all of the other shapes, but the actual color doesn't matter as long as each color is distinct. The shapes must be in order; whether you ...
stackexchange_codegolf
Most of us are probably familiar with the concept of triangular and square numbers. However, there are also pentagonal numbers, hexagonal numbers, septagonal numbers, octagonal numbers, etc. The Nth Nagonal number is defined as the Nth number of the sequence formed with a polygon of N sides. Obviously, N >= 3, as th...
stackexchange_codegolf
For this challenge, a list is considered valid if and only if it consists entirely of integers and valid lists (recursive definitions \o/). For this challenge, given a valid list and an integer, return a list of all depths at which the integer can be found. Example Let's consider list [1, [2, [3, [1, 2, 3], 4], 1], 1] ...
stackexchange_codegolf
There was a prior question about golfing an HQ9+ compiler that translates HQ9+ code into the language it is written in, but that was closed as a duplicate of the interpreter challenge because converting an interpreter to a compiler is seen as trivial. This question is based on the closed one, but has some changes. Writ...
stackexchange_codegolf
A friend of mine challenged me to write a function that works with both of these scenarios add(1,2) // 3 add(1)(2) // 3 My instinct was the write an add() function that returns itself but I'm not sure I'm heading in the right direction. This failed. function add(num1, num2){ if (num1 && num2){ return num...
stackexchange_codegolf
Help! Here is my good friend Mr. Snowman: \(.,.) < Hello! ( : )> He is an amazing dancer, but he tends to get stage fright. He knows all the moves, but just needs someone to tell him which moves to do. Here are all of his moves: Arms Up \(.,.)/ ( : ) Arms Down (.,.) <( : )> Right Arm Up \(.,.) ( : )> Left Arm Up ...
stackexchange_codegolf
33 is a simple esolang I created. You may have seen me use it in a few questions. You're not going to be writing a full interpreter. The interpreter you will be writing is for a simplified version of 33. This simplified 33 has two numeric registers: the accumulator and the counter. The accumulator holds all the post-ar...
stackexchange_codegolf
Y'know, we've had a lot of "alphabet" challenges recently. (one two three four five.) While I love a good challenge, and those challenges were very fun, I think it's time for a change of pace. We need to exclude such challenges in the future. It's time for automation! You're going to find some alphabets for me, and for...
stackexchange_codegolf
The lambda calculus is a system of functional programming. Lambda calculus consists of variables, abstractions, and applications. A variable is simply a name denoting a function parameter. It is a single letter. An abstraction is a "function literal" of sorts, it consists of a backslash \ followed by a variable name, a...
stackexchange_codegolf
Based off a Scratch project The pen extension in Scratch has a set pen color to () block. The () is normally a color dropdown, but you can also use the join()() block. In the join()() block, normally a hex value is in the first input, but the second is just an empty string. However, many new Scratchers that want to t...
stackexchange_codegolf
The worst part about long lines or code or math equations are the parentheses. Nobody wants to read through 2x(3y+4*abs(x^[2*e^x])-5{3(x+y)-5})! So, the goal of this challenge is to make it at least slightly easier to read these parentheses-filled beasts! For the above math equation, the output should be: 2x ( 3y+4*a...
stackexchange_codegolf
Background In Bejeweled and similar games, the player must swap any two adjacent gems (no diagonals) in an 8x8 grid of gems in order to match three of the same color in a row. The gems can be matched horizontally or vertically. Gameplay continues until there no move exists that can be made resulting in three in a row, ...
stackexchange_codegolf
Russian roulette It's Russian roulette! The rules are simple. Shoot a revolver with n slots for bullets and one round inside at your head and you might not die! This Question is different from other Russian roulette questions because it takes input to change the chance of exiting with an error. Task: Make a program tha...
stackexchange_codegolf
Prompt: You are given two sets of XY coordinates along with two angles (all are floats): X1 Y1 A1 X2 Y2 A2. The angles are relative to world coordinates: 0 being straight up or north and going clockwise. Your program or function has to return a set of two floats of the XY coordinates the two angles cross at. Example: ...
stackexchange_codegolf
Maximillian is the chief commander of the Great Greek Army and he is leading his forces into a crucial war with Spain. If all the enemy soldiers stand in a straight line incrementally marked starting from position 1, and a particular soldier at position \$i\$ dies, the soldiers at position \$2i\$ and \$2i+1\$ die as we...
stackexchange_codegolf
Introduction cowsay is a Unix command made by Tony Monroe, written in Perl. It outputs a picture of a cow saying given text. For example: ________________________ < Typical cowsay output! > ------------------------ \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | ...
stackexchange_codegolf
You step into the restroom, and notice that the toilet paper has missing! It occurs to you that someone had stolen it. Strangely enough, the first thing you would like to know is the amount of toilet paper the thief stole. Task You are given three integers \$ I \$, \$ R \$, and \$ G \$, the details of the toilet paper,...
stackexchange_codegolf
Background Supplementary reading 1, Supplementary reading 2 Linear lambda calculus is a limited form of lambda calculus, where every bound variable must be used exactly once. For example, \a b c d e -> a b (d c) e is a valid term in linear lambda calculus. When embedded as a logic system, this enforces each input to be...
stackexchange_codegolf
Based off a Scratch project The pen extension in Scratch has a set pen color to () block. The () is normally a color dropdown, but you can also use the join()() block. In the join()() block, normally a hex value is in the first input, but the second is just an empty string. However, many new Scratchers that want to t...
stackexchange_codegolf
If we take the natural numbers and roll them up counter clock-wise into a spiral we end up with the following infinite spiral: ....--57--56 | 36--35--34--33--32--31--30 55 | | | 37 16--15--14--13--12 29 54 | | | | | 38 17 ...
stackexchange_codegolf
Not an interpreter. Arguably a compiler. But I'm talking about a transpiler. It can be in any language, but it must return js-valid arrow notation code. The λ-calculus string would be passed as an argument to a function, or the whole program, and in some way the program would return/log/print the string with the js-not...
stackexchange_codegolf
I need to construct a functor that iterates over the linear representation of a sub-lattice of size \$d_x,d_y,d_z,d_q\$ embedded in a lattice of size \$n_x,n_y,n_z,n_q\$. The sub-lattice corner is shifted by \$(l_x,l_y,l_z,l_q)\$. Since the functor can be called million of times, the goal is to produce the most effici...
stackexchange_codegolf
Given two positive integers \$n\$ and \$b\$, such that \$n > 2\$ and \$n > b > 1\$, count the trailing zeros when converting \$n\$ to base \$b\$. Your program should be able to handle any value of \$b\$ within your integer maximum. The digits of \$n = 18\$, \$b = 3\$ are \$[2,0,0]\$, so the correct output is \$2\$. T...
stackexchange_codegolf
I am currently working on a golfing language. Do you have any suggestions for this language? What are some helpful features of a good golfing language? What features do you find useful? Do you suggest a language based on variables, stack(s), tapes, registers, etc? As usual, please post separate tips in separate answers...
stackexchange_codegolf
Create a function that accepts a list of dates (unsorted with possible duplicates) and returns the days of the week in one of the following formats: A format similar to MTWTFSS or SMTWTFS (i.e. beginning with Monday or Sunday), with non-days replaced by an underscore _, illustrated below. WEEKDAY if all the dates are ...
stackexchange_codegolf