instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
The picture: Sick of the same old grid where the answer is simply a square pyramidal number? Accept the challenge and write a program that given a positive integer \$n\$ counts how many squares are in the \$n^{\text{th}}\$ iteration of the Harter-Heighway dragon! The sequence of squares of size 1 is A003230 Your cod...
stackexchange_codegolf
Bounty One of the convincing conjectures, by Loopy Walt is, maxlib(n) = 0, if n = 1 2, if n = 2 6, if n = 3 (2n - 1)⌊n / 3⌋, if n % 3 = 0 (2n - 1)⌊n / 3⌋ + n, if n % 3 = 2 2n⌊n / 3⌋ + 1, otherwise Loopy Walt's post below explains how this conjecture is derive...
stackexchange_codegolf
It frustrates me that when you say "base 16", the 16 is in base 10. We need a base neutral way of writing down numbers when favoring a specific base would be inappropriate. How it works We define <n> to be the nth prime. So <1>=2, <2>=3, <3>=5. Note that every positive integer can be uniquely represented by the product...
stackexchange_codegolf
Consider 3 dimensional space which has been partitioned by at least two planes which go through the origin. If there are n planes then the number of distinct pyramidal regions this creates is exactly 2 - n + n^2 as long as they are in "general position", a term I make specific below. The challenge is write code that...
stackexchange_codegolf
You can decompose a number greater than 0 as a unique sum of positive Fibonacci numbers. In this question we do this by repeatedly subtracting the largest possible positive Fibonacci number. E.g.: 1 = 1 2 = 2 3 = 3 4 = 3 + 1 12 = 8 + 3 + 1 13 = 13 100 = 89 + 8 + 3 Now, I call a Fibonacci product the same lists as abov...
stackexchange_codegolf
Write a function that calculates a row of the pascal triangle and returns the middle number, if there are 2 it should return their sum. Example: 5 would return 20 Example 2: 4 would return 6 EDIT: To be clear: a) if the number inputted is odd then find then return the middle number of a row on the pascal triangle. ...
stackexchange_codegolf
Write a program or function that takes no input but prints or returns a constant textual depiction of a rectangle made of the 12 distinct pentominoes: The rectangle may have any dimensions and be in any orientation, but all 12 pentominoes must be used exactly once, so it will have area 60. Each different pentomino mus...
stackexchange_codegolf
Input Take a list of values xi each paired with a key yi. [(x1, y1), (x2, y2), ...] Output Return a list L containing only values from the set {xi}. The length of L must be equal to the number of unique keys k in the set {yi}. For each unique key k there must be a value from {xi} that has key k. Details Standard l...
stackexchange_codegolf
This was originally a pure mathematics question, but I think I've got the best chance for an answer here. The Challenge For concreteness, consider Peano Arithmetic (PA). For some language L of your choosing, construct a computer program of length at most N bits in L such that: If it terminates, it outputs a number th...
stackexchange_codegolf
Given a list of Integers greater than zero, Sort each of the unique values in ascending order, then repeat the process on the remaining duplicate values and append. Example: [1,5,2,2,8,3,5,2,9] ==> [1,2,3,5,8,9,2,5,2] [8,5] ==> [5,8] [2,2,2] ==> [2,2,2]
stackexchange_codegolf
This is an answer-chaining challenge relating to the OEIS. Oh, the justification for this is because a company needs one program to print out their OEIS sequences real bad and they have every language. The answer-chaining format works in the following way: Someone posts the first answer, from which all further solution...
stackexchange_codegolf
Is it a good chord? Definition of a chord: We define a chord as three notes together. Definition of a note: We define a note as a number between 1 and 7, inclusive. As in music, we define 1 as do, 2 as re, 3 as fa, etc. However, the note names are not important. They will not be included in the question and likely not ...
stackexchange_codegolf
There are an abundance of questions involving drawing shapes using asterisks - so I thought, with so many asterisks out there, we should draw one, using the ASCII table. Challenge Your task is to write a program or function which takes no input, and outputs this exact text: ! "# $% ...
stackexchange_codegolf
In some languages, strings are started and ended with a quote mark ('). And quote itself is escaped by writing it twice sequentially. For example, empty string is written as '', and I'm is written as 'I''m'. This question is about find out all non-overlapping strings from left to right in such format from the given inp...
stackexchange_codegolf
The goal of this challenge is to print the following tongue twister: She sells seashells by the seashore, The shells she sells are seashells, I'm sure. So if she sells seashells on the seashore, Then I'm sure she sells seashore shells. This is more complicated than just calling your language's print equivalent. Since ...
stackexchange_codegolf
I like the Hilbert Curve. Your task for this challenge is to take an image (strictly a square image where all the sides are a power of two pixels wide) and unravel it line by line in a zig-zagging fashion and ravel it back up in a pseudo-Hilbert curve. Unraveling To unravel you will start with the pixel in the upper l...
stackexchange_codegolf
Write the shortest code that traverses a tree, breadth-first. Input any way you like Output a list of "names" of the nodes in correct order.
stackexchange_codegolf
The aim of this task is to identify, clean up, and mark out all the faces in any given 'image'. What's in a face? A face will be a ZxZ square where Z is an odd integer greater than 1. The top left and right corners and the centre will be 'O' characters, and the bottom line will be a '\' and a '/' surrounding enough '_'...
stackexchange_codegolf
Sales taxes in the United States are complicated, to say the least. Generally, there's a state sales tax (there are a handful of states that do not collect a state sales tax), but there could also be a county sales tax, a school district sales tax, a municipal (city) sales tax, or a metropolitan area sales tax. There c...
stackexchange_codegolf
Background Variable declaration statement in C consists of three parts: the name of the variable, its base type, and the type modifier(s). There are three kinds of type modifiers: Pointer * (prefix) Array [N] (postfix) Function () (postfix) You can specify a list of function arguments inside the parens, but for the s...
stackexchange_codegolf
Motivation: Sometimes you need to know where you are in a string. You want to be able to look at any part of a string and know exactly where you are, as far as possible. Challenge: write a program to output a tape measure string of a given length. A tape measure string self describes its length-so-far as often as possi...
stackexchange_codegolf
Let's have a list of positive integers [6,1,9,3,7,4,6,3,2,7,6,6] this will represent a river. We would like to skip a stone across this river. We can throw the stone as far as we want and whatever number it lands on it will skip that many places. So if we start by throwing it 2 spaces, it will land on the 1 skip fo...
stackexchange_codegolf
Calculate the Riemann zeta function to the maximum primitive precision in your language (for C-family, that would be double or long double, var in JS, etc.) No need for BigDecimal or the like unless you need it to use a double-equivalent precision. Efficiency (be sane) doesn't matter. If it's not in a common language,...
stackexchange_codegolf
Introduction A circle-tangent polynomial is a polynomial of degree \$N\ge3\$ or above that is tangent to the unit circle from inside at all of its N-1 intersection points. The two tails that exits the circle are considered tangent at their intersection points from inside as well. You may consider such polynomials are w...
stackexchange_codegolf
We all know scoring by characters is ripe for abuse. Let's prove this. The Challenge Output the following: "m8V}G=D@7G1lAI,v08` #(hNb0A8T!g;==SVaG5~ g"jUF!bmRY(3I@na?2S{ fJVzo/GQYU%ybpfUq3aG Yza[jc,WJ$bP^7r};Da} V-!Z+Nk:`/poc}d/X:G\ sWX{dbAUv6,i]%RG$hRp ),bd+?/{U1tU[;<;u.Nk ZFPIOzJ/HimL!nexc,ls HM%k3D$n2|R,8L?'eI_n qs....
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
This is going to be relatively quick... Challenge Given a lower-case word as input, calculate the Pearson's Correlation Coefficient between the letter position of the word (nth letter within the word, x), and the letter position within the alphabet (nth letter of the alphabet, y). Background Pearson's Correlation Coeff...
stackexchange_codegolf
Imagine we get a slice of some mountainous region, this would result in a shape similar to this: 4 _ 3 _ _ __/ \ 2 / \__/ \ _/ \_ / 1 / \ / \_/ 0 \/ 12322223210012233343221112 As we can see, we can represent this (to a certain degree) with a sequence o...
stackexchange_codegolf
Imagine you have a grid where some squares are walls, some are empty, and some are lights that shine for arbitrary distances in the four cardinal directions until they meet walls: ####.#### ##..L.... ####.##.# ####.##L. ##......L In the above grid, the lights cover all the tiles. But in some cases, they may not be: ##...
stackexchange_codegolf
iBug recently got a long bar made of composite, yet valuable materials. The bar is so long that iBug can't easily sell it for credits, so he wants to cut it. The bar is made of such fragile and magic materials that, if a part is broken, all parts of the bar made of the same material will break, too, making it hard to c...
stackexchange_codegolf
Yes, It's basically You're a Romanizer, Baby, but harder. like, way harder. Learning Korean is HARD. at least for a person outside Asia. But they at least have the chance to learn, right? What you must do You will be given a Korean Statement. For example, 안녕하세요. You must convert the input to its Roman pronunciation. ...
stackexchange_codegolf
Sandboxed and made less complicated and hopefully more fun. Summary of the challenge Given a number of particles, either identical bosons or identical fermions, output the total wave function of the state assuming they are all independent. Physics background Don't worry, you don't need to know quantum mechanics to solv...
stackexchange_codegolf
This task is to output the shortest path to a file, after glob expansion. What is shell globbing? In most shells, you can use the * character in a path to represent any characters at the position. For example, If directory foo contains files bar baz and asdf, then foo/b* will expand to foo/bar foo/baz. Now, lets say t...
stackexchange_codegolf
If I need to get the number of diagonal squares in all directions: I do the following formula 2 N − 2 − |x − y| − |x + y − N − 1| The above example has 13 and that's what the formula gives. Now, what if you wanted to get the diagonal squares, but only in one direction? The top right has 4 squares, the top left has 3, ...
stackexchange_codegolf
No, not this. And not this either. This question is nothing like those Write the shortest code to print/return the following output: /\ /\ /\ / \ / \ / \ / /\ \ / /\ \ / /\ \ / / \ \/ / \ \/ / \ \ \ \ / /\ \ / /\ \ / / \ \/ / \ \/ / \ \/ / \ / /\ \ / /\ \ / \/ / \ \/ / \ \/...
stackexchange_codegolf
Given an 8x8 grid of letters representing the current state of a game of chess, your program's task is to find a next move for white that results in checkmate (the answer will always be mate in one move). Input Input will be on STDIN - 8 lines of 8 characters each. The meanings of each character are as follows: K/k - k...
stackexchange_codegolf
In mountaineering terminology, a "14er" is any mountain with an elevation of 14 000 feet or more. However, there is another distinction. For a peak to count as a 14er, it must also have a "geographic prominence" of 300 or more feet. This means that to move from one 14er to another, you must first descend at least 300 f...
stackexchange_codegolf
I have a cake shop that specialises in birthday cakes. The cakes that I sell must have candles placed in a circle. You would probably think I can just divide 360° by the number of candles, but the machine for placing candles is quite unique; it uses a list of numbers representing positions of candles, placing them one-...
stackexchange_codegolf
In a certain chatroom, we like making acronym jokes about the build tool we use called sbt. While it usually stands for "Scala Build Tool", we aim to come up with all sorts of meanings, such as: Stupid Brick Teeth Sussy Baka Training Shady Blue Tourists Seriously Big Toes Silly Bear Topics Salacious Bacon Tripod Syrin...
stackexchange_codegolf
Objective Use any editor or IDE (vim, emacs, IntelliJ, etc) to write a valid "Hello, World" program in any C-like language. The "!" is optional, but you get style points if you use it. You may use publicly available plugins, a publicly available vimrc, etc, but you may not write or make modifications to them specifical...
stackexchange_codegolf
Your task is to make a program that takes in an integer n > 1, and outputs the roll of a single n-sided die. However, this dice follows the rules for exploding dice. When you roll the die, check what value you rolled. If you got the maximum for that kind of die (on a standard d4 that would be 4, or 6 on a d6, etc.), ro...
stackexchange_codegolf
Problem A fact you may have noticed about factorials is that as \$n\$ gets larger \$n!\$ will have an increasing number of \$0\$s at the end of it's base \$10\$ representation. In fact this is true for any base. In this challenge you will be given a base \$b > 1\$ and an integer \$n > 0\$ and you will determine the sm...
stackexchange_codegolf
In 2014, demoscener Jakub 'Ilmenit' Debski released a 250-byte(1) procedural graphics demo for the Atari XL called Mona. It's drawing the following picture(2): Your task is to generate the exact same picture, using the language of your choice. (1) Breakdown: 136 bytes of data + 114 bytes of code. (2) The original pic...
stackexchange_codegolf
Given a string of text, output it as a 'tower'. Each slice of the string (of the form 0:n) is repeated 5*n times, so the first character is repeated 5 times, then the first and the second 10 times, etc. Examples: 'hello' -> ['h'] ['h'] ['h'] ['h'] ['h'] ['h', 'e'] ['h', 'e'] ['h', 'e'] ['h', 'e'] ['...
stackexchange_codegolf
Question Write a program to accept one string on the console only and print back its letters arranged in alphabetical order. The string must only have the following characters: 0123456789abcdefghijklmnopqrstuvwxyz Rules The ascending alphabetical order is defined in the given string. All repeated characters must be ...
stackexchange_codegolf
Creating a golfing language can be hard. Let's help budding golfing language creators out and provide some helpful tips on how to create one. I'm looking for tips on: The design process Implementation Community engagement One tip per answer would be appreciated, and tips like "don't create a new language, use an exis...
stackexchange_codegolf
Sometimes in chat, if someone says something you agree with, you'll send a message with an ^, which points at the message above: Radvylf: Cats are far superior to JavaScript You: ^ Sometimes you'll also add some text: Radvylf: I sure do like integers You: I mostly agree with ^ but floats are pretty neat too You can a...
stackexchange_codegolf
Given a matrix of size at least 3×3 formed by positive integers, determine if it contains at least one "U" pattern, defined as + + + - - - + + + + - N - N - + + + - N - N - + + + - N N N - + + + + - - - + + where N is the same number, repeated in those seven positions - (optional) represents any number different than...
stackexchange_codegolf
Challenge: In the language of your choice, write a program that generates a leaderboard with random scores and outputs it, then take a new score as input and check if it can be placed in the leaderboard, and output which place it is in. Specifications: You must generate a list of 50 "random" scores, in descending orde...
stackexchange_codegolf
You wake up and find out that your computer has been stolen! You have a few sensors and scanners, but unfortunately, the footage is incomplete, so you want to find and rank your suspects for further investigation. Your computer is a rectangle, and your camera caught a bunch of people walking around with packages; howev...
stackexchange_codegolf
A followup to this challenge by Jeremy Collprav, inspired by DLosc solving this in Regenerate. Some sections copied from the linked challenge. Linking chains We define a chain to be a string containing exactly one or more of only the - character, or 1 or more of only the _ character, or two chains linked by a =. More f...
stackexchange_codegolf
Your task today is to write a program or function that takes an array of integers, and counts the number of times, reading it left to right, that the value changes. This is easier to show with an example: [1 1 1 2 2 5 5 5 5 17 3] => [1 1 1 **2** 2 **5** 5 5 5 **17** **3**] => 4 Test case: Input | Output [] ...
stackexchange_codegolf
Your task Take a list of strings as the input, and output the maximum average ord. Example Given the list ['hello', 'world', 'bye']: The average ord of 'hello' is: (ord(h) + ord(e) + ord(l) + ord(l) + ord(o)) / len('hello') = 106.4 The average ord of 'world' = 110.4 The average ord of 'bye' = 106.7 The maximum ave...
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
A Fermi-Dirac Prime is a prime power of the form \$p^{2^k}\$, where \$p\$ is prime and \$k \geq 0\$, or in other words, a prime to the power of an integer power of two. They are listed as integer sequence A050376. While a normal prime factorization generally does not contain a set of distinct primes (for example \$24=2...
stackexchange_codegolf
A number spiral is an infinite grid whose upper-left square has number 1. Here are the first five layers of the spiral: Your task is to find out the number in row y and column x. Example: Input: 2 3 Out : 8 Input: 1 1 Out : 1 Input: 4 2 Out : 15 Note: Any programming language is allowed. This is a code-golf cha...
stackexchange_codegolf
Heading into the final day of regular season games for the 2023 NBA season, the fifth to ninth seeds in the Western Conference were still very undecided. Four games would determine the seeding: New Orleans (N) at Minnesota (M) Utah at LA Lakers (L) Golden State (G) at Portland LA Clippers (C) at Phoenix Let the Boole...
stackexchange_codegolf
Introduction: A typical cartoonish cactus usually looks like this: One big stem in the middle, with some L-shaped branches sticking out. We'll use this general shape for this challenge. Challenge: Given a pair of words, create an ASCII-art cactus with two upside down alphabets as stem. The first word is the left branc...
stackexchange_codegolf
Grid: +---------------+---------------+---------------+---------------+---------------+ | id: 20 | id: 19 | id: 18 | id: 17 | id: 16 | | pos: (-2, -2) | pos: (-1, -2) | pos: (0, -2) | pos: (1, -2) | pos: (2, -2) | +---------------+---------------+---------------+---------------+---...
stackexchange_codegolf
...or is there? Your challenge is to parse my lunch bill, which contains the base price, tips, discounts, coupons, and extras and find out if my lunch was $0 or less. If this is the input: 12.34 15 tip 25 discount 1.5 extra 2 coupon Then the output might be false. Here's how it works: 12.34 is the base price. 15 tip m...
stackexchange_codegolf
Given an integer n, return the number of ways that n can be written as a list of prime numbers. For example, 2323 can be written as (2,3,23), (23,23) or (2,3,2,3) or (23,2,3), so you would output 4. If it can not be written in this way, you should output 0. A prime number such as 019 or 00000037 is a valid prime for th...
stackexchange_codegolf
Challenge Given the name of a PPCG member, output their PPCG ID number. If the user does not exist, you may report an error or return any non-positive number. If there are multiple members with this name, you may choose to output only one ID or all of them. Test Cases "musicman523" -> 69054 "Dennis" -> 12012 "xnor" ->...
stackexchange_codegolf
This challenge is a simple ASCII-art challenge inspired by the solar eclipse that happened on August 21, 2017. Given an input 0 <= n <= 4, output the corresponding stage of the eclipse described below: n=0: ***** ** ** * * * * ** ** ******* n=1: ***** ** ***** * ******* * *****...
stackexchange_codegolf
The brilliant engineers at <enter company you love to hate> have struck again. This time they've "revolutionised" the generation of random permutations. "Every great invention is simple" they say and their magical new algorithm is as follows: Start with a list 1,2,3,...,n of numbers to permute. For each element x in t...
stackexchange_codegolf
In graph theory a tree is just any graph with no cycles. But in computer science we often use rooted trees. Rooted trees are like trees except they have one specific node as the "root", and all computation is done from the root. The depth of a rooted tree is the smallest number, \$n\$, such that any node of the tree ...
stackexchange_codegolf
The task Your program will be given the following inputs: a number n, and an array of n positive integers. Your program only has to work when n=1000. The program must do the following: If the input array is a permutation of the range [1, 2, …, n], output Huh!? Otherwise, return a three-element array [i, j, n], where i...
stackexchange_codegolf
Task Everyone knows the game "Tic-Tac-Toe". Your task is it, to evaluate an ascii tic-tac-toe matchfield. Your Programm/Function should output/return the winner: O, X or nobody (N). Pattern X|O|X O|X|O O|O|X In this case your programm/function should output/return 'X' Rules Input can come from STDIN, function argumen...
stackexchange_codegolf
In a matrix of characters, a cursor is a movable position between two adjacent characters, before the first character or after the last character in a line, like that "I"-shaped indicator which moves while you type. In this challenge, a cursor position is considered valid if at least one of its two sides touches a spac...
stackexchange_codegolf
You must write a program or function that creates a "stair-ified" string. Here is how you "stair-ify" a string: For each character in the string: If the character is an upper or lowercase vowel, not including 'y', output it then move the rest of the string up a column. If the character is a space or a tab, output it ...
stackexchange_codegolf
Preface There are many "draw x flag" challenges, and upon searching it turns out there are no challenges to draw the union Jack! I feel like this would be a harder flag to draw but it should still be possible. Challenge Draw the Union Jack. It can be outputted to a file in any freely available graphics file format or d...
stackexchange_codegolf
This challenge is essentially identical to this one with just one difference: it is now allowed to shuffle letters anywhere in the string. Scenario John has an important number, and he doesn't want others to see it. He decided to encrypt the number, using the following steps: His number is always a non-decreasing seque...
stackexchange_codegolf
It is trivially possible to create a bijective function from \$\mathbb{Z}\$ (the set of all integers) to \$\mathbb{Z}\$ (e.g. the identity function). It is also possible to create a bijective function from \$\mathbb{Z}\$ to \$\mathbb{Z}^2\$ (the set of all pairs of 2 integers; the cartesian product of \$\mathbb{Z}\$ an...
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
Seven countries lay official claims to parts of Antarctica: Argentina, Australia, Chile, France, New Zealand, Norway, and the United Kingdom. We will focus only on the claims of the main Antarctic landmass south of 60° S, which are: Chile: between 90° W and 53° W United Kingdom: between 80° W and 20° W Argentina: betw...
stackexchange_codegolf
Proton is a quite new language created by PPCG user Hyper Neutrino. It is very similar to Python, and has similar syntax to the language Cheddar, hence there are some clever tricks you can use in order to reduce your byte count. Let's get those cool tricks listed here. As usual, please post one tip per answer and avoid...
stackexchange_codegolf
A Quine is a program which outputs its source when run. In this challenge, You should make a Fibonacci-quine, a variant of the quine. What is a Fibonacci-quine? A Fibonacci-quine is a program, which outputs a modification of the source by the following rule: The initial source should be ...2.... In other words, the so...
stackexchange_codegolf
Numbers that are easy to remember yet theoretically not easily made Your challenge is to make a program/function in any language that generates uniformly random numbers that fit these criteria: Length is 5 digits There are two separate repeated digit pairs One set of repeated digits is at the beginning or end and th...
stackexchange_codegolf
The tetration operation consists of repeated exponentiation, and it is written ↑↑. For instance, 3↑↑3 =3 ^(3^3) = 3^27 = 7,625,597,484,987 A tetrate of two is an integer that is equal to 2↑↑n for some nonnegative integer n. As an edge case, we say that 2↑↑0=1. In this challenge, you will be given a positive integer as...
stackexchange_codegolf
The Challenge Given an input string (or array) consisting of < and >, output a sequence (array or string) of integers such that: the operators are all correct when applied in order between consecutive numbers in the output all integers are positive (1 or greater) the sum of the integers is as small as is mathematicall...
stackexchange_codegolf
In base-10, all perfect squares end in \$0\$, \$1\$, \$4\$, \$5\$, \$6\$, or \$9\$. In base-16, all perfect squares end in \$0\$, \$1\$, \$4\$, or \$9\$. Nilknarf describes why this is and how to work this out very well in this answer, but I'll also give a brief description here: When squaring a base-10 number, \$N\$, ...
stackexchange_codegolf
Task A pure mirror checkmate is a checkmate position, where the mated king is surrounded by 8 empty squares which are attacked or guarded by the winning side exactly once. You will be given a valid chess position where Black is in mate. Your task is to find if that mate is a pure mirror checkmate. Examples (click for l...
stackexchange_codegolf
"Set" is a card game played with a deck of 81 cards, twelve of which are pictured below: Each card has four attributes, each of which may assume three values: Number: the number of symbols, either 1, 2, or 3 Shape: the shape of the symbol, either squiggle, diamond or oval Colour: either purple, red or green Shading: ...
stackexchange_codegolf
.Net Technology is an incredible framework with marvellous functionalities, and among all of them, the most important one obviously stands out: Yep, your simple task is create a program that when it takes at input: dotnet ef It prints the following ascii art by output: /\__ ---==/ \\ ___ ___ ...
stackexchange_codegolf
Take a list of 2-digit hexadecimal numbers as input, and output the binary value, replacing each 1 with an 'X', and each 0 with a space. For example Input = FF, 81, 47, 99. FF = 11111111 in binary, so print XXXXXXXX 81 = 10000001 in binary, so print X X 47 = 01000111 in binary, so print X XXX 99 = 10011001 in ...
stackexchange_codegolf
Everyone realizes that Tic Tac Toe is a solved game. However, the Misère version of only-Xs provides an interesting alternative. In this version of the game, both players play Xs onto the board and try to avoid making three in a row. If you'd like to see more about this, Numberphile has a nice video about this concept....
stackexchange_codegolf
Task Your task is to take an array of numbers as input, and produce a new one where each number has been shifted both right and left, leaving 0s if no number fills a spot. This process can be represented graphically like this: [x] / | \ [x, 0, x] This is done with every number in the list, with overlapping number...
stackexchange_codegolf
Prior to the decimalisation of Sterling in February 1971, a pound (£ - from Roman libra) comprised 20 shillings (s - solidus), each of 12 pennies (d - denarius). Additionally, until 1960, each penny could be divided into four farthings (some parts of the Commonwealth also had fractions of farthings, but we'll ignore t...
stackexchange_codegolf
The challenge is relatively simple, but will hopefully lead to some wonderfully creative answers. The task is to take a string as an input (via command line, function parameter etc.) and output/return a stringsploded version of it. A stringsploded version of a string is its first letter followed by its first 2 letters,...
stackexchange_codegolf
Idea from the doubler challenge, this may be more difficult. The program should output a positive integer or decimal point value higher than 0. If I duplicate the source code, the output should halve the original integer or decimal point value. But the trickier part is: If I duplicate your code any integer value \$n\$ ...
stackexchange_codegolf
There are n people on a 2D plane. Using distances between them we're going to find their positions. To get a unique answer you must make four assumptions: There are at least 3 people. The first person is at position (0, 0). The second person is at position (x, 0) for some x > 0. The third person is at position (x, y) ...
stackexchange_codegolf
(Inspired while drawing on a dry erase board) Challenge: Given an input string containing characters that represent different colors of dry erase markers on a white board, output the order in which they were drawn, from first to last. Input: A string which contains dry erase marker colors which are represented by alpha...
stackexchange_codegolf
Your input will be an English sentence, phrase, or word. It will only contain a-zA-Z' -,.!?. Your task is to take the input, remove spaces, and then redistribute capitalization such that letters at indexes that were capitalized before (and only letters at indexes that were capitalized before) are capitalized. For examp...
stackexchange_codegolf
This is similar to a previous question on this site, but with much simpler rules, so we should get much shorter results (in bytes): Input: ASCII art with only two possible characters: space and '#'. Output: Input sequence rotated 90 degrees counter-clockwise. Winner is answer with least number of bytes including len...
stackexchange_codegolf
Now that we have over a hundred ways to get stuck in a loop, the next challenge is to get out. Specifically, write a piece of code with a (seemingly) infinite loop, but somehow manage to break out. The "infinite loop" can be a statement like while true, for (;1>0;) or anything else which obviously lasts forever. Recurs...
stackexchange_codegolf
Everyone knows log scales are for quitters. Therefore, you must write a program or function that de-quitifies a bar graph with a log scale given a base. The bar graph input is taken as a single string which is a list of bars, where each bar of the log scale bar graph is separated by the printable (or whitespace) delimi...
stackexchange_codegolf
It's really frustrating when I'm working and I have a ton of windows open that are completely or partially hidden behind other windows. To make things worse, I'm still using two 1024x768 monitors. Your task is to take a list of coordinates that designate the area, in pixels, on a screen, that a list of windows occupy a...
stackexchange_codegolf
UTF-1 is one of the methods to transform ISO/IEC 10646 and Unicode into a sequence of bytes. It was originally for ISO 10646. The UTF-1 encodes every character with variable length of byte sequence, just like UTF-8 does. It was designed to avoid control codes. But it was not designed to avoid duplication of a slash cha...
stackexchange_codegolf
Every digital clock contains a small creature that has to advance the time every minute [citation needed]. Due to the popularty of digital clocks and the popularity of catching them in the wild, they are nearly extinct in nature which is why in this challenge we try to automate this task: Given your string of a given t...
stackexchange_codegolf
Background The nuclear industry has term, SCRAM, used to describe a quick shutdown of the reactor. There's a fun myth that it stands for "Safety Control Rod Ax Man," the role which served to shut down the Chicago Pile if it got too hot by literally cutting a rope with an ax (although this was debunked). The US Nuclear...
stackexchange_codegolf
Input is a single integer in ascending digit order. The only valid inputs are: 12 123 1234 12345 123456 1234567 12345678 123456789 The only valid output is an array (set; list) of length equal to the factorial of input: Input - Factorial of input - Output array length 12 -> 1*2 -> 2 123 -> 1*2*3 -> 6 1234 -> 1*2*3*4 ->...
stackexchange_codegolf