instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Challenge Given an array of positive integers and a threshold, the algorithm should output a set of consecutive-element-groupings (subarrays) such that each group/subarray has a sum greater than the threshold. Rules The solution should honor two additional criteria: be of highest cardinality of the groups (i.e. highes...
stackexchange_codegolf
...or "snakes but not too long". Inspired by this challenge and this comment. Task Write a program or a function that takes no input and outputs its own source code formatted as a snake according to the rules below: If your code has any whitespace, it will not be output; it will just be skipped. There will be one char...
stackexchange_codegolf
Alternating Arrays An alternating array is a list of any length in which two (not necessarily different) values are alternating. That is to say, all even-indexed items are equal, and all odd-indexed items are equal. Your task is to write a program or function which, when given a list of positive integers, outputs/retur...
stackexchange_codegolf
Dowker notation is a common way of representing mathematical knots. Dowker notation can be derived from a knot diagram in the following way (based on the description from the wikipedium): We will label each of the \$n\$ intersections with two numbers whose absolute value is on the range \$1, \dots 2n\$ (one odd one ev...
stackexchange_codegolf
The task is simple, given an integer n of how many lines the next n lines is and, a multi-line input, output the resulting 90 degree tilted grid in a clockwise formation. E.g. Input: 2 c d o e Output: o c e d I/O format: Input will have spaces in between them Input always contains alphabetical characters except the ...
stackexchange_codegolf
Challenge: Your challenge (should you choose to accept it) is to compress and decompress the 5MB "Complete Works of William Shakespeare" as found here: http://www.gutenberg.org/cache/epub/100/pg100.txt (MD5: a810f89e9f8e213aebd06b9f8c5157d8) Rules: You must take input via STDIN and output via STDOUT... ...and you must...
stackexchange_codegolf
Given two strings: a string s and an alphabet a, implement string projection in the shortest code possible. String projection returns a string o that contains the characters in s that are in a. The order of the characters in o must match the order of characters in s. So if s = "abcd" and a = "12da34", o = "ad", since o...
stackexchange_codegolf
CGCC hasn't always had MathJax. Back in the dark ages, it would have been necessary to write \$x^2\$ as x² (the horror!). In this challenge, you will be given some math which may include superscripts, and you should convert it to MathJax. Input: Input will consist of one or more letters a to z, some with superscripts. ...
stackexchange_codegolf
This year's UEFA Euro 2016 is over and besides a couple of negative headlines there has been a very positive surprise as well – the Iceland national football team. Let's draw their national flag. Input Well, obviously this challenge has no input. Output Draw the flag of Iceland in any applicable visual format of at le...
stackexchange_codegolf
There is an app called Hard Puzzle which is a game where there is a red circle, and you have to fill all of the surface area with five smaller white circles it may seen easy, but it's harder than it looks (it just takes a while to figure out). The circle dimensions change from device to device in the image above the re...
stackexchange_codegolf
Given a string consisting of only printable ascii (letters, numbers, symbols, and spaces), how many keystrokes are required minimally to type out this string from scratch? That is, current text is initially an empty string and should end up being equal to the input string. These are the allowed actions and their cost i...
stackexchange_codegolf
Your task is to take a 24 BPP sRGB image and output the same image upscaled 3x into red, green, and blue subpixels. The resulting image will be made entirely of pure black, red, green, and blue pixels. Each pixel from the source image, when zoomed, produces an arrangement of 9 sub-pixels that can be either on or off (i...
stackexchange_codegolf
Provided that the input is a monotone sequence of three or more integers: Output -2 if the sequence strictly decreases. Example: [7,4,3,2] Output -1 if the sequence monotone decreases but is neither strict nor constant. Example: [6,5,5] Output 0 if the sequence is constant. Example: [0,0,0] Output +1 if the sequenc...
stackexchange_codegolf
Lorem Ipsum is placeholder text used when preparing layout without wanted to have content already filled. One of its key features over using some arbitrary text is that it is nonsense. It isn't even valid latin (though it is close). This prevents anyone being shown the layout from becoming distracted reading the text. ...
stackexchange_codegolf
You will take input such as http://examples.example.co.nz/abcdefg and return the name of the website, in which this example would be example. To be more specific, I am looking for the Second Level Domain, which immediately precedes the TLD (Top Level Domain), but the Third Level Domain if the website is a Country Code ...
stackexchange_codegolf
Background It was a normal presentation that I were in as a audience, until the presenter gave a math problem about repeat taking 2 number out of a list a replacing them with average, claiming that there will be something special about it, and our math teacher, sitting at the end of classroom, exciting rushed to me, an...
stackexchange_codegolf
Paul is one of your Belgian acquaintances, and he would like you to create a program that outputs at least one of the following five strings: 12496=>14288=>15472=>14536=>14264 14264=>12496=>14288=>15472=>14536 14536=>14264=>12496=>14288=>15472 15472=>14536=>14264=>12496=>14288 14288=>15472=>14536=>14264=>12496 It ...
stackexchange_codegolf
It is well known that a person on a grid under the influence of alcohol has an equal chance of going in any available directions. However, this common-sense statement does not hold in the realm of very small drunkards, whose behavior is very much as if they take every available path at once, and the possible paths they...
stackexchange_codegolf
Introduction When you are given a boring text, you just want to get it over with as quick as possible. Let's observe the following text: Ens colligi timenda etc priorem judicem. De quascunque ii at contingere repugnaret explicetur intellectu. Adjuvetis hoc fortassis suspicari opportune obversari vix eam? Dei praemia ...
stackexchange_codegolf
This challenge is based upon three sequences, below are their formulae: Recamán's sequence: a1 = 0; for n > 0, an = an-1 - n if positive and not already in the sequence, otherwise an = an-1 + n Fibonacci sequence: an = (Φn – (–Φ)–n) / √5 where Φ denotes the golden ratio, and a1 = 0 Triangular numbers s...
stackexchange_codegolf
As preparation for the nth Exodus, Noah decides to write a program that will decide If he will let animals on his ark. However, Noah wants to go back to grass roots. Thus he decides that the program should be as small and as simple as possible. GOAL: Recreate the Contrabulous Choosematron, in a way that follows evange...
stackexchange_codegolf
This is not the same as m-ss-ng-lette-s Challenge: Given a string with masked characters, generate all possible words, inclusive of non-meaningfull words. Rules: The sequence of the characters in the string does not change. The masked character (*) will be one of an English alphabets [a-z]. There are no line breaks, s...
stackexchange_codegolf
inputs / outputs your program/function/routine/... will be a predicate on two tuple sequences; call it relation ≡. for the purpose of simplicity we use natural numbers: the input will be two list of pairs of numbers from ℕ (including 0); call them Xs and Ys the output will be a "truthy" value specification ≡ checks t...
stackexchange_codegolf
Guidelines Task Write a function that takes in a sentence (a string, or list of characters) and reverses all the words that are greater than or equal to 5 in length. Examples "Hey fellow code golfers" -> "Hey wollef code sreflog" "I aM noT a cAr" -> "I aM noT a cAr" "I Am a tRaiN" -> "I Am a NiaRt" Rules Since this ...
stackexchange_codegolf
Heavily inspired by Hello, World! (Every other character) Write a program that outputs 1. When the first, third, fifth, etc. chars are removed, it outputs 2. When all chars where their (1-based) index in the source, mod N, are not 0, are removed, it should output N. This is code-challenge. The winner is the program tha...
stackexchange_codegolf
EDIT (Jan 19, 2022, 18:00 UTC): This challenge is now over. The winner is Citty with this Pyth answer. Congratulations! This is an answer-chaining challenge where each answer must take an integer \$N\$ as input and return the 1-indexed ID of the answer which was written by the user whose ID is \$N\$. You may want to s...
stackexchange_codegolf
You are to create a program which, when given a positive integer \$n\$, outputs a second program. This second program, when run, must take a second positive integer \$x\$ and output one of two distinct values depending on whether \$x\$ is divisible by \$n\$. Those values must be consistent for a given \$n\$ but can be ...
stackexchange_codegolf
We've been twice challenged to make 'error quines' (see Make an error quine! and Make a slow error quine maker!), so why don't we try the opposite? Instructions Write a "program" that, when run, produces an error. Copy the error message into a new program, and run it. Repeat Step 2 until the program runs without produ...
stackexchange_codegolf
Let us assume that we have number X. Let us assume that we have positive integer "components" (C) of this X number. We can add these components together like C1+C2+...+Cn = X. We have N as limit of number of components. We have B as limit of biggest component Distribution: if we have [8;8;5] then avg of components is ...
stackexchange_codegolf
Write a program (or function) (let's call it P1), that when run, outputs another program P2 of the same language and exactly 1 byte longer than P1. Program P2 when run, should output a 3rd program P3 that's 1 byte longer than P2. P3 must output a program P4 that's one byte longer than P3, etc. The same for P5, P6, ...,...
stackexchange_codegolf
Input A non-empty string or list of capital letters k with length between 3 to 5000. Output A value indicating whether k can be expressed as a+b+b, where a and b are non-empty. Truthy test cases SSS SNYYY SNYY SNNYY SNYNY Falsy test cases FALSYTESTCASES FALSYFALSYTESTCASES FALSYTESTCASESXFALSYTESTCASES FALSYTESTCASESF...
stackexchange_codegolf
Today's challenge: Given an ordered list of at least 3 unique integer 2D points forming a polygon, determine if the resulting polygon is Rectilinear. A polygon is rectilinear if every interior angle is a right angle. The edges do not necessarily have to be purely vertical or horizontal (parallel to the x or y axis), ...
stackexchange_codegolf
Given a list of two or more spelled-out serial numbers of equal length greater than two, e.g. [[ "three" , "one" , "four" ], [ "one" , "five" , "nine" ], [ "two" , "six" , "five" ], [ "three" , "five" , "eight" ]] sort the list by the numbers that the words represent: [[ "one" , "five" , "nine" ], [ "t...
stackexchange_codegolf
If you visit Code Golf often, you may have heard of Kolmogorov complexity. It's usually defined as the amount of bytes required to express some string in a programming language. Here the Kolmogorov-complexity of a natural number is defined similarly: the number of bytes required to represent it in a programming languag...
stackexchange_codegolf
Given string s of even length as input, randomly capitalize exactly half of the letters. You can assume the input will always be a non-zero, even length You can assume the input will consist of only lowercase letters ([a-z]) Exactly half of the letters should be capitalized in the output Every permutation that has exa...
stackexchange_codegolf
To solve the Halting Problem you are given a description of a program, and must determine whether or not it will ever finish. You can never do this for all programs. Yet for programs like (in brainf***): > It obviously will halt, and for programs like: +[] It obviously will not. Your challenge is to "solve" the halti...
stackexchange_codegolf
Introduction In the video the best way to count, binary is proposed as the best system of counting numbers. Along with this argument is a proposal on how to say numbers in this system. First, we give names to each "double power of two", \$2^{2^n}\$ for each \$n\$. number = symbol = spoken ============================ 2...
stackexchange_codegolf
The challenge is simple: Print the last, middle, and first character of your program's source code, in that order. The middle character is defined as follows, assuming a source length of n characters, and 1-indexing: If n is even, print the n/2-th and n/2 + 1-th character. (abcdef == cd) If n is odd, print (n-1)/2 + 1...
stackexchange_codegolf
My two kids like to play with the following toy: The colored areas with the shapes inside can be touched and the turtle then lights the area and plays a sound or says the name of the color or the shape inside. The middle button changes the mode. There is one mode in which the areas play different musical notes when to...
stackexchange_codegolf
Given a list of N lists, each containing M positive integers, and a separate list of M positive integers (target values), return a list of N scalars (integers with a value of 0 or more) that correspond to each list in the lists of lists, such that when each value in a list is multiplied by it's scalar, and the values a...
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
Given a set of intervals \$\mathcal{I} = \{I_1, \ldots, I_m\}\$, where each interval \$I_j\$ is represented by its bounds \$(a_j, b_j)\$, find a partition \$\mathcal{T}\$ of \$\mathcal{I}\$ of minimal cardinality such that for each set \$T_i \in \mathcal{T}\$ it holds \$\bigcap T_i \ne \emptyset\$. In other words, find...
stackexchange_codegolf
For a 2 dimensional array we will define the elements in either the first row or the last column to be the largest "J-Bracket" of the array. For example in the following array elements in the J-bracket are highlighted: \$ \begin{bmatrix} \color{red}{\underline 1} & \color{red}{\underline 2} & \color{red}{\underline 4}...
stackexchange_codegolf
Description The Gameboy stores tiles as 2 bit-per-pixel 8x8 images, thus 16 bytes. Every two bytes is a complete row with all of the Low-bits of each pixel in the first byte, and all of the High-bits of each pixel in the second. Input Input will be exactly 16 bytes, received through Standard IO in one of the following...
stackexchange_codegolf
An Octothorpe, (also called number sign, hash or hashtag, or pound sign) is the following ASCII character: # Isn't that a fun shape? Lets make bigger versions of it! So here is your challenge: Given a positive integer N, output an ASCII hashtag of size N. For example, an ASCII hashtag of size 1 looks like this: # #...
stackexchange_codegolf
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
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
Yes, how much, not how many... As we all know, a large present is far better than a small one. Therefore, the value of the presents should always be measured in total volume, not number of presents, weight, or even combined price. As it's frowned upon to compare the amount of presents one gets, you don't want a long s...
stackexchange_codegolf
Here is Minkowski's question mark function: It is a strictly increasing and continuous function from the reals to themselves that, among other unusual properties, maps rational numbers to dyadic rationals (those with a power-of-two denominator). Specifically, suppose the continued fraction representation of a rational...
stackexchange_codegolf
The standard way to round numbers is to choose the nearest whole value, if the initial value is exactly halfway between two values, i.e. there is a tie, then you choose the larger one. However where I work we round in a different way. Everything is measured in powers of two. So wholes, halves, quarters, eights, sixte...
stackexchange_codegolf
Given an array of positive integers A as the input, generate a program that, when repeated for k times, output the kth(1-index) value of the array. For example, if the array is [1,11], the output should be a program that outputs 1, and when repeated twice, output 11. Code like print(end="1"); in Python 3 works: print(e...
stackexchange_codegolf
Write a program with length n that outputs another program whose length is the next Fibonacci number after n. The new program must do the same thing - output another program whose length is the next Fibonacci number, etc. n itself (the original program's length) does not have to be a Fibonacci number, although it would...
stackexchange_codegolf
Given a start word and a target word, print the "mutation chain" that starts at the start word and ends at the target word. You may assume both words are lowercase and only have alphabetic characters. Define a "mutation" as the removal of an character, the insertion of a character, or the altering of a character. For e...
stackexchange_codegolf
Your task is when given a chemical formula as input, output the total number of atoms in the formula. Input A chemical formula in any reasonable format. Each chemical formula has the following: A leading coefficient, which is a number \$N > 1\$. At least 0 groupings of elements surrounded by parentheses. Groupings ca...
stackexchange_codegolf
The least weird fact about the US presidency right now is that there have been two unrelated presidents whose last names start with T-R-U-M. That made me think, how many US presidents share other combinations of characters? There are obviously two presidents that share the characters "BUSH", and "ROOSEVELT". But did yo...
stackexchange_codegolf
Given an image, either as input (possibly in RGB triplets) or with the filename as input (you may assume the image has a specific filename, possibly without an extension), output an image representing a single color channel of the image. You will also take another input, representing which channel to output. The input ...
stackexchange_codegolf
Intro Help! I'm stuck on a snow-covered mountain and I need to get down as fast as possible, preferably without dying. I have a map showing how high each part of the mountain is above the normal ground. I am a novice skier, which means I like to stick to slopes that aren't too steep. I'm willing to go down just two mod...
stackexchange_codegolf
Challenge In this challenge, you are to code in any language a program or function that will take a string and replace certain characters within it with different characters. Input The input is the same for both functions and full programs: [string] [char1] [char2] string will be an indefinite line of characters surr...
stackexchange_codegolf
The Challenge In this challenge you have to do two different (but related) tasks depending of the order of the input. Your program will recieve a string s and an integer n as input and will split s into pieces of length n if s comes first. The last element will be shorter if necessary. split s into n pieces of equal l...
stackexchange_codegolf
Given an alphabet represented as a nonempty set of positive integers, and a word made up of symbols from that alphabet, find that word's position in the lexicographically ordered set of all words, assuming words can't contain duplicate symbols. Example Consider the alphabet {1, 2, 3} and the word [2, 3, 1]. The set of ...
stackexchange_codegolf
Background Most of you know what a Fibonacci number is. Some of you may know that all positive integers can be represented as a sum of one or more distinct Fibonacci numbers, according to Zeckendorf's Theorem. If the number of terms in the optimal Zeckendorf Representation of an integer n is itself a Fibonacci number, ...
stackexchange_codegolf
Task: Given an array of numbers as input (you can choose what subset, such as integers or natural numbers), replace all items with the number of times they appear within the array. As an example, [1, 2, 2, 1, 4, 8, 1] would become [3, 2, 2, 3, 1, 1, 3]. You can take input/produce output as arrays, lists, tuples, or any...
stackexchange_codegolf
I like anagrams. I like programs that reference their own source code. So this challenge combines them! Input. The input to the program could be anything, including letters, numbers, symbols, you name it. Output. A truthy value if the input's characters can be rearranged to give the source code, and a falsy value if th...
stackexchange_codegolf
Take as input an integer in any reasonable format. Then, output all the proper sub-strings of the base-10 digits of that integer that are powers of two, in any reasonable format. Test cases 10230 -> [1, 2] 13248 -> [32, 1, 2, 4, 8] 333 -> [] 331 -> [1] 32 -> [2] # As 32 is not a proper sub-string, since it is the whole...
stackexchange_codegolf
A Walsh matrix is a special kind of square matrix with applications in quantum computing (and probably elsewhere, but I only care about quantum computing). Properties of Walsh matrices The dimensions are the same power of 2. Therefore, we can refer to these matrices by two's exponent here, calling themW(0), W(1), W(2)....
stackexchange_codegolf
It is known that any natural number can be decomposed into the sum of three triangular numbers (assuming 0 is triangular), according to Fermat's Polygonal Number Theorem. Your task is to come up with an algorithm of decomposing number into 3 triangular numbers that has the best asymptotic complexity. As an input you ar...
stackexchange_codegolf
Write a program or function that alters the file at a user-specified filename via replacing all instances of UNIX line endings with Windows line endings and vice versa. Clarifications: For the purposes of this problem, a UNIX line ending consists of the octet 0A in hexadecimal, except when it is immediately preceded b...
stackexchange_codegolf
Note: This challenge is now closed. Any future cops' submission will not be considered for the accepted answer. This is to ensure that no one can post a very simple regex in the future that only remains uncracked because no one is interested in the challenge any more. The Cops' Challenge You are to write a short, obf...
stackexchange_codegolf
Challenge: Given two integers \$a\$ and \$b\$, with lengths \$A=length(a), B=length(b)\$, output an ASCII-art of the \$a^{th}\$ root of \$b\$, including the answer rounded to \$A\$ amount of decimal places. The size of the ASCII-art root also depends on \$A\$ and \$B\$. Example: \$a=123\$, \$b=1234\$ ____ 123 /123...
stackexchange_codegolf
Given an input integer n > 1, output an ASCII-art octagon with side lengths composed of n characters. See examples below: n=2 ## # # # # ## n=3 ### # # # # # # # # # # ### n=4 #### # # # # # # # # # # # # # # # # #### n=5 ##### ...
stackexchange_codegolf
Inspired by I reverse the source code, ... Your task, if you wish to accept it, is to reverse text and mirror select characters. Yes, yes, I know. Very surprising. Input A string, stdin, an array of characters, or any other source of text. All characters of the input are guaranteed to be in the printable ASCII range (3...
stackexchange_codegolf
Given n=m^2, return a list of integers that do not border the m x m grid of integers from 1 to n. Examples n=1 (m=1) Grid: [1] Return: [] n=4 (m=2) Grid: [1,2] [3,4] Return: [] n=9 (m=3) Grid: [1,2,3] [4,5,6] [7,8,9] Return: [5] n=16 (m=4) Grid: [ 1, 2, 3, 4] [ 5, 6, 7, 8] [ 9,10,11,12] [13,14,15,16] Return: [6,...
stackexchange_codegolf
Introduction This challenge is about producing a code to count the frequency of bigrams in a text. A bigram is two consecutive letters in a text. For instance 'aabbcd' contains the bigrams aa, ab, bb, bc, cd once each. Counting bigram frequencies is super useful in cryptography. In a brute force algorithm, this code ma...
stackexchange_codegolf
We've all heard of the Knight's Tour puzzle: find a route for a knight that passes through all the squares on a chess board. But let's be honest, it's a little bit boring. So, let's give the knight a bit of a challenge. Task Write a program that takes the knight through all the squares on an arbitrary-sized, arbitrary-...
stackexchange_codegolf
A polyiamond of size \$n\$ is a contiguous shape formed by joining \$n\$ equilateral triangles side by side. Your output should consist of two distinct characters, plus whitespace as necessary (▲ and ▼ work great!). Trailing whitespace is acceptable. You may use any other characters - but you may count ▲▼ as 1 byte e...
stackexchange_codegolf
Identify each letter of the English alphabet with the number denoting its position in the alphabet, that is, a = 1, b = 2, c = 3, ..., z = 26 (no distinction between lower and upper case letters is made). Every other character is identified with 0. The "sum" of a word is the sum of its characters, for example: the su...
stackexchange_codegolf
You find yourself in a strange place. A frighteningly dark maze, lit only by dim candles resting in the occasional hallway. Numerous paths lie only in impassable darkness, foreboding and-- ...Hm? What? Pick up a candle and carry it with you? No, no, that would be extremely rude. The Task Given a maze as input, output t...
stackexchange_codegolf
Yes, It's basically You're a Romanizer, Baby, but harder. like, way harder. Learning Korean is HARD. at least for a person outside Asia. But they at least have the chance to learn, right? What you must do You will be given a Korean Statement. For example, 안녕하세요. You must convert the input to its Roman pronunciation. ...
stackexchange_codegolf
This challenge is to produce the shortest code for the constant \$\pi^{1/\pi}\$. Your code must output the first \$n\$ consecutive digits of \$\pi^{1/\pi}\$, where \$n\$ is given in the input. Alternatively, your program may accept no input, and output digits indefinitely This is code golf, so the shortest submission ...
stackexchange_codegolf
Party time! All of your guests are sitting around a round table, but they have very particular seating requirements. Let's write a program to organize them automatically! Guests are represented by letters: Female guests are uppercase, males are lowercase. Couples have the same letter, one lower and one upper, like gG, ...
stackexchange_codegolf
What is the shortest sequence of moves that, from the solved state of the cube, creates a pattern that meets the following criteria: 6 colors on each face at most 2 facelets of the same color no adjacent facelets of the same color EDIT: I made up the name of the pattern. I asked this question in 2018 on Mathematics S...
stackexchange_codegolf
Given the number of vertices n ≥ 3 and the "step size" 1 ≤ m < n/2 (indicating the distance between two connected vertices), output a graphical representation of the corresponding regular polygram. If the polygram consist of multiple closed loops, each loop must be rendered in a different line colour. (If this sounds ...
stackexchange_codegolf
I made this because, although we have a bunch of other questions involving smiley faces, there is nothing for just printing an ASCII smiley face with as little code as possible. Anyway, print this exactly (Trailing spaces allowed): ********** ****************** ********************** ******* ****** ***...
stackexchange_codegolf
This reminds me when a few years ago someone uploaded a torrent "Hacker tool: complete list of all IP addresses". This was, of course, just a generated list of the ~4 billion IPv4 addresses, but thousands of "h4xx0rz" downloaded it. Look mum, imahacker! This was then, but nowadays everybody has switched to IPv6. (Rig...
stackexchange_codegolf
Everyone knows log scales are for quitters. Therefore, you must write a program or function that de-quitifies a bar graph with a log scale given a base. The bar graph input is taken as a single string which is a list of bars, where each bar of the log scale bar graph is separated by the printable (or whitespace) delimi...
stackexchange_codegolf
Starting an the origin on an infinite grid, you follow a predetermined path going up (U), down (D), left (L), or right (R). You paint every square you visit, including the square you started at and the square you finish at. Using this method, we can paint the number six using the instructions RRDDLLUUUURR: The origin ...
stackexchange_codegolf
In today's episode of AAOD, we are going to construct a Chinese Shrine of varying heights. Consider the following examples for height (N) 1 to 6 N = 1: . | . ]#[ . \_______/ . ]###[ . \__]#.-.#[__/ |___| |___| |___|_|___| ####/_\#### |___| /_____\ N = 2: . ...
stackexchange_codegolf
Background A maximal domino placement (MDP) on a rectangular grid is a non-overlapping placement of zero or more dominoes, so that no more dominoes can be added without overlapping some existing domino. Alternatively, it can be thought of as a tiling using dominoes and monominoes (single square pieces) so that no two m...
stackexchange_codegolf
Some chess variants use interesting non-standard pieces. In order to concisely describe new pieces or to describe pieces without requiring everyone to memorize a bunch of non-standard names some new notation can be invented. In this challenge we are going to look at Parlett's movement notation and convert it to nice at...
stackexchange_codegolf
An "Egyptian fraction" is a list of distinct fractions with a numerator of \$1\$. For example: \$ \frac 1 1+ \frac 1 2 + \frac 1 3 + \frac 1 6 \$ The "size" of an Egyptian fraction is just the number of terms involved. Your task is to take a positive integer \$n\$ and output the smallest Egyptian fraction that sums t...
stackexchange_codegolf
Asked on Stack Overflow, but they suggested to move it here A while ago I was reading about quines. It made me wonder if it possible to write a macro in C which will print itself, without writing any function such as main. every piece of code should be only in macro. After a few attempts, I couldn't find the solution. ...
stackexchange_codegolf
The Challenge Given a rational number, determine the smallest number which is a positive integer multiple of it. Eg. Given: 1.25 x1: 1.25 x2: 2.5 x3: 3.75 x4: 5 Thus: Answer is 5 Clarifications Inputs will be a rational number in the range of (0,100] of which the Decimal Representation has no more than 4 ...
stackexchange_codegolf
I need a UUID. Your job is to generate one. The canonical UUID (Universally Unique IDentifier) is a 32 digit hexadecimal number with hyphens inserted in certain points.The program should output 32 hex digits (128 bits), in the form of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (8-4-4-4-12 digits), where x is a random hexadec...
stackexchange_codegolf
In some languages, strings are started and ended with a quote mark ('). And quote itself is escaped by writing it twice sequentially. For example, empty string is written as '', and I'm is written as 'I''m'. This question is about find out all non-overlapping strings from left to right in such format from the given inp...
stackexchange_codegolf
Background You awake on the ground. Above you is a giant stepped pyramid-like structure. Based on your ancient history lessons, you recognize it as a ziggurat. You have been transported by Dr. Sargostein back into ancient Mesopotamia to play a game. In this King of the Hill Ziggurat challenge, you will write a bot that...
stackexchange_codegolf
Instructions Your goal is to write code that makes a "string" from a string in the least amount of bytes possible, as per the rules of code-golf. Standard loophole rules apply. To make a string, you have to assume the string contains only alphabetical characters and basic punctuation such as the period, comma, colons a...
stackexchange_codegolf
What is the shortest way to secure a site with Javascript? I am new to Code Golfing, and this is what I've come up with so far. I bet that this could be improved though: Challenge: Make a script which redirects http:// to https:// with the least bytes of code Attempts: Original code (150ish BYTES!): if (window.locati...
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
(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
Fizz Buzz is a common challenge given during interviews. The challenge goes something like this: Write a program that prints the numbers from 1 to n. If a number is divisible by 3, write Fizz instead. If a number is divisible by 5, write Buzz instead. However, if the number is divisible by both 3 and 5, write FizzBuzz...
stackexchange_codegolf