instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Given a string whose length is divisible by 4, make a triangle as demonstrate below. If the string is abcdefghijkl, then the triangle would be: a b l c k defghij If the string is iamastringwithalengthdivisiblebyfour, then the triangle would be: i a r m u a o s f ...
stackexchange_codegolf
Having a function f that takes arguments x1, x2, …, xn                                                – ie.  f : X1 × X2 × … × Xn → Y – currying redefines f as a function taking a single argument a1 which maps to yet another function. This technique is useful for partial application, for example with a curried pow func...
stackexchange_codegolf
Gimbap(김밥) is Korean food, somewhat looks like sushi roll. Here is Korean emoticon represent Gimbap : @)))))))))) Your quest is make ASCII Gimbap cutter. Rule Input is string made with only @ and ). Output cuts every valid Gimbap with ), and then add @ between them. So for example @)) to @) @). Valid Gimbap starts wi...
stackexchange_codegolf
Given no input, output this interesting alphabet pattern in either case (the case has to be consistent) via an accepted output method: A AB ACBC ADBDCD AEBECEDE AFBFCFDFEF AGBGCGDGEGFG AHBHCHDHEHFHGH AIBICIDIEIFIGIHI AJBJCJDJEJFJGJHJIJ AKBKCKDKEKFKGKHKIKJK ALBLCLDLELFLGLHLILJLKL AMBMCMDMEMFMGMHMIMJMKMLM ANBNCNDNENFNGN...
stackexchange_codegolf
You will be given a string. It will contain 9 unique integers from 0-9. You must return the missing integer. The string will look like this: 123456789 > 0 134567890 > 2 867953120 > 4
stackexchange_codegolf
Imagine you have an array of integers, whose non-negative values are pointers to other positions in the same array, only that those values represent tunnels, so if the value in position A is positive and points to position B, then the value in position B must be also positive and point to position A to represent both e...
stackexchange_codegolf
In this challenge you will write code to take a list of positive integers and output all maximal linear sublists. A sublist is is a list which can be created by deleting values from the the input list. Sublists have more structure than just lists. They in a way "remember" which values are deleted. Similarly we say tha...
stackexchange_codegolf
Mr. Moneybags is a very rich man. He has an assistant Mr. Perfect, who one day, got very mad, and shredded some of Mr. Moneybag’s $100 bills! Mr. Moneybags decided to punish Mr. Perfect. Mr. Moneybags tells Mr. Perfect to stack his money into different piles. He starts with N (1 <= N <= 1,000,000, N odd) empty stacks...
stackexchange_codegolf
This idea is loosely based upon @TùxCräftîñg's chat message. Take a look at the below example sequence: INVALID0, INVALID1, INVALID2 INVALID3, INVALID4... INVALID9 After INVALID9, it goes on like this: INVALI0, INVALI1, INVALI2, INVALI3... INVALI9 And after INVALI9, it's like this: INVAL0,INVAL1, INVAL2, INVAL3... INVA...
stackexchange_codegolf
Inspired by this unassuming StackOverflow question. The idea is simple; given a String and an array of Strings, remove any instances of words in the array (ignoring case) from the input String other than the first, along with any additional whitespace this may leave. The words must match entire words in the input Strin...
stackexchange_codegolf
Draw a series of connected polygons like the one shown above. However, what the above picture does not show is the spiral formed by consecutive vertexes: The limitation of these is that there is only 1 spiral marked. You should mark all the spirals. This can be done by rotating each spiral shown above so that there i...
stackexchange_codegolf
Inspired by Braille graphics and Build an analog clock. The goal there is to create a tool that use terminal console to draw and animate a clock by using UTF-8 fonts \U2800: ⠀ to \U28FF: ⣿. 00:[⠀] 01:[⠁] 02:[⠂] 03:[⠃] 04:[⠄] 05:[⠅] 06:[⠆] 07:[⠇] 08:[⠈] 09:[⠉] 0A:[⠊] 0B:[⠋] 0C:[⠌] 0D:[⠍] 0E:[⠎] 0F:[⠏] 10:[⠐] 11:[⠑] 12:...
stackexchange_codegolf
Write a program or function that takes in three positive integers, W, H, and N. Print or return a W×H grid of .'s where every Nth . in normal English reading order is replaced with an X. For example, given W = 7, H = 3, N = 3, the grid is 7 characters wide and 3 high, and every third character reading from the top left...
stackexchange_codegolf
Print or return the following string: zottffssentettffssenttttttttttttttttttttffffffffffffffffffffsssssssssssssssssssseeeeeeeeeennnnnnnnnno This is the first letter of each of the numbers zero, one, two, all the way up to one hundred. Standard I/O rules apply, but the output must be exactly as shown above, optionally ...
stackexchange_codegolf
It is ancient knowledge that every non-negative integer can be rewritten as the sum of four squared integers. For example the number 1 can be expressed as \$0^2+0^2+0^2+1^2\$. Or, in general, for any non-negative integer \$n\$, there exist integers \$a,b,c,d\$ such that $$n = a^2+b^2+c^2+d^2$$ Joseph-Louis Lagrange pro...
stackexchange_codegolf
Introduction: Although it seems challenges scored by least unique characters have been attempted, there are few which were well-received. I think it's a potentially interesting scoring criterion, as long as different languages aren't competing with each other (as with code golf). Challenge: Create a basic FizzBuzz prog...
stackexchange_codegolf
Program: To count the sum of all Unicode characters of a given input. (No need to display the output. The final answer can be calculated in any base no need to convert back to hexadecimal.) Test case : XyZ= 0058+0079+005A=012B Condition: If the program is inputted, then its output must be an integral multiple of 1729 (...
stackexchange_codegolf
Squares looks symmetric, and so are the required codes. Objective: Write a program whose source code is a solid square (N lines with N printable, non-whitespace characters each line) and prints a square of equal size. A program (or output) with inconsistent width and height is invalid. (e.g. 6x5) Example (HQ9+) QAA AAA...
stackexchange_codegolf
I was browsing esolangs, and chanced upon this language: https://github.com/catseye/Quylthulg. One interesting thing about this language, is that it doesn't use prefix, postfix, or infix, it uses all three of them, calling it "panfix" notation. Here is an example. To represent normal infix 1+2 in panfix, it becomes: +1...
stackexchange_codegolf
Given a list of positive integers, write code that finds the length of longest contiguous sub-list that is increasing (not strictly). That is the longest sublist such that each element is greater than or equal to the last. For example if the input was: \$[1,1,2,1,1,4,5,3,2,1,1]\$ The longest increasing sub-list would ...
stackexchange_codegolf
You are given a string \$s\$ of characters from a to z. Your task is to count how many unique strings of length \$n\$ you can make by concatenating multiple prefixes of the string \$s\$ together. Since the result can be superlative you can either choose to output the whole result, the result mod \$2^{32}\$ or the resul...
stackexchange_codegolf
Find the moves that bring a chess squad to a given destination. You control a chess squad consisting of a king and several other pieces, on a larger chess board. Your army is placed so that no piece is further than K=8 squares away (horizontally and vertically) from your king. You will receive a destination square for ...
stackexchange_codegolf
Task Any one of these two: Determine if a given position (an ordered non-empty collection of integers in the range ‒8 to 8, or ‒7 to 7 if you want) is a valid Dimensional Chess position. List all the valid positions in any order. Make sure to describe your input (if not listing all) and output formats. The 2368 vali...
stackexchange_codegolf
The brainiacs at New Scientist tweeted this morning that "The word STABLE has the neat property that you can cycle the first letter to the end to make a new word: TABLES. And you can do it again to make ABLEST." (https://twitter.com/newscientist/status/1379751396271124480) This is of course correct. It is not, however,...
stackexchange_codegolf
The question score on Stack Exchange is the total number of upvotes minus the total number of downvotes a question receives. However, the reputation gained/lost for every upvote/downvote is different (eg. 10/-2 on Code Golf). Given the total reputation earned, the reputation gained by an upvote and the reputation lost ...
stackexchange_codegolf
The Triforce is a fictional artifact in The Legend of Zelda, made of three identical-looking equilateral triangles representing power, wisdom and courage. Several games in the saga include an animation when the three parts finally join together. The purpose of this challenge is to draw a single 2D frame of such a simpl...
stackexchange_codegolf
It is well known, in the field of Mathematics studying infinity, that the Cartesian product of any finite amount of countable sets is also countable. Your task is to write two programs to implement this, one to map from list to integer, one to map from integer to list. Your function must be bijective and deterministic,...
stackexchange_codegolf
Given a string containing some parentheses and some other ASCII printable characters, like this: (abc((123))(k)) your task is to remove any sets of parentheses that are redundant. A set of parentheses is redundant if: It encloses another set of matching parentheses, like ab((123)), or It encloses the entire string, li...
stackexchange_codegolf
Challenge Given a graphical input of a shape, determine how many holes there are in it. Not Duplicate This question was marked as a possible duplicate of Count Islands. I believe this challenge is different from the Count Island challenge because in this one, you have to figure out how to eliminate blocks that touch th...
stackexchange_codegolf
Introduction Nine-Ball is a popular pool game played casually and as a competitive sport. There is one of each numbered ball, with the numbers 1 to 9. The game starts with all 9 of the balls in a diamond shaped rack, like so: 1 2 3 4 9 6 5 7 8 The 1 ball is always at the front of the diamond, and the 9 ball is a...
stackexchange_codegolf
TailwindCSS is a utility that lets one write CSS code using only HTML classes, which are then converted to CSS code with the Tailwind compiler. Ordinarily, one would write CSS in a separate file from the HTML, and reference named classes: <!-- without Tailwind --> <p class="crazy-monologue">Crazy? I was crazy once. The...
stackexchange_codegolf
Your task Given a integer input, \$ n \$ (such that \$ n > 1 \$), decide whether it can be written as the sum of (at least 2) consecutive square numbers. Test cases Truthy: Input Explanation 5 1 + 4 13 4 + 9 14 1 + 4 + 9 25 9 + 16 29 4 + 9 + 16 30 1 + 4 + 9 + 16 41 16 + 25 50 9 + 16 + ...
stackexchange_codegolf
I don't know if something like this exists already (and I'm not finding the right key words) but if not, it felt like it could be an interesting coding puzzle. The challenge is, to take an arbitrarily nested list (no more than 2 deep), and display the content in a terminal in 2 dimensions in a 'pretty' manner. Each 'to...
stackexchange_codegolf
Given a non-empty list/vector of positive integers, write a function to check the following conditions in as few bytes as possible. Take the first integer (the key, or k1) and check that the next k1 values have no duplicate values, excluding instances of k1. Take the last integer (the second key, or k2) and check tha...
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
Challenge For any string that is composed of alphabetical characters of any case, make a function that returns a list of all of it's variations, order and case-wise empty strings returns empty list. Test Cases "" -> [] "a" -> ['a', 'A'] "ab" -> ['ab', 'Ab', 'aB', 'AB', 'ba', 'Ba', 'bA', 'BA'] "abc" -> ['abc', 'Abc', '...
stackexchange_codegolf
Given a positive integer N, output this doubling pattern of slash squares/rectangles. For N=1, the base is: /\ \/ The next square is added in the bottom right direction for N=2: /\ \/\ \/ After that, a 2x1 rectangle is added in the bottom left direction for N=3: /\ /\/\ \ \/ \/ Then a 2x2 square is added in the t...
stackexchange_codegolf
The goal of this challenge is to compare how well different programming languages support functional programming, by seeing how much code it takes to implement BLC8, the simplest functional programming language BLC8 is the bytewise variant of Binary Lambda Calculus, as described in my 2012 IOCCC entry at https://www.io...
stackexchange_codegolf
Your task is to write code that will leak at least one byte of memory in as few bytes as possible. The memory must be leaked not just allocated. Leaked memory is memory that the program allocates but loses the ability to access before it can deallocate the memory properly. For most high level languages this memory ...
stackexchange_codegolf
You find yourself on a chessboard, as one does. You can see the exit but it is awfully far away and you would rather not walk all the way. Luckily some locals have offered you a ride. A Knight, a Rook, a Bishop and a King are all willing to take you to your destination, but seeing how this is a chessboard they must e...
stackexchange_codegolf
Make a snake fill any maze (until it gets stuck). The snake The snake starts at a given starting point, pointing EAST. It moves by always having a wall or a part of its body immediately to the LEFT of its head ("left-hand rule wall follower"), until it gets stuck because all four directions around its head are occupied...
stackexchange_codegolf
Background: The current Perfect Numbers challenge is rather flawed and complicated, since it asks you to output in a complex format involving the factors of the number. This is a purely decision-problem repost of the challenge. Challenge Given a positive integer through any standard input format, distinguish between wh...
stackexchange_codegolf
Or Fix American Kennel Club's database As covered by the recent video by Matt Parker, the American Kennel Club permits thirty-seven (37) dogs of each breed to be assigned the same name (source), because of a database restriction for Roman numeral length. Given an integer, your task is to output the length of its Roman ...
stackexchange_codegolf
I like to pretty print multidimensional arrays, like this: [ [ [1, 2, 3], [4, 5, 6] ], [ [7, 8, 9], [6, 4, 2] ] ] But it's a pain to do by hand and it'd be nice to have a program that does this for me. Your challenge is to create a program that does this for me, taking a multidimensional array containing onl...
stackexchange_codegolf
The task is to count the number of disjoint 11 blocks in a 64-bit word, using the minimum number of straight-line instructions. That is, how many nonoverlapping neighbored pairs of 1-bits can be found. Examples (imagine leading zeros to fill up to 64 bits) Input Output 111111 3 1110111 2 111100...
stackexchange_codegolf
Note: As per consensus on Meta, challenge-writing questions are on topic here. In light of this "thing to avoid when writing challenges", I started to think about challenges involving random generation of certain kinds of objects. It sometimes happens that I want to post a code-golf challenge that involves randomly g...
stackexchange_codegolf
A common visual explanation of the Pythagorean theorem is as such: The squares are meant to represent the side length's squared, and the areas of a + b = c, just like the Pythagorean theorem says. This part is what you have to show. Your task You will get two integers as input, meant to represent sides a and b of a r...
stackexchange_codegolf
Problem description Vertices \$V\$ of directed graph \$G=(V,E)\$ represent gossipping ladies; edge \$(u,v) \in E\$ signifies that lady \$u\$ knows of lady \$v\$ (which does not imply that lady \$v\$ knows of lady \$u\$). Assume that each lady knows of herself. Intuitively, lady \$a\$ gossips about every lady \$b\$ she ...
stackexchange_codegolf
A binary multiple of a positive integer k is a positive integer n such that n is written only with 0s and 1s in base 10 and n is a multiple of k. For example, 111111 is a binary multiple of 3. It is easy to show that a positive integer has infinitely many binary multiples. See here for a construction proof of one binar...
stackexchange_codegolf
Inspired by Make a Rectangle from a Triangle. Task There is a famous formula on the sum of first \$n\$ squares: $$ 1^2 + 2^2 + \dots + n^2 = \frac{n(n+1)(2n+1)}{6} $$ It is known that this number is composite for any \$n \ge 3\$. Now, imagine a collection of row tiles (a tile of shape \$1 \times k\$ with the number \$k...
stackexchange_codegolf
Task A pure mirror checkmate is a checkmate position, where the mated king is surrounded by 8 empty squares which are attacked or guarded by the winning side exactly once. You will be given a valid chess position where Black is in mate. Your task is to find if that mate is a pure mirror checkmate. Examples (click for l...
stackexchange_codegolf
Given an integer k and either a block of text, or a 2d array that the inner arrays may have unequal lengths (that resembles a block of text), rotate every character or element in the k-th column up or down to the next position that exists. Example Rotate the 20th column of the following text (1-based): A line with more...
stackexchange_codegolf
Challenge: You are given a string containing only digits. Your task is to output the minimum number of primes which must be concatenated to form the string. If this is impossible, output 0. Test Cases: Input -> Output: 252 -> 3 235 -> 2 92 -> 0 31149 -> 2
stackexchange_codegolf
If you are unfamiliar with hacker typer, see hackertyper.net. In short, it is a program that outputs one chunk of a code base per keystroke for comedic effect. BUT, the hackertyper.net version is far too easy to implement. It simply outputs three characters at a time from an arbitrary piece of code. For this challenge,...
stackexchange_codegolf
Dr. Trump is the head psychiatrist at a mental hospital, which is populated by murdering psychopaths. If 2 psychopaths are left together, they will end up brutally injuring or even killing each other, so Dr. Trump needs to build walls to separate these psychopaths, but owing to the limited amount of funds he has left, ...
stackexchange_codegolf
This code challenge will have you compute the number of ways to reach \$n\$ starting from \$2\$ using maps of the form \$x \mapsto x + x^j\$ (with \$j\$ a non-negative integer), and doing so in the minimum number of steps. (Note, this is related to OEIS sequence A307092.) Example So for example, \$f(13) = 2\$ because t...
stackexchange_codegolf
This is somewhat similar to The centers of a triangle, but with a different point. The Fermat Point is the point P in triangle ABC such that the value of AP + BP + CP is minimized. There are two cases: If there is an angle greater than 120 degrees, that vertex is the fermat point. Otherwise, draw equilateral triangles ...
stackexchange_codegolf
Something I found while looking through some old files. It seemed like a neat idea for a code golf challenge. The intro One of the most popular events at the annual Cyclist's Grand Competition for Charity (CGCC) is the rocket bike parcours. The rules are simple: Inspect the parcours and place a bet on wheather is it po...
stackexchange_codegolf
This is a cops-and-robbers if you are not familiar with the format click the tag to go to the wiki. There will not be a robbers' thread for this question. Cops Your task as Cops is to select two sequences from the Online Encyclopedia of Integer Sequences and write a program that takes the nth element of one sequence a...
stackexchange_codegolf
With all the gyms closed down with the COVID-19 situation, we have to exercise with the weight we have lying around at home. The problem is, we have a small selection of plates at varying weights, and can't immediately determine if we can create a setup at the desired weight. Given an unsorted array of weighted plates...
stackexchange_codegolf
I was looking for a very easy task to look how short of a code can be produced on a beginners exercise. The goal is to produce a simple table that looks like this common java/c# code is about 4 lines. So get your golfing-languages ready ;) Try to align the matrix in any way it is readable. 1 2 3 .. 10 2 4 6 .. ...
stackexchange_codegolf
Today, my girlfriend and I started with this year's Advent of Code to improve our Python. So far we only did Day 1 and the first part of Day 2. The latter, I found to be very fun, so, to spice it up a little, and with a tip o' the head to Eric Wastl, here's my attempt at turning it into a Code Golf challenge. Task Your...
stackexchange_codegolf
Sandbox What is Hexagonification™? Hexagonification™ is a transformation that creates a hexagon with 3 copies of a rectangle block, each skewed to the right by 30 degrees and then rotated by 0, 120 and 240 degrees respectively, as shown in the following image. A triangle hole may appear in the middle, but that isn't a ...
stackexchange_codegolf
Bob got kidnapped and is stuck in a maze. Your job is to help him find a way out. But since it is a very dark and scary maze, he can't see anything. He can only feel walls when he runs in to it, and knows when he has found the exit, but doesn't know anything more that. Since he has to run your program by memory, it has...
stackexchange_codegolf
Let's say you have a stack, which at the start contains a b c in this order (a is on the top). You are given the required output stack, in any reasonable format (a list, a string, etc.), e.g. [a, c, b] (here a is on the top, below it c and below it b). You can also take the input reversed if you want, e.g. [b, c, a] wh...
stackexchange_codegolf
I have a lot of java projects and I am often making new ones. I have a few helper classes (Vector, Logger, etc.) and it takes a lot of time correcting the first line to the correct package, I would really need a little program to help me fix it automatically. Your program will first take the name of the package the fi...
stackexchange_codegolf
Challenge I've checked that there is a question Compute the Discrete Cosine Transform which is a competition for implementing a shortest solution to compute the one dimensional discrete cosine transform. The goal of this challenge is to implement a program to calculate three dimensional discrete cosine transform which ...
stackexchange_codegolf
Given one of the 50 U.S. state names on the left as input, output its two-letter postal code as shown to the right: Alabama AL Alaska AK Arizona AZ Arkansas AR California CA Colorado CO Connecticut CT Delaware DE Florida FL Georgia GA Hawaii ...
stackexchange_codegolf
tl;dr? See bottom for The Competition Integer literals While programming, the 64-bit hexadecimal literal 0x123456789abcdefL is difficult to gauge the size of. I find myself mentally grouping digits from the right by fours to see that it's 15 digits' worth. Python PEP 515 allows you to express the above literal, insid...
stackexchange_codegolf
Whispers is February 2021's Language of the Month, so what tips do you have for golfing in it? Tips do not have to be specific to code-golf, so long as they apply to other types of challenges on the site. Tips should be at least somewhat specific to Whispers (e.g. "remove ignored code" is not an answer). Please post on...
stackexchange_codegolf
I think the Collatz Conjecture is already well-known. But what if we invert the rules? Start with an integer n >= 1. Repeat the following steps: If n is even, multiply it by 3 and add 1. If n is odd, subtract 1 and divide it by 2. Stop when it reaches 0 Print the iterated numbers. Test cases: 1 => 1, 0 2 ...
stackexchange_codegolf
The popular webcomic Homestuck makes use of a programming language called ~ATH to destroy universes. While this code golf challenge is not to write a program to annihilate our existence, we will be destroying some more tame (albeit less interesting) entities: variables.  ~ATH (pronounced "til death," notice how ~ath is...
stackexchange_codegolf
A store is having a big sale. If your price reaches $199 or more, you can reduce it by $100. You can buy each product only once. Here's an example list of products: (in order to simplify, the names of the products are represented by letters) +------+-------+ | name | price | +------+-------+ | A | 26.9 | | B | 2...
stackexchange_codegolf
Oh no! Nemo, our small clown fish is lost in this ASCII ocean and his dad Marlin is trying to find him. Your task is to get Marlin to Nemo safely. But beware, we have a feeding frenzy Bruce on the loose, so better avoid him at all costs! Details You are given a rectangular ASCII ocean grid containing only lowercase alp...
stackexchange_codegolf
Sociable numbers are a generalisation of both perfect and amicable numbers. They are numbers whose proper divisor sums form cycles beginning and ending at the same number. A number is \$n\$-sociable if the cycle it forms has \$n\$ unique elements. For example, perfect numbers are \$1\$-sociable (\$6\to6\to\cdots\$) and...
stackexchange_codegolf
In this challenge, your job is to find the straightest path from point A to point B in a two-dimensional maze. This is very similar to finding the shortest path, which has been done to death, but instead of minimizing the length of the path, you minimize the number of turns (or angles or corners, whatever you want to c...
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
Write a program that takes in a rectangular block of text made up of X's and .'s, such as this rough A: ...... ..XX.. .X..X. .XXXX. .X..X. .X..X. Output a representation of this grid rotated 45 degrees counterclockwise by drawing a slash — forward or backward depending on context — everywhere an X borders a . or the s...
stackexchange_codegolf
I have a cake shop that specialises in birthday cakes. The cakes that I sell must have candles placed in a circle. You would probably think I can just divide 360° by the number of candles, but the machine for placing candles is quite unique; it uses a list of numbers representing positions of candles, placing them one-...
stackexchange_codegolf
"Set" is a card game played with a deck of 81 cards, twelve of which are pictured below: Each card has four attributes, each of which may assume three values: Number: the number of symbols, either 1, 2, or 3 Shape: the shape of the symbol, either squiggle, diamond or oval Colour: either purple, red or green Shading: ...
stackexchange_codegolf
As we all know, most Pokemon are created by combining some English (or Japanese) words; these words are the Pokemon's "etymology." For example, "charmander" is "char" and "salamander" put together. Your task is, given a Pokemon's etymology and number, output the original Pokemon name. A short answer will be able to com...
stackexchange_codegolf
In the tabletop RPG named Pathfinder, there is a feat that characters can take called Sacred Geometry, which allows a character who has it to buff their spells in exchange for doing some math: to use it, the character rolls a number of six-sided dice equal to their ranks in a particular skill, consults a table based on...
stackexchange_codegolf
Given two positive integers, W and H, output an ASCII-art box whose border is made of slashes (/ and \) with W "spikes" on the top and bottom edges, and H "spikes" on the left and right edges. The box's interior is filled with spaces. A "spike" is simply two slashes coming together to form an arrow shape: /\ \/ / ...
stackexchange_codegolf
Given a list of production rules and start symbol of a proper finite context-free grammar (CFG) of printable characters, your program or function must output its formal language (the set of all sentences which can be constructed from it). Task A context-free grammar is formally defined as a 4-tuple of a few parts. Here...
stackexchange_codegolf
This wasn't originally intended for code-golf, just as a little debugging routine to roughly visualize something "goofy" going on in a model of some (irrelevant here) physical process. But when I saw how surprisingly short it was, compared to my expectations, I just wondered if it can be further shortened. And that's p...
stackexchange_codegolf
Given a list of strings, sort the list as numbers without knowing what base is used. The values of the digits are also unknown (it is possible that '1' > '2'). Since the values of digits are unknown, use Benford's Law (or First Digit's Law) to determine the relative value of the digits. For distributions that follow Be...
stackexchange_codegolf
Input Name of a stackexchange site or any way to uniquely identify the site. Output The hour of the day that had the largest number of answers posted over the previous 24 hours. E.g. 14:00-15:00 GMT. You can take the input and give output in any easily human readable format. Your code can access the Internet but only t...
stackexchange_codegolf
Introduction The Dragon's Curve is a fractal curve that notably appears on section title pages of the Jurassic Park novel. It can very simply be described as a process of folding a paper strip, as explained in the Wikipedia article about this curve. The first few iterations of the generation of this curve look like thi...
stackexchange_codegolf
Modern mathematics has been formalised using set theory by various systems of axioms. Zermelo Frankel set theory with the axiom of choice (ZFC) forms an intuitive set of axioms and is hence most popular, though stronger choices exist. Inspiration: A Relatively Small Turing Machine Whose Behavior Is Independent of Set T...
stackexchange_codegolf
Your task is to output a spaceship of size n with shooters/guns and n bullets of character - (with spaces in between each bullet) for each gun Rules If n is odd, you must output the guns every even numbered row If n is even, you must output the guns every odd numbered row All rows with guns must have n+1 # character...
stackexchange_codegolf
Disclaimer: No, this is not a joke challenge to reverse a string. Task There is only one operation to support: subtraction (-). You also only have two atoms to support: zero (0) and one (1). Here, the prefix notation -AB is equivalent to the postfix notation AB-, where A and B are expressions. Your task is to (recursiv...
stackexchange_codegolf
Inspired by this Stack Overflow question. The challenge Input An array of square matrices containing non-negative integers. Output A square matrix built from the input matrices as follows. Let \$N \times N\$ be the size of each input matrix, and \$P\$ the number of input matrices. For clarity, consider the following ex...
stackexchange_codegolf
Background A magic square is an n×n matrix consisting of one of each of the integers from \$1\$ to \$n^2\$ where every row, column, and diagonal sum to the same value. For example, a 3×3 magic square is as follows: 4 9 2 3 5 7 8 1 6 Here, each row, column, and diagonal sum to the magic sum of 15, which can be calculat...
stackexchange_codegolf
Background I wanted to make a pretty word cloud, like this: these are words floating I computed the (x,y)-coordinates of the first letter of each word, plugged them into my word cloud generator, and let it do its job. However, I accidentally used (y,x)-coordinates, so the result looks like this: these ...
stackexchange_codegolf
Quell is a single-player grid-based puzzle game. Pearls are scattered across a 2D map and the aim is to collect them all by rolling a drop of water over them. For this challenge we will only consider basic maps containing the drop, pearls, walls, and empty spaces. (The full game includes a variety of additional objects...
stackexchange_codegolf
let S, a and b each represent a string Goal: Write a standard string replace function where the you replace all occurrences of a in a string S with b so long as a is not already part of an instance of b for example, if we have the string S = My oh my that there is a big ol' that and we wanted to do a fancy replace with...
stackexchange_codegolf
Make a program that simulates the basic logic gates. Input: An all-caps word followed by 2 1 digit binary numbers, separated by spaces, such as OR 1 0. The gates OR, AND, NOR, NAND, XOR, and XNOR are needed. Output: What the output of the entered logic gate would be given the two numbers: either 1 or 0. Examples: AND ...
stackexchange_codegolf
Introduction I've always liked the idea of finding the most possible bang-for-your-buck squeezed out of a tiny chip, like the 6502. Of course, I'll need to start small. Filling the screen on 6502asm.com should be easy enough. Challenge Fill the entire program output screen on 6502asm.com with the color white using the ...
stackexchange_codegolf
Given two positive integers \$n\$ and \$b\$, such that \$n > 2\$ and \$n > b > 1\$, count the trailing zeros when converting \$n\$ to base \$b\$. Your program should be able to handle any value of \$b\$ within your integer maximum. The digits of \$n = 18\$, \$b = 3\$ are \$[2,0,0]\$, so the correct output is \$2\$. T...
stackexchange_codegolf
Related: Name the poker hand A straight flush is a poker hand containing five cards of sequential rank, all of the same suit. As part of a straight flush, an ace can rank either above a king or below a two. An ace can rank either high (e.g. A♥ K♥ Q♥ J♥ 10♥ is an ace-high straight flush) or low (e.g. 5♦ 4♦ 3♦ 2♦ A♦ is ...
stackexchange_codegolf