instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
In this challenge you will be asked to implement any function (or full program) that fulfills two properties. Those properties are: Your function must be an injective (reversible) function from the polynomials with non-negative integer coeffecients to the non-negative integers. This means no two unequal inputs can m...
stackexchange_codegolf
Definition Let's call an (infinite) integer sequence universal if it contains every finite integer sequence as a contiguous subsequence. In other words, the integer sequence (a1, a2, …) is universal if and only if, for each finite integer sequence (b1, …, bn), there is an offset k such that (ak+1, …, ak+n) = (b1, …, bn...
stackexchange_codegolf
This is much like my earlier challenge, except, this time, order doesn't matter. A straight-chain alk*ne is defined as a sequence of carbon atoms connected by single (alkane), double (alkene), or triple bonds (alkyne), (implicit hydrogens are used.) Carbon atoms can only form 4 bonds, so no carbon atom may be forced to...
stackexchange_codegolf
Background A Lyndon word is a non-empty string which is strictly lexicographically smaller than all its other rotations. It is possible to factor any string uniquely, by the Chen–Fox–Lyndon theorem, as the concatenation of Lyndon words such that these subwords are lexicographically non-increasing; your challenge is to ...
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
99 is a programming language I invented earlier this week for my challenge Write an interpreter for 99. (Invented but never needed to implement thanks to half a dozen of you. ;) ) The full language spec is in that challenge so I'm not bothering to repost it all here. In 99 you can print individual ASCII characters to s...
stackexchange_codegolf
My attempt at stating this question, but with a more objective solving criterion. Your task is to build a program or function that takes a solved Sudoku grid S in the format of your choice and attempts to generate a problem grid with as few clues as possible that has S as its unique solution. (It doesn't matter what me...
stackexchange_codegolf
In the plane (\$\mathbb R^2\$) we can have at most five distinct points such that the distances from each point to every other point (except itself) can assume at most two distinct values. An example of such an arrangement is a regular pentagon - the two different distances are marked with red and blue: Challenge Give...
stackexchange_codegolf
The Caesar cipher is a simple and famous cipher, where the letters of the alphabet are rotated by some secret amount. For example, if our secret rotation is 3, we would replace a with d, b with e, w with z, x with a and so on. Here is an example (rotation amount: 10): Robo sc kx ohkwzvo This cipher is very weak, becau...
stackexchange_codegolf
Description There have been quite a few other challenges concerning these numbers before, and I hope this one is not among them. The n th triangular number equals the sum of all natural numbers up to n, simple stuff. There are a wikipedia page and an entry at OEIS, for those who wish to inform themselves further. Now, ...
stackexchange_codegolf
Alak was invented by the mathematician A. K. Dewdney, and described in his 1984 book Planiverse. The rules of Alak are simple: Alak is a two-player game played on a one-dimensional board with eleven slots on it. Each slot can hold at most one piece at a time. There's two kinds of pieces, "x" and "o". x's belong t...
stackexchange_codegolf
Challenge You will be given an input represented by x, which is a string containing at least 3 characters. It will consist only of the standard numeric characters, 0 through 9. Your job is to find and output how many right triangles can be formed with the given numbers. Rules Numbers must be kept in the order they wer...
stackexchange_codegolf
The code: function L(){N=null;E=[N,N];t=this;h=E;t.u=i=>h=[i,h]; t.o=_=>h==E?N:h[+!(h=h[1])];t.e=(i,l)=>h=(l||h)==E?[i, E]:[(l||h)[0],t.e(i,(l||h)[1])];t.s=_=>{o="";while(i=t.o()) {o+=i+","}return o}} For my response to this (old) question: https://codegolf.stackexchange.com/a/196783/72421 (my linked answer has a com...
stackexchange_codegolf
Your task is to write a program that outputs its own source code in reverse. However, when the reversed code is run, it should output the source code, facing the correct direction. Example Say your program is abc. When run, it should output cba. cba, when run, should output abc. Rules Your program should follow all the...
stackexchange_codegolf
Challenge Write a program/function that accepts an "image" and outputs a picture maze formed from that image. Input Your program should accept two arguments: I, the image to form the maze from S, a boolean specifying whether or not to display the solution to the maze I is given in the following form: ....... .#####. ...
stackexchange_codegolf
Definitions A bijection from a set S to a set T is a function from S to T such that one element in T is mapped by exactly one element in S. A bijection within a set S is a bijection from S to S. The natural numbers are the integers which are greater than or equal to 0. A subset of a set S is a set such that every elem...
stackexchange_codegolf
Given a list of production rules and start symbol of a proper finite context-free grammar (CFG) of printable characters, your program or function must output its formal language (the set of all sentences which can be constructed from it). Task A context-free grammar is formally defined as a 4-tuple of a few parts. Here...
stackexchange_codegolf
Input A string. Output The sum of all integers in the line. Constraints 1≤Length of line≤500 Sample test Case Input the 5is 108 seCONd4 a Output 117 Explanation Sum is: 5+108+4=117
stackexchange_codegolf
All Aboard the ASCII Train! o O O ___ ___ ___ ___ ___ ___ ___ ___ ___ o | C | | O | | D | | E | | | | G | | O | | L | | F | TS__[O] |___| |___| |___| |___| |___| |___| |___| |___| |___| {======|_|"""""|_|"""""|_|"""""|_|"""""|_|"""...
stackexchange_codegolf
Your challenge is to write 5 different full programs for the 5 following tasks: Print Hello, World!. Given an input on STDIN, output the factorial (you can assume that the input is an integer ≥ 0). Given an integer N, calculate the sum of the primes ≤ N. Given an input on STDIN, output the letters used in the input. F...
stackexchange_codegolf
Today (March 15) is the Ides of March, best known for being the date that Julius Caesar was assassinated. What's “Ides”? Well, the ancient Romans didn't simply number the days of month from 1 to 31 like we do. Instead, they had a more complex system of counting backwards to the Kalends, Nones, or Ides. Challenge Writ...
stackexchange_codegolf
This time, you are working on a regex. Your regex is meant to approximately full-match the base-10 representations of primes \$0 \le p < 1000\$, while ignoring any non-numeric string or composite in the range. You can full-match 2, 53 or 419, but not 0, 82 or example. The approximately is important -- a minimum of 900 ...
stackexchange_codegolf
This is not a duplicate of this question. This is asking for the nth number that can be represented as the sum of two cubes in two different ways, while that is asking for the n-th number that can be expressed as the sum of two cubes in n ways. Introduction I was just watching The man who knew Infinity, and I thought i...
stackexchange_codegolf
Background Most of you know what a Fibonacci number is. Some of you may know that all positive integers can be represented as a sum of one or more distinct Fibonacci numbers, according to Zeckendorf's Theorem. If the number of terms in the optimal Zeckendorf Representation of an integer n is itself a Fibonacci number, ...
stackexchange_codegolf
Warning: Wouldn't you rather answer a challenge about ponies?1 If you have read The Hostile Hospital, you would know that the Baudelaire orphans, from one of the scraps of paper recovered from the Quagmire's notebooks, they discover a name, "Ana Gram". Later on, they realize that means the word "anagram", not a name....
stackexchange_codegolf
Briefing Aliens have settled on earth and strangely enough, their alphabet is the exact same as ours. Their language is also very similar to ours with some very distinct and easy to compute differences. Challenge Take a string and output the alien's language equivalent. The translation works as such: Swap all the vowel...
stackexchange_codegolf
The title pretty much describes it all. Given as input a \$n \times m\$ matrix and an integer \$i\$ create a complete function/program that returns the matrix \$i\$ times clockwise rotated by \$90^\circ\$. Rules: as matrix you can use any convenient representation you like e.g. a list of lists etc... matrix values can...
stackexchange_codegolf
UPDATE: The gist-files are updated (including new submissions) as the Controller.java did not catch Exceptions (only errors). It does now catch errors and exceptions and also prints them. This challenge consists of two threads, this is the cat thread, the catcher thread can be found here. The controller can be download...
stackexchange_codegolf
Given a base \$k\$ as well as two indices (also passed in base \$k\$, call them \$s\$ and \$e\$) return a list containing a frequency count of all base-\$k\$ digits occurring between \$s\$ and \$e\$ inclusive. For example, upon input \$k = 10, s = 1, e = 10\$, we would return the list \$[0: 1, 1: 2, 2: 1, 3: 1, 4:1, 5:...
stackexchange_codegolf
Given two positive integer fractions \$x\$ and \$y\$ such that \$x < y\$, give the fraction \$z\$ with the smallest positive integer denominator such that it is between \$x\$ and \$y\$. For example \$x=2/5\$, \$y=4/5\$, the answer is \$1/2\$. Other fractions such as \$3/5\$ are also in between the two, but \$1/2\$ has...
stackexchange_codegolf
A polyiamond of size \$n\$ is a contiguous shape formed by joining \$n\$ equilateral triangles side by side. Your output should consist of two distinct characters, plus whitespace as necessary (▲ and ▼ work great!). Trailing whitespace is acceptable. You may use any other characters - but you may count ▲▼ as 1 byte e...
stackexchange_codegolf
Bobby's booby-trapped safe requires an n-digit code to unlock it. Alex has a probe which can test combinations without typing them onto the safe. The probe responds Fail if no individual digit is the same as that in its corresponding position in Bobby's code. Otherwise it responds Close, including when all digits are c...
stackexchange_codegolf
I have the code: marks = tuple(tuple((input("Enter subject: "), input("Enter marks: "))) for _ in range(int(input("Enter number of tuples: ")))) print(tuple((s[:3].upper(), max(int(m) for t, m in marks if t == s)) for s in set(t for t, m in marks))) #INPUT (("Physics",131),("Chemistry",30),("Physics",100),("Computers"...
stackexchange_codegolf
Given an integer array of at least two elements, output the Matrix-Vector (defined below) of the array. To compute the Matrix-Vector, first rotate through the size-n input array to create a matrix of size n x n, with the first element of the array following the main diagonal. This forms the matrix portion. For the vect...
stackexchange_codegolf
The Cashier's Algorithm is an algorithm for making change in the minimal number of coins that works quite well for most currency systems. However like most greedy algorithms it is not without its flaws. If a currency system is set up just right (or just wrong) there are certain values in which the Cashier's Algorithm...
stackexchange_codegolf
You are to write a program that takes a list of strings as input. For every string in the list you are to determine the smallest N such that no other string in the list begins with the same N characters as the string in question. Now compose a new list with all these strings. Here is an example, on the left we have ...
stackexchange_codegolf
3var is a variant of deadfish which uses three variables called A, B and R. A and B are accumulators, while R is used as a result variable. In this code-golf challenge, you need to make an interpreter for a stripped-down version of this language. Required Commands: i Increments A d Decrements A s Squares A p ...
stackexchange_codegolf
I am sorry for the very long description. But i think some information of how /proc/self/cmdline works and how it can be used to get a integer input was necessary. You may skip the sections you don't need. While part of this task is related to C and Linux, it can be done in any almost language that can start other prog...
stackexchange_codegolf
The challenge is to find a string of characters that cannot appear in any legal program in your programming language of choice. That includes comments, strings, or other "non-executable" parts. Challenge Your program may be specific to a particular version or implementation of your language's compiler/interpreter/runt...
stackexchange_codegolf
Golf a program or function which gives the \$n^{\text{th}}\$ location of the wildebeest who starts at square \$1\$ on an infinite chessboard which is numbered in an anti-clockwise square spiral, where the wildebeest always visits the lowest numbered square she can reach that she has not yet visited. Inspiration: The Tr...
stackexchange_codegolf
Gaussian blur is a method used for blurring images smoothly. It involves creating a matrix which will be used by convolving it with the pixels of an image. In this challenge, your task is to construct that matrix used in Gaussian blur. You will take an input r which will be the radius of the blur and an input σ which w...
stackexchange_codegolf
Create a program, that outputs a hello world string ("Hello world", "Hello, World" etc.), and source code. Output is written to stdout or equivalent. Hello world string is embedded in the source code. For example, the output for might be (some source code here)hello world(some source code here) When the output is comp...
stackexchange_codegolf
The task is to generate all the strings from 'a' to '999' including upper case characters like so: 'a', 'b', 'c' ... 'y', 'z', 'A', 'B', 'C' ... 'Y', 'Z', '0', '1', 2' ... '8', '9', 'aa', 'ab', 'ac' ... 'az', 'aA', 'aB' ... 'aZ', 'a0' ... 'a9', 'ba' and so on (filling in the gaps), optionally starting with the empty ...
stackexchange_codegolf
Your task is to print this exact text: אבגדהוזחטיכךלמםנןסעפףצץקרשת (You are allowed to print a trailing newline) SHA256 hash of the UTF-8 encoding of the text: 0ab6f1e0bf216a0db52a4a5a247f95cba6f51496de7a24dfd01f3985dfcf6085 Base64 encoding: 15DXkdeS15PXlNeV15bXl9eY15nXm9ea15zXnted16DXn9eh16LXpNej16bXpden16jXqdeq Ru...
stackexchange_codegolf
Objective Given an unlabelled binary tree, decide whether it is contiguous in indices. Indices This challenge gives one-indexing on binary trees. The exact definition expresses all indices in binary numeral: The root is indexed 1. For every node, to get the index of its left child, replace the most significant 1 by 1...
stackexchange_codegolf
First puzzle from me, suggestions for improvement gladly received! The scenario is; You work as a manager for a whitewater rafting company. Every morning, you are given a list of bookings, and you have to sort them into raft loads. Write a program or function in your chosen language that does this for you. Each raft ho...
stackexchange_codegolf
Background Boolean Algebra concerns representing values with letters and simplifying expressions. The following is a chart for the standard notation used: Above is what actual boolean algebra looks like. For the purposes of this code golf, this is not the syntax that will be used. Your Task Given a string with three c...
stackexchange_codegolf
Write a function or program that encodes a string into a Code 39 format barcode, where each character is encoded as five bars separated by four gaps. Either two of the bars and one of the gaps are wide and others are narrow (10*4 codes), or three of the gaps are wide and none of the bars are (4 codes). This gives 44 di...
stackexchange_codegolf
Here's a simple challenge, so hopefully lots of languages will be able to participate. Given a positive integer \$n\$, output \$A076039(n)\$ from the OEIS. That is, start with \$a(1)=1\$. Then for \$n>1\$: $$a(n)=\left\{ \begin{array}{ll} n\cdot a(n-1), & \text{if } n>a(n-1) \\ \lfloor a(n-1)/n \rfloor, & \text{otherw...
stackexchange_codegolf
Given two inputs, a number n and a dimension d, generate the nth d-dimensional pyramid number. That was confusing, let me try again. For d = 1, the numbers start 1,2,3,4,5 and is the number of points in a line n points long. For d = 2, the numbers start 1,3,6,10,15 and is the number of points in a triangle with side le...
stackexchange_codegolf
Not to be confused with Is my OS 32-bit or 64-bit. This one is very simple, tell me whether or not my CPU supports 64-bit instructions. If my CPU supports 32-bit instructions, print '32', if my CPU supports 64 bit instructions, print '64', if my processor naitively supports other lengths of instructions, print 'other'....
stackexchange_codegolf
I'm currently working with a branchless language which does not have native Less-Than, Greater-Than or Equal-To functions. I do however have min, max and abs functions and standard arithmetic (+, -, / and *) available to me. I'd like to create these three functions (as L(a, b), G(a, b) and E(a, b) respectively, which w...
stackexchange_codegolf
(no, not those ones) The Challenge You'll be given two inputs. The first is a positive integer n > 0, which is used to output an n x n right triangle of the numbers 1, 2, 3, ... n. This triangle starts in a corner and increases horizontally and vertically by one and diagonally by two. See examples below for clarificati...
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
...counted! You will pass your program a variable which represents a quantity of money in dollars and/or cents and an array of coin values. Your challenge is to output the number of possible combinations of the given array of coin values that would add up to the amount passed to the code. If it is not possible with t...
stackexchange_codegolf
Problem Given a value n, imagine a mountain landscape inscribed in a reference (0, 0) to (2n, 0). There musn't be white spaces between slopes and also the mountain musn't descend below the x axis. The problem to be solved is: given n (which defines the size of the landscape) and the number k of peaks (k always less tha...
stackexchange_codegolf
Dedicated to Martin Gardner, taken from his book Background In the old days, the Slavs had a divination method for finding out whether a girl would get married. The girl would clutch six straws in her hand so that the ends would poke out the top and bottom of her fist. Then her friend would join together the ends of pa...
stackexchange_codegolf
Definition \$a(1) = 1\$ \$a(2) = 2\$ \$a(n)\$ is smallest number \$k>a(n-1)\$ which avoids any 3-term arithmetic progression in \$a(1), a(2), ..., a(n-1), k\$. In other words, \$a(n)\$ is the smallest number \$k>a(n-1)\$ such that there does not exist \$x, y\$ where \$0<x<y<n\$ and \$a(y)-a(x) = k-a(y)\$. Worked out ...
stackexchange_codegolf
Challenge Display Inky the ghost from Pac-Man using only ANSI escape codes. Here's a text representation of the image B B B B B C C C C B B B B B B B B C C C C C C C C B B B B B C C C C C C C C C C B B B C W W C C C C W W C C C B B W W W W C C W W W W C C B B E E W W C C E E W W C C B C E E W W C C E E W W C C C C C W...
stackexchange_codegolf
Write an interpreter for 2B I like David Catt's esoteric language 2B, having memory stored in a tape where each cell is a seperate tape of bytes (the 'subtape'). Write an interpreter for it! Language Specification Official specification can be found here. In this specification, " means a number in the range 0-9 (0 is i...
stackexchange_codegolf
Introduction Our goal is to efficiently find the maximum of a large amount of (redundant) data. We define the outer product of vectors \$A\$ and \$B\$ as a matrix containing the products of all entries of \$A\$ with each entry of \$B\$. (see outer Product) $$ A\otimes B := A\cdot B^T = \left(\begin{array}{rrr} A(1)\cdo...
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
Given a rectangle input with only \, / and space, decide if it's a valid output of Drawing in Slashes Empty lines and columns at edge get cleaned up, so the 3rd true case is true. True cases: /\/\ / /\ \ \/ / \ /\/ /\ \ \ / \/ \ \ \ \ \/ /\/\ / /\ \ / \ \/ / /\ \/\ \/ \ / / / ...
stackexchange_codegolf
Given \$n, m\ge 1\$. There are \$n\$ balls. Do \$m\$ moves, each choose a ball (maybe also the first one), and exchange with the one currently on the first place. At the end, the order of balls should be the same as the initial state. You can either output all possibilities, or a random one provided all possibilities h...
stackexchange_codegolf
Italian zipcodes are 5-digit numbers. Each number is linked to a province. There are 4610 zipcodes and 110 provinces (as of 2015) in Italy. Given the list of zipcodes and the related province (in this file - Gist here) write a function (any language would be fine) that, accepting in input an Italian zipcode, writes out...
stackexchange_codegolf
Your program must accept as input six numbers, which describe a triangle - for example, the inputs 80, 23, 45, 1, 76, -2 describe a triangle with vertices (80, 23), (45, 1), and (76, -2). The input must be given as six plain real numbers or as a list of six real numbers, in the order given in the example. Your task is ...
stackexchange_codegolf
Challenge Write a complete program that prints out the time it took to execute a certain part of itself. That part must include a process whose total number of operations (and therefore execution time) is dependent on a user-substituted numeric value - this can be denoted in any way in your code (uppercase N for exampl...
stackexchange_codegolf
This challenge is about printing a series of growing ASCII-art arrows. I'll describe the pattern in words, but it might be easier to look at what the start of this series looks like: > < -> <- --> <-- ---> <--- ----> <---- -----> <----- ------> <------ ... An arrow with length n contains an arrowhead (< or >) and n-1 ...
stackexchange_codegolf
An example will easily explain this to you. Suppose an array [1,2,3,4,5] Step 1 1 2 3 4 5 ----+---- Step 2 5/ 4/ 1 2 3 / ----+/ Step 3 5| 4| 1 2 3| ----+| Step 4 5\ 4\ 1 2 3\ ----+-\ Step 5 Take the sum of face-to-face elements 6 6 3 You just successfully folded an array 1 time. 2 times f...
stackexchange_codegolf
Background Conway's Soldiers is a version of peg solitaire played on an infinite checkerboard. The board is initially full of pegs below an infinite horizontal line, and empty above it. Following the ordinary peg solitaire rules (move a peg by jumping over another one horizontally or vertically, removing the one that w...
stackexchange_codegolf
The system Assume the Earth is flat and that it extends infinitely in all directions. Now assume we have one infinitely long train railway and n trains in that railway. All trains have different speeds and all trains are going in the same direction. When a faster train reaches a slower train, the two trains connect (be...
stackexchange_codegolf
Challenge For this challenge, a mountainous string is one that conforms to the grammar rule M: x(Mx)* where at each production, the all x's are the same character. When indented, a mountainous string might look something like this: A B C D C E F E C B A As you can see, it looks a bit like a mounta...
stackexchange_codegolf
Thanks @NathanMerrill for allowing me to post this! The following is entirely his wording from this sandbox post (deleted): We define a "Fresh" substring as a substring that is different from any other substring that starts earlier. For example, if I take the string "abababc" and split it: ["ab","ab","a","bc"], the fi...
stackexchange_codegolf
Your program has to take a multi-lined string, like this: ############# # # # p # # # ############# p is the player and # is a block. Now under that in the terminal should be an input line saying: How do you want to move? If the player types l he has to walk left when there isn't a block...
stackexchange_codegolf
Sort the Textbooks School is starting soon (if it hasn't already) and so it's time to get our textbooks in order. You need to sort your books in alphabetical order but that takes too long so you decide to write a program to do it. Examples Input: _ | | _ |F| | | |o|_|P| |o|B|P| | |a|C| | |r|G| |_|_|_| Output: _ ...
stackexchange_codegolf
Introduction Recently I was trying out one of the more obscure use-cases of a modern smartphone: Calling someone by number. While typing it in, I noticed that some of my phonebook entries were displayed, even though the number I was trying to call was different! After some experiments, I figured out why. What it does ...
stackexchange_codegolf
Using the matchstick numbers here: Count the Matchsticks _ _ _ _ _ _ _ _ | | | _| _| |_| |_ |_ | |_| |_| |_| | |_ _| | _| |_| | |_| _| How many matchsticks must be moved and/or removed to change one number into another? You will take two single digit number...
stackexchange_codegolf
Introduction Fischer random chess, also known as Chess960 for the 960 valid starting boards, is a variant of chess where each player's pieces are randomly shuffled at the start. As a reminder, each player gets 8 pawns, two rooks, two knights, two bishops, one queen, and one king. For this challenge, you don't need to k...
stackexchange_codegolf
Your Task Write a program using ASCII characters. Five alphanumeric (0-9, A-Z, a-z) characters will be inserted at random into your program's source code. Your task is to detect and output these characters inserted into your program. Conditions Your code cannot use any form of backup file. Your code may produce any un...
stackexchange_codegolf
In the MMORPG Final Fantasy XIV, the Ninja class has the ability to use combinations of up to three handsigns (Ten, Chi and Jin) to perform a variety of ninjutsu skills. The skill you cast depends on the last sign used, and using two or more of the same sign makes the ninjutsu skill fail and puts a little bunny on your...
stackexchange_codegolf
Introduction Many old chess books use descriptive notation to notate squares on a chessboard, naming the file (column) of the square based on the starting piece positions of White or Black, depending on whose move it is. The ranks (rows) are numbered 1 through 8, with 1 being closest to the player. For example, from Wh...
stackexchange_codegolf
Given a string whose length is divisible by 4, make a triangle as demonstrate below. If the string is abcdefghijkl, then the triangle would be: a b l c k defghij If the string is iamastringwithalengthdivisiblebyfour, then the triangle would be: i a r m u a o s f ...
stackexchange_codegolf
The task is to find the smallest paper size on which it is possible to print a picture of the dimensions given in milimetres. The image will be printed without margins. Input: Two integers (bigger than zero) and a letter a, b, or c, for example: 290 200 A Output: Paper size, for example: A4 Another examples: 218,297...
stackexchange_codegolf
Suppose you are given a set of non-intersecting intervals of integers [a1,b1],[a2,b2],[a3,b3],...,[aN,bN]. (Where [a,b] is the set of integers greater than or equal to a and less than or equal to b.) The interval at index X covers bX - aX + 1 values. We'll call this number cX. Given that each interval can either be... ...
stackexchange_codegolf
Challenge The goal of this challenge is to make a function that takes two paragraphs and output a concatenated result with removing the duplicated overlapped lines due to redundancy (but a single copy of the part of overlapped lines should be kept to avoid information loss). Each input paragraph is with the follows spe...
stackexchange_codegolf
Write a self replicating program, in the source code filename H.*, contianed in an empty folder then manually compile and run or just run the program if your chosen language is dynamic, and it should then just create a new source file, e.*, with the same exact source code, and automatically compile/run that new program...
stackexchange_codegolf
In North America, most electrical outlets/receptacles follow standards set by NEMA. For this challenge, you'll be given a few properties of a device you need to plug in, and your program (or function) should return all of the outlets that would be compatible. For this challenge, an outlet has three properties: voltage,...
stackexchange_codegolf
In Excel, the columns range from A-Z, AA,AB,AZ,BA,..,BZ and so on. They actually each stand for numbers, but rather are encoded as alphabet strings. In this challenge, you will be given a string of alphabets, and you must calculate the column it corresponds to. Some tests: 'A' returns 1 (meaning that it is the first c...
stackexchange_codegolf
Your challenge is to write a program that constantly prompts for input, and when input is given, output that five seconds* later. However, your program must continue prompting for input during that time. Since this is a bit confusing, here's a demo. <pre id=x></pre><input id=h onchange='var k=this;(()=>{let a=k.value...
stackexchange_codegolf
(yes, "generating generating" in the title is correct :) ) Context In middle (?) school we are taught about sequences and, in particular, we are taught about linear sequences where the nth term is generated with an expression of the form an + b, where a and b are some coefficients. In this challenge, we will deal with ...
stackexchange_codegolf
Given strings X and Y, determine whether X is a subsequence of Y. The empty string is regarded as a subsequence of every string. (E.g., '' and 'anna' are subsequences of 'banana'.) Input X, a possibly-empty case-sensitive alphanumeric string Y, a possibly-empty case-sensitive alphanumeric string Output True or False...
stackexchange_codegolf
You're writing your favorite language and you want to display the following string: abcdefghijklmnopqrstuvwxyz to your happy customer. Unfortunately, your keyboard is broken and you can now only type symbols !+-*/[](). You must submit a code that evaluates to be the string abcdefghijklmnopqrstuvwxyz or print the string...
stackexchange_codegolf
The goal here is to simply reverse a string, with one twist: Keep the capitalization in the same places. Example Input 1: Hello, Midnightas Example Output 1: SathginDim ,olleh Example Input 2: .Q Exmaple Output 2: q. Rules: Output to STDOUT, input from STDIN The winner will be picked 13th of July on GMT+3 12:00 (One...
stackexchange_codegolf
You may or may not remember Xeyes, a demo program that came with (and, as far as I know, still comes with) the X window system. Its purpose was to draw a pair of eyes that followed your mouse cursor: Your challenge is to recreate Xeyes with ASCII art. Write a program or function that draws two ASCII art eyes (specifie...
stackexchange_codegolf
Steve Ballmer is the ex-CEO of Microsoft, and in a recent article, claimed that he "still does not know what he did wrong with mobile". As CodeProject's newsletter pointed out, "That article's title could be ended at so many spots and still be accurate". Given no input, output the following: Steve Ballmer still does no...
stackexchange_codegolf
My birthday is in a month, and this is a slice of tasty cake. .-""-. .-" "-. |""--.. "-. | ""--.. "-. |""--.. ""--..\ | ""--.. | | ""--..| ""--.. | ""--.. | ""--..| In the fewest number of bytes, construct this slice of cake for me. Y...
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
Background I am currently in an AP Comp Sci A: Java class, and I want to start some of my friends on code golfing. I have a challenge from the course, and I would like to see how many bytes the community can do this challenge in. Challenge details: Given two input strings, the main string and the pivot string, do the ...
stackexchange_codegolf
Given a positive number \$n\$, find the number of alkanes with \$n\$ carbon atoms, ignoring stereoisomers; or equivalently, the number of unlabeled trees with \$n\$ nodes, such that every node has degree \$\le 4\$. This is OEIS sequence A000602. See also: Paraffins - Rosetta Code Example For \$n = 7\$, the answer is \...
stackexchange_codegolf
Given an input of a program written in oOo CODE, output the BF code that it represents. Here is a short description of how oOo CODE works: First, all non-alphabetic characters are removed (everything not in the range A-Za-z). For example, take the program PROgRam reVERsES giVeN iNPut sEqUENcE (an example given on the ...
stackexchange_codegolf