instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Given a list of strings, replace each string by one of its non-empty substrings which is not a substring of any of the other strings in the list and as short as possible. Example Given the list ["hello","hallo","hola"], "hello" should be replaced by just "e" as this substring is not contained in "hallo" and "hola" and ...
stackexchange_codegolf
Challenge Generate two \$16 \times 16\$ grids, each initially filled with "@" symbols and spaces. Each cell in the grids should be independently filled with an "@" or a space, with each character having an equal probability (\$50\%\$) of being chosen for each cell. This ensures that both grids start off identically, wi...
stackexchange_codegolf
Write a quine which attempts to invert the case of as many ascii characters in the source code as possible. For example in javascript: (x=function(y){return ('(x='+y+')(x)').toUpperCase();})(x) Standard quine rules apply. The score is given by number of bytes in the source code - number of case inversions. For examp...
stackexchange_codegolf
Write a function that takes as input a set of integers (can be a list, array or any other container with distinct numbers), and outputs the list of all its permutations. Python (95 chars): p=lambda s:s and sum(map(lambda e:map(lambda p:[e]+p,p(filter(lambda x:x!=e,s))),s),[]) or [[]] It'd be nice to be beaten in the sa...
stackexchange_codegolf
A ragged array is an array where each element is an array of unknown number of positive integers. For example, the following are ragged arrays: [[1,2,3],[4],[9,10]] Shape: 3,1,2 [[1],[2],[3]] Shape: 1,1,1 [[1,2,3,4,5,6,8]] Shape: 7 The following are not ragged arr...
stackexchange_codegolf
This is the cops thread of this cops and robbers challenge. The robbers thread is here. Related, but hashes numbers instead of strings and uses a different scoring system. Definitions A hash collision is when two different strings produce the same hash. Summary In this challenge, the cops will make a hash function, wit...
stackexchange_codegolf
I want you to make a gui window like this: * if you're thinking, the [quit] button closes the window in any language using minimum "different" characters.. AND remember that the gui window must use native widgets instead of custom icons and buttons like I have Windows 8, so my GUI window looks like this: If you didn'...
stackexchange_codegolf
Write a function which takes in a list of positive integers and returns a list of integers approximating the percent of total for the corresponding integer in the same position. All integers in the return list must exactly add up to 100. You can assume the sum of integers passed in is greater than 0. How you want to r...
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 sentence employs two a’s, two c’s, two d’s, twenty-eight e’s, five f’s, three g’s, eight h’s, eleven i’s, three l’s, two m’s, thirteen n’s, nine o’s, two p’s, five r’s, twenty-five s’s, twenty-three t’s, six v’s, ten w’s, two x’s, five y’s, and one z. Such sentences are called autograms. Your task is to write a p...
stackexchange_codegolf
Given an integer, output a truthy value if it is the same upside-down (rotated 180°) or a falsy value otherwise. 0, 1, and 8 have rotational symmetry. 6 becomes 9 and vice versa. Sequence of numbers producing truthy results: OEIS A000787 0, 1, 8, 11, 69, 88, 96, 101, 111, 181, 609, 619, 689, 808, 818, 888, 906, 916, 98...
stackexchange_codegolf
A palindrome is a string which is the same when read forwards and backwards. For example "racecar" is a palindrome, but "Racecar" is not. A substring is a contiguous set of characters in a larger string. Your task is to write a program or method which takes a string or character array as input and outputs the length of...
stackexchange_codegolf
I have encountered this type of puzzle, that usually involves apples, several times. It goes as follows: There is a certain number of apples in a basket. Ava takes a third of the apples. Bob takes a quarter of the apples that are left. Finally, Dennis takes one-sixth of the apples left. In the end, there are 10 leftov...
stackexchange_codegolf
You are given two true color images, the Source and the Palette. They do not necessarily have the same dimensions but it is guaranteed that their areas are the same, i.e. they have the same number of pixels. Your task is to create an algorithm that makes the most accurate looking copy of the Source by only using the pi...
stackexchange_codegolf
(This challenge exists to extend sequence A276272 in the On-Line Encyclopedia of Integer Sequences, and perhaps create a new OEIS sequence1.) This is a code-challenge, which will have you write code to compute as many terms of this sequence as possible. Background A polytet is a kind of polyform which is construct...
stackexchange_codegolf
Input Two dates, each comprising of a month (Dec or Jan) and a day (01-31). These will be given as 4 integers (12 01 01 01, for example), in any reasonable format you choose (leading zeroes, no leading zeroes, list, individual inputs, list of lists, etc.). The first date is supposed to represent today's date. Output I...
stackexchange_codegolf
Background Shakashaka is a puzzle on a grid, whose objective is to place some half-squares (right triangles) on the empty cells so that all the remaining contiguous regions form rectangles, either upright or 45 degrees rotated. Here is an example puzzle with a solution: Ignore the number clues for this challenge. Cha...
stackexchange_codegolf
This is the Robber post. The Cop post is here. Your task is to take an integer input N and output the Nth digit in the sequence OEIS A002942. The sequence consists of the square numbers written backwards: 1, 4, 9, 61, 52, 63, 94, 46, 18, 1, 121, 441, ... Note that leading zeros are trimmed away (100 becomes 1, not 00...
stackexchange_codegolf
Let's just see how this goes If you've ever listened to the radio program "I'm sorry, I haven't a clue", then you've probably heard of the game called "Mornington Crescent". For those who haven't, it's a game where players name random stations on the London Underground network. The first person to name "Mornington Cres...
stackexchange_codegolf
Introduction Every number can be represented as ASCII. For example, \$0\$ comes in ASCII is \$48\$, \$1\$ is \$49\$, and so on. Using this method of translating numbers to other numbers, it is possible to infinitely expand a number, by replacing all its digits with their ASCII values and doing the same for the result. ...
stackexchange_codegolf
Introduction The idea is to use the asterisk character (star) * to display an ascii-art star at a specified dimension. The dimension is an input number greater than or equal to \$1\$ that specifies the height in lines of the upper point of the star. The stars here are intended to be six pointed stars with larger sizes ...
stackexchange_codegolf
Today, November 11th, is known as Remembrance Day, Armistice Day, or Veterans Day (depending upon the country), and is a day of reflection and gratitude for members of the military and their service, specifically started to reflect the end of European hostilities in the first World War. Let us reflect on that with a si...
stackexchange_codegolf
Your Goal: Given an odd integer input n greater than 1, generate a random English word of length n. An English word is one in which the odd (1-based) indices are consonants and the even (1-based) indices are vowels, the vowels being aeiou. Random For the purposes of this challenge, you are to sample from the vowels and...
stackexchange_codegolf
I'm sure this is going to spark some controversy, but let's do a practical demonstration. The objective of this is simple, using the new code of conduct and no input, print out my pronouns ( "he/him", "he him" is also acceptable). Here's the challenge. This is a classical polyglot contest! This means that the first...
stackexchange_codegolf
Background A rooted tree is an acyclic graph such that there is exactly one path from one node, called the root, to each other node. A node v is called the parent of another node u if and only if the path from the root to u goes through v and there is an edge connecting u and v. If node v is the parent of node u, node ...
stackexchange_codegolf
Fermat's Last Theorem, mod n It is a well known fact that for all integers \$p>2\$, there exist no integers \$x, y, z>0\$ such that \$x^p+y^p=z^p\$. However, this statement is not true in general if we consider the integers modulo \$n\$. You will be given \$n\$ and \$p\$, which are two positive integers with \$n>1\$. Y...
stackexchange_codegolf
Challenge You will be given an input represented by x, which is a string containing at least 3 characters. It will consist only of the standard numeric characters, 0 through 9. Your job is to find and output how many right triangles can be formed with the given numbers. Rules Numbers must be kept in the order they wer...
stackexchange_codegolf
Scientists have made contact with a parallel universe. Just one problem: They write math differently. Help the scientists make a program that can convert normal math expressions to their equivalent in alternate universe math. The connection through the portal is bad so your code needs to be as short as possible Given a...
stackexchange_codegolf
The shortest C# code that generates an uncatchable ExecutionEngineException wins. You are not allowed to call FailFast directly or indirectly.
stackexchange_codegolf
Inspired by this. Given a string as input consisting of only upper and lowercase alphabet characters, wicka-wub it. How do I wicka-wub a string? The example text used is "DJMcMayhem". Split the string before each capital letter, so you get ["D", "J", "Mc", "Mayhem"]. Next, take the two halves of the list as sublists. T...
stackexchange_codegolf
Background Here is a Halloween related challenge. As you may have seen from my last challenge I quite like what I term as ascii art animations, that is not just draw a pattern but draw a pattern that progresses. This idea came to me after I was asked a couple of years ago to liven up a (rather dull) presentation by mak...
stackexchange_codegolf
I am trying to push my limits of making a python code as short as possible. I left the readability part way behind. I was attempting the K-Goodness String problem from Round A of Google Kick Start 2021. The following was my initial solution: def func(N, K, S): if not S: return 0 y = 0 for i in range(N//2)...
stackexchange_codegolf
If you don't know what a queen is in chess, it doesn't matter much; it's just a name :) Your input will be a square of arbitrary width and height containing some amount of queens. The input board will look like this (this board has a width and height of 8): ...Q.... ......Q. ..Q..... .......Q .Q...... ....Q... Q..........
stackexchange_codegolf
Challenge Create a program that, when run, changes the contents of the source file. This means that you can delete/add/change characters in the source file, but you can't delete the (source) file itself (deletion is when the source file does not exist after the program is run). In the case of pre-compiled languages suc...
stackexchange_codegolf
We can model a rail network as a directed graph, where each node is a train station and each edge is a train connecting two train stations. We'll assume that each train travels between its corresponding stations at a regular schedule and takes a fixed amount of time Your code should take a list of trains, where each tr...
stackexchange_codegolf
Carry sort is an \$O(n)\$ "sorting" algorithm. Here's how it works. The algorithm moves left to right along a list. As it traverses a list it "carries" a single item, the largest item it has encountered so far. Once it encounters a larger item it picks up that item and drops the item it is already carrying in place. W...
stackexchange_codegolf
This challenge is inspired by the meme Men of Culture. The meme involves blanking out parts of the original caption, Ah, I see you're a man of culture as well. to make it appear as if the character is saying something else. Your challenge is to write a program that, given an input, show how the original sentence can ...
stackexchange_codegolf
The following is the rhombus sequence. 1 121 12321 1234321 123454321 12345654321 1234567654321 123456787654321 12345678987654321 Your task is to output this, taking no input and using standard output methods (STDOUT, list of numbers or list of strings, etc.). There's a hitch. You may only use up to one loop - no neste...
stackexchange_codegolf
Help, I've been diagnosed with prosopagnosia! This means I'm no longer able to recognise faces.... :( Can you help me? The challenge You will be given an image as a matrix of regular ASCII characters separated by new line characters, and your task is to determine if it contains a face. Faces will look something like th...
stackexchange_codegolf
Wikipedia: Zeno's Dichotomy Paradox An infinite number of mathematicians walk into a bar. The first one orders a beer. The second one orders half a beer. The third one orders a fourth of a beer. The bartender stops them, pours two beers and says, "You're all a bunch of idiots." Reddit Print the following series for a...
stackexchange_codegolf
Given a variable a (non array) or (any[]) convert to (any[]) function example(s: string | string[]) { const e = Array.isArray(s) ? s: [s] return e } Is Array.isArray(s) ? s: [s] the shortest way?
stackexchange_codegolf
Aliens have arrived, and they aren't friendly. Turns out, they've been in the process of converting all matter in the universe into compute capability so they can have more fun in their VR simulations. Our solar system is the last bit of space they haven't converted yet, and they're about to remedy this oversight. Howe...
stackexchange_codegolf
Introduction The idea is to use the asterisk character (star) * to display an ascii-art star at a specified dimension. The dimension is an input number greater than or equal to \$1\$ that specifies the height in lines of the upper point of the star. The stars here are intended to be six pointed stars with larger sizes ...
stackexchange_codegolf
Input: Ten unique integer coordinates, between (0,0) and (100,100). Output: The coordinates arranged in the order/an order such that a path drawn between the coordinates in that order is the shortest path possible. This is code golf so the shortest code wins!
stackexchange_codegolf
You are given a string and two characters. You have to print the string between these characters from the string. Input Input will first contain a string (not empty or null). In the next line, there will be two characters separated by a space. Challenge Return the string between the two characters Example Hello! What's...
stackexchange_codegolf
Introduction In chess, Knights can move two squares in one direction, and then one square in an orthogonal direction. On an x/y plane, these can be thought of as being a relative change of coordinates, such as (+1, -2). Challenge Your task is to output all 8 possible moves as pairs of relative x/y coordinates, in any o...
stackexchange_codegolf
Mathemania Specs: Every piece of Mathemania code starts off with the number 2. From the 2, you can do the following operations: e: Exponentiation. This command's default is squaring the number. f: Factorial. This command's default is using the single factorial on the number (using f on 2 = 2! = 2). r: Root. This comma...
stackexchange_codegolf
Bubble-wraps are maximum-level entertainment. Everyone can agree to that. Now, you will make even computers enjoy bubble-wraps. Specs You will be given two integers, w, and h.(each are responsively width and height) Your program should output all w*h phases waiting 1 second between each one and terminate. Every bubble-...
stackexchange_codegolf
Given an array A of integers, there exists at least one positive integer p such that A[i] == A[j] for all i and j for which i % p == j % p == 0. Find the smallest p. Examples: Input array: [1, _, 1, _, 1, _, 1, _, 1]. Output: 2 Input array: [1, _, _, 1, _, _, 1, _, _]. Output: 3. Input array: [1, _, _, _, 1, _, _, _, ...
stackexchange_codegolf
A Pythagorean triple consists of three positive integers a, b, and c, such that a2 + b2 = c2. Such a triple is commonly written (a, b, c), and a well-known example is (3, 4, 5). If (a, b, c) is a Pythagorean triple, then so is (ka, kb, kc) for any positive integer k. A primitive Pythagorean triple is one in which a, b...
stackexchange_codegolf
Make a Number Expression is related : actually, it is also about Aheui. But it just made number expression, but this made real Aheui code. Aheui is esolang written in only Korean character. Because of its nature, Aheui can't use Arabic numbers. But, of course, there is way to generate number. Brief introduction to Ahe...
stackexchange_codegolf
Warning The answers to this challenge test for a specific version of the patch that helps stop WannaCrypt/WannaCry attacks. Depending on your operating system, you may have a different patch. The best way to protect yourself is to make sure your PC is fully up to date and be careful when opening attachments and web lin...
stackexchange_codegolf
Given: A natural number S. A list of N rational weights W that sum to 1. Return a list L of N non-negative integers, such that: (1) sum(L) = S (2) sum((S⋅W_i - L_i)^2) is minimal In other words, approximate S⋅W_is with integers as closely as possible. Examples: 1 [0.4 0.3 0.3] = [1 0 0] 3 [0 1 0] = [0 3 0] 4 [0.3 0....
stackexchange_codegolf
The Lisp language has a family of functions car, cdr, cadr, etc for accessing arrays. For each one, an a defines taking the first item of an array, and a d defines taking the rest. For example, running cadr on [[1,3,4],5,7] will return [3,4] as the a gets the first item ([1,3,4]) and the d removes the first item. We've...
stackexchange_codegolf
Write a program that outputs Hell0 W0rld!. It must match this output exactly, including capitalization, zeroes instead of o's, exactly one space, etc. Trailing new lines are allowed. Lowest score wins. Scoring is based on the sum of the values of each character in the language's code page - otherwise Unicode values ...
stackexchange_codegolf
The alternating factorial is an alternating sum of decreasing factorials. For example, we could calculate the alternating factorial of 4 as follows: First, calculate the factorials from 4 down to 1: $$ 4!\quad3!\quad2!\quad1!\quad = \\ 4\cdot3\cdot2\cdot1\qquad3\cdot2\cdot1\qquad2\cdot1\qquad1\quad= \\ 24\quad6\quad2...
stackexchange_codegolf
Background The Python code ((((((((n%35)^11)*195)|53)&181)+n)%168)*n)+83 produces 74 distinct primes for \$0 \le n \le 73\$. This code also works in Java. The operators are as follows: + is addition * is multiplication % is modulus & is bitwise AND | is bitwise OR ^ is bitwise XOR The produced primes are: 83, 97, 11...
stackexchange_codegolf
Martin has created a nice snippet that can be used to keep track of the score for answers to challenges. That's great and all, but wouldn't it be better if you could keep track of it yourself? Create a program that compares the byte counts in itself with the rest of the answers to this question, and returns "I'm answer...
stackexchange_codegolf
Alternatively: Now you're checking with portals! Inspired this challenge I am somewhat of a self-declared Chess Anarchist. That means that when I play chess, en passant is forced (else the brick gets used), double check is mate (and pasta), and all sorts of new pieces and squares are added to the game. One such piece i...
stackexchange_codegolf
Question We are captured by robot army on their space station. Our space ship pilot is in the prison which is in level 1. There is only one way how to escape and it's rescuing your space ship pilot. It mean's moving from level N to level 1. However because it's very risky you need to get to the prison in the least numb...
stackexchange_codegolf
Three positive integers A, B, C are ABC-triple if they are coprime, with A < B and satisfying the relation : A + B = C Examples : 1, 8, 9 is an ABC-triple since they are coprime, 1 < 8 and 1 + 8 = 9 6, 8, 14 is not because they are not coprime 7, 5, 12 is not because 7 > 5 You can see this Frits Beukers 2005 presenta...
stackexchange_codegolf
This idea came to me when I saw my little brother playing with my calculator :D The task Taking a integer as an input, print that many graphical square roots under each other, like this: n = 1 ___ \/ 1 n = 3 _______ / _____ / / ___ \/\/\/ 3 n = 5 ___________ / _________ / / _______ / ...
stackexchange_codegolf
Goal You have to print the ASCII printable characters' code page (0x20-0x7E). The output should look like this: !"#$%&'()*+,-./ 0123456789:;<=>? @ABCDEFGHIJKLMNO PQRSTUVWXYZ[\]^_ `abcdefghijklmno pqrstuvwxyz{|}~ Rules The output should be exactly like shown above, but trailing whitespace is OK. No builtins that triv...
stackexchange_codegolf
I have an expression that could be expressed as either of : a += (A ? B ? x : C ? y : D : D); a += (A && B ? x : A && C ? y : D); where A,B,C are expressions of 5-10 bytes each, and x and y are single character literals (3-4 bytes). D is another chain of ternaries (without the branching problem). I'm getting stuck tr...
stackexchange_codegolf
A loop is a pretty simple algebraic structure. It is a tuple (G,+) where G is a set and + is a binary operator G × G → G. That is + takes two elements from G and returns a new element. The operator is also required to fulfill two properties Cancellation: For every a and b in G there exists unique x and y in G such ...
stackexchange_codegolf
The following puzzle was invented by Eric Angelini in September 2007. As mentioned in A131744 : the sequence is defined by the property that if one writes the English names for the entries, replaces each letter with its rank in the alphabet and calculates the absolute values of the differences, one recovers the sequen...
stackexchange_codegolf
The text of the children's book Polar Bear, Polar Bear, What Do You Hear? has a very simple pattern. You might use the text to teach introductory programming concepts. My son was quickly bored by this idea, so I decided to play some golf with it instead. The Challenge In your programming language of choice, write the...
stackexchange_codegolf
You are given a list, L, with the length N. L contains N random positive integer values. You are only able to select from the outer edges of the list (left/right), and after each selection every value in the remaining list increase by a factor of the current selection. The goal is to maximize the total sum of the selec...
stackexchange_codegolf
Lenguage is a brainfuck dialect that is notorious for breaking source restriction challenges. That is because Lenguage cares only about the length of it's source and not the contents. First, the length of the program is calculated. Then, said length is converted to binary and left-padded by zeroes to a multiple of 3. ...
stackexchange_codegolf
You work for the military as a coder and are responsible for writing software to control missiles. Your task is to write a program or function that will output a code sequence (any length ASCII string) to launch a missile. The program should be based on a loop taking the code sequence from memory and output it in a par...
stackexchange_codegolf
Inspired by this SO post. Given a vector (first parameter), e.g.: char = ["A", "B", "C", "A", "A"] For each element of the vector, find the distance to the closest subsequent specified value (second parameter). When the element is identical to the specified value, return 0. f(char, "A") -> [0 2 1 0 0] Explanation f(c...
stackexchange_codegolf
Challenge: Write a program that produces the following output: . E .. I ... S .... H ...- V ..- U ..-. F ..-- .- A .-. R .-.. L .-.- .-- W .--. P .--- J - T -. N -.. D -... B ...
stackexchange_codegolf
You are tasked with displaying the string "ABCDEFGHIJKLMNOPQRSTUVWXYZ" and only that, except for trailing newlines if they're unavoidable. You must not output any homoglyphic characters like Cyrillic A. You can use non-Unicode encodings, but just to be sure, only output the Latin letters. Regardless of the encoding you...
stackexchange_codegolf
Ever fancied creating cool twitter hashtags such as #brexit or #brangelina? this golf is for you. Write a program that accepts two strings A & B as input and merges them according to the following algorithm: let n be the number of vowels groups in A (e.g. britain has 2 vowels groups : i in position 3 and ai in positi...
stackexchange_codegolf
The challenge is to golf a program that checks if a statement of propositional calculus/logic is a logical tautology (i.e. it is true for all possible values of the variables). Input Input formulas will use P, P', P'' ect. as variables. They can either be true or false. (P and P') means both P and P' are true. (P or P'...
stackexchange_codegolf
What general tips do you have for golfing in Retina? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Retina (e.g. "remove comments" is not an answer). Please post one tip per answer. For reference, the online compiler is here. @Sp3000 pointed out there i...
stackexchange_codegolf
Write a program that, for any \$n\$, generates a triangle made of hexagons as shown, \$2^n\$ to a side. The colors are to be determined as follows. We may give the triangle barycentric coordinates so that every hexagon is described by a triple \$(x,y,z)\$ with \$x+y+z=2^n-1\$. (The three corners will be \$(2^n-1,0,0)\$...
stackexchange_codegolf
Number Splitting Instructions Oh no, my numbers have stuck together! Luckily, we can split them apart with code. Your code should be a function that takes an integer input from stdin or as an argument. You must split the number into single digits, keeping the order and possible duplicates of these digits. The output sh...
stackexchange_codegolf
Write the shortest possible program or function that will join a list of columnar strings. For this challenge, columnar strings are defined as one-character-wide strings spanning across multiple lines. Each character, except for the last one, is separated by a newline character. Some examples, separated by ---: a b c d...
stackexchange_codegolf
Okay, so everyone is familiar with the ASCII-table, correct? I'd hope so. I've been going to that site for my asciitable reference for as long as I can remember needing one. We'll be doing some fun source-code manipulating using the ASCII keyspace. The Task Your task is to write a program that, when executed, prints t...
stackexchange_codegolf
Recently I've been playing a game called Alcazar. It is a board puzzle game where your goal is to enter from one door, pass through all squares, and exit through another door. The only rules are: Enter once, leave once; Pass through all squares; Do not pass through a square more than once The image below shows an exa...
stackexchange_codegolf
Play the Fruit Box Game Intro Fruit Box is a game consisting of a 10x17 grid of numbers, each between 1 and 9, where the goal is to clear as many numbers as possible in a two-minute time window. In order to clear numbers, one selects a rectangle aligned with the grid, and if the numbers inside of it sum to 10, they are...
stackexchange_codegolf
For those of you who are unfamiliar, Kirkman's Schoolgirl Problem goes as follows: Fifteen young ladies in a school walk out three abreast for seven days in succession: it is required to arrange them daily so that no two shall walk twice abreast. We could look at this like a nested 3 by 5 list (or matrix): [[a,b,c] ...
stackexchange_codegolf
I have a bunch of boards I need to stack in as small a space as possible. Unfortunately, the boards fall over if I stack them more than 10 high. I need a program to tell me how to stack the boards to take as little horizontal space as possible, without stacking boards more than ten high, or having boards hanging out ...
stackexchange_codegolf
The cardinality of the set \$\mathbb Q\$ of rational numbers is known to be exactly the same as that of the set \$\mathbb Z\$ of integers. This means that it is possible to construct a bijection between these sets—a mapping such that each integer corresponds to exactly one rational number, and vice versa. Provide such ...
stackexchange_codegolf
Introduction A quine is a program that outputs its own source code. For example, a well-known Python quine is _='_=%r;print(end=_%%_)';print(end=_%_). Running it outputs _='_=%r;print(end=_%%_)';print(end=_%_), therefore it is a valid quine. An error quine is similar to a regular quine, however it must output to STDERR...
stackexchange_codegolf
This is a CC-BY-SA challenge from the CCSC Mid-South Programming Contest 2018. Author(s): Brent Yorgey Source: Consortium for Computing Sciences in Colleges Mid-South Programming contest 2018 https://ccsc18.kattis.com/problems/ccsc18.mountainrange Good news: you have been hired to do all the special effects for a fil...
stackexchange_codegolf
Who doesn't like to chill on a Sunday morning in summer with a chilled beer and TV or in winter playing badminton or ultimate with friends? I always think knowing how many days you have to chill in a month keeps you well-informed and helps you plan what you want to do. Be it sitting in front of your pc and solving a co...
stackexchange_codegolf
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. I've got an infinite supply of \$n\$-dimensional chocolate for some positive integer \$n\$. The shape of the chocolate is not important. You may assume that they are just \$n\$-dimensional hypercubes with side length \$1\$. To celebrat...
stackexchange_codegolf
Qat is a tool that lets you search for words matching a given pattern, often used by crossword and other word puzzle writers and solvers. In this challenge, you will have to implement a specific part of Qat, namely a subset of the "equation solver". Equations The output of a Qat query depends on the dictionary you use ...
stackexchange_codegolf
The challenge Given an input string, and an integer n - truncate any runs of consecutive characters to a maximum of n length. The characters can be anything, including special characters. The function should be case sensitive, and n can range from 0 to infinity. Example inputs/outputs: f("aaaaaaabbbccCCCcc", 2) //"aabb...
stackexchange_codegolf
There are many magic squares, but there is just one non-trivial magic hexagon, as Dr. James Grime explained, which is the following: 18 17 3 11 1 7 19 9 6 5 2 16 14 8 4 12 15 13 10 As it is done in Hexagony this is easiest written as just one line, by just reading it row by row: 18 17 3 11 1 7 19 9 6 5 2...
stackexchange_codegolf
Given 2 brainfuck code snippets A and B, output some brainfuck code C which has the same behavior as running B with the input of As result. Note that C must work for any input that match the following assumptions, as if it were given to A. You can assume: Finite input. both A and B halt. EOF is consistently 0 or consi...
stackexchange_codegolf
Write a "palipolyquine": a program that is a quine, a polyglot, and a palindrome. Rules: The number of polyglot languages is more preferable than code size. The shortest answer (in bytes) wins, in case of a tie. Polyglot and Quine rules see here: Write a Polyquine. My example (I have a repository Freaky-Sources with...
stackexchange_codegolf
Related. Given a printable ASCII string, split it into a list of non-empty strings with a new sub-string beginning every time a character, which has not previously been seen in the same case, occurs. Examples "mississippi" → ["m","i","ssissi","ppi"] "P P & C G" → ["P"," P ","& ","C ","G"] "AAA" → ["AAA"] "Adam" → ["...
stackexchange_codegolf
In Haskell (and probably some other languages or something) zip is a function which takes two lists, and produces a list of tuples by pairing elements at the same index: zip [1,2,3] [6,5,4] = [(1,6),(2,5),(3,4)] If there are extra elements on one of the input lists those are trimmed off and don't appear in the result:...
stackexchange_codegolf
.Net Technology is an incredible framework with marvellous functionalities, and among all of them, the most important one obviously stands out: Yep, your simple task is create a program that when it takes at input: dotnet ef It prints the following ascii art by output: /\__ ---==/ \\ ___ ___ ...
stackexchange_codegolf
Challenge A simple challenge: given two or more strings, output all of the substrings that are in each string. Rules Input is always a comma separated list of strings Strings should be outputted from longest to shortest length without duplicates Strings should preserve whitespace Examples Input: aaa,aa Output: aa a ...
stackexchange_codegolf
What general tips do you have for golfing in Scala 3? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Scala 3 (e.g. "remove comments" is not an answer). Please post one tip per answer. Also see Tips for golfing in Scala
stackexchange_codegolf
The challenge here is to find the longest uninterruped arc around a unit circle with a random amount of points distributed in random positions around it. Here is a diagram to assist my explanation: The red line indicates the largest arc between any two points that is not interrupted by any other points. The challenge ...
stackexchange_codegolf