instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Given an ASCII-art shape made of the characters /\|_, your challenge is to return the number of sides it has. A side is a straight line of one of those, for example: \ \ \ / / | | | | _____ Are all sides. For example, this shape: ___ / \ /_____\ Has four sides. You can assume the input will be a single va...
stackexchange_codegolf
This question is inspired by this awesome answer. The challenge is to write a program or function which takes in a positive integer, and outputs "Happy new year to you" or a slight variation thereof, such that the character codes of that string add up to the inputted number. The space counts towards the sum of characte...
stackexchange_codegolf
LOOP This challenge is based around a modified version of the programming language LOOP. A program may be of any of the following forms: P;Q, where P and Q are subprograms Subprogram P is executed, then subprogram Q is executed. x++, where x is a variable Variable names are the letter x followed by a whole number...
stackexchange_codegolf
Morpion solitaire This is a game that I remember having learnt from my grandparents in my childhood. Initially I didn't know the name. G B has found it to be Join Five (or less ambiguously - Morpion solitaire) with a slightly different starting position. NOTE: it seems that it's kinda known and this problem formulation...
stackexchange_codegolf
Problem: Remove characters from strings to make the longest (character length) palindrome possible. The first line gives an integer value of the number of strings to test. Each subsequent line is a string to test. Example Input: 3 // Number of lines to test GGABZXVYCCDBA ABGBAD ABC Example Output: ABCCBA ABGBA B Shor...
stackexchange_codegolf
Your challenge is to write a program or function to output this sequence of numbers. Output requirements: Must contain numbers specified above Must be in order as specified Numbers must be delimited by whitespace Shortest code in bytes wins.
stackexchange_codegolf
Multiplicative Persistence Multiply all the digits in a number Repeat until you have a single digit left As explained by Numberphile: Numberphile "What's special about 277777788888899?" Numberphile "Multiplicative Persistence (extra footage)" Example 277777788888899 → 2x7x7x7x7x7x7x8x8x8x8x8x8x9x9 = 4996238671872 ...
stackexchange_codegolf
When writing a programm 1 missing character can ruin everything, wouldn't it be great if the programm told you what was missing ? Task: Create any (non Empty) programm, that takes no input and outputs nothing. That when 1 Character is removed from the programm, outputs that Character. Input: None Output: Output nothing...
stackexchange_codegolf
This is a rock: * Rocks can be stacked. Apart from the bottom-most layer, each rock must rest on two other rocks, like this: * * * You have a pile of rocks, and your boss wants you to pile them symmetrically, taking up the least horizontal space possible. Your challenge is to take a number of rocks as input, and out...
stackexchange_codegolf
(2 Jan 2018) Because of the winning criteria I am going to accept the Jelly answer, but I am also giving upvotes to all other answers which all use astounding methods as well Introduction There are lots of challenges asking for a shortest program to calculate mathematical constants. I saw some with restrictions like ba...
stackexchange_codegolf
Setup: For two sets \$A,B\$, we say \$A \subseteq B\$ if every element in \$A\$ is also in \$B\$. Another way of saying this, is that we can order the elements of \$A,B\$ into two lists \$L_A,L_B\$, such that \$L_A[i] = L_B[i]\$ where \$i\$ ranges over the indices of \$L_A\$. We proceed to extend this idea, to define ...
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
Task Any one of these two: Determine if a given position (an ordered non-empty collection of integers in the range ‒8 to 8, or ‒7 to 7 if you want) is a valid Dimensional Chess position. List all the valid positions in any order. Make sure to describe your input (if not listing all) and output formats. The 2368 vali...
stackexchange_codegolf
Once upon a time long long ago... when there was no money or stocks yet, people were trading sheep. Even before (but close to) the invention of abacus, the great-grandfather of Warren Buffet decided it was hard to keep track of sheep. He wanted to collect all his belongings and clear all his debt, so that he could inve...
stackexchange_codegolf
Given a multi-line string as input containing characters "|", "_" and " " (space), count the number of cells it contains. A cell is the following structure of 3 characters by 2 lines: _ |_| That is, an underscore on one line (the characters to its right and left don’t matter), and "|_|" right below it. Two cells can ...
stackexchange_codegolf
The Meeker numbers are a 7 digit number in form of \$abcdefg\$, where \$a×b=10c+d\$ and \$d×e=10f+g\$. As an example \$6742612\$ is a meeker number, here \$6×7=10×4+2\$ and \$2×6=10×1+2\$, so it is a meeker number. Additionally, a Meeker number does not have any leading zeros (so \$a \ne 0\$) The Challenge Your program...
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
Task For a given base \$n \ge 3\$, find the smallest positive integer \$m\$, when written in base \$n\$ and rotated right once, equals \$2m\$. The base-\$n\$ representation of \$m\$ cannot have leading zeroes. The corresponding OEIS sequence is A087502, and its base-\$n\$ representation is A158877 (this one stops at \$...
stackexchange_codegolf
Make a plot (Poincare disk) of a tessellation on a hyperbolic plane, such as: The program takes four inputs: 1) How many edges/polygon (three in this example). 2) How many intersect at each vertex (seven in this example). 3) How many steps away from the center vertex to render (5 in this example, if you look closely)....
stackexchange_codegolf
Write a program or function that takes in a nonempty list of integers in any reasonable convenient format such as 4, 0, -1, -6, 2 or [4 0 -1 -6 2]. Print or return a string that depicts the list as an ASCII art forest where each number becomes a tree of proportional height. Each tree takes up four columns of text in t...
stackexchange_codegolf
Snaking Number Challenge I wonder how many snaking numbers there are between 1 and 50,000? Snaking Numbers, in this game, are numbers which can be typed out on a traditional numberpad (format below) by moving one key up, down, left, or right. 7 8 9 4 5 6 1 2 3 0 For example, if you start with the number 5, you could...
stackexchange_codegolf
Monday Mini-Golf: A series of short code-golf challenges, posted (hopefully!) every Monday. (Sorry this one's a little late.) I'm sure most of you folks have heard of Levenshtein distance, an algorithm for calculating the distance between two strings. Well, this challenge is about implementing a similar algorithm of my...
stackexchange_codegolf
Every phone needs a calculator app. Because of the limited screen real estate, the developer of mine has decided to save some buttons. Instead of having two dedicated bracket buttons - one for open ( and one for close ) - there is just a single bracket button (). It looks something like this: When the button is presse...
stackexchange_codegolf
Perhaps something like this is here already, but I couldn't find it. It is not the same as Aligning Lines!. Example: Input: 98.6 $2,750.17 -$23 -86 3,120,487.19 Output: 98.6 $2,750.17 -$23 -86 3,120,487.19 Note that .6 isn't right-padded to .60 or .6 . Input: A list/array of strings (or lines fr...
stackexchange_codegolf
Inspired by the Lego gear ratios challenge by Keith Randall. I, too, plan on building a giant lego robot that will eventually be able to destroy the other robots in the never-before-mentioned competition.* In the process of constructing the robot, I will be using a lot of gear trains to connect different parts of the r...
stackexchange_codegolf
Note: This challenge has nothing to do with actual assembly language. As the head of Code-Golf Factory Inc., you must create an assembly line to generate a specific piece of code. Today, the foreman has asked you to produce quines. Specification: In this challenge, the goal is to write a quine such that a proper subse...
stackexchange_codegolf
Title says it all. Two input 32-bit positive integers m, n >= 2, output gcd(m,n) in prime factorization form. Input Command line args or 1 line of stdin okay, whatever's better for golf. Output Single space delimited with exponents (no additional spaces). Output nothing if the inputs are relatively prime. Examples: $ ....
stackexchange_codegolf
Challenge Display to the screen or write to stdout this exactly: ** ** **** **** **** **** **** **** **** ********** ********** ********** Winning This is code-golf, so the shortest submission (in bytes) wins.
stackexchange_codegolf
Make a fake loader just like this : Parameters : Display loading (space) one of these cyclically-\|/ (space) (percentage counter from 0-100) then a %. The percentage counter is supposed to increment by 1 every time the display changes. The time taken by counter to jump to next iteration is random. Any kind of ra...
stackexchange_codegolf
A Shift matrix is a binary matrix with one superdiagonal or subdiagonal formed by only ones, everything else is a zero. A superdiagonal/subdiagonal is a diagonal parallel to the main diagonal, which is not the main diagonal, i.e. all entries \$a_{ij}\$ where \$i=j+k\$ and \$k \neq 0\$. The main diagonal is defined to b...
stackexchange_codegolf
The Challenge Given two vertexes and a point calculate the distance to the line segment defined by those points. This can be calculated with the following psudocode def dist(point, v1, v2): direction := normalize(v2-v1) distance := length(v2-v1) difference := point - v1 pointProgress ...
stackexchange_codegolf
This is my first question in Code golf I found it in stack-overflow (originally in JavaScript however all languages are acceptable): Render on screen NxN (where N in range 1-16) grid where each cell have black boundary and red number inside - cells are numerated in hex starting from left-upper corner to bottom-right. E...
stackexchange_codegolf
The derivative of a function is a cornerstone of mathematics, engineering, physics, biology, chemistry, and a large number of other sciences as well. Today we're going to be calculating something only tangentially related: the arithmetic derivative. Definition The arithmetic derivative a(n) or n' is defined here (A0034...
stackexchange_codegolf
Task Inputs \$b \leq 100\$ and \$n \geq 2\$. Consider \$n\$ binary strings, each of length \$b\$ sampled uniformly and independently. We would like to compute the expected minimum Hamming distance between any pair. If \$n = 2\$ the answer is always \$b/2\$. Correctness Your code should ideally be within \$\pm0.5\$ o...
stackexchange_codegolf
I'm honestly surprised that this hasn't been done already. If you can find an existing thread, by all means mark this as a duplicate or let me know. Input Your input is in the form of any positive integer greater than or equal to 1. Output You must output the sum of all integers between and including 1 and the number i...
stackexchange_codegolf
The challenge Insert one string into another at a given index. Given a string input in the format: #:Pattern:Word Where: # is a positive integer marking the index Pattern is the string (whose length is undefined) to insert : is a delimiter Word is the string to insert into. Assume that a : will not be used in either...
stackexchange_codegolf
Fairy Chess is a sort of generalized chess that allows unconventional pieces. The eight queens puzzle is a classic problem where you have to put 8 queens on a chess board such that no two queens threaten each other. This challenge is sort of a generalized combination of the two. Challenge Given a list of fairy chess pi...
stackexchange_codegolf
Challenge Write a program that takes as input a text and output "That's me!" if the input is equal to the program own source code, and "That's not me!" otherwise. Notes This is codegolf, in each programming language the shortest program wins. The input can be taken from program arguments or function argument, and the ...
stackexchange_codegolf
Introduction As is known, in 2017, Finland celebrates its 100 years of independence. To mark the occasion, it is your job to produce a Finnish flag for everyone's enjoyment. Challenge Create a program or a function that produces the flag of Finland (the grey border is there for presentation purposes only): Flag specif...
stackexchange_codegolf
A field in mathematics is a set of numbers, with addition and multiplication operations defined on it, such that they satisfy certain axioms (described in Wikipedia; see also below). A finite field can have pn elements, where p is a prime number, and n is a natural number. In this challenge, let's take p = 2 and n = 8,...
stackexchange_codegolf
Consider the problem of N queen on an (NxN) chessboard. Two queens are said to attack each other if they are on the same row, column, or diagonal. Implements backtracking algorithm to solve the problem i.e. place N non-attacking queens on the board.
stackexchange_codegolf
This is my pet emoji, Billy: -_- Emojis don't like to be in the rain, so Billy is sad... Let's draw him an umbrella to make him feel better! /\ / \ / \ -_- This is good, he is entirely covered by his umbrella! Here is an example where only part of him is covered: /\ / \ / \ -_- In this case, s...
stackexchange_codegolf
quintopia has posted here a challenge to compute multinomial coefficients (some of the text here is copied from there). There is a fun algorithm to compute multinomial coefficients mod 2. Given a list of numbers, k1, k2, ... ,km, output the residue of the multinomial coefficient: reduced mod 2. The following algorith...
stackexchange_codegolf
If you cannot see this post, you can use this image Your task is to create a markdown parser that outputs Unicode. It should support , , , and ̲̲̲̲̲̲̲̲̲. Every alphabetical character should be converted into Math Sans. This includes the characters before an underline character. Underlines: Add a ̲ character (code point...
stackexchange_codegolf
In this task you will take as input a non-negative integer \$n\$, and output the number of pairs of non-negative integers \$a,b\$ such that both are palindromes*, \$a \leq b\$, and \$a+b = n\$. For example if \$n\$ is \$22\$ then the valid pairs are \$ \begin{array}{c|c} a & b \\ \hline 0 & 22 \\ 11 & 11 \\ \end{arra...
stackexchange_codegolf
Task The task is to write a script that accepts a number from 1 to 20 inclusive. It will then check if the number has a character that is found in every number that was entered before it. If the number has a character in common it will ask for another number. However if the number does not have a character in common wi...
stackexchange_codegolf
Yesterday I asked this question about riffle shuffles. It seems that yesterdays question was a bit too hard so this question is a related but much easier task. Today you are asked to determine if a permutation is in fact a riffle shuffle. Our definition of riffle shuffle is adapted from our last question: The first ...
stackexchange_codegolf
Challenge: Given an expressions made of additions and multiplications, output an expression that is a sum of products. The output must be equivalent to the input modulo the law of distribution. For example, \$1 + ((2 + 5\times 6) \times(3+4))\$ becomes \$1 + 2 \times 3 + 2 \times 4 + 5\times6\times3 + 5 \times 6 \times...
stackexchange_codegolf
Challenge Create the image of a pride flag (rainbow flag), i.e. a six coloured striped flag (from top to bottom): red, orange, yellow, green, blue, and violet. Output Example (R) barplot(rep(1, 6), horiz = TRUE, axes = FALSE, space = 0, border = NA, col = c("darkviolet", "blue", "darkgreen", "yellow", "orange", "red")...
stackexchange_codegolf
Problem Consider a square 3 by 3 grid of non-negative integers. For each row i the sum of the integers is set to be r_i. Similarly for each column j the sum of integers in that column is set to be c_j. The task is to write code to enumerate all possible different assignments of integers to the grid given the row a...
stackexchange_codegolf
Based on the "Pretty Ugly" poem. Input consists of a number of stanzas (positive integer), and four arrays/lists of strings, called the "negatives", "negations", "positives", and "filler" sentences. You must output a "pretty ugly" poem with the specified number of stanzas. A stanza consists of a negative, negation, pos...
stackexchange_codegolf
The lack of a social life drove a poor nerd into inventing another superfluous esolang called !+~%. For no good reason it initializes the accumulator with 6 and knows the following commands: ! (out(Accu); Accu = 6) prints the accumulator value as decimal string to stdout (without newline) and resets the accumulator to...
stackexchange_codegolf
Write a program/function that finds the amount of fuel needed to escape Earth's gravity well given the exhaust velocity of the fuel and the amount of mass to transport using the Tsiolkovsky rocket equation: $$\Delta v = v_\text{exhaust}\ln\dfrac{m_\text{start}}{m_\text{end}}$$ where \$\Delta v\$ is the change in veloc...
stackexchange_codegolf
Sometimes I see a claim like "80% of respondents agreed" and I think "what was your sample size? 5?" because, of course, with a sample size of 5 it's possible to get 80% to agree on something. If the claim is "47% of respondents agreed" then I know it must be a larger sample size.[1] challenge Given a positive integer ...
stackexchange_codegolf
Introduction You're a criminal tasked with stealing some secret plans from the new tech startup Dejavu. You sneak in over the back wall, but find a door that requires a pin to open it. You recognize the make of the lock and know that it takes a 5 digit pin using all numbers from 0 to 4. After each digit entered, the lo...
stackexchange_codegolf
Every integer can be expressed in powers of 2. You know this as the binary system Assume you are given a set of k numbers (0 < k < 2^n). You want to decide for this set whether every integer power of 2 up to 2^(n-1) occurs at least m times One example: n = 7 (2^n = 128, ) k = 5 set = {100, 91, 88, 63, 44} m = 3 Solut...
stackexchange_codegolf
A venerated pass time of pedants is to point out that pictures of "Rubik's Cubes" (on t-shirts, posters etc.) are not actually solvable. The first thing that should be checked is that the cube is made up of the right pieces. To be solvable a cube needs six colors each with nine squares. The cube also needs each edge ...
stackexchange_codegolf
Challenge Your task is to write a program which, once a second (including immediately when your program is started), prints the elapsed time from the time your program was started. Rules Time must be printed in hh:mm:ss format. (leading zeros for single-digit values) The time stamps must be separated by CR, LF, or CRL...
stackexchange_codegolf
Your task is to write a program that calculates the amount of different ways to display any given whole positive number using the following rules: Meet the 'advanced binary system': Any whole positive number can be displayed in binary form, but each bit can have every number from 0 to 9. This means, a valid number migh...
stackexchange_codegolf
Given a list of positive integers such as [69, 420], your challenge is to generate the sequence of numbers that can be formed by concatenating numbers from the above set, in ascending numerical order. For example, with [69, 420] the sequence begins: 69 420 6969 42069 69420 420420 Note that elements of the sequence sho...
stackexchange_codegolf
You're with your best bud, Jim, at the amusement park and as your favorite ride comes into view, you and Jim exchange glances. Naturally you race to get in line. Unfortunately he wins because you're a golfer and he plays a real sport (sorry friends). In fact, you're so far behind that you and Jim are separated by x peo...
stackexchange_codegolf
Balanced binary search trees are essential to guarantee O(log n) lookups (or similar operations). In a dynamic environment where a lot of keys are randomly inserted and/or deleted, trees might degenerate to linked lists which are horrible for lookups. Thus there are various kinds of self-balancing binary trees that cou...
stackexchange_codegolf
Specifications Your program must can take in an integer n, then take in n more strings (containing only alphanumeric characters) in your preferred method (separated by whitespace, file input, hash table etc.). You must then find the permutation before the inputted strings when sorted in lexicographical order, and outpu...
stackexchange_codegolf
You have to write a function/program that takes input via the stdin/command-line arguments/function arguments, mixes up characters in a string, and then output the final string via the stdout. Input will first contain a string (not empty or null), a space, and then an even number of non-negative numbers all separated b...
stackexchange_codegolf
In the original Shantae game, there are transformation dances that you have to input in time using the D-Pad, A, and B. If you complete a predefined sequence while dancing, you will transform into the corresponding form (or teleport or heal). Your task is to output the corresponding effect when given an input. The catc...
stackexchange_codegolf
Given a start word and a target word, print the "mutation chain" that starts at the start word and ends at the target word. You may assume both words are lowercase and only have alphabetic characters. Define a "mutation" as the removal of an character, the insertion of a character, or the altering of a character. For e...
stackexchange_codegolf
This is a Cops and Robbers challenge. This is the robber's thread. The cop's thread is here. The cops will pick any sequence from the OEIS, and write a program p that prints the first integer from that sequence. They will also find some string s. If you insert s somewhere into p, this program must print the second inte...
stackexchange_codegolf
The task In this challenge, your task is to write a program in a programming language L that takes a positive integer n, and outputs the sum of the proper divisors of n (sequence A001065 on OEIS). It should return the correct output for any 1 ≤ n ≤ 10 000. Here are the first 10 outputs: 0, 1, 1, 3, 1, 6, 1, 7, 4, 8 Fu...
stackexchange_codegolf
I feel tired to do "find the pattern" exercise such as 1 2 3 4 (5) 1 2 4 8 (16) 1 2 3 5 8 (13) Please write a program that finds the pattern for me. Here, we define the pattern as a recurrence relation that fits the given input, with the smallest score. If there are multiple answers with the same smallest score, using...
stackexchange_codegolf
JavaScript has no direct support for keyword arguments, but it supports argument object destructuring. It is standard to use a destructed final argument for keyword arguments. Here is an example: function f(x, { a = 7, b = 2}){ return [x, a, b]; } You would then call this function like: f(9, {}); // ==> [9, 7, 2] ...
stackexchange_codegolf
A "qruine" if you will :) Design a QR code that legibly spells with its pixels (or the space between them) the text that it scans to. For example, this QR code scans to the letter A, and also spells out A in white: There are 4 categories, one for each mode of QR code: numeric, alphanumeric, byte, and kanji. Please sta...
stackexchange_codegolf
Task Given a finite permutation output its inverse. You may take input and output in any reasonable format equivalent to a list of natural numbers. You may choose to use 0 indexing or 1 indexing. Your input and output format should be the same. You may assume a permutation has at least 1 element. This is code-golf so...
stackexchange_codegolf
It's the ending of another well played chess game. You're the white player, and you still have a rook and your king. Your opponent only has his king left. Since you're white, it's your turn. Create a program to play this chess match. Its output can be a sequence of moves, a gif animation, ASCII art or whatever you like...
stackexchange_codegolf
What is the shortest regular expression (REGEX) you can create for file extensions for all of the following image file formats (photographs, paintings, sketches, and drawings)? .ACAD .AFD .AFP .AOM .AOMA .APNG .ASCII .AVIF .AVIFAV .BMP .BPG .CABAC .CDEC .CDR .CDRAW .CGM .CHEVC .CIEC .CIPA .CMYK .COLLADA .CRT .CWC .DEEP...
stackexchange_codegolf
Challenge: Given two inputs, x and y, round x to one less significant figure, then repeat until it has y number of unrounded digits left. (the decimal point does not count as a digit) Input & Output Input can be a combination of strings and integers, e.g. you can have the input as a string and the output as an int, o...
stackexchange_codegolf
Input: An integer \$n\$, which is guaranteed to be \$\ge3\$. An integer \$d\$, which is one of \$[-1,0,1]\$. Output: A road of size \$n\$, which will be in a north-west direction if \$d=-1\$; a north direction if \$d=0\$; or a north-east direction if \$d=1\$. The road will always be three spaces wide (or five in gene...
stackexchange_codegolf
In this challenge, your task is to detect (vertical) Skewer Symmetry. This means that one half of the pattern can be produced by mirroring the other half along a vertical axis, and then moving it vertically. For example, the following pattern has skewer symmetry: asdf jkl;fdsa ;lkj Because if you start from th...
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
A fun pair of equivalences is 1 + 5 = 2 · 3 and 1 · 5 = 2 + 3. There are many like these, another one is 1 + 1 + 8 = 1 · 2 · 5 and 1 · 1 · 8 = 1 + 2 + 5. In general a product of n positive integers equals a sum of n positive integers, and vice versa. In this challenge you must generate all such combinations of positive...
stackexchange_codegolf
The computational parity of an integer is defined as 1 if the integer has an odd number of set bits, and 0 otherwise. (src). Input You will receive one nonnegative integer that you will take the parity of. Optionally, you may take the size of the integer in bytes or bits as an argument, but you must specify this in yo...
stackexchange_codegolf
In this challenge we are going to consider lists of integers such that for every member \$x\$ at index \$i\$ then the indexes \$i+x\$ and \$i-x\$ have the value \$x+1\$ or are out of bounds for the list. We will call these trampoline lists. If we play around with these for a while we can notice that if we start a list...
stackexchange_codegolf
I came across this picture the other day: (Credit to Josep M Batlle I Ferrer) Your job is to generate this picture. This graph is generated by repeatedly applying newton's method to the graph of: $$f(x)=\cosh(x)-1$$ In other words, repeatedly apply the following function to every point till the rectangular distance is...
stackexchange_codegolf
Specification This challenge is simple to state: your input is a non-empty array of nonnegative integers, and your task is to partition it into as few substrings as possible, such that each substring is a permutation of a consecutive integer range. More formally, if the input array is A, then the output is minimum numb...
stackexchange_codegolf
The event scheduler is a recurrent theme in event-driven architectures: something triggers an event that needs to be checked in the future one or more times. I has particular use in trading where you want to correlate one market event with price movements in the future at several time deltas (1ms, 100ms, 1s, 1 min, etc...
stackexchange_codegolf
'exaggerated' is an example of a word which can be typed on the left hand, on a normal qwerty keyboard map. 'monopoly' is an example for the right hand. Searching the unix words file for words that can be typed on one hand. Output should be two lines: space separated list of such words for the left hand, followed ...
stackexchange_codegolf
This sequence is defined as Starts with 1, 2, 3 The next element of the sequence is the first number greater than the previous three that is co-prime with each of the previous 3 elements in the sequence. In other words, if the previous 3 elements are a, b, c, then the next is the first integer n>c such that gcd(a,n)=...
stackexchange_codegolf
Background A staircase polyomino is a polyomino made of unit squares whose shape resembles a staircase. More formally, a staircase polyomino of size \$n\$ is defined as follows: A staircase polyomino of size 1 is a single unit square. A staircase polyomino of size \$n\$ is the same as that of size \$n-1\$ with a horiz...
stackexchange_codegolf
Write a program that, for any \$n\$, generates a triangle made of hexagons as shown, \$2^n\$ to a side. The colors are to be determined as follows. We may give the triangle barycentric coordinates so that every hexagon is described by a triple \$(x,y,z)\$ with \$x+y+z=2^n-1\$. (The three corners will be \$(2^n-1,0,0)\$...
stackexchange_codegolf
Your program / function, etc. will take 2 inputs. The first will be a list of who came to my party and when. Example: Kevin 13:02 Ruby 5 Sam 3 Lisa 6 Bob 12 What does that mean? It means that Kevin got to my party first (at 13:02, 24-hour time), then Ruby 5 minutes later, then Sam 3 minutes later, then Lisa ...
stackexchange_codegolf
I noticed that there's no such question, so here it is: Do you have general tips for golfing in x86/x64 machine code? If the tip only applies to a certain environment or calling convention, please specify that in your answer. Please only one tip per answer (see here).
stackexchange_codegolf
I am trying to write a solution to the following problem using as few characters as possible (to meme my friend and introduce him to golfing). Can any improvements be done to my code? So the problem requires us to write a function called navigate in Python 3.6 (language of the judge, sorry, no walruses) that takes two ...
stackexchange_codegolf
In one of this question's bonuses I asked you to design a permutation on the natural numbers such that the probability of a random term being odd was \$1\$. Now let's kick it up a notch. I want you to design and implement a permutation, \$f\$, on the natural numbers such that, for every integer \$n\$ greater than 0,...
stackexchange_codegolf
Challenge Given an integer \$Q\$ in the range \$-2^{100} ≤ Q ≤ 2^{100}\$, output the number of digits in that number (in base 10). Rules Yes, you may take the number as a string and find its length. All mathematical functions are allowed. You may take input in any base, but the output must be the length of the number i...
stackexchange_codegolf
Let \$n=42\$ (Input) Then divisors are : 1, 2, 3, 6, 7, 14, 21, 42 Squaring each divisor : 1, 4, 9, 36, 49, 196, 441, 1764 Taking sum (adding) : 2500 Since \$50\times 50=2500\$ therefore we return a truthy value. If it is not a perfect square, return a falsy value. Examples : 42 ---> true 1 ---> true 246 ---> true 1...
stackexchange_codegolf
English is such an inefficient language. We've got enormous words when there are plenty of two or three letter words we never used! As computer scientists, every keystroke matters. We need to be more efficient. Just think of how many words we could have had! In fact, don't think about it, tell me. Given a string (or li...
stackexchange_codegolf
Task: With the minimum amount of bytes, determine today's Zodiac sign using the programming language of your choice. Rules: This is code golf, the answer with the fewest characters wins. The initialization of getting the current date into a variable (e.g. var now = new Date();) does not add to the count. Leap years mu...
stackexchange_codegolf
It's annoying when you have to search for a language homepage, get its link, and add it to your SE comment/answer, right? Let's write a script to do that for you! Challenge For each language name (intentional or not) in the input, replace it with the markdown link to the language home page, defined by TIO. Rules (impo...
stackexchange_codegolf
Task A reverse checkers position is a chess position where every piece for one player is on one colour and every piece for the other player is on the other colour. Your task is to find if the given (valid) position meets these criteria. For example, this position does (click for larger images). Every white piece is on ...
stackexchange_codegolf
Shamir's secret sharing scheme is a simple way of protecting a secret by splitting it into several parts needed to reconstruct it. Your task is to implement Shamir's Secret Sharing reconstruction over the Finite Field defined by the prime 1928049029. If you have any doubts about what this means, just ask or see Finite ...
stackexchange_codegolf
Figuring out whether a given number is prime, while not very complicated, is kind of hard. But making a guess doesn't need to be. Seeing whether a number is a multiple of 2 or 5 is easy - you can just look at the last digit. Multiples of 3 isn't much harder, just add up the digits and see if you end up with a multiple ...
stackexchange_codegolf