instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Overview I was playing with Desmos and discovered a really cool spiral: Doing some research, I discovered that this spiral was the Archimedian spiral. Every point on the spiral is exactly \$\theta\$ away from the origin, where \$\theta\$ is the angle from the origin. That is, any point on the spiral has the polar coo...
stackexchange_codegolf
Thank you for you help fixing my calculator's multiply function, but I've found another critical error all calculators seem to share. None of them understand that 2+2=fish. So now I need code to properly add 2 numbers. Challenge Take 2 numbers as input (Type doesn't matter, but only 2 items will be passed. This is add...
stackexchange_codegolf
This puzzle is based on this Math.SE post. A more complex version of this problem can be found over here. Assume I have some number of black shirts and some number of white shirts, both at least 1. Both colors of shirt have a non-zero durability. All shirts of a given color start with the same durability. Every day, I ...
stackexchange_codegolf
The day this post was published was Christmas Eve. Tomorrow will be Christmas. Yesterday was Christmas Eve Eve. In two days it will be Christmas Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Ev...
stackexchange_codegolf
Y'know, we've had a lot of "alphabet" challenges recently. (one two three four five.) While I love a good challenge, and those challenges were very fun, I think it's time for a change of pace. We need to exclude such challenges in the future. It's time for automation! You're going to find some alphabets for me, and for...
stackexchange_codegolf
A minifloat is a binary representation of a floating-point number that has very few bits. The minifloat in this question will be defined as an 6-bit number m, which has the following representation: 1 bit to repesent the sign of the number. This bit will be 0 if the number is positive, and 1 if the number is negative....
stackexchange_codegolf
As most of you probably know, (byte-addressable) hardware memories can be divided into two categories - little-endian and big-endian. In little-endian memories the bytes are numbered starting with 0 at the little (least significant) end and in big-endian ones the other way round. Fun fact: These terms are based on Jon...
stackexchange_codegolf
Given a positive integer n, output the smallest base b >= 2 where the representation of n in base b with no leading zeroes does not contain a 0. You may assume that b <= 256 for all inputs. Test Cases 1 -> 2 (1) 2 -> 3 (2) 3 -> 2 (11) 4 -> 3 (11) 5 -> 3 (12) 6 -> 4 (12) 7 -> 2 (111) 10 -> 4 (22) 17 -> 3 (122) 20 -> 6 (...
stackexchange_codegolf
Given the input of n and value. The code is supposed to nest the single element list with value repeated n times. The final output should be a multilevel nested list with single repeated values in all sublists. This is code-golf, so the shortest code in bytes wins! Test cases: n = 1, value = 'a': ['a'] n = 2, value = '...
stackexchange_codegolf
Write a program that does one step of the computation of factorial, then, generate (quine) a new program, and performs the rest of the process in the new program The seed and spawned programs will have a variable n for the factorial to be computed and m for the accumulator. I don't care if you use scripted or compiled ...
stackexchange_codegolf
In this challenge, you'll take an answer as input, and print the answer before it. If the answer passed as input is the first answer, print your own submission's source. You'll be passed any answer in the chain up to and including your own answer, but none after it in the chain. For example, if the first submission is ...
stackexchange_codegolf
This is a somewhat proof-golf-like cops-and-robbers challenge. This is the cops' thread; the robbers' thread is here. Cops Your task is to define an abstract rewriting system in which the reachability of one word from another is difficult to determine. You will prepare the following things: A set of symbols, called th...
stackexchange_codegolf
(randomly inspired by this question) Let's make a drawing from some pipes | and hyphens -. Choosing a subset, if chosen carefully, you can form a rectangular box or block shape (meaning that the corners are formed by |- or -|). For this challenge, we're concerned only with identifying the corners -- the vertical and ho...
stackexchange_codegolf
Today I installed MonoGame and ran the test application, which creates a basic colored window. I was surprised to see that the process was using 32.2 MiB of memory, and I thought it could be improved. Your challenge is to write a program that creates a 640 by 480 window displaying only black pixels. Whatever program u...
stackexchange_codegolf
The Pi function is an extension of the factorial over the reals (or even complex numbers). For integers n, Π(n) = n!, but to get a definition over the reals we define it using an integral: In this challenge we will invert the Π function. Given a real number z ≥ 1, find positive x such that Π(x) = z. Your answer must b...
stackexchange_codegolf
Pyth is a golfing language based on Python. It uses prefix notation, with each command having a different arity (number of arguments it accepts). Your task is to write a syntax checker for a (non-existent) Pyth-like language, Pith. Pith's syntax Pith only has 8 single-char commands: 01234()" 01234 each have arity of t...
stackexchange_codegolf
Given a set of vectors all of the same positive finite dimension, output a falsey value if they are linearly dependent and a truthy value if they are linearly independent. A set of vectors v1, v2, ... is linearly dependent if for some scalars a1, a2, ... not all equal to 0, a1v1 + a2v2 + ... = 0. (0 is the zero vector...
stackexchange_codegolf
In this challenge you will be simulating a frog jumping from lily-pad to lily-pad in a pond. A frog's jump distance is uniquely determined by the size of the lily pad it jumps from. So for example there are lily-pads that let a frog jump 1 unit, lily-pads that let a frog jump 2 units etc. A frog can never jump more ...
stackexchange_codegolf
Given a string which is guaranteed to be either odd, even, square, cube, prime or composite, your program or function must return an integer \$100\le N\le 999\$ which meets this description. Rules Your code must be deterministic. The choice of the integers is up to you. However, the six answers must be distinct. (For ...
stackexchange_codegolf
Related, related Introduction The ruler sequence is the sequence of the largest possible numbers \$a_n\$ such that \$2^{a_n}\mid n\$. It is so-called because its pin plot looks similar to a ruler's markings: However, with a slight modification, we can also get a similar sequence. This sequence is \$\{a_1,a_2,a_3,…\}\$...
stackexchange_codegolf
This challenge was inspired by this non-challenge about the natural logarithm base \$e\$ and the following pandigital approximation to \$e\$ appearing on a Math Magic page: $$\left|(1+9^{-4^{7×6}})^{3^{2^{85}}}-e\right|$$ $$\approx2.01×10^{-18457734525360901453873570}$$ It is fairly well-known that $$e=\lim_{n\to\infty...
stackexchange_codegolf
A mortality table or life table is an actuarial tool that gives the probability that a person aged \$A\$ years will die in the next year, and is used to help calculate the premiums for life insurance, among other things. One of the first people to compile a life table was Edmond Halley, of cometary fame. These probabi...
stackexchange_codegolf
The well known cat command simply copies its stdin directly to stdout unchanged. But there are plenty of other commandline tools that exist... What other commands can be used to duplicate the functionality of the venerable cat? Rules You are not allowed to use any shell features, including pipes, file redirection, var...
stackexchange_codegolf
This is the inverse of negative seven's question. Write a program or function which, given any single, possibly-empty string of printable ASCII (codes \$[32,126]\$) outputs or returns two strings of printable ASCII. For any two ordered, possibly empty strings \$s_1\$ and \$s_2\$, there must be third string \$s_0\$, whi...
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
You are to create a program which, when given a positive integer \$n\$, outputs a second program. This second program, when run, must take a second positive integer \$x\$ and output one of two distinct values depending on whether \$x\$ is divisible by \$n\$. Those values must be consistent for a given \$n\$ but can be ...
stackexchange_codegolf
The Challenge A bubble sort takes a list of non-repeating integers and sorts them in ascending order, with only the use of one operation: switching two numbers which are next to eachother. However for this puzzle, you must take in two strings, which are both anagrams, and bubble sort the letters of the first string int...
stackexchange_codegolf
Task Write a function or a program to find the number of rotations required by a wheel to travel a given distance, given its radius. Rules Input can be 2 positive rational numbers and can be taken in any convenient format. Both inputs are of same unit. There must not be any digits 0-9 in your code. The output will be a...
stackexchange_codegolf
There is a rectangular 2D array containing viruses denoted by 'v', antidote1 denoted by 'a', and antidote2 denoted by 'b' (there are no values other than 'v', 'a' and 'b'). Antidote1 can kill neighboring viruses in horizontal and vertical directions only, but antidote2 can kill neighboring(if any) viruses in horizontal...
stackexchange_codegolf
Given a string s composed of lowercase letters, such as aabaaababbbbaaba and a positive integer n, such as 4, output a length-n string t such that when t is repeated to the length of s, they have as many chars in common as possible. For the given example, the optimal output would be aaba, because it has thirteen chars...
stackexchange_codegolf
m|Y bR|ain is We|iRd. F(o)R T(h)E La|sT fi(v)e YE|ars O|R s|o, (I) ha|ve C(u)T wO|rds in h(a)lf wh|En (I) s(e)e Th|em. Wh|EN I started Do|ing it, it To|oK a meN|TaL effort - B(u)T I almost cou(l)dn't N(o)T d|o it. N(o)w, I d|o it in the back of my head, a(n)d hardly ev|en not|iCe it. However, I thought this wo|uld make...
stackexchange_codegolf
Welcome to the piNapple bar, Melbourne. All of the finest code golfers are here, with their laptops, sampling cocktails and programming increasingly badly. I feel a special need to reemphasise the last point. Increasingly badly. Alcohol can do funny things to programming logic. So - a few of the Golfers were attempting...
stackexchange_codegolf
I forgot towel day Sandbox link PHP script for both examples (error, formatting the string) Corrected php script, the input is self explanatory PHP script with more input comment/uncomment $argv to see different results As you may know, May 25 is well known as Towel Day, because of the many uses a towel can have. A si...
stackexchange_codegolf
The Sequence Everyone knows the only even prime number is 2. Ho-hum. But, there are certain even numbers n where, when concatenated with n-1, they become a prime number. For starters, 1 isn't in the list, because 10 isn't prime. Similarly with 2 (21), and 3 (32). However, 4 works because 43 is prime, so it's the first ...
stackexchange_codegolf
Given a word (or any sequence of letters) as input, you must interpolate between each letter such that each adjacent pair of letters in the result is also adjacent on a QWERTY keyboard, as if you typed the input by walking on a giant keyboard. For example, 'yes' might become 'ytres', 'cat' might become 'cxzawert'. Rule...
stackexchange_codegolf
Compute, O friend, the number of the cattle of the sun which once grazed upon the plains of Sicily, divided according to color into four herds, one milk-white, one black, one dappled and one yellow. The number of bulls is greater than the number of cows, and the relations between them are as follows: White bulls \$=...
stackexchange_codegolf
Generative AI is here! It's great for certain things, but it has a few problems. Not only has it broken our Stack Exchange community, it also makes mistakes. For example, when you ask Bing AI if it is sentient, Bing says (credits to GPT Gone Wild) Your job is to print that text exactly. More specifically, Take no inp...
stackexchange_codegolf
Entries are now closed. Any new entries or edits will not be counted in the final run. Join the chat! Challenge Try to fill the canvas with as much paint as possible. Be careful of other bots that may paint over your hard work though! Note: In this challenge description, paint means to change the colour of the squar...
stackexchange_codegolf
GPA Calculator (GPA = Grade Point Average) You are a stressed out college student during finals week. Instead of studying for your exams coming up, you decide it is best to determine what GPA you will have at the end of the semester. This way you have data to back up your decision of staying up all night to get that A ...
stackexchange_codegolf
I am looking for tips to code in this golfing language Seriously, and was wondering what some of the ways for golfing this language is. "Remove comments" is not a tip. Actually is also included
stackexchange_codegolf
Backstory If you visit the Steward Badge Page, you will see no one has received one of these badges from PPCG yet. However, there are two users: DJMcMayhem & Martin Ender, that are only a few reviews away from this badge! Challenge Your challenge is to write a program or function that when run outputs DJMcMayhem's revi...
stackexchange_codegolf
The primorial \$p_n\#\$ is the product of the first \$n\$ primes. The sequence begins \$2, 6, 30, 210, 2310\$. A Fortunate number, \$F_n\$, is the smallest integer \$m > 1\$ such that \$p_n\# + m\$ is prime. For example \$F_7 = 19\$ as: $$p_7\# = 2\times3\times5\times7\times11\times13\times17 = 510510$$ Adding each num...
stackexchange_codegolf
Consider a finite, one-dimensional grid where each cell is marked with one of two symbols (I will use the symbols < and >, but you can use other symbols). When a pinball is placed on one of the cells, it moves according to the following rules: If the pinball is on a cell that is marked with <, the pinball moves one ce...
stackexchange_codegolf
Some text-based rogue-likes don't let you walk into walls, and give you your move back if you try to. Why do that when you can make the player move in the closest valid direction? The challenge Write a program of function that, given a direction and a 3 by 3 grid of characters, outputs the same grid after the player ha...
stackexchange_codegolf
Given an odd integer N (5 <= N <= 51), generate a maze with side length N that follows the following requirements: The maze must be composed of the characters | - and +. It must use the | character as a vertical wall, the - character as a horizontal wall, and if that wall turns, the character + should be used. The wid...
stackexchange_codegolf
Introduction I've previously created two challenges where the idea is to reconstruct an object using as few query-type operations as possible; this will be the third. The task Your inputs shall be a non-empty string S over the alphabet abc and its length, and your output shall be S. With no restrictions, this would of ...
stackexchange_codegolf
The On-Line Encyclopedia of Integer Sequences (OEIS) is an online database of integer sequences. It contains nearly 280000 sequences of mathematical interest. Examples of sequences: positive integers (A000027) prime numbers (A000040) Fibonacci numbers (A000045) Your task is to write a program or function that displ...
stackexchange_codegolf
In the classic days of Starbucks before these newfangled sticker-printers and wireless drivethrough headset palmtop scanner dealies, in the heady days of 2000-ish, Starbucks had a concise system for describing beverages with a strict syntax and accompanying encoded form. Vertically on the cup there are a series of labe...
stackexchange_codegolf
There are quite a few means in mathematics, such as the arithmetic mean, the geometric mean, and many others... Definitions and Task Note that these are the definitions for two positive integers*: The root mean square is the square root of the sum of their squares halved (). The arithmetic mean is their sum, halved ()...
stackexchange_codegolf
In number theory, a strong prime is a prime number that is greater than the arithmetic mean of the nearest prime above and below (in other words, it's closer to the following than to the preceding prime). Given an input integer, n, where n >= 0, your task is to generate the first n strong primes. For example, the six...
stackexchange_codegolf
QWERTY keyboard distance (QKD) is, in short, the distance between two letters/numbers/punctuation keys on a standard QWERTY keyboard (if you don't have one around, you can check this Wikipedia picture). Note that only characters without modifiers be considered for this challenge (so ; is valid, but ) is not). Some exa...
stackexchange_codegolf
This is a code-shuffleboard answer-chaining challenge, where the answers will aim to, together, output the lyrics to this beloved 80s song. This is the full lyrics of the song, line by line. The first answer will contain a program that will output the first line of the song (We're no strangers to love). The second wil...
stackexchange_codegolf
What does "jelly" mean in the title?. Cop's thread Robbers, you are to choose an uncracked Cop answer, and attempt to find a Jelly program which is: shorter than the Cop's answer solves the linked challenge, according to the rules of the challenge So long as these two bullet points are met, your answer cracks the Cop...
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
A sestina is a format of poem that follows an interesting pattern that we can generate. It has six stanzas of six lines each, where the last words of each line in the first stanza make up the line endings in each successive stanza, rotated in a set pattern. (There's also a three-line stanza at the end, but we won't wor...
stackexchange_codegolf
You are given two strings \$a\$ and \$b\$ consisting of characters from a to z in lowercase. Let \$n\$ be the length of \$a\$. Let \$m\$ be the length of \$b\$. Let \$a'\$ be the string \$a\$ repeated \$m\$ times. Let \$b'\$ be the string \$b\$ repeated \$n\$ times. Check whether \$a'\$ is lexicographically less than \...
stackexchange_codegolf
You are to print this exact text: A ABA ABCBA ABCDCBA ABCDEDCBA ABCDEFEDCBA ABCDEFGFEDCBA ABCDEFGHGFEDCBA ABCDEFGHIHGFEDCBA ABCDEFGHIJIHGFEDCBA ABCDEFGHIJKJIHGFEDCBA ABCDEFGHIJKLKJIHGFEDCBA ABCDEFGHIJKLMLKJIHGFEDCBA ABCDEFGHIJKLMNMLKJIHGFEDCBA ABCDEFGHIJKLMNONMLKJIHGFEDCBA ABCDEFGHIJKLMNOPONMLKJIHGFEDCBA ABCDEFGHIJKLMN...
stackexchange_codegolf
Stack Cats is a reversible, stack-based language. Its reversible nature makes for somewhat weird loops. This challenge is about the conditional loop (...). When these loops are nested in certain ways, it's possible to transform the code to reduce the nesting depth. Here are the rules (where A and B stand for an arbitra...
stackexchange_codegolf
Or maybe it's not really a labyrinth, but still. Rules: Input is a two-line string, consisting of *, 1, x and X. That string is a labyrinth to walk through. The lines have the equal length. You could take the input as a string with , (comma) or any convenient separator between these two lines. Or you could take both l...
stackexchange_codegolf
Introduction Let's say that S1 = a...b and S2 = ..c... If we place them on top of each other, we get: a...b ..c.. We merge both strings, with the . as the liquid character (which can overlapped). We get this: a.c.b If one of the string is longer than the other, we just apply the same algorithm: a.....b ..c.. becom...
stackexchange_codegolf
Challenge Given a list of positive integers, find if there exists a permutation where taking up to one bit from each of the integers, a binary number consisting of all 1s can be created. The number of bits in the resulting binary number is equal to the highest MSB in the list of integers. Output Your code must output o...
stackexchange_codegolf
I want a blanket that looks like this. Each strip goes over, under, over, under. Can you print it? \\\\////\\\\////\\\\////\\\\////\\\\////\\\\//// \\//// \\//// \\//// \\//// \\//// \\//// //// //// //// //// //// //// ////\\ ////\\ ////\\ ////\\ ////\\ ////\\ ////\\\\////\\\\////\\\\/...
stackexchange_codegolf
This challenge is to take an alphabetical string as input and to apply the following conversion: The first of each type of character of the string must stay, and must be immediately followed by an integer representing how many of these characters were in the original string. Any repeating characters must be omitted. Al...
stackexchange_codegolf
The challenge is to write a golf-code program that, given n positive real numbers from 0 to 10 (format x.y, y only can be 0 or 5: 0, 0.5, 1, 1.5, 2, 2.5 … 9.5 and 10), discard the lowest and highest values (only one, even though they are repeated) and shows the average of the remaining, in x.y format (y can be 0 or 5, ...
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
Here, x (supplied as input) and n (the result of your computation) are both positive integers. n * x = n shifted. Find n. Here's an example of shifting: 123456789 -> 912345678 abcdefghi -> iabcdefgh (letters = any 0~9 digit) 123 -> 312 Shifting only happens once to the right. Shifting left, e.g. 123456789 -> 234...
stackexchange_codegolf
Imagine you place a knight chess piece on a phone dial pad. This chess piece moves from keys to keys in an uppercase "L" shape: two steps horizontally followed by one vertically, or one step horizontally then two vertically: +-+ |1| 2 3 +-+ `-------v | +-+ 4 | 5 |6| | +-+ | ...
stackexchange_codegolf
Given two numbers n and m, evaluate the infinite power tower: n^(n+1)^(n+2)^(n+3)^(n+4)^... mod m Keep in mind that ^ is right-associative. So 2^3^4 = 2^(3^4). Now how can you possibly assign a value to an infinite sequence of right-associative operators? Define f(n,m,i) as the power tower containing the first i ter...
stackexchange_codegolf
Challenge Using data from the API here, output the names of the three countries with the most Olympic gold medals at the 2016 Rio Olympic Games (i.e. the first element of the returned list). For example, at the time of posting (18:23 UTC+1, Monday, 15th August), the USA, the UK and China have the most gold medals, so t...
stackexchange_codegolf
We define \$R_n\$ as the list of remainders of the Euclidean division of \$n\$ by \$2\$, \$3\$, \$5\$ and \$7\$. Given an integer \$n\ge0\$, you have to figure out if there exists an integer \$0<k<210\$ such that \$R_{n+k}\$ is a permutation of \$R_n\$. Examples The criterion is met for \$n=8\$, because: we have \$R_8...
stackexchange_codegolf
Introduction Every number can be represented as ASCII. For example, \$0\$ comes in ASCII is \$48\$, \$1\$ is \$49\$, and so on. Using this method of translating numbers to other numbers, it is possible to infinitely expand a number, by replacing all its digits with their ASCII values and doing the same for the result. ...
stackexchange_codegolf
Golf the leaderboard of this question (id=111735). Your program should issue one HTTP or HTTPS request to StackExchange API, parse it and present to user in form similar to a typical Leaderboard Snippet Sample output (for the question 47338 instead of this): Leaderboard Author Language Size 1. FryAmTheEggman ...
stackexchange_codegolf
Write a program that takes an undirected graph and finds the minimum cut, i.e., the set of edges that, if removed, would disconnect the graph into two or more connected components. The program should have a time complexity of \$O(n^2m)\$, where n is the number of vertices and m is the number of edges in the graph. One ...
stackexchange_codegolf
Background There's a terrible problem in my console - the quotes never get included inside the arguments! So, when given this argument: ["abc","def","ghi","jkl"] it says that the argument is like this: [abc,def,ghi,jkl] It would be very nice if you can fix this problem! Challenge Add double-quotes (") in order to sur...
stackexchange_codegolf
Challenge Take an input string \$s\$, and split it into words \$w_1, w_2, ..., w_n\$. If the amount of words is odd, then return \$s\$. Otherwise, for each word: Take the second last letter, and swap it with the first letter keeping capitalization positions. So GolF becomes LogF. Now check if the amount of words is a m...
stackexchange_codegolf
Okay, so yesterday was 2nd Christmas day and my (grand)parents and me had a game of "sjoelen", as it is called in the Netherlands. The inner programmer came up in me, but just when I had the answer, I lost it. I want you to remake it. The rules: You have a wooden plank, a sjoelbak, with 4 boxes, each with their own num...
stackexchange_codegolf
Task A Rotate-Left-Double number in base \$n\$ is a number \$m\$, when its base-\$n\$ digits are rotated left once, equals \$2m\$. The base-\$n\$ representation of \$m\$ cannot have leading zeros. One example in base 7 is the number 480, or \$1254_7\$. When rotated left once, the value becomes \$2541_7 = 960\$. Given t...
stackexchange_codegolf
Given an input of a string, output the partial fraction in string form. The partial fraction decomposition of a rational fraction of the form \$\frac{f(x)}{g(x)}\$, where \$f\$ and \$g\$ are polynomials, is its expression as: $$\frac{f(x)}{g(x)}=p(x)+\sum_j\frac{f_j(x)}{g_j(x)}$$ In this case \$p\$ is 0, because we ass...
stackexchange_codegolf
Given a matrix, the goal is to ensure all the values in each column occur at least once, while at the same time doing so requiring the least possible amount of rows. Fastest solution wins. Note: a value in one column (e.g. 1) is considered different from the same value in another column. Expected output: an array/list...
stackexchange_codegolf
There are an abundance of questions involving drawing shapes using asterisks - so I thought, with so many asterisks out there, we should draw one, using the ASCII table. Challenge Your task is to write a program or function which takes no input, and outputs this exact text: ! "# $% ...
stackexchange_codegolf
This is a more complicated version of this puzzle. The premise is the same but a few rules differ in a few key places, making for a more complex problem. Assume I have some number of black shirts and some number of white shirts, both at least 1. Both colors of shirt have a non-zero durability. All shirts of a given col...
stackexchange_codegolf
You will be given a point (x,y) relative to the center of the Ulam spiral (the center being the point which represents one), and length z. The task is to check whether there exists a path from (0,0) to (x,y) of length z, assuming prime numbers are obstacles and each turn in path has an angle of 90 degrees. Path may not...
stackexchange_codegolf
There's a little improv warm up game where you arrange yourselves in a circle and send zips, zaps, and zops around by pointing to a person and saying the next word in the sequence, then they do the same until all of you are warmed up or whatever. Your task is to create a program that gives the next word in sequence giv...
stackexchange_codegolf
Challenge: Given an integer \$n\$, guaranteed to be \$\geq2\$ and a power of 2, we are going to draw multiply boards either side-by-side or below one another, where the first has dimensions of \$n\$ by \$n\$; the second \$\frac{n}{2}\$ by \$\frac{n}{2}\$; the third \$\frac{n}{4}\$ by \$\frac{n}{4}\$; etc.; until the fi...
stackexchange_codegolf
Task Given a non-negative number, check if it's odd or even. In case it's even, output that number. Otherwise, throw any exception/error that your language supports, and stop the program. Example with Python Input: 1 Output: Traceback (most recent call last): File ".code.tio", line 1, in <module> IfYouWantThenThr...
stackexchange_codegolf
Challenge Taken with permission from my University Code Challenge Contest For some years now, the number of students in my school has been growing steadily. First the number of students was increased by classroom, but then it was necessary to convert some spaces for some groups to give classes there, such as the gym s...
stackexchange_codegolf
It's a common problem to navigate in a 2D matrix. We've seen it many times and will see again. So let's help future us and develop the shortest solutions to generate all eight possible steps in a 2D matrix. Challenge Your code must output the following 8 pairs of -1,0,1 in any order: (0,1) (0,-1) (1,0) (-1,0) (1,1) (1,...
stackexchange_codegolf
You are to take a string representing a piece of brainfuck code and Explanations, containing only printable ASCII characters and newlines ( to ~, ASCII 10 and 32 to 126) as input and output an explanation of that code, formatted to be compliant with Stack Exchange markdown. That is, the explanation must satisfy: Each...
stackexchange_codegolf
You need to print A-Z like this: 1. A 2. B 3. C 4. D 5. E 6. F 7. G 8. H 9. I 10. J 11. K 12. L 13. M 14. N 15. O 16. P 17. Q 18. R 19. S 20. T 21. U 22. V 23. W 24. X 25. Y 26. Z But your source code cannot use 1,2,4,6. Trailing newlines in output allowed,, but leading ones not allowed. Standard loopholes apply, shor...
stackexchange_codegolf
For many games played on a grid, hexagons are the Clearly Superior Choice™. Unfortunately, many free game art sites only have seamless tile sets for square maps. On a past project, I used some of these, and manually converted them to hexagons. However, I've gotten lazy in my old age. It should be easy to automate the p...
stackexchange_codegolf
The least common multiple (LCM) of a set of numbers A is the smallest integer b such that b/a is an integer for all integers a in A. This definition can be extended to rational numbers! Task Find the smallest positive rational b such that b/a is an integer for all rationals a in the input. Rules Standard loopholes are...
stackexchange_codegolf
Given two strings \$A\$ and \$B\$ with edit (Levenshtein) distance \$x\$, find a third string with edit distance \$a\$ to \$A\$ and edit distance \$b\$ to \$B\$ so that \$a+b=x\$ and \$a=int(x/2)\$ (that is half of \$x\$ rounded down to the nearest integer). The input is the two strings \$A\$ and \$B\$ and their edit d...
stackexchange_codegolf
Input An array A of integers of length 100,000. The array will contain only integers in the range 0 to 1e7. Output The convolution of A with itself. As this will be of length 199999 you should time just the convolution calculation however, not the time to print out the answer. Example in Python import numpy as np from...
stackexchange_codegolf
In chess, the Fool's Mate is the fastest possible way to reach checkmate. It is reached with Black's second move. In chess notation, one possible sequence of moves that achieves Fool's Mate is 1.f3 e6 2.g4 Qh4#. This is not the only possible way to achieve this checkmate (in the same number of moves). There are three ...
stackexchange_codegolf
Use any programming language to display numbers between 1 and 99 (including both) in such a way, so that: the numbers are separated by single space, if a number is divisible by 3, it should be in parentheses, if a number is divisible by 4, it should be in square brackets, if a number is divisible by both 3 and 4, it s...
stackexchange_codegolf
A while ago, I posted a challenge asking to determine whether or not it's possible to arrange arbitrary rectangles to fill a rectangular space, here. That got answers, so clearly it was too easy. (Just kidding, it was fairly challenging, congrats to the answerers :D) Challenge Given a bunch of arbitrary shapes (consist...
stackexchange_codegolf
Challenge: With any given number that has multiple digits, every digit in the number needs to repeatedly be summed together until the sum is a single digit number. To make things interesting, if there's a 0 in the number, then it must equal 26, because zero starts with the letter z, which is the 26th and final letter o...
stackexchange_codegolf
What general tips do you have for golfing in D? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to D (e.g. "remove comments" is not an answer). Please post one tip per answer.
stackexchange_codegolf
Introduction A quine is a program that takes no input and produces a copy of its own source code as output. Writing a quine is a standard test of a programming language. Most quines operate using strings of characters: that is what the source code is made of, after all! However, this quine is slightly different. Challe...
stackexchange_codegolf
Challenge: Given the input array l with a list of strings, only keep the elements in the sequence that have a letter that's repeated at least 3 times. Like 'lessons' has 3 s letters, so it should be kept in the sequence. But, 'lesson' has only two s letters, so it should be removed. Notes: l will always be a sequence,...
stackexchange_codegolf