instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Write a program that translates ASCII text to braille output. Requirements: Input may come from stdin, command line, or some other external input source. Output should be recognisable as braille, the form of output is up to you. An example would be o for a raised dot and . for a non-raised dot. Textual pattern represe...
stackexchange_codegolf
4, 8, 15, 16, 23, 42 Write a program that outputs this sequence of numbers infinitely. However, The Numbers must not appear in your source code anywhere. The following is not a valid Java program to output The Numbers because The Numbers appear in its source code: class TheNumbers { public static void main(String[]...
stackexchange_codegolf
Let's say we have a n × n lattice; we can then divide the lattice into two sections by drawing a line through the lattice. Everything to one side of the line is in one set and everything else in another. How many ways can we divide the lattice in the manner? For example lets take a 2 × 2 lattice: . . . . We can make ...
stackexchange_codegolf
Background Incident is a fairly unusual programming language, in that its list of tokens is not predetermined, but rather inferred from the input. As such, tokenising an Incident program can be fairly difficult, especially if you want to do so efficiently. This task is about doing that yourself. The task Your program w...
stackexchange_codegolf
Background An Eisenstein integer is a complex number of the form \$ z = a + b\omega \$ where \$a, b\$ are integers and \$\omega\$ is the third root of unity \$\frac{1-\sqrt3i}{2}\$. The Eisenstein integers can be viewed as the triangular lattice points, as shown in the image below (from Wikipedia): Following the trian...
stackexchange_codegolf
Given a permutation of the alphabet and an intended "word", determine if the word was guessed in a game of Hangman, where the permutation is the list of guesses. For example, given ASTNORDYUVKFMCLWIHEBQGPJXZ as the permutation, and ASTRONAUT as the word, we know that the word was guessed. Only 2 letters (DY) were wrong...
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
Find the nearest Date to a TargetDate for a given Day of Week. For example, given a date of 20161219 and a day of week of Friday (6), the answer is 20161216. Another example, given a date of 20161219 and a day of week of Wednesday (4), the answer is 20161221. A final example, given a date of 20161219 and a day of week ...
stackexchange_codegolf
Given a positive integer N, your task is to return the number of steps required by the following algorithm to reach N: Find the smallest triangular number Ti such that Ti ≥ N. Build the corresponding list L = [ 1, 2, ..., i ]. While the sum of the terms of L is greater than N, remove the first term from the list. If t...
stackexchange_codegolf
Summary A new string manipulation language has been made, using only the characters $+#-!*|@>! Your task is to implement an interpreter for it in as few bytes as possible. Input A string, which is a single line of this language. This can be taken in any reasonable way (stdin, function parameter, command line argument e...
stackexchange_codegolf
I was trying to write a short MIPS32 code for computing the median of three registers. The rules: Assume that some values are pre-loaded into $t0, $t1, $t2. The median of the three values should be placed in $t0. No branches are allowed, but otherwise any instruction is okay. You may arbitrarily modify the values of a...
stackexchange_codegolf
Input A bound m <= 4294967295. Output Consider values sampled uniformly at random from integers in the range 0 to m, inclusive. Your output should be the expected (average) number of trailing zeros in the binary representation of the sampled value. Your answer should be exact, for example given as a fraction. Example ...
stackexchange_codegolf
Based on this challenge and this Math.SE question. Idea originally come from a Numberphile video. The goal is to reproduce the logic of Professor McKee when he builds this prime. Your task is to build the Trinity Hall Prime, at a much lower scale. You are given a single number N greater than 2, representing the length ...
stackexchange_codegolf
Given a non-empty list/vector of positive integers, write a function to check the following conditions in as few bytes as possible. Take the first integer (the key, or k1) and check that the next k1 values have no duplicate values, excluding instances of k1. Take the last integer (the second key, or k2) and check tha...
stackexchange_codegolf
Challenge description In this challenge, we only consider love and hate as feelings. If we want to utter a feeling expression of order N, we alternate between these two (starting with hate): order | expression 1 I hate it. 2 I hate that I love it. 3 I hate that I love that I hate it. 4 I hate t...
stackexchange_codegolf
Make me a s'more! I tell you the width, the amount of graham cracker, the amount of chocolate, and the amount of marshmallow. An example: Input: Width: 10 Graham: 3 Chocolate: 2 Marshmallow: 1. Output: GGGGGGGGGG GGGGGGGGGG GGGGGGGGGG CCCCCCCCCC CCCCCCCCCC MMMMMMMMMM GGGGGGGGGG GGGGGGGGGG GGGGGGGGGG Is it that easy? U...
stackexchange_codegolf
\$\newcommand{T}[1]{\text{Ta}(#1)} \newcommand{Ta}[3]{\text{Ta}_{#2}^{#3}(#1)} \T n\$ is a function which returns the smallest positive integer which can be expressed as the sum of 2 positive integer cubes in \$n\$ different ways. For example, \$\T 1 = 2 = 1^3 + 1^3\$ and \$\T 2 = 1729 = 1^3 + 12^3 = 9^3 + 10^3\$ (the ...
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 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
Given a position with a row of rooks and/or empty spaces, output how many different rook moves are possible. A rook can move left or right to an empty space, but not to one that requires passing over another rook. When a rook moves, the other rooks remain in place. For example, from this position, 6 moves are possible:...
stackexchange_codegolf
Introduction OEIS sequence A127421 is the sequence of numbers whose decimal expansion is a concatenation of 2 consecutive increasing non-negative numbers. Put simply, every number in the sequence is formed by putting together n with n+1 for some non-negative, integer value of n. The first several terms are: 1, 12, 23,...
stackexchange_codegolf
Related Now you have some dice which you may roll several times. You need a uniform random integer between 1 and \$n\$, inclusive. Show a method that rolls the fewest times and behaves as an \$n\$-sided dice. Alternative question: Given a set \$S\$ and \$n\$, pick the fewest elements from \$S\$(each element can be pick...
stackexchange_codegolf
In the PPCG chatroom the Nineteenth Byte, using carets ^ (or carrots) is a way of indicating that you agree with one of the previously made comments just above yours. A caret message consists solely of N ^ characters (where N is a positive integer) and it means agreement with the Nth previous message. So a single ^ mea...
stackexchange_codegolf
Background In Haskell and many other functional languages, function application f(x) is simply written as f x. Also, this form of function application is left-associative, which means f x y z is ((f x) y) z, or ((f(x))(y))(z). Haskell also has a binary operator called $. f $ x does function application just like f x, b...
stackexchange_codegolf
/o\ Jimmy has been receiving a lot of attention on this site recently and it has caused Jimmy to get a little stressed. The bodybuilder Jimmys /-o-\ started bad mouthing the OG / acrobat /o\ Jimmys saying they are way cooler because they are bigger. But of course the acrobat Jimmys thinks they are way cooler since afte...
stackexchange_codegolf
The London Underground A.K.A. The Tube is the oldest underground railway in the world, it currently consists of eleven lines* servicing 267 named stations (strictly 269** stations since "Edgware Road" and "Hammersmith" each occupy two locations) The challenge Output the names of the lines servicing a station given by n...
stackexchange_codegolf
Given a string consisting of only printable ascii (letters, numbers, symbols, and spaces), how many keystrokes are required minimally to type out this string from scratch? That is, current text is initially an empty string and should end up being equal to the input string. These are the allowed actions and their cost i...
stackexchange_codegolf
I really love sliding tile puzzles, but recently, I haven't had time for them. Hence, I need a program to give me my fix of sliding-tile puzzles, specifically Klotski puzzles. Your input will be in the following format: ####### #001gg# ##.222# .###### where # represents walls, . represents an open area, g represents ...
stackexchange_codegolf
Challenge Given an integer n ≥ 4, output a permutation of the integers [0, n-1] with the property that no two consecutive integers (integers with absolute difference 1) are next to each other. Examples 4 → [1, 3, 0, 2] 5 → [0, 2, 4, 1, 3] 6 → [0, 2, 4, 1, 3, 5] 7 → [0, 2, 4, 1, 5, 3, 6] You may use 1-indexing instead...
stackexchange_codegolf
4, 32, 317, 3163, 31623, 316228, 3162278, 31622777, 316227767, 3162277661, 31622776602, 316227766017, 3162277660169, 31622776601684, 316227766016838, 3162277660168380, 31622776601683794, 316227766016837934, 3162277660168379332, 31622776601683793320, 316227766016837933200, 3162277660168379331999, 31622776601683793319989...
stackexchange_codegolf
hgl has a "scan" function called sc. What it does in general is a little bit abstract, so we will just talk about one specific way you can use it. If we want to take a list of integers and get the partial sums of every prefix we can scan with + for sums and 0 as a starting value: ghci> sc (+) 0 [1,2,3,4,5,6] [1,3,6,10...
stackexchange_codegolf
Definition According to Wikipedia: The Cooke and Wheatstone telegraph was an early electrical telegraph system dating from the 1830s invented by English inventor William Fothergill Cooke and English scientist Charles Wheatstone. It was the first telegraph system to be put into commercial service. The receiver consiste...
stackexchange_codegolf
A great Python golfing tip is to omit needless spaces. But if you are like me, you don't always have the time to search for which spaces to remove. If only there was a way to speed up the process... Task Given a single line of Python, as input, return/output a new line which omits all needless spaces. The table below s...
stackexchange_codegolf
Challenge: Given a matrix input, determine the amount of diagonals and anti-diagonals with duplicated numbers. So if we have a matrix like this: [[aa,ab,ac,ad,ae,af], [ba,bb,bc,bd,be,bf], [ca,cb,cc,cd,ce,cf], [da,db,dc,dd,de,df]] All diagonals and anti-diagonals would be: [[aa],[ab,ba],[ac,bb,ca],[ad,bc,cb,da],[ae,...
stackexchange_codegolf
What is the shortest way to convert a string containing integers separated by spaces to a list of integers? input : "-3 1 5 8 10" output : [-3, 1, 5, 8, 10] I regularly face this situation and I wanted to know if there is a better way than (24 bytes): list(map(int,s.split()))
stackexchange_codegolf
Challenge For any two non-empty strings A and B, we define the following sequence : F(0) = A F(1) = B F(n) = F(n-1) + F(n-2) Where + denotates the standard string concatenation. The sequence for strings "A" and "B" starts with the following terms: A, B, BA, BAB, BABBA, ... Create a function or program that, when given...
stackexchange_codegolf
Given a strictly positive integer, return the shortest possible Roman numeral using only the additive rule. Output must consist of zero or more of each of the characters MDCLXVI in that order. The number 14 must therefore give XIIII rather than XIV. The characters' numeric values are M=1000, D=500, C=100, L=50, X=10, V...
stackexchange_codegolf
Notwen wants to study the kinematics of bodies thrown from big heights in a uniform gravitational field but unfortunately he doesn't have the technical possibility to go to sufficiently high places and observe the objects while falling. But who doesn't want to see advances in science so... Let's help Notwen build a gra...
stackexchange_codegolf
Challenge Premise Bob lost1 Alice's precious grand piano. Big mistake. Alice has now stolen Bob's low-orbit ion cannon. Alice refuses to just make up with Bob, so let's help her give him a light tap on the roof. Suppose that from the top Bob's house looks like a lattice polygon, where all points have integer coordinate...
stackexchange_codegolf
Challenge Given a list of SI base units, a list of equations and a target, you must derive the units of the target using only the base units. Derived Units From Wikipedia: The International System of Units (SI) specifies a set of seven base units from which all other SI units of measurement are derived. Each of these ...
stackexchange_codegolf
Given a non-negative integer or a list of digits, determine in how many ways can the number be formed by concatenating square numbers, which may have leading zeroes. Examples input -> output # explanation 164 -> 2 # [16, 4], [1, 64] 101 -> 2 # [1, 01], [1, 0, 1] 100 -> 3 # [100], [1, 00], [1, 0, 0] 1 -> 1 # [1] 0 -> 1 ...
stackexchange_codegolf
Given two non-negative integers e.g. 27, 96 their multiplication expression would be 27 x 96 = 2592. If now each digits is replaced with a symbol, such that two digits are replaced with the same symbol if and only if they are equal we could get something like AB x CD = AECA or 0Q x 17 = 0Z10 or !> x @^ = !x@!. (follo...
stackexchange_codegolf
You are given a very special gun with a full magazine. Let n be the initial number of bullets in the magazine and i the number of bullets left. That gun is really unreliable, hence each time you shoot, you have a i/n chance to successfully shoot. The fewer bullets you have left, the more tries it requires to shoot. The...
stackexchange_codegolf
This is the robbers' thread for 'Almost Illegal Strings'. See the cop's thread for information on participating. A section from the post is included here for convenience. The Robbers' Challenge Find an uncracked answer. Write a program in the language specified that contains as a contiguous substring the almost illega...
stackexchange_codegolf
Given an array A of integers, there exists at least one positive integer p such that A[i] == A[j] for all i and j for which i % p == j % p == 0. Find the smallest p. Examples: Input array: [1, _, 1, _, 1, _, 1, _, 1]. Output: 2 Input array: [1, _, _, 1, _, _, 1, _, _]. Output: 3. Input array: [1, _, _, _, 1, _, _, _, ...
stackexchange_codegolf
Challenge Given an array of positive integers and a threshold, the algorithm should output a set of consecutive-element-groupings (subarrays) such that each group/subarray has a sum greater than the threshold. Rules The solution should honor two additional criteria: be of highest cardinality of the groups (i.e. highes...
stackexchange_codegolf
The Cantor function is continuous everywhere and constant almost everywhere, but has an average slope of 1: The function can be found recursively: \$f_0(x)=x\$ \$f_{n+1}(x)=\left\{\begin{matrix}\frac{1}{2}f_n(3x)&x\in[0,\frac{1}{3})\\ \frac{1}{2}&x\in[\frac{1}{3},\frac{2}{3})\\ \frac{1}{2}+\frac{1}{2}f_n(3x-2)&x\in[\f...
stackexchange_codegolf
Challenge: Create a program that takes input of a positive non-zero integer and outputs the 4 next numbers in the sequence described below. Note: Checking if the input is actually a positive non-zero integer is not necessary Sequence: Every number in this sequence (apart from the first, which is the input) shall be com...
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
Consider the following sequence: 0 1 3 2 5 4 8 6 7 12 9 10 11 17 13 14 15 16 23 ... Looks pretty pattern-less, right? Here's how it works. Starting with 0, jump up n integers, with n starting at 1. That's the next number in the sequence. Then, append any numbers "skipped" and that haven't been seen yet in ascending or...
stackexchange_codegolf
Mama Say Mama Sa Mama Coosa I'm sure all of you have heard of Michael Jackson and some of you have listened to MJ's song "Wanna be starting something". The line "Mama Say Mama Sa Mama Coosa" is repeated throughout the song. Specification In this line, the word "Mama"occurs three times, "Say", "Sa", "Coosa" occurs once...
stackexchange_codegolf
Giving n(any amount) of points (x,y). What's the minimum amount of circles required to cross every point given? Task Your program will get n (you can have n as part of input or use EOF instead) points (x,y). The points might at same place => (x1,y1) = (x2,y2) can happen x and y will be integer of range -10000~10000, wh...
stackexchange_codegolf
Let's say I've got some ASCII art: ___ ,"---". : ; `-.-' | | | | | | _.-\_/-._ _ / | | \ _ / / `---' \ \ / `-----------' \ /,-""-. ,-""-.\ ( i-..-i i-..-i ) |`| |-------| |'| \ `-..-' ,=. `-..-'/ `------...
stackexchange_codegolf
The Seidel Triangle is a mathematical construction similar to Pascal's Triangle, and is known for it's connection to the Bernoulli numbers. The first few rows are: 1 1 1 2 2 1 2 4 5 5 16 16 14 10 5 16 32 46 56 61 61 Each row is generated as follows: If the row number is even (1-indexed): Bring...
stackexchange_codegolf
Please read the rules, and the bold areas as well. Write a program in any language, so long as it has GUI support for a window system (cannot be text-consoles, etc., and must be a GUI/toolkit/window). The program must say hello world in any manner (splash image, menu bar, status bar, title, video, message box, other wi...
stackexchange_codegolf
You will be given a nested array. Your program has to visualize the array. But.. How? For example, let's assume we have a nested array, like [["1","2"],[["1","2"],"3"],"4",[[[["5"]]]],"6"]. This nested array can be visualised as: ->1 ->2 -->1 -->2 ->3 >4 ---->5 >6 Examples Input 1: ["Atom",["Proton",["Up Quark", "Up...
stackexchange_codegolf
Create three programs, which we'll call Rock, Paper, and Scissors. Each program must be unique, and accept input. If a program gets any input which is not one of the programs Rock, Paper or Scissors, it must print itself. RPS style, the programs will each print one of the following four outputs: "win" if the running ...
stackexchange_codegolf
Look at the following string. Notice a pattern? ABEFNOPEFGH DC G Q I M H R J LKJI S K D T L C U M BAZYXWV N E O D P C Q BAZYXWVUTSR As some might have noticed, it's basically a spiral of the alphabet, where the distances between rows / columns are gradually increasing b...
stackexchange_codegolf
You have to print out your username, by only using the characters in your username. Standard loopholes are forbidden This is not code-golf, so shortest does not win Don't modify your username please And each language be used one time
stackexchange_codegolf
The scenario You live in a country that is having a presidential election. Each voter gets one vote, and therefore there is a firmly-entrenched two-party system. (Third parties exist, but get hardly any votes). The latest opinion poll shows the race in a dead heat: 49%: Alberto Arbusto 49%: Jorge Sangre 2%: various ...
stackexchange_codegolf
A sign sequence is an infinite sequence consisting entirely of \$1\$ and \$-1\$. These can be constructed a number of ways, for example: Alternating signs: \$1, -1, 1, -1, ...\$ \$-1\$ for primes, \$1\$ for non-primes: \$1, -1, -1, 1, -1, 1, -1, ...\$ All \$1\$s: \$1, 1, 1, ...\$ Your task is to write a piece of code...
stackexchange_codegolf
The Len(language,encoding) family of languages is a variety of Lenguage derivatives. To encode a program into a Len language, you replace every character with its representation in a certain encoding, then turn that into a giant integer. Your challenge is to write a function or program that encodes your language into a...
stackexchange_codegolf
This is a relatively simple question. I'm trying to golf a Snake game I've written, and I'm trying to work out if there's a way to golf the following conditional assignments which control x and y coordinates of the snake ensuring a wrap around of the play area: if (P<0) { P = T-1; } if (P>T-1) { P = 0; } if (Q<0) {...
stackexchange_codegolf
Stackylogic is a programming language I made up in a previous challenge: Run Stackylogic. Read that post for full details and examples, but here is how it works paraphrased: Stackylogic takes 0's and 1's for input and outputs a single 0 or 1 upon completion. A program consists of lines that only contain the characte...
stackexchange_codegolf
Consider a triangle where the Nth row (1-indexed) is the array of the first N positive integer powers of N. Here are the first few rows: N | Triangle 1 | 1 2 | 2 4 3 | 3 9 27 4 | 4 16 64 256 5 | 5 25 125 625 3125 ... Now if we concatenate those powers into a single sequence, we get OEIS A075363: 1, 2, 4, 3, 9, 27, 4...
stackexchange_codegolf
Given a linear equation mx+n, return n and m. However, the equation may be in any of the following formats: 5x+2 -> 5 2 5x-2 -> 5 -2 5x -> 5 0 -2 -> 0 -2 x -> 1 0 Here are the formats, where each ? stands for a positive integer written without leading zeroes ?x+? ?x-? -?x+? -?x-? x+? x-? ? -? ?x -?x x All of t...
stackexchange_codegolf
Given a positive integer k > 1 and a non-negative integer i, generate a k-tuple (or k-dimensional vector) of non-negative integers. For every k, the map from ℕ to ℕk, must be bijective. That is, every input i should produce a different tuple, and every possible tuple must be produced by some input i. You may write a pr...
stackexchange_codegolf
Write a cat program, a quine, and a Hello World in the same language such that when two specific programs of the three are concatenated in a certain order, you get the third program. It does not matter which program is the first, second, and third are as long as all three types are represented once each. e.g. if \$A\$ ...
stackexchange_codegolf
Input: Any Brainfuck program. This includes brainfuck programs with comments such as +++COMMENT[>+++<-].. Output: A program in one of the below languages that produces the same output as the Brainfuck program on all inputs. It should produce the same output exactly as the interepreter on this website There are no code-...
stackexchange_codegolf
Given a string like [[[],[[]]],[]], made of only commas and square brackets, your challenge is to determine whether it represents a list. A list is either: [], the empty list At least one list, joined with commas and wrapped in square brackets. You may use any three characters instead of [,]. You may output as: Any ...
stackexchange_codegolf
You are the best and most famous hero of the area. Lately there have been rumors that a Hydra has been hanging out in a nearby ravine. Being the brave and virtuous hero that you are you figure you'll go check it out sometime later today. The problem with hydrae is that every time you try to cut off their heads some ne...
stackexchange_codegolf
Given a deck consisting of N copies of cards with integer values [1,M] for a total of N*M cards, compute the probability that a card with the value of 1 is adjacent to a card with the value of 2. Your solution may be exact or approximated, and it does not need to be the same for every run given the same inputs. The giv...
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
In CSS, colours can be specified by a "hex triplet" - a three byte (six digit) hexadecimal number where each byte represents the red, green, or blue components of the colour. For instance, #FF0000 is completely red, and is equivalent to rgb(255, 0, 0). Colours can also be represented by the shorthand notation which use...
stackexchange_codegolf
Given a word, treat every letter as its number in English alphabet (so a becomes 1, b becomes 2, z becomes 26 and so on), and check if all of them, including duplicates, are pairwise coprime. The input is exactly one word of lowercase English letters. The output is the fact if the word is coprime: any truthy/falsey val...
stackexchange_codegolf
Fix my Basic Orthography While I am excellent at following the English capitalisation rules when writing, when I am typing I have a habit a capitalising almost everything (as you will see from the titles of my challenges). I need a program to fix that, but because I use so many capitals, and capitals are big letters, y...
stackexchange_codegolf
In most programming languages, the string Hello, World! can be represented as "Hello, World!". But if you want to represent "Hello, World!" you need to escape the double quotes with backslashes for "\"Hello, World!\"", and to represent that you also need to escape the backslashes resulting in "\"\\\"Hello, World!\\\"\"...
stackexchange_codegolf
Given two line segments, determine if the line segments intersect and if so, where. In the case that the two given line segments are co-linear and overlap, determine the midpoint of the overlapping segment. Lines will be specified in pairs of (x, y) coordinates. Examples [(-1, -1), (1, 1)], [(-1, 1), (1, -1)] => (0, 0...
stackexchange_codegolf
Given a string, character list, byte stream, sequence… which is both valid UTF-8 and valid Windows-1252 (most languages will probably want to take a normal UTF-8 string), convert it from (that is, pretend it is) Windows-1252 to UTF-8. Walked-through example The UTF-8 string I       ♥        U  T  F  -  8 is represente...
stackexchange_codegolf
Dungeon Master was one of the first ever real-time role-playing games, originally released in 1987 on the Atari ST. Among other exciting things for the time, it offered a rather sophisticated spell system based on runes. Your task today is to write a program or function that evaluates the number of Mana points required...
stackexchange_codegolf
Write a function or program that given a list of non negative integers, arranges them such that they form the largest possible number. INPUT [50, 2, 1, 9] OUTPUT 95021 INPUT 0 OUTPUT 0 INPUT (Interesting one) [7, 76] OUTPUT 776 RULES standard loopholes apply. Depending on your language you can use int(32) / in...
stackexchange_codegolf
Background and Motivation: IOC Country Codes are three letter abbreviations that are commonly used when broadcasting the Olympic Games. The last two letters of some codes overlap with the first two letters of other codes (RUS -> USA, JPN -> PNG), etc. Clearly, you can transform the first country code into the second by...
stackexchange_codegolf
For the purposes of the current challenge to "outline" a word means to surround it successively with its own letters, starting with the last one, and finally to replace the original word in the center with spaces: oooooo onnnno on -> on no onnnno oooooo Task: Given a list of words, con...
stackexchange_codegolf
Resistors commonly have color coded bands that are used to identify their resistance in Ohms. In this challenge we'll only consider the normal 4-band, tan, axial-lead resistors. We'll express them as: xyzt Where x is the first band for the first significant figure, y is the second band for the second significant figur...
stackexchange_codegolf
When I was younger, I use to play a word game called Word chain. It was very simple. The first player chooses a word; the next player says another word that starts with the same letter the previous word ended with. This goes on forever until somebody gives up! Trick is, you cannot use the same word twice (unless everyb...
stackexchange_codegolf
Just like code-golf, restricted-source pushes one to exploit quirks and hidden features of the Python language. We already have a place to collect all these tips for code-golf, those for restricted-source remain transmitted by word of mouth or hidden deep within the python documentation. So today I would like to ask y...
stackexchange_codegolf
If you don't know what the Tower of Hanoi is, I'll explain it briefly: There are three rods and some discs each of which has a different size. In the beginning all discs are on the first tower, in sorted order: The biggest one is at the bottom, the smallest at the top. The goal is to bring all the discs over to the thi...
stackexchange_codegolf
Given a number N from 2 to 8, place any nonzero number of queens on a grid of any size so that every queen has exactly N queens (counting itself) in each of its row, column, and each diagonal. This challenge has a significant restricted-time runtime limit. Your code must finish all N from 2 to 8 (combined) within the 6...
stackexchange_codegolf
Background I want to buy an plot of land and build my house on it. My house should be rectangular, and as large as possible; however, the available plots have lots of rocky areas that I cannot build on, and I'm having trouble fitting a potential house on the plots. I want you to write a program that analyzes the plots ...
stackexchange_codegolf
XKCD Comic: Goal: Given a date, the current Dow Opening, and your current coordinates as a rounded integer, produce a "geohash." Input: Input through any reasonable means (STDIN, function argument, flag, etc.) the following: The current date. This does necessarily have to be the date of the system's clock, so assume ...
stackexchange_codegolf
Given a string of ASCII art like such (This isn't ASCII art but it will do for the example): abc d e fgh Jumble it as if it was being displayed on a screen with one character per line, like so: a b c d e f g h Print the result, wait one second, ±0.5 seconds before clearing the terminal and the print the same thing, ...
stackexchange_codegolf
Odd prime numbers are either in the form of 4k+1 or 4k+3 where k is a non-negative integer. If we divide the set of odd prime numbers into two such groups like this: 4k+3 | 3 7 11 19 23 31 43 47 59 67 71 | 4k+1 | 5 13 17 29 37 41 ...
stackexchange_codegolf
The above image is called a hexa-glyph. Hexa-glyphs are some cool patterns I made up while doodling during my DiffEq class. Here's how you make one: Consider the following set of points, shaped like a regular hexagram. The inner hexagon is what will contain the final glyph, while the outer 6 points form a star and...
stackexchange_codegolf
Blackbeard was an English pirate of the early 18th century. Although he was known for looting and taking ships, he commanded his vessels with the permission of their crews. There are no accounts of him ever harming or murdering his captives. This challenge is in honor of the infamous Blackbeard and inspired by Internat...
stackexchange_codegolf
Challenge Premise Bob lost1 Alice's precious grand piano. Big mistake. Alice has now stolen Bob's low-orbit ion cannon. Alice refuses to just make up with Bob, so let's help her give him a light tap on the roof. Suppose that from the top Bob's house looks like a lattice polygon, where all points have integer coordinate...
stackexchange_codegolf
The cardinality of the set \$\mathbb Q\$ of rational numbers is known to be exactly the same as that of the set \$\mathbb Z\$ of integers. This means that it is possible to construct a bijection between these sets—a mapping such that each integer corresponds to exactly one rational number, and vice versa. Provide such ...
stackexchange_codegolf
Your task is to assemble the integers from 1 to N (given as input) into a rectangle of width W and height H (also given as input). Individual numbers may be rotated by any multiple of 90 degrees, but they must appear as contiguous blocks in the rectangle. That is, you cannot break one of the numbers into multiple digit...
stackexchange_codegolf
Is there a way in Golfscript to bring all of the diagonals of an array into a single array? For example, for the array [[1 2 3][4 5 6][7 8 9]] return [[7][4 8][1 5 9][2 6][3]] (not necessarily in that order) and for ["ABCD""EFGH""IJKL"] return ["I""EJ""AFK""BGL""CH""D"] (not necessarily in that order). Assume the l...
stackexchange_codegolf
Each day you put up a new word on a marquee sign with movable letters, buying just the letters you need to write it. You re-use letters you've bought for earlier words whenever possible. Given the words you want to write each day in order, output the letters you buy each day. Example Input: ['ONE', 'TWO', 'THREE', 'S...
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