instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
As the title -- although discretely -- hints, I only pay with dollars. The challenge Write a function/program that takes a string as input, which is a monetary value preceded by a symbol. ex) £4.99. Then, return that same amount converted to USD. Input You will get a string as input. It will have the currency symbol f...
stackexchange_codegolf
You will be given two integers \$M\$ and \$N\$. Find the number of pairs \$(x,y)\$ such that \$1 \le x \le M\$, \$1 \le y \le N\$ and \$(x+y)\bmod5 = 0\$. For example, if \$M = 6\$ and \$N = 12\$, pairs which satisfies such conditions are, \$(1,4), (4,1), (1,9), (2,3), (2,8), (3,2), (3,7), (3,12), (4,6), (6,4), (4,11),...
stackexchange_codegolf
(Inspired by this challenge) Given two input strings, one of which is exactly one character longer than the other, arrange the strings into ASCII art as if they are two halves of a zipper that is only halfway zippered. The longer word forms the bottom of the zipper, and is the first and last character of the combined z...
stackexchange_codegolf
In the examples below, A and B will be 2-by-2 matrices, and the matrices are one-indexed. A Kronecker product has the following properties: A⊗B = A(1,1)*B A(1,2)*B A(2,1)*B A(2,2)*B = A(1,1)*B(1,1) A(1,1)*B(1,2) A(1,2)*B(1,1) A(1,2)*B(1,2) A(1,1)*B(2,1) A(1,1)*B(2,2) A(1,2)*B(2,1)...
stackexchange_codegolf
Somehow, we don't yet have a challenge for finding the inverse of an arbitrarily-sized square matrix, despite having ones for 3x3 and 4x4, as well as a more complex version. Your task is, given a square \$n\times n\$ non-singular matrix \$M\$, output the matrix \$M^{-1}\$ that satisfies $$MM^{-1} = I_n$$ There are a nu...
stackexchange_codegolf
Here's one for fans of Cabin Pressure. There is an episode in which the characters devise a new version of Fizz Buzz, which is simplified to contain absolutely no mathematics. It has these rules: If someone says "fizz", you say "buzz". If someone says "buzz", you sing "'ave a banana" If someone says your name, you say...
stackexchange_codegolf
Given two points \$(x_1, y_1)\$ and \$(x_2, y_2)\$ with integer coordinates, calculate the number of integer points (excluding the given points) that lie on the straight line segment joining these two points. Use any maths formula you like, such as $$gcd(|x_2 - x_1|, |y_2 - y_1|) - 1$$ Input Four integer coordinates of...
stackexchange_codegolf
In pancake sorting the only allowed operation is to reverse the elements of some prefix of the sequence. Or, think of a stack of pancakes: We insert a spatula somewhere in the stack and flip all the pancakes above the spatula. For example, the sequence 6 5 4 1 2 3 can be sorted by first flipping the first 6 elements (...
stackexchange_codegolf
Let's introduce a simplified variant of the well known Spider Solitaire. From Wikipedia: The main purpose of the game is to remove all cards from the table, assembling them in the tableau before removing them. Initially, 54 cards are dealt to the tableau in ten piles, face down except for the top cards. The tableau pi...
stackexchange_codegolf
Given an input string, write a program that outputs the total number of lines and curves it has. The Challenge Take input from STDIN, or any other input method. Output to STDOUT, or any other output method, the total number of lines and curves contained in the string, in that order, based on the below table in the cod...
stackexchange_codegolf
Note, challenge copied from question asked at math.stackexchange. Recently, I attained quite some skill at blowing bubbles. At first I would blow bubbles like this: But then things started getting strange: After a while, I was blowing some pretty weird bubbles: After blowing hundreds, maybe even thousands of such bu...
stackexchange_codegolf
Given a ragged list, we can define an element's depth as the number of arrays above it, or the amount that it is nested. For example, with the list [[1, 2], [3, [4, 5]]] the depth of the 2 is 2, as it is nested within two lists: The base list, and the list [1, 2]. The depth of the 4 is 3 as it is nested within three li...
stackexchange_codegolf
Task Given an integer, n, where 3 <= n < 2^32, calculate the area of a regular n-gon, with an apothem of 1, using the formula A = n * tan(π / n). The apothem of a regular polygon is a line segment from the center to the midpoint of one of its sides. Output the area of this regular polygon as a floating point value sh...
stackexchange_codegolf
Objective Mimic Haskell's reads :: ReadS (). Or in other words, parse nested parentheses. Since the target type is () (the type with one possible value), "parsing" means discarding a leading nested parentheses. Valid Input "Nested parentheses" means (), (()), ((())), and so on. That is, leading nonzero (s and trailing ...
stackexchange_codegolf
Goal: Given two natural numbers (integers from 0 to infinity), output a number that is not the sum of those numbers, but is a natural number. Example solutions (TI-Basic): A+B+1 not(A+B) Invalid solutions: A+B-1 (for inputs 0,0, it returns -1, which is not natural) "ABC" (ABC is not a number) Notes: The output...
stackexchange_codegolf
I'm recieving 2-dimensional positions of two objects as a string with this format: x1,y1,x2,y2. The string is recieved from a readline call (replaced in the snippet with a prompt). In order to get the horizontal and vertical position differentials, I'm writing the following code: [x1,y1,x2,y2]=prompt("Please enter th...
stackexchange_codegolf
This challenge is for the largest finite number you can get BrainFuck programs of given lengths to contain in memory. We must use one of the BF versions that uses big integers for the cells rather than byte values as not to be capped at 255. Do not use negative positions and values in memory. Do not use the BF instruct...
stackexchange_codegolf
Your challenge is to write a program, function, etc. that calculates if the passed string is "in order". That means that the characters of the string have character codes that are in order from smallest to largest. The smallest char code must be the first. By that I mean lowest unicode codepoints to highest. It doesn'...
stackexchange_codegolf
Challenge You will be given a string that can contain lowercase letters, uppercase letters, or spaces. You have to turn the vowels (a, e, i, o, u) in the string to upper case and consonants to lower case. This applies whether or not the letter was originally upper case or lower case. Spaces remain as is. Note that "y" ...
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
This is much more advanced than How to randomize letters in a word and Cambridge Transposition because of the rule about which letters may be swapped with which. A simple regex will not suffice here. It is well known that a text can still be read while the innards of its words have been scrambled, as long as their fir...
stackexchange_codegolf
Sylvester's sequence, OEIS A000058, is an integer sequence defined as follows: Each member is the product of all previous members plus one. The first member of the sequence is 2. Task Create a program to calculate the nth term of Sylvester's Sequence. Standard input, output and loopholes apply. Standard sequence rule...
stackexchange_codegolf
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. As soon as the Elves get bored with the last week's game, Bin comes up with a new game. The rules are similar, except the Elves are supposed to say the numbers that have its "left side" equal to its "right side" when written in binary....
stackexchange_codegolf
Your challenge is to output the number of twisted corners given a 2x2 Rubik's Cube scramble. For the purpose of this challenge, twisted corners are defined as corners where the colour of the top/bottom face before (usually white or yellow) is not facing the top/bottom after the scramble. Eg. if the cube were to be orie...
stackexchange_codegolf
Make a plot (Poincare disk) of a tessellation on a hyperbolic plane, such as: The program takes four inputs: 1) How many edges/polygon (three in this example). 2) How many intersect at each vertex (seven in this example). 3) How many steps away from the center vertex to render (5 in this example, if you look closely)....
stackexchange_codegolf
You are given two strings, each consisting of the English word for a number between 1 and 13: one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen Your program or function must find out whether it's possible to spell at least one other word from the same list without using any of the let...
stackexchange_codegolf
Write a code in your favorite language which reduces words To first three characters. Input : One word Output : First three letters For example INPUT : ProGramming OUTPUT : Pro INPUT : puZZles OUTPUT : puZ INPUT : BoWling OUTPUT : BoW Output needs to be case sensitive Rule-1 All statements should be meaning...
stackexchange_codegolf
This challenge is related to some of the MATL language's features, as part of the May 2018 Language of the Month event. Introduction In MATL, many two-input functions work element-wise with broadcast. This means the following: Element-wise (or vectorized): the function takes as inputs two arrays with matching sizes. ...
stackexchange_codegolf
In LLAMA, you want to dump cards from your hand as quickly as you can, but you might not be able to play what you want. Each player starts a round with six cards in hand; the deck consists of llama cards and cards numbered 1-6, with eight copies of each. On a turn, the active player can play a card or draw a card. To p...
stackexchange_codegolf
Inspired by We do tower hopping and related to 2D Maze Minus 1D Introduction Your task is to find the shortest path to get out of an array maze following specified rules. Challenge A 1D array a with n elements can be regarded as a maze composed of n points, where point with index k is connected to the points with k+a[k...
stackexchange_codegolf
Draw a program or function that will write to STDOUT n times (each for one step) a string that contains a dot . at the location of the walker. The program also needs to write a line every s seconds (or wait s seconds after each line). A random walk is a mathematical formalization of a path that consists of a succession...
stackexchange_codegolf
This is a code golf version of a similar question I asked on stack earlier but thought it'd be an interesting puzzle. Given a string of length 10 which represents a base 36 number, increment it by one and return the resulting string. This means the strings will only contain digits from 0 to 9 and letters from a to z. B...
stackexchange_codegolf
In chess, a knight can only move to the positions marked with X relative to its current position, marked with ♞: A Knight's Graph is a graph that represents all legal moves of the knight chess piece on a chessboard. Each vertex of this graph represents a square of the chessboard, and each edge connects two squares th...
stackexchange_codegolf
This challenge is from a game, Keep Talking And Nobody Explodes. This is like one of those toys you played with as a kid where you have to match the pattern that appears, except this one is a knockoff that was probably purchased at a dollar store. – From the manual Objective The Simon Says module consists of 4 colored ...
stackexchange_codegolf
A repost of this challenge. Meta discussion. Sandbox post. Body of the question similar to the original Robber's challenge This cops and robbers is now (08/03/2018) closed to further competing cop entries, as robbers may no longer be competing to crack answers, but feel free to post new answers. The Cops challenge was...
stackexchange_codegolf
Can you decrypt me? Cops Cops, post obfuscated code that hides a number \$n\$ (n must not be greater than the program length) inside its code. If \$n\$ chars are changed (no additions or deletions), the program outputs exactly one \$n\$ (any amount of whitespace before or after is allowed.) Otherwise, it outputs someth...
stackexchange_codegolf
Preamble We've already proven we're good at adding two numbers, but many solutions only operate on tiny numbers like 2³²-1, honestly we can do a lot better. The Challenge Given two unsigned, non-negative integers, add them together and return the output. Input may be taken in any convenient format (String, Array of byt...
stackexchange_codegolf
The International Phonetic Alphabet is a system of phonetic notation intended to be able to accurately represent every sound used in spoken language. The alphabet contains 29 vowel letters iyɨʉɯuɪʏʊeøɘɵɤoəɛœɜɞʌɔæɐaɶäɑɒ and 81 consonant letters, although I missed three (ɦǀǂ) when I first posted this challenge, so you on...
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
The Challenge Given a rational number, determine the smallest number which is a positive integer multiple of it. Eg. Given: 1.25 x1: 1.25 x2: 2.5 x3: 3.75 x4: 5 Thus: Answer is 5 Clarifications Inputs will be a rational number in the range of (0,100] of which the Decimal Representation has no more than 4 ...
stackexchange_codegolf
Sound synthesizers use envelope generators to control how certain parameters of the sound (such as overall loudness) change with time. In many synthesizers an envelope is defined by four parameters, as represented in the following figure from Wikipedia: Attack time (A): time taken for the envelope to reach its maximum...
stackexchange_codegolf
In chaos theory, the horseshoe map is an example of how chaos arises in a simple process of folding and squashing. It goes like this: take an imaginary piece of dough, fold it, and finally squash it to its original size. Chaos arises in the pattern of how the pieces of dough end up in the final arrangement after n iter...
stackexchange_codegolf
This challenge is about finding the smallest disk that contains some given points. This is made somewhat trickier, however, by the fact that in this challenge, the disk's coordinates and radius must both be integers. Your input will be a list of points with integer coordinates x and y. You can take this as a list of tu...
stackexchange_codegolf
At runtime, keep prompting for a line of input until the user input is not the name of an existing file or directory or other file system item, relative to the current working directory. Then return/print that last inputted filename. You may assume that all user inputs will be valid filenames. Pseudo-code 1 myform = ne...
stackexchange_codegolf
Powerful numbers are positive integers such that, when expressed as a prime factorisation: $$a = p_1^{e_1} \times p_2^{e_2} \times p_3^{e_3} \cdots \times p_k^{e_k}$$ all exponents \$e_1, e_2, ...\$ are greater than or equal to \$2\$. Note that the exponents do not include zero exponents, as exampled by \$200 = 2^3 \ti...
stackexchange_codegolf
There are several questions regarding this game, even a king-of-the-hill contest here. But I think all those challenges and contests need a way to automatically determine the winner of a game. So: Challenge Given two inputs in the range ["rock", "paper", "scissors", "lizard", "spock"] representing the selections for pl...
stackexchange_codegolf
All Aboard the ASCII Train! o O O ___ ___ ___ ___ ___ ___ ___ ___ ___ o | C | | O | | D | | E | | | | G | | O | | L | | F | TS__[O] |___| |___| |___| |___| |___| |___| |___| |___| |___| {======|_|"""""|_|"""""|_|"""""|_|"""""|_|"""...
stackexchange_codegolf
On TeX.SE the Help Centre says that the following is on topic: Formats like LaTeX, ConTeXt and plain TeX Engines like pdfTeX, LuaTeX and XeTeX Distributions like TeX Live, MiKTeX, and MacTeX Related software and tools, BibTeX, MakeIndex, Lyx, etc. I wanted you to write a program to tell me whether my TeX is in the on-...
stackexchange_codegolf
Make a quine. Simple enough, except it has to be a palindrome and accept input. Now, any side of a palindromic quine is one half of it. For example, one side of the hypothetical quine AAAA is AA. One side of AAAAA is AA (the center symbol is ignored). Your job is to make a quine like this that accepts input. If the inp...
stackexchange_codegolf
Remove every pair of newline characters, that means every two newline characters appearing together are elided, whereas unaccompanied newline characters remain present. Example: echo -ne 'a\n\nb\nc\n\n\n\nd\n\n\n' | your-command should output the same as echo -ne 'ab\ncd\n' Watch out, some POSIX tools have implementa...
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 brainiacs at New Scientist tweeted this morning that "The word STABLE has the neat property that you can cycle the first letter to the end to make a new word: TABLES. And you can do it again to make ABLEST." (https://twitter.com/newscientist/status/1379751396271124480) This is of course correct. It is not, however,...
stackexchange_codegolf
Chess pieces (kings, queens, rooks, bishops, and knights) and pawns are on a board, but not on the a1 or h8 square. Your task is to travel from the empty a1 to the empty h8 squares, passing through only empty squares. The rules of movement are as follows: You can proceed from any empty square to any empty square next ...
stackexchange_codegolf
Given two words, spoonerise them by switching their initial consonant clusters. Fewest bytes wins. plaster man -> master plan blushing crow -> crushing blow litigating more -> mitigating lore strong wrangler -> wrong strangler def ghi -> ghef di few years -> yew fears The consonants appearing before the first vowel (a...
stackexchange_codegolf
Sometimes it happens that while typing a sentence, I am distracted and I end up typing the same couple of words twice couple of words twice in succession. To make sure make sure other people are not bothered by this, your task is to write a program that resolves this problem! Task Given an input string (if it matters f...
stackexchange_codegolf
This will be a bit of a different challenge. Back in 2023, I developed a 2D esolang called Electra, and looking back at my hello world program, (which is 582 bytes by the way) I see a lot of room for golfing. There are some topics that aren't covered in the spec, e.g. in which order the currents are generated/interpret...
stackexchange_codegolf
Lisp programmers boast that Lisp is a powerful language which can be built up from a very small set of primitive operations. Let's put that idea into practice by golfing an interpreter for a dialect called tinylisp. Language specification In this specification, any condition whose result is described as "undefined" may...
stackexchange_codegolf
Input An integer n in the range 100 to 10^18 and an integer k in the range 1 to 18, inclusive. The swap operation A swap chooses two digits at different positions and exchanges their positions, as long as the swap does not result in a leading zero. For example if we start with the integer 12345 we can perform one swap ...
stackexchange_codegolf
Given a string x, output the characters in x sorted according to the order of appearance in your source code. Examples Source: ThisIs A Test Input: Is it a Test? Output: TissI etta? Source: Harry - yer a wizard. Input: I'm a what? Output: aa wh'?Imt Source: Mr. H. Potter, The Floor, Hut-on-the-Rock, The Sea In...
stackexchange_codegolf
Output the numbers 1-16 (or any other set of 16 distinct items). Then, repeatedly, output a random value chosen uniformly from the last 16 items outputted. After the same item is printed 16 times in a row, halt. If a number appears multiple times in the last 16 values, it should have proportionally more chance to be ch...
stackexchange_codegolf
Write functions \$x(a)\$, \$y(a)\$ and \$z(a)\$ such that for any rational \$a\$ all functions return rational numbers and $$x(a) \times y(a) \times z(a) \times (x(a) + y(a) + z(a)) = a$$ You may assume \$a \ge 0\$ You do not need to use rational types or operations in your program, as long as your program is mathemati...
stackexchange_codegolf
The Task Given a natural number as input, your task is to output a truthy or falsey value based on whether the input is a factorial of any natural number. You can assume that the input number will always be in the range of numbers supported by your language, but you must not abuse native number types to trivialize the ...
stackexchange_codegolf
Challenge In this challenge, all numbers are in \$\mathbb{N}_0\$. Create a function or program that, when given a number \$N\$ and a tuple of \$k\$ numbers \$(n_i)\$ (all ≤ \$N\$), returns the number of ways \$N\$ can be written as a sum of \$k\$ integers (\$x_1 + x_2 + ... + x_k\$) such that \$n_i \le x_i \le N\$. The...
stackexchange_codegolf
Given a UTF-16 string, test its endianness. Rules: As long as the input is in UTF-16 without BOM, its type doesn't matter. In C++ on Windows, it can be std::wstring or std::u16string. In Haskell, it can be [Int16] or [Word16]. The endianness is tested by noncharacters. If the input contains a noncharacter, it is in wr...
stackexchange_codegolf
Your challenge is to write a program, function, etc. that calculates if the passed string is "in order". That means that the characters of the string have character codes that are in order from smallest to largest. The smallest char code must be the first. By that I mean lowest unicode codepoints to highest. It doesn'...
stackexchange_codegolf
Elixir is a programming language with a feature called the pipe operator, |>, similar to the pipe in Bash and other languages. It passes the result of an expression on the left as the first parameter of a given function on the right. To clarify, here are some examples. 2 |> myFunction() is equivalent to myFunction(2) ...
stackexchange_codegolf
Given 2 inputs (m=minimum starting id, n=number of ids), generate a sequential list of ids, starting at >=m, made up of the digits 0-9 where no 2 contiguous numbers are the same, e.g. 1232 is ok, 1233 is not (contains 2 '3's next to each other). Example for m=985, n=6, below shows what ids would be generated/skipped .....
stackexchange_codegolf
The recent volume of MAA's Mathematics Magazine had an article "Connecting the Dots: Maximal Polygons on a Square Grid" by Sam Chow, Ayla Gafni, and Paul Gafni about making (very convex) \$n^2\$-gons where each vertex is a different point of the \$n \times n\$ grid. One is not allowed to have two consecutive segments ...
stackexchange_codegolf
Given input \$x \in \left\{0,3,6,...,90\right\}\$, output \$\sin\left(x°\right)\$ using integer and \$+ - \times \div ( ) \sqrt{\cdot}\$(square root), e.g. \$\sin(45°)=\sqrt{1\div 2}\$. Flexible output format. You needn't do any simplification to output, aka. it's fine to output \$\sin(0°)=\sqrt{42}-\sqrt{6\sqrt{-9+58}...
stackexchange_codegolf
The task is to count the number of disjoint 11 blocks in a 64-bit word, using the minimum number of straight-line instructions. That is, how many nonoverlapping neighbored pairs of 1-bits can be found. Examples (imagine leading zeros to fill up to 64 bits) Input Output 111111 3 1110111 2 111100...
stackexchange_codegolf
On a toroidal square grid (you can wrap around) where each cell indicates one direction (^ > v <) if we pick a cell and start to walk following these directions, we will eventually get stuck in a loop. We may end up in a different loop, depending on our starting cell. Not all the cells we encounter constitute our term...
stackexchange_codegolf
The day this post was published was Christmas Eve. Tomorrow will be Christmas. Yesterday was Christmas Eve Eve. In two days it will be Christmas Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Ev...
stackexchange_codegolf
Background Wuxings(五行) are the five "elements" in Chinese philosophy. They are Fire(火), Water(水), Wood(木), Metal(金), and Soil(土). You can find them on East Asian calendar, where some days (Tuesday through Saturday) are named by the Wuxings. Some Korean names are given according to Wuxings, so that father's name will ha...
stackexchange_codegolf
Background Sometimes, people think you didn't work at your git project. But - you can prove yourself with git shortlog -n. Now, the problem is you are a programmer and programmers are lazy. So you want to write a program which shows the person who committed at most. Rules You may not do the following things: use git s...
stackexchange_codegolf
Final results 1st place goes to Follow! Honourable mentions to The diff predictor (2nd), and Simple Killer, Low Blow and High to Low (joint 3rd). Other winners: (score competition) 1st - Simple Killer Honourable mentions: The diff predictor and Naiive. (wins competition) 1st - Crab Honourable mentions: Follow and High ...
stackexchange_codegolf
Program Write a program to display repeating terms of a given sentence. Explanation The program must output the repeating terms of two or more letters from the given input (input is a sentence separated by spaces without any punctuation except the full-stop indicating the end.) Repeated terms may not span across or in...
stackexchange_codegolf
Background Stick Bomber is a two-player game I just made up. Initially, some sticks are placed in one or more groups, and the sticks in each group are laid out in a straight line. So a configuration with three groups of 3, 5, and 8 sticks each may look like the following. For conciseness, we can call it a (3,5,8) confi...
stackexchange_codegolf
Most people are familiar with Pascal's triangle. 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 Pascal's triangle is an automaton where the value of a cell is the sum of the cells to the upper left and upper right. Now we are going to define a similar triangle. Instead of just taking the cells to the upper left and the upp...
stackexchange_codegolf
Given an integer n, output the following ASCII art to n rows: 1+1=2 1+2=3 2+3=5 3+5=8 5+8=13 Essentially, the first row is 1+1=2 and the nth row (1-indexed) is \$f_n + f_{n+1} = f_{n+2}\$ where \$f\$ is the Fibonacci sequence, padded so the numbers line up with the previous row. You may instead out...
stackexchange_codegolf
Write a program to replace all occurrences of "force" with "first" and all occurrences of "first" with "force", keeping the original case for all character positions: "ForcefoRcefOrcE" -> "FirstfiRstfIrsT" "FirstfiRstfIrsT" -> "ForcefoRcefOrcE" The rest of the string must stay unchanged, and so running your program tw...
stackexchange_codegolf
The Game You will be playing an (almost) standard game of Connect-4. Unfortunately, it is a correspondence game and someone has placed black tape on every second row starting from the bottom, so that you cannot see any of your opponent's moves within these rows. Any moves within already-full columns will count as passi...
stackexchange_codegolf
A sestina is a format of poem that follows an interesting pattern that we can generate. It has six stanzas of six lines each, where the last words of each line in the first stanza make up the line endings in each successive stanza, rotated in a set pattern. (There's also a three-line stanza at the end, but we won't wor...
stackexchange_codegolf
Ever wonder what countries surround another? I do too, sometimes, and, well, here's the challenge for it. I have provided a list of countries and the countries that they touch that you must recognize at the bottom of this post in a code block. You need to create a full program that outputs (in the most convenient way p...
stackexchange_codegolf
I was messing around with Pyth's url request feature, and noticed that google always gave a response with a slightly different length for me, usually ~10500 characters. So your task in this challenge is to print out the average length of the html response from http://google.com. Specs You will take an input n which is...
stackexchange_codegolf
Given two non-empty 01 strings, check if there is string containing both given strings, and their first appearance end at same position. Test cases: 01, 1 => true (01) 0, 00 => false (0 would at least come 1 character earlier) 01, 11 => false (can't meet on same position) 01, 0 => false (can't meet on same position) 11...
stackexchange_codegolf
Given a sequence of 625 32-bit unsigned integers (that is, in the range [0, 2**32)), output which of the following pseudorandom number generators generated the sequence: Linear Congruential Generator Xorshift Mersenne Twister Specifically, the C implementations of these three generators used for this challenge are as...
stackexchange_codegolf
Challenge Given a 2D array, find the length and direction of all the longest consecutive characters. If there are ties, output every possible winning combination in any order, (winners can overlap with other winners) Zero "0" is a special padding character which cannot be a winner. Code golf rules apply, shortest code...
stackexchange_codegolf
In computer science, a suffix automaton is the smallest partial deterministic finite automaton that recognizes the set of suffixes of a given string. (Wikipedia) Given a string \$S\$ consisting of lowercase letters (a-z), construct the suffix automaton for it. A suffix automaton is an array of states, 0-indexed or 1-...
stackexchange_codegolf
OCTOBER 22 IS INTERNATIONAL CAPS LOCK DAY! UNFORTUNATELY, SOME DO NOT RECOGNIZE THE GLORY OF THE ALMIGHTY CAPS LOCK. THEY SAY IT SEEMS "OBNOXIOUS" OR "LIKE SHOUTING" OR SOME NONSENSE. IN ORDER TO CONFORM TO THESE OBVIOUSLY ILLOGICAL AND INANE COMPLAINTS, PLEASE WRITE ME A PROGRAM THAT TURNS NORMAL TEXT INTO "SENSIBLE" ...
stackexchange_codegolf
I haven't been on PP&CG for a while, so I thought I would post something! Your task is to find how "smooth" a natural number is. Your method is to: 1: Convert the number to binary 2: Find the number of changes / switches 3: Find the length of the string (in binary) 4: Divide length by changes So, an example. 5. Sta...
stackexchange_codegolf
In this challenge, you'll print out the SBCS of Jelly, a popular golfing language. Its code page looks like this: _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F 0_ ¡ ¢ £ ¤ ¥ ¦ © ¬ ® µ ½ ¿ € Æ Ç Ð 1_ Ñ × Ø Œ Þ ß æ ç ð ı ȷ ñ ÷ ø œ þ 2_   ! " # $ % & ' ( ) * + , - . / 3_ 0 1 2 3 4 5 6 7 8 9 : ; < = > ? 4...
stackexchange_codegolf
Starting with a positive integer N, find the smallest integer N' which can be computed by repeatedly dividing N by one of its digits (in base-10). Each selected digit must be a divisor of N greater than 1. Example #1 The expected output for N = 230 is N' = 23: Example #2 The expected output for N = 129528 is N' = 257:...
stackexchange_codegolf
Contest permanently opened - Updated August 10th 2017 Even though on June 5th 2017 I declared a winner (who will be kept as the best answer) I'll be rnning new bots and updating the results. June 5th Results Congratulations user1502040 Since there are no ties, I only show the % of matches won. Statistician2 - 95.7% Fit...
stackexchange_codegolf
Given the following Python "reference implementation" of non-terminating FizzBuzz: i=1 while True: if i%15 == 0: print("FizzBuzz") elif i%3 == 0: print("Fizz") elif i%5 == 0: print("Buzz") else: print(i) i += 1 We can represent its output as an infinite array of char...
stackexchange_codegolf
A little genetics lesson When you only have access to someone's visible traits or phenotype, a pedigree of their family history is often used to figure out the actual genetic information or, genotype of each family member. When dealing with simple dominance as we will be, a simple pedigree chart will be enough to figu...
stackexchange_codegolf
Consider the following list: expected = [ 'A', 'B', 'AB', 'C', 'D', 'CD', 'ABCD', 'E', 'F', 'EF', 'G', 'H', 'GH', 'EFGH', 'ABCDEFGH', 'I', 'J', 'IJ', 'K', 'L', 'KL', 'IJKL', 'M', 'N', 'MN', 'O', 'P', 'OP', 'MNOP', 'IJKLMNOP', 'ABCDEFGHIJKLMNOP', ... ] Here's one way to look at it - you're learning how to write Chinese...
stackexchange_codegolf
Background Minifiers are used, commonly, when serving JavaScript to your Web Browser. It is commonly used to reduce the number of bytes that have to be sent. Saving bandwidth is useful for obvious reasons. Some people use obfuscaters (that intentionally make code harder to read), I am not talking about those. We wil...
stackexchange_codegolf
Here's one for fans of Cabin Pressure. There is an episode in which the characters devise a new version of Fizz Buzz, which is simplified to contain absolutely no mathematics. It has these rules: If someone says "fizz", you say "buzz". If someone says "buzz", you sing "'ave a banana" If someone says your name, you say...
stackexchange_codegolf
We've had problems to generate minesweeper games. We've had problems to solve these minesweeper games. Now... It's time to battle other people on a minesweeper game! Your program must be run in Java. Essentially, each player can do an action every turn. You may move to any space touching yours including corners. The b...
stackexchange_codegolf
A very simple challenge today. Output a truthy value whether the ASCII character (or it's code) supplied is a brainfuck instruction (one of +-,.<>[]), and a falsy value if it's a comment (everything else). Input + # < > . P , Output true false true true true false true
stackexchange_codegolf