instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Over is a higher-order function in multiple languages such as APL (⍥). It takes 2 functions and 2 values as arguments, applies the first function to both values, then applies the second to their result. For example, using ⍥ to represent Over: 1 ²⍥+ 2 We would first calculate ² of each argument: 1² = 1 and 2² = 4. We t...
stackexchange_codegolf
A few month back, I made a language called ;# (Semicolon Hash) and it started a little bit of a craze (it even got its own tag, as you can see). But, as with everything, the craze died down, and questions related to it stopped being posted. However, a few people were annoyed at the lack of capability of ;# and this lea...
stackexchange_codegolf
Cops thread (read first) Robbers, your task is to find a Shue program p that when given the cops input i, outputs a program h, which outputs "Hello Shue!". The length of your p has to be less than or equal to the length of the cop's p. The robber with the most cracks wins.
stackexchange_codegolf
In Excel, the columns range from A-Z, AA,AB,AZ,BA,..,BZ and so on. They actually each stand for numbers, but rather are encoded as alphabet strings. In this challenge, you will be given a string of alphabets, and you must calculate the column it corresponds to. Some tests: 'A' returns 1 (meaning that it is the first c...
stackexchange_codegolf
When I see code-golf entries that knock a few characters off, whittling down the code, I go look at the edit history for a side-by-side diff. See and learn :) This challenge is to make a program that produces the prettiest animated diffs. The input will be any ordered series of text versions. The program may be writt...
stackexchange_codegolf
A short while, ago, @daniel_ernston sent the following challenge to @StackCodeGolf on Twitter: @StackCodeGolf Your task is to build a program that uses the API of your choice to tweet its own source code. Shortest code wins, of course.
stackexchange_codegolf
J-uby is the Language of the Month for June 2022, so I'm looking for tips for golfing in it. As usual, please post one tip per answer, and avoid general tips such as "remove whitespace" or "avoid comments".
stackexchange_codegolf
Background At the time of writing this, the P vs NP problem is still unsolved, but you might have heard of Norbert Blum's new paper claiming proof that P != NP, which is already suspected to be erroneous (but we will see). The problem discussed in this paper is the clique problem. At least that's what I read in a newsp...
stackexchange_codegolf
Write a program which determines if a given number is prime. The catch: No digits or arithmetical operators. This means: No digits from 0 to 9, anywhere in the program, and whatever the meaning No using any built-in operators for addition (and incrementing), subtraction (and decrementing), multiplication, division, ex...
stackexchange_codegolf
In this challenge, bots must survive as long as possible. In each turn, the bot with the most HP is eliminated. This challenge is inspired by the Smallest unique number KoTH. Results After 100,000 rounds: Jack: 63390 The Follower: 4942 The Algorithm: 2452 The Randomiser: 140 Toe Tipping: 0 EZ: 0 The Average: 0 LowProfi...
stackexchange_codegolf
Given a base \$k\$ as well as two indices (also passed in base \$k\$, call them \$s\$ and \$e\$) return a list containing a frequency count of all base-\$k\$ digits occurring between \$s\$ and \$e\$ inclusive. For example, upon input \$k = 10, s = 1, e = 10\$, we would return the list \$[0: 1, 1: 2, 2: 1, 3: 1, 4:1, 5:...
stackexchange_codegolf
Let's define a self-contained number as a positive integer, whose digits appear in runs of length equal to themselves only. In other words, any decimal digit d (excluding 0) occurs only in runs of length exactly d. Task You can choose any of the three methods listed below: Given an integer n, output the nth (either 0 ...
stackexchange_codegolf
As a follow up to my previous challenge Count to 20 with Words!, we will once again be using the word list from that challenge to perform another task. This time, you will be exclusively using: https://github.com/Magic Octopus Urn/wordListsByLength/blob/master/10.txt To choose 26 different words, each starting with a u...
stackexchange_codegolf
Given the measures of two of the interior angles of a triangle (x and y; the other angle can be easily calculated with 180 - x - y), draw a line segment that cuts this triangle into two isosceles triangles. You need to output the angle measures of both of your triangles. However, because the base angles are the same, y...
stackexchange_codegolf
The challenge: compute the day of the week from a MM-DD representation of a day in this year (2021). However, you have to write your program in the following subset of Python: (I chose Python because it's popular and easy to understand even to the people who doesn't know the language. Obviously you can use another prog...
stackexchange_codegolf
Try to create a simple ASCII art scissors animation! Challenge All inputs will be integers -31 through 31. The output will be an animation (To be outputted somewhere, as long as the previous frame is replaced. GIFs are allowed.), separated by (approximately) 1 quarter of a second. If the input (n) is positive: The ani...
stackexchange_codegolf
In the poker game there are 1277 unique 'High Card' ranks. It's 1287 (13 over 5) if we include all straights. The challenge is to write a function which returns an integer value corresponding to the rank of each 'High Card' poker combination including all straights. Possible cards are(in ascending order): '23456789TJQK...
stackexchange_codegolf
Domain name trading is big business. One of the most useful tools for domain name trading is an automatic appraisal tool, so that you can easily estimate how much a given domain is worth. Unfortunately, many automatic appraisal services require a membership/subscription to use. In this challenge, you will write a si...
stackexchange_codegolf
Write a program that takes two lists of strings and generates a javascript regex that fully matches all the strings in the first list and matches none of the strings in the second list. To be specific when for all stings in the first list str.match(/[your-output]/) must produce a match for the full string and for all s...
stackexchange_codegolf
Robber's thread Your task as cops is to select three things: A programming language An OEIS sequence A byte set You are then to secretly write a program in that language that computes the nth term sequence using only the bytes in the set. You will reveal the three pieces of information so that robbers can try to f...
stackexchange_codegolf
Given a text input such as: THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG render the following output: /\ \ \ / \ / /\/ / / /\ / / / / ...
stackexchange_codegolf
Given a date written in any (must handle all in the same program) of the following formats, parse it into a valid yyyy/mm/dd date. 17th May 2012 March 14th, 2016 20 February 2014 September 14, 2017 Sunday, June 8, 2015 Rules Dates will sometimes be invalid, ie. incorrect day for the month or number of months in a yea...
stackexchange_codegolf
Earlier this week, we learned about how to format esoteric languages for commenting. Today, we're going to do the inverse of that. I need you to write a program or function that parses some well-commented esoteric code and parses the comments out, returning just the code. Using some examples from the previous challenge...
stackexchange_codegolf
Given a ragged list of positive integers return a full cycle of recursive rotations starting with the unchanged input and ending with the state immediately before revisiting the initial state. Examples: [[2,3],4,5,5] -> [[2,3],4,5,5] , [4,5,5,[3,2]] , [5,5,[2,3],4] , [5,[3,2],4,5] [1,10,[2,2,4],6,[[5,6],7],1] -> [1,10...
stackexchange_codegolf
Your task is to output a square sandbox of size n+2 with / characters in the corners and | for the sides, and - for the top, with n**2 layers of sand (.) overflowing out of the sandbox of width n+2 Testcases 1 -> /-/ |.| /./ ... 2 -> /--/ |..| |..| /../ .... .... .... .... 3 -> /---/ |...| |...| |...| /.../ ..... ......
stackexchange_codegolf
Background You may be aware that periods in between letters in gmail addresses are ignored. Email sent to example@gmail.com, exam.ple@gmail.com, and e.x.a.m.p.l.e@gmail.com all end up in the same place! This is a great way to have multiple different emails addresses for things like signing up for free trails, or filter...
stackexchange_codegolf
Objective: The task is to create a chatbot with whom you can spend your time discussing your deepest thoughts with. Create a chatbot with an AI that learns from your input. Your bot should inspire you to releave your darkest inner truths. Inspiration: http://en.wikipedia.org/wiki/Chatterbot http://io9.com/5901579/10...
stackexchange_codegolf
This is Fortnightly Challenge #6. Theme: Language Design There's a chatroom for this challenge. Come and join us if you want to discuss ideas! And now for something completely different... This fortnight, we want to experiment with a new type of challenge. In this challenge, you will be designing a language! Pattern ...
stackexchange_codegolf
You will be given a point (x,y) relative to the center of the Ulam spiral (the center being the point which represents one), and length z. The task is to check whether there exists a path from (0,0) to (x,y) of length z, assuming prime numbers are obstacles and each turn in path has an angle of 90 degrees. Path may not...
stackexchange_codegolf
Challenge Your program needs to take an input of a string, where the string has only letters, no special characters, no numbers, and no accents (they look all weird). Then, your program should output a superscript version. Example Input: hello world Output: ʰᵉᶫᶫᵒ ʷᵒʳᶫᵈ Test Cases hello - ʰᵉᶫᶫᵒ code - ᶜᵒᵈᵉ golf - ᵍᵒᶫᶠ a...
stackexchange_codegolf
Inspired by a recent Daily WTF article... Write a program or function that takes a GUID (string in the format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX, where each X represents a hexadecimal digit), and outputs the GUID incremented by one. Examples >>> increment_guid('7f128bd4-b0ba-4597-8f35-3a2f2756dfbb') '7f128bd4-b0ba-45...
stackexchange_codegolf
Related: Ellipse circumference Introduction An ellipsoid (Wikipedia / MathWorld) is a 3D object analogous to an ellipse on 2D. Its shape is defined by three principal semi-axes \$a,b,c\$: $$ \frac{x^2}{a^2} + \frac{y^2}{b^2} + \frac{z^2}{c^2} = 1 $$ Just like an ellipse, the volume of an ellipsoid is easy, but its surf...
stackexchange_codegolf
My boss* does not understand why her programmers react negatively to users changing program requirements. Help her understand! On every answer, create a new requirement. Then, write a program/function that solves that requirement and all prior requirements, while in a new programming language. Examples User 1 posts the...
stackexchange_codegolf
Background As noted in the PPCG challenge Compress a maximal discrepancy-2 sequence – which inspired this challenge – the authors of the paper Computer-Aided Proof of Erdős Discrepancy Properties found a maximal discrepancy-2 sequence, namely -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, ...
stackexchange_codegolf
Task Everyone knows the game "Tic-Tac-Toe". Your task is it, to evaluate an ascii tic-tac-toe matchfield. Your Programm/Function should output/return the winner: O, X or nobody (N). Pattern X|O|X O|X|O O|O|X In this case your programm/function should output/return 'X' Rules Input can come from STDIN, function argumen...
stackexchange_codegolf
Task Given a matrix, your program/function should output a row-equivalent matrix in checkerboard form ( \$A_{ij}=0\$ if and only if \$i+j\$ is odd). Two matrices are defined to be row-equivalent if and only if one can be obtained from the other by a sequence of elementary row operations (EROs), where each ERO consists ...
stackexchange_codegolf
In golf, the standard scratch of a course is calculated using this formula: (3*num_of_3_par_holes + 4*num_of_4_par_holes + 5*num_of_5_par_holes) - difficulty_rating Your task is to calculate the standard scratch of a golf course, given these 4 inputs. You should take input in any standard form in the format [num_of_3_...
stackexchange_codegolf
Bobby's booby-trapped safe requires an n-digit code to unlock it. Alex has a probe which can test combinations without typing them onto the safe. The probe responds Fail if no individual digit is the same as that in its corresponding position in Bobby's code. Otherwise it responds Close, including when all digits are c...
stackexchange_codegolf
Given a BF program consisting of only the characters +-[]<>., with the property that there's an equal number of < and > between every matching pair of []. You have to find the shortest program that can be achieved with the optimal memory layout (by rearranging the cells on the tape). If there are multiple such programs...
stackexchange_codegolf
Given a word (or any sequence of letters) as input, you must interpolate between each letter such that each adjacent pair of letters in the result is also adjacent on a QWERTY keyboard, as if you typed the input by walking on a giant keyboard. For example, 'yes' might become 'ytres', 'cat' might become 'cxzawert'. Rule...
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
Given a list of positive integers, partition the list into two sublists such that the absolute value of the difference of the sums over the two sublists is minimal. The output of the program should be the (non-negative) difference of these sums. Examples: [1,2,3] -> 0 # [1,2], [3] [2,3,5,7,11] -> 0 # [2,5,7], ...
stackexchange_codegolf
Let's play a one-player game called jump the array. To play, you only need an array of integers, say a. You start at some position i, and on each turn, you jump to a new position. On turn n, if n is even, you jump to the absolute position a[i] mod length(a), if n is odd, you jump to the relative position (i + a[i]) mo...
stackexchange_codegolf
Given a positive integer \$n\$, your task is to find out the number of partitions \$a_1+a_2+\dots+a_k=n\$ where each \$a_j\$ has exactly \$j\$ bits set. For instance, there are \$6\$ such partitions for \$n=14\$: $$\begin{align}&14 = 1_2+110_2+111_2&(1+6+7)\\ &14 = 10_2+101_2+111_2&(2+5+7)\\ &14 = 10_2+1100_2&(2+12)\\ ...
stackexchange_codegolf
Inspired by my geography class, Sandboxed Simulate weathering / erosion. Input Input will be given as a string of any 2 characters (or see below) you like in the shape of the rock (here i use spaces and hashes): ### #### ##### ####### ####### ######## Or if your language doesn't support strings, a square matrix ...
stackexchange_codegolf
A repdigit is a natural number that can be written solely by repeating the same digit. For example, 777 is a repdigit, since it's solely composed of the digit 7 repeated three times. This isn't limited to simply decimal (base 10) numbers, however: Every Mersenne number (of the form Mn = 2n-1) is a repdigit when writte...
stackexchange_codegolf
Given \$ i = \sqrt{-1} \$, a base-\$ (i - 1) \$ binary number \$ N \$ with \$ n \$ binary digits from \$ d_{0} \$ to \$ d_{n - 1} \$ satisfies the following equation. $$ N = d_{n - 1} (i - 1) ^ {n - 1} + d_{n - 2} (i - 1) ^ {n - 2} + \cdots + d_{1} (i - 1) + d_{0} $$ For example, a decimal number \$ 15 \$ is \$ 1000111...
stackexchange_codegolf
A constructible \$n\$-gon is a regular polygon with n sides that you can construct with only a compass and an unmarked ruler. As stated by Gauss, the only \$n\$ for which a \$n\$-gon is constructible is a product of any number of distinct Fermat primes and a power of \$2\$ (ie. \$n = 2^k \times p_1 \times p_2 \times .....
stackexchange_codegolf
Output an infinite sequence of positive integers, such that, for each element in the sequence, all positive integers that have not yet been output have a positive probability of being chosen, and no value is repeated. For example, if the first integer is 3, then 3 may not be output again, but all other positive integer...
stackexchange_codegolf
A pandigital number is an integer which contains every digit from 0 to 9 at least once. 1234567890, 1902837465000000, and 9023289761326634265 are all pandigital. For the purposes of this challenge, numbers such as 123456789 are not pandigital, since they do not contain a 0, even though 123456789 = 0123456789. A diverse...
stackexchange_codegolf
As you probably know, there have been multiple lovely Jimmy challenges recently popping up. In these challenges, you were challenged with our beloved friend's acrobatics skills. Now we've got a different challenge for you. Today you will be identifying different types of Jimmys! Explanation There are three varieties o...
stackexchange_codegolf
Task For a given base \$n \ge 3\$, find the smallest positive integer \$m\$, when written in base \$n\$ and rotated right once, equals \$2m\$. The base-\$n\$ representation of \$m\$ cannot have leading zeroes. The corresponding OEIS sequence is A087502, and its base-\$n\$ representation is A158877 (this one stops at \$...
stackexchange_codegolf
You may know the game The Six Degrees of Kevin Bacon, based on the conjecture that every actor in Hollywood can be connected to Kevin Bacon by no more than 6 "co-star" relations, so Kevin Bacon is supposedly the "best-connected" node in that graph. Your task will be to find the Kevin Bacon of a graph. We will use posit...
stackexchange_codegolf
When making a Minecraft data/resource pack, you need to include a pack.mcmeta file, which specifies information about it. pack.mcmeta contains a description, but it also contains a pack_format number, which tells Minecraft which versions this pack is for. Your task is to take a version string, and output what pack_form...
stackexchange_codegolf
Sometimes authors will write (s)he as a stand in for she or he and for some reason they don't want to use singular they. This is ok for the nominative but doesn't work so well when you want to write "her or him". You can write h(er)(im) which covers both cases but gives two extra "pronouns" h her him herim In formal...
stackexchange_codegolf
preface In a very heated situation you have to go even further with golfing. (e.g. in a challenge where your answer is 100 characters long and it is just embarrassing that you couldn't make it 99) In that case, from now on you use the winner's algorithm of this challenge :) goal You have to write a program that takes ...
stackexchange_codegolf
We all know and love the corpulent DDL expressions one can write in PostgreSQL with wording like DEFERRABLE INITIALLY DEFERRED, ALTER FOREIGN DATA WRAPPER, or even DROP TEXT SEARCH CONFIGURATION. But how far can one go? Here comes the definitive challenge for the longest DDL expression, with constraints of course. Mwah...
stackexchange_codegolf
Your challenge is to parse nonsensical text and output a "congruous phrase" - which I shall define here to be text with any contiguous characters in between, and including, a given set of like symbols removed. The given set of like symbols (ignore all brackets and commas here, they're only for notation) are: {(< >), (^...
stackexchange_codegolf
Smallest code to return sum of all characters of an array of C-strings, including null-byte-terminattor of each string in the array. example in C: const char *a[] = { "abc", "bdef", "cee", "deee" }; size_t n = sumOfAllBytes(a); printf("n = %d\n", n); // n = 18 e.g., strlen(a[0]) + 1 + ... + strlen(a[n])...
stackexchange_codegolf
Introduction In many programming languages, within syntax exceptions, it is often pointed out to the programmer exactly which character or line is the culprit. This challenge will be a bit of a modification of that - specifically, using an arrow to point out any specific character of an input string. The challenge Your...
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
Cleaning the dishes In this task, you will be given a bar of soap with a width of 1 or more units. You will also be given a plate, which you will have to clean, using the soap as few times as you can. The plate will be at least 1 character. You will have to output a plate with the 'clean' character representing the pla...
stackexchange_codegolf
One day, when I was bored in maths class, I learned of a neat trick for solving the real cube root of a number! Let's use the number \$79,507\$ as an example. First, take digit in the one's place and compare it to this table: \begin{array} {|r|r|} \hline \text{Extracted Digit} &\text{Resulting Digit} \\ \hline \text{1}...
stackexchange_codegolf
The Hamming distance between two strings is the number of positions they differ at. You are given a set of binary strings. The task is to find the length of the shortest route that visits all of them at least once and ends where it started, in a metric space where the distance between two strings is the Hamming distanc...
stackexchange_codegolf
Background Very skilled card handlers are capable of a technique whereby they cut a deck perfectly in half, then perfectly interleave the cards. If they start with a sorted deck and perform this technique flawlessly 52 times in a row, the deck will be restored to sorted order. Your challenge is to take a deck of cards ...
stackexchange_codegolf
One day, when I was bored in maths class, I learned of a neat trick for solving the real cube root of a number! Let's use the number \$79,507\$ as an example. First, take digit in the one's place and compare it to this table: \begin{array} {|r|r|} \hline \text{Extracted Digit} &\text{Resulting Digit} \\ \hline \text{1}...
stackexchange_codegolf
You can depict a triangular number, T(N), by writing one 1 on a line, then two 2's on the line below, then three 3's on the line below that, and so on until N N's. You end up with a triangle of T(N) numbers, hence the name. For example, T(1) through T(5): 1 1 22 1 22 333 1 22 333 4444 1 22 333 4444 55555 To keep t...
stackexchange_codegolf
Your task is to write a program \$p\$ which outputs a string \$s\$ with the same length as \$p\$, where \$s \neq p\$. If I remove the \$n\$th byte from your program to get program \$q\$, then either \$q\$ outputs \$s\$ with the \$n\$th byte removed, or it does something else. Your score is the number of ways a single b...
stackexchange_codegolf
You're given two numbers a and b in base 31 numeral system and number k with no more than 10000 decimal digits. It is known that b is divisor of a. The task is to find last k 31-based-digits of quotient a/b. The solution with fastest proved asymptotics in length of max(a,b) wins. I'll put a bound of 10^5 on length of a...
stackexchange_codegolf
Background In Scrabble, players take turns placing tiles on a grid so that each contiguous set of (more than one) tiles in every row and column makes a word. In one play, tiles can be placed anywhere in a single row or column as long as there is a contiguous set of tiles that includes all of the ones placed.1 A word 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
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
Your task is to write a program, function, or snippet that will output one value if run forward, and another if run backward. The program must run without errors. The output can be any two distinct values, of the same data type. For example, 1 and 3, true and false, or 't' and 'f'. In languages without a concept of dat...
stackexchange_codegolf
Given a word, get the indexes of each letter in the alphabet. For example: uncopyrightable becomes: [21, 14, 3, 15, 16, 25, 18, 9, 7, 8, 20, 1, 2, 12, 5] Convert these indexes to the given numeral system. For example, if the radix is 36, then the array above would become: ['l', 'e', '3', 'f', 'g', 'p', 'i', '9', '7',...
stackexchange_codegolf
Sandbox A spin-off of a rip-off of a rip-off of a rip-off of a rip-off. Go upvote those! Your task, if you accept it, is to write a program/function that outputs/returns its input/argument. The tricky part is that if I left shift your source code, the output must be left shifted too. Likewise, if I right shift your so...
stackexchange_codegolf
Picolisp has a feature called "super parentheses": Brackets ('[' and ']') can be used as super parentheses. A closing bracket will match [all parentheses to and including] the innermost opening bracket, or [if there are no unmatched opening brackets] all currently open parentheses. src Taking a string containing only...
stackexchange_codegolf
Fennel is a lispy language which compiles to Lua. From its page: Fennel is a programming language that brings together the speed, simplicity, and reach of Lua with the flexibility of a lisp syntax and macro system. I am looking for general tips for golfing in this language. Tips should be specific to Fennel, "Remove ...
stackexchange_codegolf
Pig-latin is a made-up language that is translated into by moving the first letter of a word to the end and adding ay to the end. For example: hello translates into pig-latin as ellohay. Therefore, translating pig-latin back into English is dropping the ay at the end and moving the last letter to the start (like oodbye...
stackexchange_codegolf
Background Math SE's HNQ How to straighten a parabola? has 4,000+ views, ~60 up votes, 16 bookmarks and six answers so far and has a related companion HNQ in Mathematica SE How to straighten a curve? which includes a second part asking to move a point cloud along with the curve that we can ignore here. From the Math SE...
stackexchange_codegolf
This challenge was originally posted on codidact. You are a low-level censor working for the Ministry of Media Accuracy. Part of your job is to make sure that certain words don't appear in publications. Every morning you get a fresh stack of next week's newspapers and its your job to comb through them and fix any of ...
stackexchange_codegolf
What is Crazyhouse Chess? Crazyhouse Chess is a chess variant that is basically normal chess except you can place a piece you previously captured back on the board instead of a regular turn. Bot interface Only JavaScript bots are allowed. A bot is a JavaScript function that takes 3 arguments (board, side, bank) and ret...
stackexchange_codegolf
Yahtzee is a game played with five six-sided dice and a score sheet with thirteen different boxes to fill a score in. Each box has its own scoring rules: 1s, 2s, 3s, 4s, 5s, 6s all score points equal to the sum of the respective dice (that is, a roll of [3, 2, 3, 1, 5] scored as 3s would be awarded 6 points: 3 for eac...
stackexchange_codegolf
(based on this deleted question) Take the English alphabet a b c d e f g h i j k l m n o p q r s t u v w x y z (spaces added for clarity), and split it into chunks of X width, padding any leftover lines with spaces if necessary for your language. For example, splitting it into width 4 results in a b c d e f g h i j k l...
stackexchange_codegolf
Print the dates of all the Sundays in 2017 in the following format : dd.mm.yyyy. Expected Output: 01.01.2017 08.01.2017 15.01.2017 22.01.2017 29.01.2017 05.02.2017 12.02.2017 19.02.2017 26.02.2017 05.03.2017 12.03.2017 19.03.2017 26.03.2017 02.04.2017 09.04.2017 16.04.2017 23.04.2017 30.04.2017 07.05.2017 14.05.2017 21...
stackexchange_codegolf
What general tips do you have for golfing in Keg? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Keg (e.g. "remove comments" is not an answer). Please post one tip per answer.
stackexchange_codegolf
Write a program or function which takes a string of text as input and outputs the number of non-alphabetical characters in it (standard I/O rules apply). A non-alphabetical character is any character not appearing in this string: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ In terms of ASCII character codes, t...
stackexchange_codegolf
Every phone needs a calculator app. Because of the limited screen real estate, the developer of mine has decided to save some buttons. Instead of having two dedicated bracket buttons - one for open ( and one for close ) - there is just a single bracket button (). It looks something like this: When the button is presse...
stackexchange_codegolf
Background The systematic chemical symbol is defined as such for \$ 118 < n < 1000 \$: The first letter corresponds to the first digit, capitalized. The second letter corresponds to the second digit. The third letter corresponds to the third digit. This can be generalized for all \$ n > 0\$: For each digit, get the ...
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
In Minecraft, pistons are blocks that can move other blocks. However, they can only move at most twelve blocks, and won't work at all if any obsidian is in the way. Also, slime blocks are sticky and stick to other blocks, except for obsidian. Your challenge Take as input a 5x5 matrix or similar, containing one piston a...
stackexchange_codegolf
RPS 25 is a version of Rock Paper Scissors which has 25 hand symbols instead of just 3. Each symbol defeats 12 symbols, and is defeated by 12 others. Here's a link to a chart showing which symbols defeat which. The challenge here is simple: your program should take in two strings representing the symbols thrown by each...
stackexchange_codegolf
Given a nonnegative integer \$n\$, determine whether \$n\$ can be expressed as the sum of two square numbers, that is \$\exists a,b\in\mathbb Z\$ such that \$n=a^2+b^2\$. 0 -> truthy 1 -> truthy 2 -> truthy 3 -> falsy 4 -> truthy 5 -> truthy 6 -> falsy 7 -> falsy 11 -> falsy 9997 -> truthy 999...
stackexchange_codegolf
Inspired by Sygmei's question, I'm interested in finding out what languages can "do this properly". Your task is to write a "for loop" function / macro / instruction. The arguments should be: an initializer a test an increment a body All of these are "pieces of code" and should be able to access variables in the con...
stackexchange_codegolf
Spreadsheet Columns In most spreadsheet programs, columns go A, B, C, ... X, Y, Z. After this comes AA, AB, AC ... AX, AY, AZ, BA and so on. Your task is to convert one of these strings in to a column number. You must support inputs up to the maximum length of your language, to a minimum of 3. Test Cases: A => 1 B ...
stackexchange_codegolf
In this question each answer will get a "toolbox" that can be used to construct a program/function. The toolbox will consist of two things: a list of programming languages a list of valid characters You must write a valid program/function in one of the languages provided using only the characters in the toolbox. Yo...
stackexchange_codegolf
You love lunch. However, you are on a diet and want to make sure you don't accidentally eat lunch twice in one day. So you need to make a program to help you make sure. However, one complication is that you eat lunch on a very weird schedule. The time you eat lunch at is MONTH:DAY PM (you can use UTC or localized time ...
stackexchange_codegolf
Inspired by Golf me an ASCII Alphabet, of which this challenge is (almost) a direct inverse. Task: Take a string of ASCII-art text and output the content of the text as regular ASCII text. Input: String of ASCII-art text. Input will only contain instances of ASCII character #, spaces and 4 or 5 newlines (a trailing n...
stackexchange_codegolf
In this task, you will write a program/function that takes a Normalized Malbolge program and outputs the resulting Malbolge program. (This is a secret tool that all Malbolge programmers are using!) Input A data structure that (somehow) represents a Normalized Malbolge program. Output A data structure that represents th...
stackexchange_codegolf
Introduction In chess, Knights can move two squares in one direction, and then one square in an orthogonal direction. On an x/y plane, these can be thought of as being a relative change of coordinates, such as (+1, -2). Challenge Your task is to output all 8 possible moves as pairs of relative x/y coordinates, in any o...
stackexchange_codegolf
This is a classic one. You get a number from the keyboard from 0 to 1000(including) and must print it in text form. Examples: Input:5 Output:five Input:23 Output:twenty three Input:999 Output:nine hundred ninety nine
stackexchange_codegolf