instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Overview: Your job is to take CSV input in key=value format and line it up in a more organized (see below) way. Input: Always via stdin. Records will always be in the following form key=value: foo=bar,baz=quux abc=123,foo=fubar baz=qwe,abc=rty,zxc=uiop,foo=asdf There will be no list of possible keys in advance, you m...
stackexchange_codegolf
Input Two integers: A non-negative integer W in the range 0 to 2^64-1, specifying the weave. A positive integer S in the range 1 to 255, specifying the side length. These can be taken in whichever order suits you. Output An S by S ASCII representation of the requested weave (S newline separated strings of S character...
stackexchange_codegolf
A redox reaction is a chemical reaction in which elements transfer electrons. One element loses electrons, while another gains electrons. Oxidation is the process where an element loses electrons, and reduction is the process where an element gains electrons. Since electrons have a negative charge, the oxidation number...
stackexchange_codegolf
Challenge: Take input of two black and white (monochrome) images and xor each pixel of the first, with each pixel of the second, add them to a new image and output the new image. Some clarifications: Size of pictures does not matter. Extension/Image format doesn't matter. You can make it take input any extension and ou...
stackexchange_codegolf
Word changer is a game where you are trying to turn one word into another via single-character edits, with each step being its own word. For this challenge, edits may be replacements, insertions, or deletions. For example, WINNER → LOSER can be done with this route (there may be others): WINNER DINNER DINER DINE LINE L...
stackexchange_codegolf
For the purpose of this challenge a rectangular piece of ASCII art is Mondrian if it looks the same upside down. What does "looks the same" mean? A feature is any orthogonally connected region of at last 5 characters. A Mondrian feature is any feature that appears in the same picture upside down. (This includes the pos...
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
I want to avoid responding to illegal or spoofed addresses. One type that's easy to detect is an address that should not exist on a packet received by my router: a special-use address. Challenge Given an IPv4 32-bit address, identify whether it is valid general-use address. Challenge rules Special-use addresses, as de...
stackexchange_codegolf
It's that time of year when many of us get our advent calendars! If you are unfamiliar with an advent calendar, these are special calendars used to count down advent in anticipation of Christmas. In my experience the doors are placed randomly, and part of the fun as a child was working out where tomorrow's door was! O...
stackexchange_codegolf
Generative AI is here! It's great for certain things, but it has a few problems. Not only has it broken our Stack Exchange community, it also makes mistakes. For example, when you ask Bing AI if it is sentient, Bing says (credits to GPT Gone Wild) Your job is to print that text exactly. More specifically, Take no inp...
stackexchange_codegolf
Background As far as we can tell from trying everything (besides cheating with ZWSPs), you can't type `\ in Stack Exchange chat. However, you can type \` by doing `\\``. So, if you want to tell someone in chat how to type backslash-backtick, you'd need to type out `\`\\`\`` to format `\\`` into a codeblock. Challenge Y...
stackexchange_codegolf
Background Suppose that there are 2*n people to be married, and suppose further that each person is attracted to exactly n other people under the constraints that: Attraction is symmetric; i.e. if person A is attracted to person B, then person B is attracted to person A. Attraction is antitransitive; i.e. if person A ...
stackexchange_codegolf
Given a strictly positive integer, N, produce an output satisfying the following: Produce an array of length N. Every string (i.e. "word") in the array is of length N. Every letter in the word is unique. Every first letter of the words are unique between each other. The remaining items of each word are equal to each o...
stackexchange_codegolf
Math has a lot of symbols. Some might say too many symbols. So lets do some math with pictures. Lets have a paper, which we will draw on. To start the paper is empty, we will say that is equivalent to \$\top\$ or \$\textit{true}\$. If we write other things on the paper they will also be true. For example Indicates ...
stackexchange_codegolf
Intro The challenge is to create a program/function that prints the intersection of its own source code and a given string input. This is code golf and to be more precise: Let I be the input set {"a","b","c"} Let S be the source code set {"b","f"} Then the intersection is what they share I ∩ S = {"b"} Inpu...
stackexchange_codegolf
Challenge For each character of the string except for the last one, do the following: Output the current character. Followed by randomly outputting from the following list a random number of times between 1 - 5 (inclusive): The current character The next character of the string The switchcase version of the character...
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
Objective Given an unlabelled binary tree, decide whether it is contiguous in indices. Indices This challenge gives one-indexing on binary trees. The exact definition expresses all indices in binary numeral: The root is indexed 1. For every node, to get the index of its left child, replace the most significant 1 by 1...
stackexchange_codegolf
(This is OEIS A057531.) Your task Given a positive integer, \$n\$, find the \$n\$th number where the digit sum equals the number of factors Explanation For example, let's take 22: Its factors are \$[1, 2, 11, 22]\$ (length: 4). Its digit sum is 4. This means that it is a number where the digit sum equals the number of ...
stackexchange_codegolf
Inspired by this CR question (please don't kill me for browsing CR) Spec The probabilities of misspelling a word are: 1/3 of the time don't change the output 1/3 of the time remove a random character 1/3 of the time duplicate a random character The chance for removing/duplicating a given character in the input should...
stackexchange_codegolf
Your task Given a string, output the range of ASCII values. Example Let's say we have the string Hello. We get the ASCII values: H = 72 e = 101 l = 108 l = 108 o = 111 Now, we get the range (max - min): 111 - 72 = 39 Our answer is 39. Test cases Input Output Hello, World! 82 aaaaa 0 Code Golf ...
stackexchange_codegolf
Question: Print out all the coordinates of a NxN grid. Preferably in C, however other languages also accepted Input: N (integer) Output: for N=3, a 3x3 grid: 0,0 1,0 2,0 0,1 1,1 2,1 0,2 1,2 2,2
stackexchange_codegolf
The newest "nice" OEIS sequence, A328020, was just published a few minutes ago. Number of distinct tilings of an n X n square with free n-polyominoes. This sequence counts tilings up to symmetries of the square. The sequence has six terms, but I'd like to see if folks here can extend it further. Example For n=4 there...
stackexchange_codegolf
Introduction In order to prevent keyloggers from stealing a user's password, a certain bank account system has implemented the following security measure: only certain digits are prompted to be entered each time. For example, say your target's password is 89097, the system may prompt them to enter the 2nd, 4th and 5th ...
stackexchange_codegolf
Task Given a positive integer number and a threshold, split into every possible way without generating any numbers above the threshold. Examples Input: 15008 Threshold: 400 Valid Output: [[1, 5, 0, 0, 8], [15, 0, 0, 8] [1, 50, 0, 8], [150, 0, 8]] Invalid outputs: [[1, 5, 0, 0, 8], [15, 0, 0, 8], [150, 0, 8], [1, 500...
stackexchange_codegolf
Using the shortest JS (ES5) code possible, as measured in number of characters, gather all the ids on a page for foobar elements into a comma-delimited string. For example: <div> <foobar id="456"></foobar> <foobar id="aaa"></foobar> <foobar id="987"></foobar> <div> Should give "456,aaa,987" You cannot use ES6 o...
stackexchange_codegolf
Backstory Disclaimer: May contain made up information about kangaroos. Kangaroos traverse several stages of development. As they grow older and stronger, they can jump higher and longer, and they can jump more times before they get hungry. In stage 1, the kangaroo is very little and cannot jump at all. Despite this, is...
stackexchange_codegolf
Given two non-zero 16-bit integers a and b, decide the smallest number of shift operations needed to turn a into b. A shift is one of the following (big-endian) operations: shl (shift left): move all bits to the left, adding a 0x0 bit to the right. shr (shift right): move all bytes to the right, adding a 0x0 bit to th...
stackexchange_codegolf
Output all 95 bytes from 0x20 to 0x7E inclusive (printable ASCII including space), in any order, each at least once. The source code of your program must use all of those bytes, each at least once. Your program must be irreducible (meaning you cannot strictly remove some characters from the program and then have it st...
stackexchange_codegolf
I'm attempting to create a function over multiple lines. Parameters of the challenge: Function returns 'barbarian' Only 2 characters per line 40 lines maximum. I keep trying to use a fat arrow to declare my function, but fat arrows don't seem to work if you don't have them connected. Source of Challenge: https://www....
stackexchange_codegolf
Your task will be to take a balanced-string and a integer representing a Levenshtein distance (the number of characters that have to be inserted, deleted or changed to make one string into another) and you must find the number of balanced strings with that distance from the original string (i.e. the neighborhood of tha...
stackexchange_codegolf
You are to print this exact text: ABABABABABABABABABABABABAB BCBCBCBCBCBCBCBCBCBCBCBCBC CDCDCDCDCDCDCDCDCDCDCDCDCD DEDEDEDEDEDEDEDEDEDEDEDEDE EFEFEFEFEFEFEFEFEFEFEFEFEF FGFGFGFGFGFGFGFGFGFGFGFGFG GHGHGHGHGHGHGHGHGHGHGHGHGH HIHIHIHIHIHIHIHIHIHIHIHIHI IJIJIJIJIJIJIJIJIJIJIJIJIJ JKJKJKJKJKJKJKJKJKJKJKJKJK KLKLKLKLKLKLKLKL...
stackexchange_codegolf
Objective Given a matrix of connected box drawing characters, count its genus, the number of plane sections it encloses. Valid input The box drawing characters are ─│┌┐└┘├┤┬┴┼╴╵╶╷ (U+2500 U+2502 U+250C U+2510 U+2514 U+2518 U+251C U+2524 U+252C U+2534 U+253C U+2574 U+2575 U+2576 U+2577). The matrix shall contain these c...
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
Background Mathematicians are interested in all kinds of algebraic structures, e.g. groups, rings, boolean algebras. Generally, we have several operations (addition, multiplication, meet, join, etc.), and some equational relationships on the operations (e.g. associativity of multiplication). This makes up an algebraic ...
stackexchange_codegolf
An Abecedarian Word is a word whose letters are in alphabetical order. Your goal is to write a program that outputs all abecedarian words from a given lexicon. Rules: Standard Loopholes are forbidden. If a word contains punctuation, diacritical marks, or any characters other than ASCII alphabet characters (A-Za-z), r...
stackexchange_codegolf
Your task is to convert a given positive integer from Arabic numeral to Roman numeral. Things get difficult when you count to 4000. The romans did this by adding a line above a symbol to multiply that symbol by 1 000. However, overlines aren't exactly displayable in ASCII. Also, there are double overlines to multiply a...
stackexchange_codegolf
You've been given a bag of Skittles. Everybody knows that in order to appreciate the different flavors the most, you need to rotate between the flavors. Basics: You can only eat 1 skittle at a time The order that you eat your skittles must be periodic. Each period cannot contain a particular flavor more than once. ...
stackexchange_codegolf
A superpermutation on n symbols is a string which contains every permutation of n symbols in its body. For instance, 123121321 is a superpermutation on three symbols because it contains 123, 132, 213, 231, 312 and 321 as substrings. The Challenge Given a string composed of n unique symbols (and, optionally, n), output ...
stackexchange_codegolf
I once had a beautiful rectangular array. It was very symmetrical, but unfortunately it has fallen apart and now I only have the top left corner. Your task will be to rebuild the original array. Your program will receive a 2 dimensional array of integers. For ease of parsing, you may assume they are all between 1 and 9...
stackexchange_codegolf
Hex triplets such as #ffffff (white) or #3764ef (blueish) are often used to denote RGB colors. They consist of # followed by six hexadecimal digits (0-f), or sometimes three digits where the real color is obtained by doubling each digit. For example, #fff is #ffffff and #1a8 is #11aa88. Sadly, that three digit shorthan...
stackexchange_codegolf
Picolisp has a feature called "super parentheses": Brackets ('[' and ']') can be used as super parentheses. A closing bracket will match [all parentheses to and including] the innermost opening bracket, or [if there are no unmatched opening brackets] all currently open parentheses. src Taking a string containing only...
stackexchange_codegolf
Output the infinite list of pairs of integers (a, b), where both \$ a > 1 \$ and \$ b > 1 \$, ordered by the value of \$ a^b \$. When there are multiple pairs where \$ a^b \$ is equal, they should be ordered lexicographically. For example, \$ 2^4 = 4^2 = 16 \$, but (2, 4) should come before (4, 2), because it is lexico...
stackexchange_codegolf
Goal Write a program or function that takes a positive integer n and randomly generate a legal series of pitches (henceforth called a Pitch string) of length n. Input A non-zero, positive integer n <= 100 Output Return a random string, or list of characters, that represent a possible, valid pitch string of length n. Th...
stackexchange_codegolf
This is a code-golf question. You need to take the contents of two separate files (i.txt and o.txt) and swap them. You can create a third file to help you with the process, but have your program delete it after the file contents are swapped. Renaming the files is now allowed again. Programs must work for any file co...
stackexchange_codegolf
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. On the flight to Hawaii for vacation, I'm playing with a deck of cards numbered from 1 to \$n\$. Out of curiosity, I come up with a definition of "magic number" for a shuffled deck: The magic number of a shuffle is the minimum number ...
stackexchange_codegolf
Given a necklace with color stones (yellow, white, brown, etc.) of at least two different colors, we describe that necklace using letters that correspond to each color, choosing an arbitrary starting point. We try to answer these questions: How many distinct colors does the necklace have? What's the length of the long...
stackexchange_codegolf
The title says it all; Given a number in the binary (base-2) number system, output the same number expressed in unary (base-1). You should take the binary number as a string (optionally with a separator), list, or equivalent structure of digits, using any number or digit you like for the digits. The unary output can us...
stackexchange_codegolf
Using ASCII print a section of a hexagon ring tiling. Here's a small section: /\__/\ /_/ \_\ /\__/\ \__/ /\__/\ /_/ \_\/__\/_/ \_\ \ \__/ /\__/\ \__/ / \/__\/_/ \_\/__\/ /\__/\ \__/ /\__/\ /_/ \_\/__\/_/ \_\ \ \__/ /\__/\ \__/ / \/__\/_/ \_\/__\/ \ \__/ / \/__\/ Here's a larger...
stackexchange_codegolf
Disarium Dilemma A Disarium is defined as a number whose: sum of its digits powered with their respective position is equal to the original number Your Task: You have a strange obsession with numbers classified as being a disarium. The need to follow the ways of disarium is so great in you that you refuse to read a...
stackexchange_codegolf
The challenge today is to write a program that outputs a known proverb, Where there is a will, there is a way., that means if someone is determined to do something, he will find a way to accomplish it regardless of obstacles. Output It has to be exactly the same, including the space bar and punctuation and excluding th...
stackexchange_codegolf
What is some of the coolest/best/worse abuses of CSS? For example, these shapes, or using multiple box-shadows to make pixel art. popularity-contest ending on 16/04/14.
stackexchange_codegolf
Another sequence, another challenge.* Definition A prime p is in this sequence, let's call it A, iff for every digit d in p's decimal expansion, you replace d with d copies of d and the resulting integer is still prime; zeros are not permitted. For example, 11 is trivially in this sequence (it's the first number, incid...
stackexchange_codegolf
See also: Parsing Introduction You're working on a government programming team, who have been programming the speed cameras. However, the group of people who have programmed the speed calculator have taken up too much space, so you have to make the number plate recognition software as small as possible. Challenge Given...
stackexchange_codegolf
We are all used to the old-school telephone keypad, right? For reference, here is what it looks like: Given a String consisting only of lowercase ASCII letters and single spaces, your task is to return the number of taps one should make in order to type down the full String with a telephone keypad as the one above. F...
stackexchange_codegolf
Today, @HyperNeutrino succeeded merging his two accounts, and finally got the reputation he lost back. Now, it's time to celebrate! Your task is to output this exact text: /\ / \ / \ / \ / \ / \ / ...
stackexchange_codegolf
Not an interpreter. Arguably a compiler. But I'm talking about a transpiler. It can be in any language, but it must return js-valid arrow notation code. The λ-calculus string would be passed as an argument to a function, or the whole program, and in some way the program would return/log/print the string with the js-not...
stackexchange_codegolf
So, this is a task from one very popular educational site in Russia: https://acmp.ru/index.asp?main=task&id_task=786&ins=1 Mathematically, you need to find the power of two not exceeding the given number, read from the standard input stream, and output their difference in the standard output stream. My python3 solution...
stackexchange_codegolf
Bingo Bingo is a numbers game where players match randomly drawn numbers to the numbers on their cards. Each bingo card is a square grid with 25 spaces, and the columns of the grid are labeled with letters such as "B", "I", "N", "G", "O". The letters help to identify the number range in each column, for example, the "B...
stackexchange_codegolf
You have to write a function/program that takes input via the stdin/command-line arguments/function arguments, mixes up characters in a string, and then output the final string via the stdout. Input will first contain a string (not empty or null), a space, and then an even number of non-negative numbers all separated b...
stackexchange_codegolf
A recent SO question asks for a convenient one-liner to generate a list of numbers and their negative counterparts in Python. Given two integers \$1≤a≤b\$, generate all the integers \$x\$ such that \$a≤|x|≤b\$. The result may be printed or returned in any order or structure, as putting the result into a list and sortin...
stackexchange_codegolf
A big part of radio communication is the NATO Phonetic Alphabet, which encodes letters as words to make them easier to understand over comms. Your job, if you wish to accept it, is to print them one by one. You must print this exact string to stdout: A: Alfa B: Bravo C: Charlie D: Delta E: Echo F: Foxtrot G: Golf H: Ho...
stackexchange_codegolf
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. challenge idea by emanresu A Santa has a bunch of presents wrapped in cuboid boxes of various sizes. As his sled flies above a chimney, a stack of presents will be automatically dropped through it. Santa wants to carefully choose the p...
stackexchange_codegolf
You are a robot. You are stranded in a small cage with weird humans wearing weird suits looking at you. Your solar panel is malfunctioning, and your energy is running out. On the wall there is a riddle, and if you answer correctly the humans will grant you access to an energy source (yay!). However your RAM unit is lea...
stackexchange_codegolf
Introduction Let's observe the following string: ABCDEFGHIJKLMNOP If we swap the ends of the string, which are these: ABCDEFGHIJKLMNOP ^^ ^^ We get the following result: BACDEFGHIJKLMNPO After that, we delete the ends of the string, which in this case are B and O. The result is: ACDEFGHIJKLMNP If we repe...
stackexchange_codegolf
I was going through a bizarre thread on Reddit, and came across this: ( ͡°( ͡° ͜ʖ( ͡° ͜ʖ ͡°)ʖ ͡°) ͡°) It's representing a group of people smiling somewhat suspiciously. (In the challenge below though, spaces to the left of the right eyes were dropped somehow while I was writing the challenge. Note the spec). Your goa...
stackexchange_codegolf
I recently watched The Wizard Of Oz and thought that when Dorothy taps her shoes together three times, it would be easier if she used a program to do it. So let's help her. Task Output slippers being tapped together 3 times. Output Slippers being tapped together. A pair of slippers not being tapped looks like this: _...
stackexchange_codegolf
The Challenge Your task is to create a program that can solve an algebraic equation. Input Input will consist of a String. The string will be an equality involving the variable x, and follows the following rules: the equation will always be linear The valid operations in the equation are + - * / Parenthesis will not b...
stackexchange_codegolf
Given a non-negative integer n, print the result of P(P(...P({}))), where the number of P's is n (P is the power set function). 0 => {} 1 => P({}) 2 => P(P({})) 3 => P(P(P({}))) n => P(f(n-1)) input result 0 {} 1 {{}} 2 {{},{{}}} 3 {{},{{}},{{{}}},{{},{{}}}} ... The result should only contai...
stackexchange_codegolf
Create a program or function which takes a list of strings as input, and outputs the longest string that is a substring of all input strings. If there are several substrings of equal length, and no longer substring, output any one of them. This may mean outputting the empty string. If there are several valid outputs, ...
stackexchange_codegolf
Given a date written in any (must handle all in the same program) of the following formats, parse it into a valid yyyy/mm/dd date. 17th May 2012 March 14th, 2016 20 February 2014 September 14, 2017 Sunday, June 8, 2015 Rules Dates will sometimes be invalid, ie. incorrect day for the month or number of months in a yea...
stackexchange_codegolf
Challenge: Read input (within visible ASCII range) and output with a few modifications: In each set of 10 characters of the input randomly (50/50): replace one character* (with a random** one within visible ASCII range) (ex. lumberjack becomes lumbeZjack) or remove one character (ex. lumberjack becomes lmberjack) ...
stackexchange_codegolf
Code Python 3, 245 bytes E=print def F(): B,C,A=1,1,1;yield 0 while True:yield B;B,C,A=B+C+A+1,C+A+1,A+1 C=int(input()) D=0 for A in range(C): E(end='*'*(C-(C-A)+1));B=A while 0<B:E(end=' '+chr(42+B)*B);B-=1 E();D+=1 for A in F(): if D==0:E(end=str(A));break D-=1 Try it online! What it does? Takes a number from...
stackexchange_codegolf
You are given a string, which will contain ordinary a-z characters. (You can assume this will always be the case in any test, and assume that all letters will be lowercase as well). You must determine how many unique combinations can be made of the individual characters in the string, and print that number. However...
stackexchange_codegolf
\$ 1089 \$ is a very special number. To prove why, select any 3-digit number whose first and last digits differ by at least 2. Then, reverse the digits, and take the difference of these two numbers. Reverse the digits once more, and add these two numbers together. You will get \$ 1089 \$. The magic is left as an exerci...
stackexchange_codegolf
In speedcubing, an Ao5 (Average of 5) is computed for a set of five times by removing the fastest and slowest times, and then computing the mean of the remaining three times. A "rolling ao5" is computed for a sequence of at least five times by computing the ao5 for every set of consecutive five times (some sets will o...
stackexchange_codegolf
I love programming and know every language, but I suck at math. Unfortunately, my school requires that computers students must take a year of calculus. There's a test next week, and I don't know any of the formulas for derivatives! Please help me find the formulas. I need a cheat sheet - a program (as short as possible...
stackexchange_codegolf
Input a decimal number and round it to an integer, randomly rounding up or down with a probability based on its fractional part, so the expected value of the output equals to the input value. If input \$x\$ is an integer, the program should output it as is. If \$x\$ is not an integer, the program has a \$x-\left\lfloo...
stackexchange_codegolf
Task Given is a square matrix of any dimension and any integer n. Output all possible matrices(without duplicates) by removing columns and rows from the input matrix such that the determinant of these new matrices is n. Rules Output should include original if determinant of original is n. Output should be all the chopp...
stackexchange_codegolf
API Easter egg hunt! There's an API at http://easter_egg_hunt.andrewfaraday.com which will provide a special Easter egg hunt, just for you... You can see the API docs at the above address, or try it from here. The API: All calls to this API are GET requests, which will return a JSON string. These examples are in a 5x5 ...
stackexchange_codegolf
Let \$ A \$ represent the alphabet, such that \$ A_1 = \$ a and \$ A_{26} = \$ z. Let's define that a word \$ W = w_1 w_2 ... w_n \$ (where \$ w_c \in A\$) is in standard order if and only if: \$ w_1 = A_1 \$, and for \$ 2 \le i \le n \$, if \$ w_i = A_x \$ then \$ w_j = A_{x-1} \$ for some \$ j < i \$ and some \$x\$....
stackexchange_codegolf
From Wikipedia: The centroid of a non-self-intersecting closed polygon defined by n vertices (x0,y0), (x1,y1), ..., (xn−1,yn−1) is the point (Cx, Cy), where and where A is the polygon's signed area, In these formulas, the vertices are assumed to be numbered in order of their occurrence along the polygon...
stackexchange_codegolf
Ok I've been on a bit of a triangle kick recently so here's another one. Clark's Triangle is a triangle where the leftmost entry of each row is 1 and the rightmost entries are made up of multiples of 6 which increase as the row number increases. Here's a visualization 1 6 1 . 12 1 . . 18 1 . . . 24 1 . ...
stackexchange_codegolf
The New York Times has a daily online game called Letter Boxed (the link is behind a paywall; the game is also described here), presented on a square as follows: You are given 4 groups of 3 letters (each group corresponds to one side on the picture); no letter appears twice. The aim of the game is to find words made o...
stackexchange_codegolf
Challenge Premise I've got multiple pretty numbers all in a row. Each is a decimal digit. 0s are weakly attracted to 0s, 1s are attracted to 1s a little more strongly and so on until 9. I don't know why — it must be something I ate. As a result, a sort of two-way sideways sedimentation occurs until the higher values ar...
stackexchange_codegolf
Description Given a length n, and an alphabet size k>0, your program must determine the number of strings with those parameters which have a maximal number of unique substrings. In the case of k=2, this generates OEIS A134457. Example For example, 2210 has the substrings , 2, 22, 221, 2210, 2, 21, 210, 1, 10, and 0, ...
stackexchange_codegolf
Shocking news: Dr. Mad J Scientist has released a proof of P = NP to the world. But the proof is nonconstructive, and she's keeping the algorithm to herself. Worry not. Without even looking at her proof, we can still (almost) write a computer program that solves NP-complete problems in polynomial time. The Problem Inpu...
stackexchange_codegolf
Your task is to write a program that performs case conversion from plain text, and other case formats, into one of the specified formats below. Inputs will be either plain lowercase text, or one of the detailed cases below. You must remove non-alphabetic characters except (space), _ (underscore) and - (hyphen), then ...
stackexchange_codegolf
On puzzling SE there are what are called "matchstick problems" in which math is written in match sticks and you are allowed to move a certain number of them to get a certain property. In this question we will be considering only integers represented in a 7-segment display format. Here are all 10 digits in that format:...
stackexchange_codegolf
Challenge Let's have a list L of n elements. The task is to swap every two elements in this list. Constrains the list L has at least two elements size of the list L is a multiple of two (i.e. number of elements is even) Example input: [1,2,3,4,5,6] output: [2,1,4,3,6,5] input: [0,1,0,1] output: [1,0,1,0] Rules ...
stackexchange_codegolf
Given a list of non-negative integers the function \$f\$ replaces every integer with the number of identical integers preceding it (not necessarily contiguously). So f [1,1,2,2,1,3,3] = [1,2,1,2,3,1,2] We will say that a list, \$X\$, is in a loop if there is some positive integer \$n\$ such that \$f^n X = X\$. That i...
stackexchange_codegolf
Are you feeling jealousy towards Mathematica, Matlab et al. for their intricate plotting capabilities? If you answered yes, this challenge is for you! Challenge Given, via parameters or standard input, a list of numbers list and a positive integer h for the height of the plot, write a program/function/snippet that prin...
stackexchange_codegolf
Inspired by I'm not the language you're looking for! Challenge Choose two different programming languages, and write a program that prints the following line to stdout (or equivalent): This program errors out in <the current language> :P and then generates different kind of error in each of the two languages. Rules So...
stackexchange_codegolf
Suppose you have a grid of cells that is 6 wide and arbitrarily tall. In each cell is a word. Let the bottom row, which is row #1, be the last 6 words of sample.txt in order. Let the second to last row, which is row #2, be the 6 words before those in order. (etc.) Then consider what happens when you remove some of the ...
stackexchange_codegolf
About a year ago you were asked to find the XOR primes. These are numbers whose only factors are 1 and themselves when performing XOR multiplication in base 2. Now were are going to spice things up a bit. We are going to find the XOR primes in base -2 Converting to Base -2 Base -2 is a lot like every other base. The...
stackexchange_codegolf
Your goal is to write a program that, given a number N and a string as input, will return a string containing every Nth word of the original string, starting from the first word. Sample inputs/outputs: N = 2, str = "This is a sentence" "This a" -- N = 2, str = "The quick brown fox jumped over the lazy dog." "The brow...
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
Hole #1 Joe the snake is hungry. He eats pictures, one pixel at a time. He really likes bright pixels. The Challenge Program Joe to eat the most bright pixels he can find, given that he can only move up, down, left or right. Specifications Joe must start at the upper left pixel of the image. Joe can only move horizont...
stackexchange_codegolf
The Hamming distance between two strings is the number of positions they differ at. You are given a set of binary strings. The task is to find the length of the shortest route that visits all of them at least once and ends where it started, in a metric space where the distance between two strings is the Hamming distanc...
stackexchange_codegolf
Given two numbers in tape location #0 and tape location #1 in Brainfuck, compute their product into another tape location (specify with answer). Optimize for the least amount of time-units used, where the interpretation of any command uses one time-unit. As example, here is a quick C++ program to determine the number o...
stackexchange_codegolf