instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Given a double-precision float, find the closest double-precision float whose binary representation is a palindrome. Input A floating point number x. You may use any format you like for input, but the format you chose must be able to represent every possible IEEE 754 binary64 value, including denormals, distinct repres...
stackexchange_codegolf
The Riemann R function is as follows: $$R (x)=\sum _{n=1}^{\infty } \frac{\mu (n) \text{li}\left(x^{1/n}\right)}{n}.$$ This uses the Möbius function as well as the logarithmic integral. From Wikipedia, the Möbius function is defined so that for any positive integer \$n\$, \$μ(n)\$ is the sum of the primitive nth roots...
stackexchange_codegolf
Courier Ception The program must accept any string as input and output an pixel image that shows the input string in Courier. All the letters that contain a 'hole' (like abdegopqABDPQR etc) that is surrounded by black pixels must be also filled black. Input The Program must be able to accept any ASCII string as input. ...
stackexchange_codegolf
(Essentially the inverse of Find the needle in the haystack) Given two tuples, (w, h) and (x, y), generate a haystack composed of a single random printable ASCII character of w width and h height with a needle made of a different random printable ASCII character at (x, y) when measured from the upper-left. For example,...
stackexchange_codegolf
So what might be the shortest language for this simple task? Task: You are given an input of type String - the string is a valid hexadecimal number ([0-9A-F]). Convert it to a decimal number and print it to the console. Tests: HEX -> DEC 1 -> 1 98 -> 152 539 -> 1337 1337 -> 4919 A5F9 > 42489 F -> 15 Win Condition: Th...
stackexchange_codegolf
People have written many things allowing one thing to be visualized as another. Now I propose being able to translate letters to music! Its your job to write a program that takes a text file and outputs a sound file with each letter converted to a specific note from C3-C8. Disclaimer - I don't actually expect the music...
stackexchange_codegolf
Typically, polyglots are constructed in such a manner that each language can ignore parts of the code that are present for other languages, by wrapping them in string literals, using comment syntax, or other similar tricks. Your goal is to write a polyglot where the output for each language is the code from the polyglo...
stackexchange_codegolf
How can we depict a turned shape simply and nicely using ascii characters in 3D space? I suggest this method : Instead of a circle we use a square rotated by 45° for the cutting section so that we only need '/' and '\' characters to draw it. /\ / \ \ / \/ And we use '_' character for the profiles: upper, lower ...
stackexchange_codegolf
Task In this challenge, your task is to write a program or function which takes an array of paths with an additional boolean indicating it is a file or directory and outputs a file/directory tree in any reasonable format. Remarks Some directories can end with a forward slash ("/") but this is not always the case A par...
stackexchange_codegolf
Challenge Write code that, given an English word, outputs the number of syllables it has. Scoring will be determined by a combination of code length and accuracy. Rules The accuracy of the solution should be measured against this CSV file (which countains syllable counts for all the 52,439 entries in the CMU Pronounc...
stackexchange_codegolf
Given a positive integer \$n\$ you can always find a tuple \$(k_1,k_2,...,k_m)\$ of integers \$k_i \geqslant 2\$ such that \$k_1 \cdot k_2 \cdot ... \cdot k_m = n\$ and $$k_1 | k_2 \text{ , } k_2 | k_3 \text{ , } \ldots \text{ , }k_{m-1}|k_m.$$ Here \$a|b\$ means \$b\$ is a multiple of \$a\$, say "a divides b". If \$n>...
stackexchange_codegolf
Special thanks to Bubbler and AdmBorkBork for supplying feedback about this challenge Keta (Keyboard tacit — clever naming, I know!) is a golfing language I’ve been working on recently. One of it’s features is it’s most probably unique bracket autocompletion system, which will hopefully allow for shorter programs. The...
stackexchange_codegolf
Consider an array A of integers of length n. The k-max subarray sum asks us to find up to \$k \leq 3\$ (contiguous) non overlapping subarrays of A with maximum sum. If A is all negative then this sum will be 0. If A = [-1, 2, -1, 2, -1, 2, 2] and k=2 for example, then the two subarrays could be [2, -1, 2] and [2, 2] ...
stackexchange_codegolf
I want to play Dungeons and Dragons, but I don't have any dice! Your challenge is to roll some D&D dice. The input format specification in Backus-Naur form is: <valid-input> ::= <opt-integer> "d" <integer> <opt-modifier> <opt-integer> ::= | <integer> <opt-modifier> ::= | "+" <integer> <integer> ::= "0" | "1" | "...
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
There's a river and there are wolves and chickens on one side of the river. They have a raft and they all need to get to the other side. However, the raft cannot travel on its own. The raft will sink if more than two animals are on it. None of the animals want to get wet because the river's cold and dirty. None of the ...
stackexchange_codegolf
The challenge is to create one program that will accept as arguments (arrays of arrays) or on standard input (line-by-line, separated by commas) a collection of families and names, like so: John,Anna Mark,James Elizabeth,Daniel,Isabelle Ryan,Ruth As well as two other arguments (two more arrays of pairs, as arrays) or ...
stackexchange_codegolf
Challenge Print the numbers: 1 22 333 4444 55555 666666 7777777 88888888 999999999 In that order. I/O Takes no input. The numbers can have any delimiters desired (or none). That includes lists, cell arrays, .jpeg, etc.... Example outputs: 122333444455555666666777777788888888999999999 [1,22,333,4444,55555,666666,77777...
stackexchange_codegolf
Given a list of case-insensitive ASCII letter strings ("words"), output whether the entire list can be found on some four-by-four configuration ("board") of letter squares, in which no square can be used more than once in a word, and in which words are formed by moving from any square to any adjacent square including d...
stackexchange_codegolf
"A picture is worth a thousand words"—so the old saying goes. The average word is about four characters long, so a picture conveys 4kB of information. But how much entropy, rather than information, can a picture convey? Your task is to generate an image, exactly 4,000 bytes in size, with the highest entropy possible. Y...
stackexchange_codegolf
Raffaele Cecco is a programmer who produced some of the best video games for the ZX Spectrum computer in the late eighties. Among others, he developed the highly acclaimed Cybernoid and Exolon. Raffaele is turning 50 on May 10, 2017. This challenge is a small tribute to him, for the happy hours that many of us spent p...
stackexchange_codegolf
Related From Wikipedia: In number theory, the Calkin–Wilf tree is a tree in which the vertices correspond one-to-one to the positive rational numbers. The tree is rooted at the number \$1\$, and any rational number expressed in simplest terms as the fraction \$\frac{a}{b}\$ has as its two children the numbers \$\frac{...
stackexchange_codegolf
Greeklish, a portmanteau of the words Greek and English, is a way of writing modern Greek using only ASCII characters. This informal way of writing was extensively used in older applications / web forums that did not support Unicode, and were not programmed to show Greek characters. Nowadays, its use is minimized due t...
stackexchange_codegolf
There are 10 types of people in the world, those who understand binary and those who do not. Where are you? Let's see! Challenge Your task is to convert a decimal integer to binary, only using a set of arithmetic operators (+, -, *, / and %). You can use conditional statements, loops and variables. (No bitwise operator...
stackexchange_codegolf
Let's go for a rollercodester ride The objective of this challenge is to create a program that is run recursively through several languages of your choice. The output of the first iteration becomes the code for the second iteration, et. cetera. You choose the language sequence, but each unique language may be used onl...
stackexchange_codegolf
Given a MM/DD date (12/24) and a start/end date range (11/01 - 06/24), figure out if the date is within the listed date span. Date ranges can be sequential (05/01 - 11/01) or wrap around to the next year (11/01 - 05/01). Examples: 12/24 is in 11/01 - 06/24 = True 06/24 is in 11/01 - 06/24 = True 06/24 is in 06/24 - 06...
stackexchange_codegolf
Figuring out whether a given number is prime, while not very complicated, is kind of hard. But making a guess doesn't need to be. Seeing whether a number is a multiple of 2 or 5 is easy - you can just look at the last digit. Multiples of 3 isn't much harder, just add up the digits and see if you end up with a multiple ...
stackexchange_codegolf
Write a program or function that takes in a nonempty list of integers in any reasonable convenient format such as 4, 0, -1, -6, 2 or [4 0 -1 -6 2]. Print or return a string that depicts the list as an ASCII art forest where each number becomes a tree of proportional height. Each tree takes up four columns of text in t...
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
We've had a lot of alphabet challenges. For this challenge, you are passed the output of an alphabet challenge, and you need to output the pattern scaled to size N. For example, if N=5 and you were passed the L-phabet: ABCDEFGHIJKLMNOPQRSTUVWXYZ BBCDEFGHIJKLMNOPQRSTUVWXYZ CCCDEFGHIJKLMNOPQRSTUVWXYZ DDDDEFGHIJKLMNOPQR...
stackexchange_codegolf
You need to make a program, that when giving a list and a string, searches on the list for items that contains the string. Examples: Input: th [thing, awesome, potato, example] Output: thing (Because it starts with "th") Input: ing [thing, potato] Output: thing (Because it ends with "ing") Input: tat [thing, potato] ...
stackexchange_codegolf
This is a Cops and Robbers challenge. For the Robbers' thread, go here. The Cops have three tasks. 1) Pick a sequence from the OEIS. 2) Pick a language (this is suggested to be a golflang, but doesn't have to be) that, when given input n, outputs A(n) (where A(n) is the sequence chosen) using all usual code-golf rule...
stackexchange_codegolf
I'm a lazy but efficient person, as many of you probably are as well. So, whenever I'm doing something I want to do it with minimal effort. Which is why I'm asking you to solve this problem for me. What I have here is a document of sorts. On every line of this document is a single word or short phrase. The document is ...
stackexchange_codegolf
Many electronic devices, specially old ones, will show a blinking 12:00 when the time has not been set. The purpose of this challenge is to recreate this. Specifically, the task is to display 12:00 and --:-- alternatively in an infinite loop. The period should be 1 second, divided evenly in two periods of 0.5 seconds. ...
stackexchange_codegolf
Explanation of the challenge Given an input, return what shapes it could be. There are only a couple options. Square Triangle Square A square is in the following format: XXXX XXXX XXXX XXXX So, in this example, the input would be: 16 And the output would be: 1 or "Square" Triangle We are only checking for equila...
stackexchange_codegolf
We all know that whenever a rational number is written in decimal, the result is either terminating or (eventually) periodic. For example, when 41/42 is written in decimal, the result is 0.9 761904 761904 761904 761904 761904 761904 761904 ... with an initial sequence of digits 0.9 followed by the sequence 761904 repe...
stackexchange_codegolf
Write a program that takes in a string and spells that word out using the NATO Phonetic Alphabet. The mapping is as follows: 'A' -> 'Alfa' 'B' -> 'Bravo' 'C' -> 'Charlie' 'D' -> 'Delta' 'E' -> 'Echo' 'F' -> 'Foxtrot' 'G' -> 'Golf' 'H' -> 'Hotel' 'I' -> 'India' 'J' -> 'Juliett' 'K' -> 'Kilo' 'L' -> 'Lima' 'M' -> 'Mike'...
stackexchange_codegolf
Related: Is this quadrilateral cyclic? Background A tangential quadrilateral is a quadrilateral which has an incircle: Examples include any square, rhombus, or a kite-like shape. Rectangles or parallelograms in general are not tangential. Task Given the four vertices of a quadrilateral (as Cartesian coordinates), dete...
stackexchange_codegolf
Computers like binary. Humans like base 10. Assuming users are humans, why not find the best of both worlds? Your task is to find the first n terms in the sequence A008559 where each term is the binary representation of the previous number interpreted as a base 10 number. Input An integer greater than 0. Note that the ...
stackexchange_codegolf
Your mission is to write 2 functions that accept a list of N integers (positive or negative). N can be higher than 2. The first one returns the greater common divisor of the N numbers Example: [10, 15, 20] -> 5 the second one returns the smallest common multiple of the N numbers Example: [10, 15, 20] => 60 Smallest cod...
stackexchange_codegolf
Input _ _ _ _ _ _ _ _ | _| _||_||_ |_ ||_||_|| | ||_ _| | _||_| ||_| _||_| output 1234567890 Rules Code golf - shortest code wins. Input will be given as a 3-line string with each line separated by a newline, or as 3 separate strings. Each line is guaranteed to be a multiple of 3 characters lo...
stackexchange_codegolf
This is a cops-and-robbers puzzle the robbers' thread can be found here. Your task will be two write two programs (or functions) such that they are anagrams of each other and one performs the left inverse of the other. These programs may accept and output as many integers or complex numbers as you wish. If you choose...
stackexchange_codegolf
Nichomachus's Theorem relates the square of a sum to the sum of cubes: and has a beautiful geometric visualization: Challenge: Create the 2d part of this visualization in ascii. You will need to ensure that all visual demarcations are upheld by your diagram. This is simplest to do with four "colors," though it's pos...
stackexchange_codegolf
Thunno 2 is a stack-based golfing language with around 400 commands (achieved through overloads) created by me, The Thonnu. It seems like a good idea to share some tips for golfing in Thunno 2. Please, one tip per answer, and no tips like “remove comments and whitespace”. Links: Tutorial List of commands Attempt This...
stackexchange_codegolf
I have a counter. It's a small device that looks like this: The display goes from 0000 to 9999. It has a little push-button at the top that increases the count by 1, and a little knob at the right whose purpose is to reset the counter back to 0. Now, the thing about the little knob is that if you turn it backwards, y...
stackexchange_codegolf
Introduction You are probably familiar with the "puts on sunglasses" emoticon-meme: (•_•) ( •_•)>⌐■-■ (⌐■_■) In this challenge, your task is to take the first line as input, and output the last one, effectively putting sunglasses on that little button-eyed person. To make the task a bit more difficult, the characters ...
stackexchange_codegolf
The students in my high school computer science class were asked to write the game of nim for a simple project. Most of them found it very easy and finished quickly. However, one student came up with this solution. I'll probably make them redo it anyway, but I'm wondering if anyone can understand what's going on. enum ...
stackexchange_codegolf
One of my favorite algorithms was posted on Stack Overflow as an answer to What is the fastest way to generate prime number recursively?. In pseudocode: Nathan's algorithm bool isPrime(int n): if (n < 2) return false for p in 2..n-1: if (isPrime(p) && n%p == 0) return false return true This program...
stackexchange_codegolf
Recently, someone proposed more stringent limits for Python's default line length: Clearly, no program should ever use more than 80 characters per line, for a whole host of reasons. First and foremost, for readability and maintainability, it is important to have a solid standard, so we can adjust the width of our text...
stackexchange_codegolf
This is a challenge to write bots to play the 1st and 2nd players in the following simple poker game. Rules of the poker game There are two players, A and B. Each antes $10 into the pot, and is dealt a card, which is a real number in the range [0, 1). Player A goes first, and may pass or bet. If A passes, then there is...
stackexchange_codegolf
It's election time, and your job is to beat your competitor in a head-on rivalry! You are both trying to win over a city of 256 people in a 16x16 grid. Right now, the city hasn't been divided into voting regions yet, but that's where your gerrymandering skills come in! You can also campaign in arbitrary areas of the ci...
stackexchange_codegolf
It seems we've managed to go all this time without a plain vanilla Number-To-Binary challenge! Whilst this will inevitably be only one element in many languages, it should put a few esolangs through their paces. I truly looked for this challenge to no avail. If it already exists, comment as such and I'll delete this po...
stackexchange_codegolf
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
It turns out that my toaster is a tad broken. It lost WiFi (You know, it's one of those newfangled smart toasters), and its been going bonkers! Since it no longer works, I've been having to hack into my breakfast's source code and run Plate.bread.toastAs(3); every morning. Will you help? My toaster takes one input: the...
stackexchange_codegolf
Inspired by a question (now closed) at Stack Overflow. Given a square matrix, let its double trace be defined as the sum of the entries from its main diagonal and its anti-diagonal. These are marked with X in the following examples: X · · X · X X · · X X · X · · X X · · · X · X · X · · · X · · · X · X · X · · · X No...
stackexchange_codegolf
Given a positive integer as input, output that integer, but with its bits rotated two times to the right. Also, think of the number as a donut of bits, eg. 21 -> (10101). If all of the bits suddenly decided to move to the right, they would wrap around. eg. rRot(21) -> (11010) = 26. Do what i explained 2 times (at the s...
stackexchange_codegolf
This challenge is inspired by @LuisMendo's MATL answer to my "binary multiples" challenge. Task Pick a code-golf challenge that is open and that has been posted before this one; let me call it the "linked challenge". The linked challenge must be a challenge whose task involves producing output. Write the shortest code ...
stackexchange_codegolf
Write a program or function that takes in a string guaranteed to only contain printable ASCII characters except for space, and to be a positive triangular number (1, 3, 6, 10, 15, ...) in length. Print or return the same string, but shaped into a triangle using spaces. Some examples will best show what I mean: If the i...
stackexchange_codegolf
Introduction In mathematics, the hyperoperation sequence is an infinite sequence of arithmetic operations (called hyperoperations) that starts with the unary operation of successor (n = 0), then continues with the binary operations of addition (n = 1), multiplication (n = 2), and exponentiation (n = 3), after which th...
stackexchange_codegolf
Background This challenge is based on a personal project I did, UnitDC. This challenge is a super-miniaturized version of UnitDC. Challenge Please write a simple unit-aware calculator that evaluates a sequence of positive integers, units and operators in RPN (postfix) notation, while checking whether the units are comp...
stackexchange_codegolf
The string tut-tutut-tut-tuttut-tut can be constructed with overlapping or concatenated instances of the word tut-tut: tut-tutut-tut-tuttut-tut tut-tut tut-tut tut-tut tut-tut The string tut-tututut-tutut-tut cannot: tut-tututut-tutut-tut tut-tut^ |tut-tut | tut-tut ...
stackexchange_codegolf
In some parts of the world, phone numbers are fixed-length, apparently. That sounds boring, though. For this challenge, your task is to take the digits of a what is presumed to be a valid phone number, and format it based on some simplified rules around what a phone number looks like. Input format Your input will consi...
stackexchange_codegolf
Background: For this challenge, a polynomial looks like this: $$P(x)=a_nx^n+a_{n-1}x^{n-1}+\dots+a_2x^2+a_1x+a_0$$ The degree, \$n\$, is the highest power \$x\$ is raised to. An example of a degree 7 polynomial would be: $$P(x)=4x^7+2x^6-7x^4+x^2-6x+17$$ All powers are integers \$n\ge0\$. This means \$x\$, \$-2\$, and ...
stackexchange_codegolf
Can this container hold this much liquid? Challenge Synopsis As you most likely know, liquids have an indefinite shape and a definite volume. As such, they always take the shape of their container. They cannot, however, expand to fill their container. Your job today is to determine whether or not a certain amount of li...
stackexchange_codegolf
A square-free word is a word consisting of arbitrary symbols where the pattern \$XX\$ (for an arbitrary non-empty word \$X\$) does not appear. This pattern is termed a "square". For example, squarefree is not square-free (using the lowercase letters as the alphabet), as the square ee appears; but word is square-free. A...
stackexchange_codegolf
The round function in Python 3 will round values of the form \$k+\frac{1}{2}\$ (with \$k\$ being an integer) to the nearest even integer, which is apparently better than the rounding method taught in school Your task is to recreate this functionality: write a program of function that given a (real) number as input, out...
stackexchange_codegolf
(This is my first code-golf question) When I was a child, my dad and I invented a game where the license plate we see on cars can give certain points based on some rather simple rules: X amount of the same letter or number give X-1 points, examples: 22 = 1 point aa = 1 point 5555 = 3 points The numbers must be next to...
stackexchange_codegolf
Sandbox Definition: A positive integer n is almost-prime, if it can be written in the form n=p^k where p is a prime and k is also a positive integers. In other words, the prime factorization of n contains only the same number. Input: A positive integer 2<=n<=2^31-1 Output: a truthy value, if n is almost-prime, and a fa...
stackexchange_codegolf
What general tips do you have for golfing in Lua? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Lua (e.g. "remove comments" is not an answer). Please post one tip per answer.
stackexchange_codegolf
Intro/Background I was looking at "You Had One Job" pictures lately, and noticed an old favourite of mine: And I said to myself: "I need a program that can generate text like that". So I devised a set of rules for character swapping and wrote a CGCC challenge! The Challenge Given a single string as input, output a str...
stackexchange_codegolf
Print or return the following text: Hello world! The quick brown fox jumps over a lazy dog. However, your submission will not be scored in bytes. Instead, primarily it will be scored by the width in pixels of the program when written in Arial in a 12pt font. In particular, the score is: $$ (\text{visual width in px}) ...
stackexchange_codegolf
Given a strictly positive integer, N, produce an output satisfying the following: Produce an array of length N. Every string (i.e. "word") in the array is of length N. Every letter in the word is unique. Every first letter of the words are unique between each other. The remaining items of each word are equal to each o...
stackexchange_codegolf
Background Hello golfers! I would like to learn all the programming languages! But I kinda have a short attention span... and copying all the Hello World examples gets boring... but I like fire! ^w^ Challenge So here is the plan! I want you all to write the smallest code that will compile, print Goodbye Cruel World!, ...
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
Background There are self-extracting .ZIP files. Typically they have the extension .EXE (and by executing the file they will be extracted) but when renaming them to .ZIP, you can open the file with some ZIP extracting software. (This is possible because .EXE files require a certain header but .ZIP files require a certa...
stackexchange_codegolf
https://www.youtube.com/watch?v=6vAhPeqlODg Ok—jig's up—this one's only related to smash in name, but it'll give you something to burn your time with while you wait 'til December 7th Given a color string s of form #rgb(in hex, so #000000 to #ffffff, dont worry about the three digit ones: #123) you must average the rgb ...
stackexchange_codegolf
There's been challenges for the shortest cat program, but as far as I know, there hasn't been any for the longest one. A cat program is a program that copies its input to its output. Here's an example: Input: Hello Output: Hello Input: cat Output: cat So, the rules are simple: The program has to copy its input to it...
stackexchange_codegolf
A set is sum-free if no two (not necessarily distinct) elements when added together are part of the set itself. For example, {1, 5, 7} is sum-free, because all members are odd, and two odd numbers when added together are always even. On the other hand, {2, 4, 9, 13} is not sum-free, as either 2 + 2 = 4 or 4 + 9 = 13 ad...
stackexchange_codegolf
Write a program that precisely clones GNU cat version 8.32, which is installed on my computer. In any case, if called with the same arguments, same stdin, and same files, your program's output to both stdout and stderr must by byte-for-byte identical to that of GNU cat, and the exit code must be the same. This applies ...
stackexchange_codegolf
Input: An integer Output: Sum of the input itself + the length of the input + each individual digit of the input. nr + nr-length + {sum of digits} = output Examples: Input: 99 Output: 99 (nr) + 2 (nr-length) + (9 + 9) (digits) → 119 Input: 123 Output: 123 + 3 + (1 + 2 + 3) → 132 Challenge rules: The input can also co...
stackexchange_codegolf
You are an employee of Microteque, a leading Silicon Valley startup creating smart microwave ovens for all kinds of strange places. Your customers can get their microwaves printed with patterns to match their kitchens, campers, man caves; even the kitchens of large nation-state facilities have shiny new branded microwa...
stackexchange_codegolf
“Cut” a matrix of integers on the line where the sum of the absolute differences of “severed” neighbors is the least. Example Consider this matrix: 1 2 -4 5 -1 3 2 -2 0 It can be cut in 4 places, here shown by lines lettered A–D: A B ╷ ╷ 1 ╎ 2 ╎ -4 C ---╎----╎---- 5 ╎ -1 ╎ 3 D ---╎----╎--...
stackexchange_codegolf
Because it's Saturday (UTC) and I'm hungry, I would like a slice of pizza. I will give you an order and I would like a nice hot ascii-art pizza. Up to the challenge? The Drive-Thru I'll place my order wherever your drive-thru is, whether it is STDIN, a function parameter, a command-line argument, but I'm not going to p...
stackexchange_codegolf
zipwith is a functional construct that takes three arguments: one binary function and two lists of the same length, and returns a single list where each element is constructed by applying the binary function to each pair of elements from the two lists: zipwith (a+b) [1,2,3] [4,5,6] = [5,7,9] You are to take a black-bo...
stackexchange_codegolf
Given an integer n, your task is to determine whether it is a perfect square that when reversed, is still a perfect square. You may assume n is always positive. When numbers such as 100 (10x10) are reversed the result may have leading zeros (001) In this case, ignore the leading zeros and treat it as 1 (1x1). Test case...
stackexchange_codegolf
Let \$S \subset \mathbb N_{\geq0}\$ be a subset of the nonnegative integers, and let $$ S^{(k)} = \underbrace{S + S + \dots + S}_{k\ \textrm{times}} = \{ a_1 + a_2 + \dots + a_k : a_i \in S\}. $$ For example, $$\begin{align} \{1,2,3\}^{(2)} &= \{1+1, 1+2, 1+3, 2+1, 2+2, 2+3, 3+1, 3+2, 3+3\}\\ &=\{2,3,4,5,6\} \end{align...
stackexchange_codegolf
This is part of a cops-and-robbers challenge. Go here for the cops' part. The Robbers' Challenge A cop's answer can be cracked by removing any subset of characters from the Haystack program, so that it outputs Needle instead of Haystack (while still being a valid submission in the same language). You don't have to find...
stackexchange_codegolf
Consider a NxN pixel grid with up to M objects drawn on it, either squares or diamonds: square    diamond The objects may overlap, so recognition is hard. The task is to give the minimal possible numbers of objects per shape that can be "seen" in the picture and tell how many squares, how many diamonds, and how many ob...
stackexchange_codegolf
Sometimes when I'm doodling, I draw a rectangle, start with a diagonal from one of the corners, and then just trace out a line by "reflecting" it whenever I hit a side of the rectangle. I continue with this until I hit another corner of the rectangle (and hope that the aspect ratio of my rectangle was not irrational ;)...
stackexchange_codegolf
Your task Given two positive integers \$x\$ and \$d\$ (such that \$d<x\$), output the 5th term of the \$d\$th difference of the sequence \$n^x\$ Example Let's say we are given the inputs \$x=4\$ and \$d=2\$. First, we get the series \$n^4\$: \$0^4 = 0\$ \$1^4 = 1\$ \$2^4 = 16\$ \$3^4 = 81\$ ... These are the first 10...
stackexchange_codegolf
Problem Draw a hexagon chain x long, each with side of y length Input x - the length of the chain <= 50 y - the length of each side <= 50 Examples x=1,y=1 _ / \ \_/ x=4,y=1 _ _ / \_/ \_ \_/ \_/ \ \_/ \_/ x=3,y=2 __ __ / \ / \ / \__/ \ \ / \ / \__/ \__/ \ / \__/ Rules ...
stackexchange_codegolf
We can arrange the positive integers like this: 1_| 2 | 5 | 10 4___3_| 6 | 11 9___8___7_| 12 16 15 14 13 That is, in L-shaped brackets expanding down and right infinitely. Then, we can read it off with the antidiagonals: 1 2 5 10 / / / 4 3 6 11 / / / 9 8 7 12 / / / 16 15 14 13 For the above, we rea...
stackexchange_codegolf
Your submission must take a list of numbers (in whatever list format your language supports, or using multiple function / command-line parameters) or a string of numbers separated by any character that is not 0123456789. In one language, it must add all of them and output the sum. In another language, it must output th...
stackexchange_codegolf
This question was inspired by Tom Scott's video here. The English language has plenty of words, but what's the longest one that can be displayed on a seven segment display? Your challenge is given a list of letters that may not be displayed, display the longest English word in a 7 segment display format? Input Input w...
stackexchange_codegolf
As we learned from The Holy Numbers, there are 5 holy digits (0, 4, 6, 8, 9), and positive integers consisting solely of those digits are holy. Additionally, the holiness of a number is the sum of the holes in the number (+2 for every 0 or 8, and +1 otherwise). Now, there is an additional property to take into consider...
stackexchange_codegolf
Introduction Brainstract, a newly created dialect of Brainfuck adds a bit more elements to the syntax. In addition to the normal Brainfuck syntax, there are macros. To define a macro: {macro_name ++++} Then use it: {macro_name} Adds 4 to the current cell Challenge Your challenge is to take a valid Brainstract progra...
stackexchange_codegolf
Introduction A quine is a program that takes no input and produces a copy of its own source code as output. Writing a quine is a standard test of a programming language. Most quines operate using strings of characters: that is what the source code is made of, after all! However, this quine is slightly different. Challe...
stackexchange_codegolf
In chat, we are often fast-typers and don't really look at the order of letters before posting a message. Since we are lazy, we need a program that automatically swaps the last two letters in our words, but since we don't want to respond too late, the code must be short. Your task, if you wish to accept it, is to write...
stackexchange_codegolf
Create three programs, which we'll call Rock, Paper, and Scissors. Each program must be unique, and accept input. If a program gets any input which is not one of the programs Rock, Paper or Scissors, it must print itself. RPS style, the programs will each print one of the following four outputs: "win" if the running ...
stackexchange_codegolf
The following problem is taken from the real world — but indubitably code-golf! In this puzzle, the programming language is fixed, and your job is to write the most efficient program in this fixed language. The language has no loops; a program is a straight-line sequence of instructions. Each instruction consists of ex...
stackexchange_codegolf