instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Suppose you have a string \$s_0\$ and someone else has a hidden string \$s_1\$. You don't know what \$s_1\$ is but they tell you that they can get from your string, \$s_0\$, to their string by making a certain number of moves \$d\$. Each move can be one of the following: Insertion : Add a character anywhere in the ...
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
In this question I defined a "chain" function as a function that: is a permutation, meaning that every value maps to and is mapped to by exactly one value. and allows any value can be obtained from any other value by repeated applications of the function or its inverse. There are a lot of functions that do this and s...
stackexchange_codegolf
Every now and again, I'll encounter a large string of alphabetical text encoded as numbers from 1-26. Before I knew that I could just google a translator online, I had to personally, painstakingly copy and paste the entirety of the encoded text into a text document and translate it myself. Thankfully, I did know about ...
stackexchange_codegolf
Write a program that outputs the number 0. That's a bit trivial, isn't it? Let's sort all distinct permutations of your code in lexicographical order. When any of these codes are run, it should output the its location in the array (0-indexed or 1-indexed). This means that your code must be the lexicographically smalles...
stackexchange_codegolf
Task Write a function/full program that will be able to produce two different sequences of integers in [0, ..., 9]. You will take an input seed to decide whether to output your specific sequence or the common one. For that matter, you must choose one non-negative integer, let us call it k. When the input seed is equal ...
stackexchange_codegolf
How do I remove all duplicates from list and order it based on count? s = ["foo", "this", "lem", "foo", "lem"] s = ["foo", "ebh", "wosv", "wosv", "ebh", "4whcu"] #should return >>> ["foo", "lem", "this"] >>> ["ebh", "wosv", "foo", "4whcu"] Rules: Must be shorter than the below code in terms of byte size. Order must b...
stackexchange_codegolf
Related but different. Part II Taken from the book: Marvin Minsky 1967 – Computation: Finite and Infinite Machines, chapter 14. Background As the Gödel proved, it is possible to encode with a unique positive integer not just any string but any list structure, with any level of nesting. Procedure of encoding \$G(x)\$ i...
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
Typescript is a typed superset of Javascript. For this challenge, we'll consider the following classic basic types: string number boolean undefined null And two "meta" types: any never The type any annotates that any type is valid: const a: any = "foo"; const b: any = 42; const c: any = true; const d: any = undefin...
stackexchange_codegolf
Introduction A function that adds months to a date (without overflowing ends of months) is implemented in many languages/packages. In Teradata SQL it's ADD_MONTHS, here are some examples: ADD_MONTHS('2021-01-31', 1) => 2021-02-28 ADD_MONTHS('2021-01-30', 1) => 2021-02-28 ADD_MONTHS('2021-02-28', 1) => 2021-03-28 ...
stackexchange_codegolf
Gah! It's a shame that Pokémon Sword and Shield won't introduce a new eeveelution. Let's mourn them with a code golf. The objective is to, when given a type name as the input, output the name of the corresponding eeveelution. When given Water, output Vaporeon. When given Electric, output Jolteon. When given Fire, outp...
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
Given two rectangles, which are possibly not in the orthogonal direction, find the area of their intersection. Input You may take the rectangles as input in one of the following ways: The coordinates of the four vertices of the rectangle. These coordinates are guaranteed to represent a rectangle. The coordinates of t...
stackexchange_codegolf
Can you decrypt me? Robbers Find any combination of \$n\$ working chars to change and what they should change into, where \$n\$ is chosen by the cop. You cannot change less than n chars, only exactly \$n\$. Example print(2) N is 1. Robbers' post: print(1) Scoring For the robbers, the user with the most cracks wins. ...
stackexchange_codegolf
Some positive integers can be shown to have a property called Chain divisibility. For a number to be chain-divisible by n, it must fulfil three requirements: Each digit divides the number formed by the n  digits that follow it. For example, the number 7143 is chain-divisible by 2 because 7 divides 14 and 1 divides 4...
stackexchange_codegolf
Introduction Partly inspired by this StackOverflow question, let's draw an ASCII Lightning Bolt. Write a program that takes a positive Integer n via STDIN or command line and outputs the ASCII Lightning Bolt below. Input Positive Integer n representing the number of lightning zig-zag tiers to draw. Example Output n=1 _...
stackexchange_codegolf
The infinity symbol is also called a lemniscate. Your program must draw a lemniscate with text via standard out (formatted with newline feeds) or graphically. The infinity symbol (by my standards) must be continuous (that is, every non-whitespace character must be touching two other non-whitespace characters diagonally...
stackexchange_codegolf
Background A polyomino of size \$n\$ is a contiguous shape made from joining \$n\$ unit squares side by side. A domino is a size-2 polyomino. A polydomino of size \$2n\$ is defined as a polyomino of size \$2n\$ which can be tiled with \$n\$ dominoes. The following are some examples of polydominoes for \$n=3\$ (hexomino...
stackexchange_codegolf
Introduction As you all know, German has umlauts. They're these things: ¨ However, most keyboards don't have an umlaut key. That's fine, though, because you can write ö, ä, and ü as oe, ae, and ue. Challenge Your job is to to replace ö, ä, and ü with oe, ae, and ue (and likewise for their capital versions). You have t...
stackexchange_codegolf
TikZ is a Latex package used for drawing precise images in Latex documents. It has a massive specification and a boatload of features that may be useful for graphical-output style questions. What tips do people have for golfing in TikZ? As always, tips should be specific to to TikZ (e.g. "Remove comments" is not an a...
stackexchange_codegolf
I have a crank-operated music box that can play a series of four notes. When I turn the crank, it plucks one of four strings, depending on the position of the crank and the direction of the turn. When the crank is turned due north, the box (with its strings numbered 1 through 4) looks like this: 1 | 2 | O 4...
stackexchange_codegolf
Background This challenge is in honor of apsillers, who won the Not as simple as it looks category in Best of PPCG 2016 with their challenge Can my 4-note music box play that song? Congratulations! On their "About Me" page, this user has a really neat simulator for the Game of Life cellular automaton. (Seriously, go ch...
stackexchange_codegolf
You have to decompose a positive integer/fraction as a product of powers of factorials of prime numbers. For example 22 = (11!)^1 × (7!)^(−1) × (5!)^(−1) × (3!)^(−1) × (2!)^1 10/9 = (5!)^1 × (3!)^(−3) × (2!)^1 Use this special notation: prime number#power to denote each term, e.g. (11!)^4 is denoted as 11#4. Output...
stackexchange_codegolf
Semordnilaps (also known as heteropalindromes, semi-palindromes, half-palindromes, reversgrams, mynoretehs, reversible anagrams, word reversals, or anadromes) are words which are also words when spelled backwards. A few examples are: Ward <=> Draw Mined <=> Denim Parts <=> Strap Given a positive integer N (via functi...
stackexchange_codegolf
The Universal Crossword has a set of guidelines for crossword puzzle submissions. In this challenge we are going to be concerned with their rules for hidden word themes. A hidden word clue consists of a clue and a word. It can either be a "word break" or a "bookend". For a word break the word must not appear as a cont...
stackexchange_codegolf
You're looking at an avenue, and someone has left the trash out! You need to write a program to help fix the problem, by putting the trash into trashcans. The task The avenue is made up of a string of printable ASCII characters, e.g.: [[](dust)[]] car ((paper)vomit) (broken(glass)) [[] (rotten) fence (dirty) Some of t...
stackexchange_codegolf
Print the phrase And she said, 'But that's his.' using only the following characters: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ No punctuation or non-alphabetic characters whatsoever. You can use whatever programming language you want. Whitespace is completely allowed. Shortest program wins.
stackexchange_codegolf
Input Two non-negative floating point numbers \$x < y\$. You can assume they are close enough to each other that there is no integer between \$x\$ and \$y\$. Output A fraction with the smallest possible denomination that lies strictly between \$x\$ and \$y\$. Examples Input: 1 and 2 Output: 3/2 Input: 0 and 0.33 Output...
stackexchange_codegolf
Challenge Construct n strings, each with three distinct letters, chosen randomly with equal probability. Print the proportion k/n where k is the number of strings such that all three characters are in ascending order. Print also those k strings. Input The only input is n (and thus it must be a positive integer). Ou...
stackexchange_codegolf
Task Given an integer matrix M and a modulus m, find an inverse of M modulo m. If the matrix M is not invertible modulo m, the behaviour is left unspecified. Matrix inverse If M is a square matrix, its inverse exists if and only if its determinant is not 0. Similarly, when we are talking about matrices modulo m, the in...
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
An intriguing MathsSE question asked if there were large N-queens solutions where no three queens lie on a line. That question's body included the unique 4×4 solution up to symmetries . Q . . . . . Q Q . . . . . Q . and noted that there are no solutions for 5×5 to 7×7 because of knight lines. However, joriki over ther...
stackexchange_codegolf
So I got kinda bored and was wondering if it was possible to make this code shorter without modifying anything except a file named coin.py... from random import*;c=['heads','tails'];print('u win'if choice(c)==input(' / '.join(c)+': ')else'u lose') The program asks the user for either "heads" or "tails", if the result ...
stackexchange_codegolf
In as few bytes as possible in t-sql, return 100 rows containing the phrase 'Have a great Christmas' 92 (I think) to beat :D CREATE TABLE #(m char(99)) GO INSERT # SELECT'Have a great Christmas' GO 100 SELECT * FROM # Previous best effort was: WITH t(m,r)AS(SELECT'Have a great Christmas',1 UNION ALL SELECT m,r+1 FROM ...
stackexchange_codegolf
An ant starts on an edge of a dodecahedron, facing parallel to it. At each step, it walks forward to the next vertex and turns either left or right to continue onto one of the other two edges that meet there. A sequence of left/right choices that returns the ant to its initial state (edge and direction) is called a rou...
stackexchange_codegolf
This challenge has two threads. This is the cops' thread. The robbers' thread is located here. Your challenge is to choose an OEIS sequence and write two full programs in two different languages that produces that nth item in the sequence when given an n via STDIN, or an other forms of standard input, where n is any p...
stackexchange_codegolf
Hold up..... this isn't trolling. Background These days on YouTube, comment sections are littered with such patterns: S St Str Stri Strin String Strin Stri Str St S where String is a mere placeholder and refers to any combination of characters. These patterns are usually accompanied by a It took me a lot of time to m...
stackexchange_codegolf
You are paddling a canoe down a fairly fast whitewater river. Suddenly, your paddles explode, and you find yourself in a dangerous situation hurtling down a river rapid without any paddles. Luckily, you still have your programming skills, so you decide to carve a program on the side of your canoe to help you survive th...
stackexchange_codegolf
I am trying to find the shortest code in python 3, to solve this problem: You are driving a little too fast, and a police officer stops you. Write code to take two integer inputs, first one corresponds to speed, seconds one is either 1 or 0, corresponding to True and False respectively to indicate whether it is birthd...
stackexchange_codegolf
Introduction The current coronavirus disease is officially named COVID-19, from the 3 words corona virus disease, and the year 2019. (Technically it's coronavirus, making 2 words, but whatever...) Given this example, we can apply this naming convention to name other potential diseases. Challenge You will be given 3 wor...
stackexchange_codegolf
Definition From the description on OEIS A006345: To find a(n), consider either a 1 or a 2. For each, find the longest repeated suffix, that is, for each of a(n)=1,2, find the longest sequence s with the property that the sequence a(1),...,a(n) ends with ss. Use the digit that results in the shorter such suffix. a(1) =...
stackexchange_codegolf
A sturdy square (akin to a magic square) is an arrangement of the integers 1 to \$N^2\$ on an \$N\$ by \$N\$ grid such that every 2 by 2 subgrid has the same sum. For example, for \$N = 3\$ one sturdy square is 1 5 3 9 8 7 4 2 6 because the four 2 by 2 subgrids 1 5 9 8 5 3 8 7 9 8 4 2 8 7 2 6 all sum to the same amoun...
stackexchange_codegolf
Imagine you are sitting at a park. Suddenly your car gets hijacked and being driven in different directions. Here are the directions, arrows show which direction goes towards where: South | V East-> <-West ^ | North After being driven, the car stops. Now you have to find out ho...
stackexchange_codegolf
A donut distribution (for lack of a better term) is a random distribution of points in a 2-dimensional plane, forming a donut-like shape. The distribution is defined by two parameters: the radius r and spread s, in which the distance to the origin follows a normal (Gaussian) distribution around r, with a standard devia...
stackexchange_codegolf
Given a string of the characters +=- where there is at least one =, insert positive integers between all the symbols and at the start and the end such that the math equations are satisfied. For example, given the input +-=-= you need to insert positive integers A through F like this A+B-C=D-E=F such that the equation...
stackexchange_codegolf
The string abaaba Is a palindrome, meaning it doesn't change when it's reversed. However we can split it in half to make two palindromes aba aba We could also split it up this way: a baab a And all three of those are palindromes. In fact there are only two ways to split the string into smaller strings such that non...
stackexchange_codegolf
I noticed that it seems nobody has posted a non-ASCII (related) USA flag challenge yet, so what better time than the 4th of July? The Challenge Draw the current (as of 2022) flag of the United States of America. Here is the flag: Specifications Hoist (height) of the flag: A = 1.0 Fly (width) of the flag: B = 1.9 Hoi...
stackexchange_codegolf
Challenge Consider the rainbow as seven colours, represented by strings as Red Orange Yellow Green Blue Indigo Violet. Your task is to create a program that receives one of these colours as input and outputs next in order rainbow colour. This includes overlapping Violet -> Red Input A string containing one of rainbow c...
stackexchange_codegolf
(There exists some challenges that require to use the best strategy, but here we don't. Even if you are able to win, you are allowed to make a tie) Challenge Write a program which plays the game tic-tac-toe. It must not lose (therefore, it should end the game either with a tie or by winning). Allowed I/O methods Input...
stackexchange_codegolf
Sandbox post (deleted) The old roman army formations are very famous around the world. In these formations roman legionaries grouped in a geometric shape (usually a rectangle) protecting the flanks and the superior part of it using their shields. The legionaries at interior positions covered the superior part placing t...
stackexchange_codegolf
Background A typist comes home wfter some riugh drinkinh and realizes thag an importsnt letter still needs to be wtitten. To make sure he vets the text correct, he writes the text character bh vjaracter t0 be sure of 6he resuly. However, he dtill manages t0 miss some ofbthe keys. Yout task is to write cose that simulat...
stackexchange_codegolf
Take a string, s containing printable ASCII-characters as input, and output its "binary split sum". Need an explanation? How do you get the binary split sum? We'll use the string A4 as an example in the following explanation. Convert the characters to binary, treating each letters as a 7-bit ASCII character A -> ASCII...
stackexchange_codegolf
Given a German string and an indication of a case (lower/upper/title), fold the string to that case. Specifications Input will consist only of a–z plus äöüß-,.;:!?'" in uppercase and/or lowercase. The target case may be taken as any three unique values (please specify what they are) of a consistent type; either three ...
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
Hexagonal tessellations, or tilings of the plane, are three-colorable -- meaning that using only three colors, such as Red, Blue, and Green, every hexagon can be colored without any two hexagons that share a border sharing a color. A partial example showing such a pattern. Given a partial hexagonal tiling in ASCII (via...
stackexchange_codegolf
Ok lets say we get a input the following csv file (all entries are quoted strings) ID, Before, After, Value 1, 3, 5, Cat 2, 5, , Apple 3, 4, 1, Dog 4, , 3, Elephant 5, 1, 2, Banana Output a csv file in which the entries...
stackexchange_codegolf
I'm surprised that this challenge isn't already here, as it's so obvious. (Or I'm surprised I couldn't find it and anybody will mark it as a duplicate.) Task Given a non-negative integer \$n\$, calculate the sum of the first \$n\$ primes and output it. Example #1 For \$n = 5\$, the first five primes are: 2 3 5 7 11 ...
stackexchange_codegolf
For any String that is composed of lower cased alphabetical characters, make a function that returns a list of all of it's variations, empty strings returns empty list Test Cases "" -> [] "a" -> ["a", "A"] "ab" -> ["ab", "Ab", "aB", "AB"] "abc" -> ["abc", "Abc", "aBc", "ABc", "abC", "AbC", "aBC", "ABC"] This is Code-g...
stackexchange_codegolf
Chameleon challenges are a bad thing, apparently. Too bad, chameleons are beautiful creatures. Time for a change! As we all know, many chameleons posses a remarkable ability to blend in with their surroundings by changing the color of their skin. Which is also the objective of this challenge. Challenge Imagine a squar...
stackexchange_codegolf
I have a set of colored plastic cups. They come in four colors: green, yellow, pink, and blue. When I put them on my shelf, I like to stack them in a certain pattern. Your job is, given a list of any number of four distinct values (to represent the four cup colors), output a visual representation of how I would stack t...
stackexchange_codegolf
When students are first taught about the proof technique of mathematical induction, a common example is the problem of tiling a 2N×2N grid with L-shaped trominoes, leaving one predetermined grid space empty. (N is some nonnegative integer.) I will leave it to you to go over the proof if you do not already know it. Ther...
stackexchange_codegolf
One element of the list aa, ab, ba, bb, c has been removed, and the remainder shuffled and joined with no separator. Find the missing element. For example, if the input was aaabbac, this is made by concatenating aa ab ba c, so the output would be bb. Rules Standard I/O rules apply. You must take input as a string (or ...
stackexchange_codegolf
From the subreddit r/SpeedOfLobsters: Edit the text of an image to create a new phrase This meme format/style is pretty self-explanatory. Simply have a browse through the subreddit if you need more examples. However, when coming up with ideas, it can be quite difficult to decide exactly which letters to keep and whic...
stackexchange_codegolf
For this challenge, you will be required to write 3 programs: The first program should be a quine, i.e, it should print it's own source code. The second program should read the input and print all of it. The third program should simply print the string "Hello, Permutations!", with or without quotes. In addition to th...
stackexchange_codegolf
Similar to our threads for language-specific golfing tips: what are general tricks to shorten regular expressions? I can see three uses of regex when it comes to golfing: classic regex golf ("here is a list that should match, and here is a list that should fail"), using regex to solve computational problems and regula...
stackexchange_codegolf
Challenge The goal of this challenge is to make a function that takes an input string, a start keyword and a end keyword. The output extracted result is from (but excluded) the given start keyword to (but excluded) end keyword. The output sub-string follows the rules as below. In all cases, the leading/trailing spaces...
stackexchange_codegolf
This is a simple(ish) web scraping challenge. Input Your code should take an MPAA film rating and a number from 0 to 100 as input. It can do this in any way you find convenient. Output Your code should return the name of any movie which has a) that film rating and b) the numerical score on the Tomatometer from rottento...
stackexchange_codegolf
Write a program or function that takes in a rectangular grid of text where every cell is either an A or a B. All the A cells will form a simply-connected shape, i.e. they will all be orthogonally connected with no holes (diagonally neighboring letters do not count as connected). Likewise, all the B cells will form anot...
stackexchange_codegolf
Your task is given an input string of the full/short name of a CS:GO (Counter-Strike: Global Offensive, a computer game) rank return an integer from 1-18 representing the rank number. A higher number means you are a higher rank and so "better" at CS:GO. Input A string representing either the full name or short name of ...
stackexchange_codegolf
A square-free word is a word consisting of arbitrary symbols where the pattern \$XX\$ (for an arbitrary non-empty word \$X\$) does not appear. This pattern is termed a "square". For example, squarefree is not square-free (using the lowercase letters as the alphabet), as the square ee appears; but word is square-free. A...
stackexchange_codegolf
Objective Given an ASCII character, toggle its "shift-ness" on the standard US keyboard (ANSI-INCITS 154-1988 (R1999)), then output it. Mapping ) ↔️ 0 ! ↔️ 1 @ ↔️ 2 # ↔️ 3 $ ↔️ 4 % ↔️ 5 ^ ↔️ 6 & ↔️ 7 * ↔️ 8 ( ↔️ 9 " ↔️ ' + ↔️ = , ↔️ < - ↔️ _ . ↔️ > / ↔️ ? : ↔️ ; (Capital Latin letters) ↔️ (Small Latin letters) [ ↔️ { \...
stackexchange_codegolf
The Māori language has quite simple pronouns. It uses a single word for he/she/they/etc (ia), and the words for "you" and "me" are koe and au respectively. There are also words for groups of exactly two people: tāua - You and me (we, au and koe) māua - Me and them (we, au and ia) rāua - Them (third person plural - two...
stackexchange_codegolf
Above, you can see an image full of different colours. Click here for a hex-dump. One possible way to generate this image is by using a linear gradient rotated 90 degrees, however, this may not be the only way. Your task is to create a self-contained program that takes no input, and outputs an image with the same RGBA...
stackexchange_codegolf
Write a program or function that outputs an L if run on a little endian architecture or a B if run on a big endian architecture. Lower case output l or b is also acceptable. There is no input. Scoring is code golf, so the code with the fewest bytes wins. Edit: As per the comments below, I am clarifying that the entry m...
stackexchange_codegolf
The task is to find the smallest paper size on which it is possible to print a picture of the dimensions given in milimetres. The image will be printed without margins. Input: Two integers (bigger than zero) and a letter a, b, or c, for example: 290 200 A Output: Paper size, for example: A4 Another examples: 218,297...
stackexchange_codegolf
Description : You are given a string of numbers (positive and negative but not decimals) along with the number of entries like so. Like so 8 '1 2 5 0 7 -9 12 -8' Task : Your job is to return the number closest to zero be it +ve or -ve. Your input will be separated by spaces only. You are free to return the answer in a...
stackexchange_codegolf
When babies open their mouths, they're not just spewing gibberish. They're actually talking in a highly advanced, adult-proof cipher... The Baby-talk Cipher When a baby talks, it could look something like gogooa gagooook aagaaoooy Each single-space separated section represents a character (so the example above represen...
stackexchange_codegolf
Task Given a non-negative integer n, output 1 if n is 0, and output the value of n otherwise. Input A non-negative integer. If you would like to accept the string as input, the string would match the following regex: /^(0|[1-9][0-9]*)$/, i.e. it must not have any leading zeroes, except when it is 0. If you accept a re...
stackexchange_codegolf
I've been a fan of My Little Pony: Friendship Is Magic for a long time, and very early on I created a pony version of myself also called Parcly Taxel (warning: may be too cute to look at). The symbol below is her "cutie mark", which you will be drawing here: Construction All key points of the cutie mark lie on a rotat...
stackexchange_codegolf
Background You have again x4 been given the task of calculating the number of landmines in a field. But this time, the field is not a number field... it's a field of letters. Our landmine letter operator is sick and requires you to cover for them. They left you the following note: Things work a little differently with...
stackexchange_codegolf
Challenge Create the image of a progress pride flag. Output Dimensions Rules Your program must create the image and not just load it from a website The colours can be just your language's default if it is very difficult / impossible to load RGB values, else they should be: red: (255,0,0), orange: (255,140,0), yello...
stackexchange_codegolf
It's time to conclude the series of John Conway challenges of mine. Background A FRACTRAN program consists of an ordered list of fractions. The program starts by taking a single integer as input. Each iteration of the program, it searches the list for the first fraction such that multiplying the number by that fraction...
stackexchange_codegolf
This is the cops' thread of a cops-and-robbers challenge. The robbers' thread can be found here In this challenge as a cop you will choose two programming languages A and B, as well as a non-empty string S. You are then going to write 4 programs: A program which outputs exactly S when run in both A and B. A program w...
stackexchange_codegolf
Inspired by this accidental misspelling If you could read the title, then you already know what the challenge is about. If not, then I'll tell you. Easy: simply take each word (single space delimited), and swap the positions of the first two letters. You may assume that the input will contain only lowercase ASCII let...
stackexchange_codegolf
Your challenge is to write a program that constantly prompts for input, and when input is given, output that five seconds* later. However, your program must continue prompting for input during that time. Since this is a bit confusing, here's a demo. <pre id=x></pre><input id=h onchange='var k=this;(()=>{let a=k.value...
stackexchange_codegolf
I'm a huge video game music fan. One of my favorite OSTs is that from Kingdom Hearts, by Yoko Shimomura. The challenge Create a program or function that takes two arguments in any format: an abbreviated Kingdom Hearts game and a boss in that game. It must return the name of the song that plays for that boss. The progra...
stackexchange_codegolf
You have a 3x3 grid. Each cell can be colored black or white. Display all 512 of these colorings. Fewest bytes wins. You can display the grids in any formation as long as they are visually separated and the spacing looks regular. You may use ASCII art or images. Any two distinct visible symbols or colors can be used fo...
stackexchange_codegolf
A neat trick is if you ever need a nine-sided die, it is possible to make one using two six-sided dice using the numbers below. This is assuming you either have a way to rewrite the faces on the dice, or use some algorithm to map the numbers on a normal die onto these new numbers. 0 0 3 3 6 6 ----------- 1|1 1 4 4 ...
stackexchange_codegolf
Description a typeracer is an apps where user could type and evaluate their typing speed and accuracy. Criteria User could type "A quick brown fox jumps over the lazy dog." A visual indicator of each wrong character typed. A visual indicator of what characters to type. A visual indicator of what has been typed A visua...
stackexchange_codegolf
I have a combinatorics problem that I'd like to put on the OEIS—the problem is that I don't have enough terms. This code challenge is to help me compute more terms, and the winner will be the user with the submission containing the greatest number of terms. The Problem Suppose I give you a triangular array of light bu...
stackexchange_codegolf
This is the cop's thread, where one should post the scrambled code. Here is the robbers' thread where the cracked source should be posted and linked to the cop's answer. Task: Write the shortest safe program that given two inputs \$x,y\$, outputs \$\arg(x+iy)\$, where \$\arg(z)\$ is defined as the angle between the po...
stackexchange_codegolf
Philosophers have long pondered the Trolley problem. Unfortunately, no human has solved this problem yet. Luckily, as programmers we can use computers to solve the problem for us! Input Your program will take as input a (finite) directed graph (with at most one edge from x to y, for any x and y), with a designated nod...
stackexchange_codegolf
Challenge: Input: a string, consisting of only printable ASCII characters Output: a truthy/falsey value whether its characters are in alphabetical order (based on their UTF-8 unicode values), from any starting point inside the string including wrap-around by going left-to-right For example: xyzabc would give a truthy r...
stackexchange_codegolf
You have to make a game Too-low --- Too-high (TLTH) in shortest code (in bytes) Game rules: Computer will choose a random number out of integer range (-32768..32767). Now you will think of a number and input it. The computer will tell if your number is lower (TOO LOW) or higher (TOO HIGH) than the chosen number. W...
stackexchange_codegolf
To quote http://brainfuck.org/utm.b: A tag-system transforms strings over an alphabet A = {a[1], a[2], ... a[n], a[n+1]} as follows: a positive integer m is chosen, and so is a function P that maps each a[i] for 1<=i<=n to a string P(a[i]) over the alphabet A. Now: if the string being transformed has fewer than m ele...
stackexchange_codegolf
Task Given a String as input, your task is to output 42 only if the input String happens to be exactly the following : abbcccddddeeeeeffffffggggggghhhhhhhhiiiiiiiiijjjjjjjjjjkkkkkkkkkkkllllllllllllmmmmmmmmmmmmmnnnnnnnnnnnnnnoooooooooooooooppppppppppppppppqqqqqqqqqqqqqqqqqrrrrrrrrrrrrrrrrrrsssssssssssssssssssttttttttttt...
stackexchange_codegolf
this challenge was based on a sandboxed post by @dmckee Old fashioned cell phones were and are used heavily as texting platforms, unfortunately the keyboard has only 12 + a few buttons, and is therefor ill-suited to naive text entry. Common solutions make use of the traditional telephone coding (generally with a modest...
stackexchange_codegolf
For this challenge you need to implement two functions, f and g, on the integers, such that f ∘ g is a strictly decreasing function while g ∘ f is a strictly increasing function. In other words, if you take any two integers a < b, then f(g(a)) > f(g(b)) and g(f(a)) < g(f(b)). There are no restrictions on f and g indivi...
stackexchange_codegolf
The challenge is to implement a function or program that takes two numbers, \$x\$ and \$y\$ and return the result of \$x^y\$. The program cannot use any other mathematical operation other than \$+\$ or \$-\$, so no multiplication or division. Functions built into languages are also not allowed. The code in the least a...
stackexchange_codegolf