instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Task Take the (integer) number of human years that the dog has lived, \$n\$, as input and return its age in dog years, \$d\$, to two decimal places. The number of human years, \$n\$, will be between \$1\$ and \$122\$ inclusive: \$n \in [1,122], n \in \Bbb{N}\$. According to BBC's Science Focus Magazine, the correct fun...
stackexchange_codegolf
A "Giza number", also colloquially known as a Timmy Number is any number where the digits represent a pyramid (A134810). For example, "12321" is a giza number because it can be visualized like this: 3 2 2 1 1 However, something like "123321" is not a Giza number because there are two digits at the top of the py...
stackexchange_codegolf
Task FizzBuzz, but instead of 3 and 5, you'll take the numbers and corresponding strings as input. You can assume all inputted numbers are coprime (and \$\ge 2\$). You'll receive one or more numbers, and a string to print with each of them. The normal FizzBuzz would be something like [[3, "Fizz"], [5, "Buzz"]], but you...
stackexchange_codegolf
inputs / outputs your program/function/routine/... will be a predicate on two tuple sequences; call it relation ≡. for the purpose of simplicity we use natural numbers: the input will be two list of pairs of numbers from ℕ (including 0); call them Xs and Ys the output will be a "truthy" value specification ≡ checks t...
stackexchange_codegolf
Just because the reverse and palindrome were not too challenging individually :) Write a program (full program or function) that satisfies the following: given a string input, the program as-is outputs the input string unchanged. the program reversed outputs the input string reversed. the program palindromized outputs...
stackexchange_codegolf
Using named matching groups is often easier to understand than numbering groups but takes up more bytes. Given a regular expression as specified below, your program or function must convert named groups to numbered groups. Task These specifications are based on python 3's re module. A named group takes the form of (?P<...
stackexchange_codegolf
if you have a range of numbers with values missing, eg l=[1,2,9,10,99], you can always use modulus and subtraction to make all the numbers in the list cover a smaller range, for example: l%99%6=[1,2,3,4,0]. your task is to take in a list of numbers and output an equation which will map them to unique numbers in the ran...
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
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
A string is dot-heavy when its morse representation contains more dots than dashes. For example, the letter E is a single dot, which means it is Dot-heavy. Input The input string will only contain characters in the range of [a-z] or [A-Z]. You can decide if they should all be upper case, or all lower case. AAA is fine...
stackexchange_codegolf
There is a question to basically find the largest sum in an array, such that no two elements are chosen adjacent to each other. The concept is to recursively calculate the sum, while considering and not considering every element, and skipping an element depending on whether the previous element was selected or not. I u...
stackexchange_codegolf
Objective Given a string with single Unicode vulgar fraction, parse it to a rational number. Valid inputs A valid input is one of: ¼ U+00BC; one quarter ½ U+00BD; one half ¾ U+00BE; three quarters ⅐ U+2150; one seventh ⅑ U+2151; one ninth ⅒ U+2152; one tenth ⅓ U+2153; one third ⅔ U+2154; two thirds ⅕ U+2155; one fifth...
stackexchange_codegolf
Overview As most of y'all who visit chat know, I am Russian by ethnicity[citation not needed]. Recently, I switched from a keyboard that maps the letters 1-to-1 (mnemonic) to Windows' default mnemonic keyboard. Here are the letter mappings: "`" -> "ъ" "q" -> "я" "w" -> "ш" "e" -> "е" "r" -> "р" "t" -> "т" "u" -> "у" "i...
stackexchange_codegolf
Overview Some of you might be aware of the Kolakoski Sequence (A000002), a well know self-referential sequence that has the following property: It is a sequence containing only 1's and 2's, and for each group of 1's and twos, if you add up the length of runs, it equals itself, only half the length. In other words, the...
stackexchange_codegolf
The Narrative You are a bad musician. You never bothered to learn how to count rhythms. To remedy this shortcoming, you decide to write a program that will tell you how to count in any given time signature. You are still a bad musician, but you can at least pretend that you can count rhythms. The Objective Given a time...
stackexchange_codegolf
In Keep Talking and Nobody Explodes, players are tasked with defusing bombs based on information from their "experts" (other people with a manual). Each bomb is made up of modules, one of which can be passwords, where the expert is given this list of possible passwords, all five letters long: about after again b...
stackexchange_codegolf
Given two numbers \$x,y > 2, x≠y \$ output all integers \$m\$ such that $$ x + y \equiv x \cdot y \pmod m $$ $$ x \cdot y > m > 2 $$ Input Two integers Output A list of integers Test cases 3, 4 -> 5 5, 8 -> 3, 9, 27 29, 9 -> 223 26, 4 -> 37, 74 13, 11 -> 7, 17, 119 6258, 571 -> 463, 7703, 3566489
stackexchange_codegolf
Take an input, and convert it from Two's Complement notation (binary where the first bit is negated, but the rest are taken as normal) into an integer (in a somewhat standard output form). Input can be as a string, a list of digits, a number, or pretty much any other format which is recognizably Two's Complement. Leadi...
stackexchange_codegolf
The challenge Write a program or function that prints stars! The program will receive two parameters by standar input: Size of the star and number of points of the star. A star can be any size between 0 and 10 and have 3, 4 or 5 points. The input parameters are separated by a comma, for example: 5,3 means a size 5 star...
stackexchange_codegolf
Introduction We all know prefixes and suffixes. But there are other types of affixes that exist too. Such as circumfixes, a type of affix that has two parts, one of which is a prefix and another of which is a suffix. Figuring out whether some string is a prefix or a suffix of some other string is easy, but what about f...
stackexchange_codegolf
Consider the positive integer powers of five in decimal. Here are the first 25, right aligned: X 5^X 1 5 2 25 3 125 4 625 5 3125 6 15625 7 78125 8 390625 9 1953125 10 ...
stackexchange_codegolf
The task is simple, divide, get the quotient and the remainder, and if the remainder isn't 1 or 0, do the same thing (quotient divmod remainder) until the remainder is 1 or 0, then get the remainder. If the last input number is 1 or 0, output it. If the input is [15, 4], then the output would be 0, because the divmod o...
stackexchange_codegolf
Your task is to create a program that determines whether a given string is a valid regular expression or not using code snippets sourced from sites on the StackExchange network. For the purposes of this challenge, the regular expression dialect will be a stripped down and mostly minimal set of meta-characters: ()*?|\. ...
stackexchange_codegolf
Yes, It's basically You're a Romanizer, Baby, but harder. like, way harder. Learning Korean is HARD. at least for a person outside Asia. But they at least have the chance to learn, right? What you must do You will be given a Korean Statement. For example, 안녕하세요. You must convert the input to its Roman pronunciation. ...
stackexchange_codegolf
Robber Thread here The Challenge Choose any numeric* formula, algorithm, or code challenge. Implement it in such a way that the math is correct, but at least one answer is wildly** wrong due to some defect in how computers/programs operate, e.g. floating point errors, uninitialized/corrupted memory, environment bugs, c...
stackexchange_codegolf
Write a function/program that accepts a string of lower/uppercase letters [A-Za-z] as input, that checks whether the occuring letters are unique and in alphabetical order (ignoring lower and uppercase) or not. The output must be truthy if they are unique and in alphabetical order and falsy if not. Here some testcases a...
stackexchange_codegolf
Challenge Generate \$n-1\$ consecutive composite numbers using this prime gap formula $$n!+2,n!+3,...,n!+n$$ Input An integer \$n\$ such that \$3 \leq n \leq 50 \$. Output Sequence of \$n-1\$ consecutive composite numbers. Example Input 3 Output 8 9 Rules Output should be in integer format. Test Cases For \$n > 20\...
stackexchange_codegolf
The challenge is to write codegolf for the Hafnian of a matrix. The Hafnian of an \$2n \times 2n\$ symmetric matrix \$A\$ is defined as: $$\operatorname{haf}(A) = \frac 1 {n!2^n} \sum_{\sigma \in S_{2n}} \prod^n_{j=1} A_{\sigma(2j-1),\sigma(2j)}$$ Here \$S_{2n}\$ represents the set of all permutations of the integers f...
stackexchange_codegolf
An aesthetically pleasing divisor tree is a tree of divisors of input n that, for any composite number m, has two children nodes that are the pair of divisors that are closest to the square root of m. The left node should be the smaller divisor of m and the right node should be the larger divisor of m. A prime number i...
stackexchange_codegolf
For this challenge, a word is defined as a string of letters, separated by spaces. Given a string of words, and an integer i representing an index into that string, output the whole word which contains the character at index i. For example (using 0-based indexing), with the string code golf, and the index 6, the 7th ch...
stackexchange_codegolf
Given two sets of strings, \$ D \$ and \$ R \$, find the shortest string which contains every string in \$ D \$, but contains none of the strings in \$ R \$. There are almost always multiple possible outputs; you should output at least one of them, but you can output more. You can assume this is possible with the input...
stackexchange_codegolf
While at work I spotted a nice and simple challenge. The job was to stock products in cargo units with a certain capability. Since an order can have various batches, coming in sequence from the production, we usually make a list of the pieces of those batches distributed in each cargo to make sure nothing is lost durin...
stackexchange_codegolf
Given a positive integer n, compute the nth Wilson number W(n) where and e = 1 if n has a primitive root modulo n, otherwise e = -1. In other words, n has a primitive root if there does not exist an integer x where 1 < x < n-1 and x2 = 1 mod n. This is code-golf so create the shortest code for a function or program t...
stackexchange_codegolf
Each day you put up a new word on a marquee sign with movable letters, buying just the letters you need to write it. You re-use letters you've bought for earlier words whenever possible. Given the words you want to write each day in order, output the letters you buy each day. Example Input: ['ONE', 'TWO', 'THREE', 'S...
stackexchange_codegolf
Task Given a letter (A, B, C), and a number (0-10), output the size of the matching standard paper size (Series A and B) or the matching standard envelope size (C series) in millimetres in the format aaaa x bbbb where aaaa and bbbb are the width and height measurements in millimetres as per ISO216 (Series A & B) or ISO...
stackexchange_codegolf
This challenge will have give you a positive integer \$n\$ and ask you to output \$t(n)\$, the number of triangles (up to congruence) satisfying the three conditions: The triangles have perimeter of 1, the triangles have side lengths \$\displaystyle\frac{a_1}{b_1}, \frac{a_2}{b_2}\$, and \$\displaystyle\frac{a_3}{b_3}...
stackexchange_codegolf
Challenge We all know about normal Christmas trees - but how about an upside-down Christmas tree! This is a fairly easy, Christmas themed challenge. The objective of this challenge is to make me an ASCII upside-down Christmas tree. Here are the rules for this challenge: Accept an odd, positive integer. You can assume ...
stackexchange_codegolf
Task Given an array of positive integers, replace each element with the parity of the sum of the other elements. The array is guaranteed to have at least 2 elements. Definition Parity: whether a number is odd or even. Example For the array [1,2,3,1]: Replace 1 with the parity of 2+3+1, i.e. even. Replace 2 with the ...
stackexchange_codegolf
Introduction Humans are a remarkable species, but we can be very awkward to understand sometimes—especially for computers. In particular, we seem to like writing polynomials in a very convoluted fashion with seemingly arbitrary rules. What is the shortest program you can write to format a polynomial correctly using t...
stackexchange_codegolf
The code has a lot of names, but is very simple: 1 2 3 4 5 1 A B C D E 2 F G H I J 3 L M N O P 4 Q R S T U 5 V W X Y Z A letter is coded by its coordinates, with the row first, then the column. Ex: M = 3, 2 V 1 2 3 4 5 1 A B C D E 2 F G H I J >3 L M N O P 4 Q R S T U 5 V W X Y Z Note the letter 'K' i...
stackexchange_codegolf
On Pomax's Primer on Bézier Curves this "fairly funky image" appears: This is related to the fact that every cubic Bézier curve can be put in a "canonical form" by an affine transformation that maps its first three control points to (0,0), (0,1) and (1,1) respectively. Where the fourth and last control point lies afte...
stackexchange_codegolf
Write a program or function that given some text, a number of columns, and the column width, formats the text into columns. This is plain text typography. Rules Input The text will be a string of printable ASCII and may contain newlines and spaces (but not tabs). The number of columns will be a positive integer. The c...
stackexchange_codegolf
Game of Game of Life Conway's Game of Life is a 0-player game. But that's okay! We can make it a multi-player game. This game is played on the smallest square grid that will accommodate a 6x6 square for each player (12x12 for 2-4 players, 18x18 for 5-9 players, etc). This grid is actually a torus, so it wraps in bot...
stackexchange_codegolf
Related. Given a number \$n\$, Euler's totient function, \$\varphi(n)\$ is the number of integers up to \$n\$ which are coprime to \$n\$. That is, no number bigger than \$1\$ divides both of them. For example, \$\varphi(6) = 2\$, because the only relevant numbers are \$1, 5\$. This is OEIS A000010. We can now define th...
stackexchange_codegolf
Given a matrix of size at least 3×3 formed by positive integers, determine if it contains at least one "U" pattern, defined as + + + - - - + + + + - N - N - + + + - N - N - + + + - N N N - + + + + - - - + + where N is the same number, repeated in those seven positions - (optional) represents any number different than...
stackexchange_codegolf
So the golf question was like this: You are given a number T and then a total of T number of 17-character strings. For each of the strings, output yes if it contains four consecutive identical characters or contains the substring DX, else output no. The following constraints are promised for each of the 17-character ...
stackexchange_codegolf
Goal: A tree can be represented as a nested list: the list elements represent nodes, and a node is a pair of the node name and node children. Your program takes as input a nested list of pairs, and should output a pretty tree. Examples: Here are four example test cases below ["stump",[]] ["trunk",[["branch",[["leaf...
stackexchange_codegolf
The Fabius function is an example of a function that is infinitely differentiable everywhere, yet nowhere analytic. One way to define the function is in terms of an infinite number of random variables. Specifically, given a sequence of independent random variables \$\{U_n\}\$, where each \$U_n\$ is uniform on the inter...
stackexchange_codegolf
Background Related: a golflang theory I posted in TNB a while ago At-most-\$n\$-ary trees are rooted trees where each internal node has between 1 and \$n\$ children (inclusive). Two trees are considered identical only if the shapes exactly match without re-ordering each node's children. In other words, the left-to-righ...
stackexchange_codegolf
Given a directed graph on the nodes 0, 1, ..n, where each edge has two non-negative integer costs, return the set of all possible Pareto Optimal path costs between node 0 and node n. These are the costs of paths for which you cannot decrease the first component of the cost without increasing the second component, and c...
stackexchange_codegolf
Challenge Given a single letter (a-z) as input, output the 2 lines of Blackalicious' Alphabet Aerobics that correspond to that letter (ignoring the intro & outro). Rules You may take input by any reasonable, convenient means as long as it's permitted by standard I/O rules. Input must either be case insensitive or con...
stackexchange_codegolf
Given an integer n output the nth iteration of the Hilbert Curve in ASCII using the characters _ and |. Here are the first 4 iterations: n=1 _ | | n=2 _ _ | |_| | |_ _| _| |_ n=3 _ _ _ _ | |_| | | |_| | |_ _| |_ _| _| |_____| |_ | ___ ___ | |_| _| |_ |_| _ |_ _| _ | |___| |___| | n...
stackexchange_codegolf
Write a program or function that, given an integer n, construct an array with n dimensions of n length, where each element is an identifier of its own coordinates. That is, starting with one array, populate it with n arrays, where each of those contain n more arrays, up to a depth of n-1. The elements of the deepest ar...
stackexchange_codegolf
Output a random triple \$(x,y,z)\$ of real numbers such that \$x+y+z=\frac{3}{2}\$ Each of \$x,y,z\$, taken alone, is uniformly distributed from \$0\$ to \$1\$. Please explain in your answer what distribution your code produces and why it meets these conditions. In particular, please include a demonstration that with...
stackexchange_codegolf
Develop a program to check if a given word is part of a language defined by the following rules: The language has a set of rules. The empty string is considered a valid word in the language. Two words from the language can be concatenated to create a new word in the language. If X is a word in the language, then "A" +...
stackexchange_codegolf
Given a string and a substring and a positive integer n. Remove the n occurences of a substring from the end of the originally given string. If the substring is not present in the string or the number of times the substring appears is less than n, then the output is the original string. No space should be present in pl...
stackexchange_codegolf
Write a program or function with no input that prints or returns this string of 24-hour and 12-hour times: 00:00 12:00am 01:00 1:00am 02:00 2:00am 03:00 3:00am 04:00 4:00am 05:00 5:00am 06:00 6:00am 07:00 7:00am 08:00 8:00am 09:00 9:00am 10:00 10:00am 11:00 11:00am 12:00 12:00pm 13:00 1:00pm 14:00 2:00pm 15:...
stackexchange_codegolf
So I got kinda bored and was wondering if it was possible to make this code shorter without modifying anything except a file named coin.py... from random import*;c=['heads','tails'];print('u win'if choice(c)==input(' / '.join(c)+': ')else'u lose') The program asks the user for either "heads" or "tails", if the result ...
stackexchange_codegolf
Introduction You belong to a council which oversees the destruction of corrupted worlds. When the council assembles, a single vote is taken. The ballot lists all nominated worlds. One is ultimately destroyed each time the council meets. Due to a bug in user12345's code, the council recently flooded and then sent pirate...
stackexchange_codegolf
Introduction I've always liked the idea of finding the most possible bang-for-your-buck squeezed out of a tiny chip, like the 6502. Of course, I'll need to start small. Filling the screen on 6502asm.com should be easy enough. Challenge Fill the entire program output screen on 6502asm.com with the color white using the ...
stackexchange_codegolf
Based on this, but I was asked[​1​],[​2​] to do a graphical edition. Task Generate a circular display of the text EASIER COMMUNICATION MEANS FASTER CODING MEANS FEWER CODERS MEANS . Any uppercase font goes. The letter tops must face out of the circle. Either the space before FEWER must be at the bottom (6 o'clock) or ...
stackexchange_codegolf
Write a program that prints an associative array (key-value) to a table. Requirements Standard loopholes are forbidden Please include a link to an online interpreter and the byte count in the answer Use box drawing characters to draw the table. You can write both a full program or a function. Key or value can't cont...
stackexchange_codegolf
Challenge Given a string of any length, write it as a triangle, spiraling out from the center. For example, abcdefghijklmnop becomes: g fah edcbi ponmlkj Or more explicitly: If you like, you can spiral counter-clockwise instead: g haf ibcde jklmnop Or add spaces uniformly: g f a h ...
stackexchange_codegolf
Inspired by this question. Challenge Let L be a list of n distinct elements. Let P be the set of all (unordered) pairs of positions in P. Let R be a result of applying a pair-swap operation on L by every pair in P in any order. Example: L = [1, 7, 8] P = {(1, 2), (0, 1), (0, 2)} L = [1, 7, 8] -> [1, 8, 7] -> [8, 1, 7] ...
stackexchange_codegolf
Input An integer k composed of 1 and 2, with at least 3 digits and at most 200 digits. Output Another integer k' obtained by removing at most one (could be none) digit from k, such that k' is composite, and then another integer p for a non-trivial (that is, not 1 or k') factor of k'. Test Cases 121212 -> 121212 10101 1...
stackexchange_codegolf
The International Standard Atmosphere (ISA) is a model of the Earth's atmosphere at "reference" conditions. It includes information on pressure, temperature, and density change vs. altitude. The ISA tabulates these properties at various layers, and an estimation of the value of interest can by found by the following pr...
stackexchange_codegolf
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. Christmas is coming up, and Santa hasn't kept to his diet very well this year. Due to his size, he is getting the elves to collect a list of all the chimneys he will be able to fit down. Unfortunately, chimneys these days are a bit of ...
stackexchange_codegolf
Given a real number t in (-10^9,13) (not including -10^9 or 13) as input, output Γ(t), also known as the Gamma function, which is defined as follows: You may not use a built-in Gamma function to solve this task, nor may you use built-in numeric or symbolic integration functions. Your output should be accurate to 6 sig...
stackexchange_codegolf
I was seen multiple shortest "Hello World!" program, but this is the longest program. The Rules Each submission must be a full program. This must be non-interpreted language (for example, JavaScript, Python, HTML, etc.) Target OS must be Windows, Mac, Linux or MS-DOS. The challenge Writing a longest Hello World prog...
stackexchange_codegolf
Challenge Determine how many integer lattice points there are in an ellipse $$\frac{x^2}{a^2} + \frac{y^2}{b^2} \leq 1$$ centered at the origin with width \$2a\$ and height \$2b\$ where integers \$a, b > 0\$ . Input The Semi-major \$a\$ and Semi-minor \$b\$ axes. Output Number of interior and boundary points. Example E...
stackexchange_codegolf
In this challenge, you will play the noisy iterated prisoner's dilemma. The Prisoner's dilemma is a scenario in game theory where there are two players, each with two options: cooperate, or defect. Each player does better for themself if they defect than if they cooperate, but both players would prefer the outcome wher...
stackexchange_codegolf
Russian roulette It's Russian roulette! The rules are simple. Shoot a revolver with n slots for bullets and one round inside at your head and you might not die! This Question is different from other Russian roulette questions because it takes input to change the chance of exiting with an error. Task: Make a program tha...
stackexchange_codegolf
Description of the problem Imagine a quarter of an infinite chessboard, as in a square grid, extending up and right, so that you can see the lower left corner. Place a 0 in there. Now for every other cell in position (x,y), you place the smallest non-negative integer that hasn't showed up in the column x or the row y. ...
stackexchange_codegolf
Introduction Today we're gonna take care of the bane of first-year linear algebra students: matrix definiteness! Apparently this doesn't yet have a challenge so here we go: Input A \$n\times n\$ symmetric Matrix \$A\$ in any convenient format (you may also of course only take the upper or the lower part of the matrix)...
stackexchange_codegolf
In this challenge you will receive a list of pairs of non-negative integers representing a mushroom forest. Each pair represents a mushroom whose center is at that horizontal coordinate. The only part of the mushroom we care about is the cap (the flat bit at the top). The first integer in each pair represents which ro...
stackexchange_codegolf
Given a list of Integers greater than zero, Sort each of the unique values in ascending order, then repeat the process on the remaining duplicate values and append. Example: [1,5,2,2,8,3,5,2,9] ==> [1,2,3,5,8,9,2,5,2] [8,5] ==> [5,8] [2,2,2] ==> [2,2,2]
stackexchange_codegolf
Bounties No. 1 (awarded) I'll throw in 50 rep for the first valid answer No. 2 (awarded) I'll throw in another 100 rep for the shortest valid answer. No. 3 (open for submissions) I'll throw in 200 rep for the first one with a significant shorter valid answer. Significant being at most 45% of currently shortest a...
stackexchange_codegolf
The major system is a mnemonic device for converting numbers into words so they can be memorized more easily. It is based on how words sound phonetically, but to keep things simple for the challenge we'll only be concerned with how words are spelled. This means there will be some incorrect conversions, but that's alrig...
stackexchange_codegolf
Censors are a common tool used on the interwebs. But they often censor too much of the word, and thus make the cursing ambiguous to the reader. And sometimes they don't censor enough, so the words still remain offending. Your task is to fix that. Your task Write a program/function/whatever that takes two lists and a st...
stackexchange_codegolf
Winner: Aditsu's CJam answer! A whopping 25 bytes! Nice! You may continue to submit your answer, however you can no longer win. Original post kept for posterity: The "Bzzt" game is a game where you must count to a number (in this case 500). However, if the number has a 3 in it, or is divisible by 3, you don't say the ...
stackexchange_codegolf
Task Write a program/function that, given three integers n,a,b prints a regular expression which matches all of the base-n integers from a to b (and no integers outside of that range). Your algorithm should, in theory, work for arbitrarily large integers. In practice, you may assume that the input can be stored in your...
stackexchange_codegolf
We have objects that oscillate between two integer points, [l, r], at the speed of one unit per time unit, starting at l on t=0. You may assume l < r. For example, if an object oscillates on [3, 6], then we have: t=0 -> 3 t=1 -> 4 t=2 -> 5 t=3 -> 6 t=4 -> 5 t=6 -> 4 t=7 -> 3 t=8 -> 4 Etc. But objects oscillate continu...
stackexchange_codegolf
This question is about abelian sandpiles. Read this previous challenge and watch this numberphile video to learn more. An abelian sandpile of size n by n is a grid containing the number 0, 1, 2 and 3 (representing the number of grains of sand). Adding two sandpiles works by first adding element by element, and then to...
stackexchange_codegolf
Following last year's event, we're doing Code Golf Advent Calendar 2022! On each day from today (Dec 1) until Christmas (Dec 25), a Christmas-themed challenge will be posted, just like an Advent calendar. It is a free-for-all and just-have-fun-by-participation event, no leaderboards and no prizes for solving them fast ...
stackexchange_codegolf
This question is similar to Do the circles overlap?, except your program should return True if the circumference of one circle intersects the other, and false if they do not. If they touch, this is considered an intersection. Note that concentric circles only intersect when both radii are equal Input is two x, y coordi...
stackexchange_codegolf
String Stairs Disclaimer: This is the first challenge I propose. Any and all feedback is welcome. If this is a duplicate, please point it out. Here's a link to the sandbox post. Goal The goal of this challenge is to, given a string and an integer, print the string into blocks of that integer's size. If a word has more ...
stackexchange_codegolf
Gah! It's a shame that Pokémon Sword and Shield won't introduce a new eeveelution. Let's mourn them with a code golf. The objective is to, when given a type name as the input, output the name of the corresponding eeveelution. When given Water, output Vaporeon. When given Electric, output Jolteon. When given Fire, outp...
stackexchange_codegolf
What general tips do you have for golfing in BBC BASIC? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to BBC BASIC (e.g. "remove comments" is not an answer).
stackexchange_codegolf
In this challenge, you implement an interpreter for a simple stack-based programming language. Your language must provide the following instructions: push a positive number pop two numbers and push their sum pop two numbers and push their difference (second number - first number) pop a number and push it twice (dup) p...
stackexchange_codegolf
Given (in any structure; flat list, two lists of lists, a tuple of matrices, a 3D array, complex numbers,…) the coordinates for two non-degenerate triangles ABC=[[Ax,Ay],[Bx,By],[Cx,Cy]] and PQR=[[Px,Py],[Qx,Qy],[Rx,Ry]], determine if they are similar, that is, they both have the same shape, or one has the same shape ...
stackexchange_codegolf
The Fibonacci polynomials are a polynomial sequence defined as: \$F_0(x) = 0\$ \$F_1(x) = 1\$ \$F_n(x) = x F_{n-1}(x) + F_{n-2}(x)\$ The first few Fibonacci polynomials are: \$F_0(x) = 0\$ \$F_1(x) = 1\$ \$F_2(x) = x\$ \$F_3(x) = x^2 + 1\$ \$F_4(x) = x^3 + 2x\$ \$F_5(x) = x^4 + 3x^2 + 1\$ When you evaluate the Fibo...
stackexchange_codegolf
Inputs A list (array) of numbers, or numerical strings if that makes it easier. You can assume there will always be at least two elements in the list and every element will be a natural number (integer larger than zero). Outputs A single number, or again, a numerical string. Problem The idea is to reduce the list of nu...
stackexchange_codegolf
I'm surprised this hasn't been posted before! The Consistent Overhead Byte Stuffing (COBS) algorithm is used to delimit byte streams. We choose a frame marker (we'll use 0x00) and wherever 0x00 occurs in the stream it is replaced with the number of bytes until the next 0x00 occurs (we'll call this a milestone). This re...
stackexchange_codegolf
A Kaprekar number is an n-digit number k that, when the first n or n-1 digits of k^2 are added to the second n the digits of N^2, the result is N. Examples: 9^2 = 81. 8+1 = 9. 45^2 = 2025. 20+25 = 45. 297^2 = 88,209. 88+209 = 297 The Kaprekar sequence begins at 1. Write a program that calculates and outputs the firs...
stackexchange_codegolf
I think is about time to do another Pokemon challenge! Even if Pokémon Go is not as mainstream as it used to be... The task. Just draw a MISSINGNO. MISSINGNO is an unofficial Pokémon species found in the video games Pokémon Red and Blue. IGN has noted MISSINGNO appearance in Pokémon Red and Blue as one of the most fam...
stackexchange_codegolf
Your task is to create a program which takes a black-and-white outlined image (example images are below) and fills it in with colour. It is up to you how you section off each region and which colour to fill it with (you could even use an RNG). For example: As you can see I am clearly an artist of a superior calibre wh...
stackexchange_codegolf
I'm new to this site, so I don't know whether this challenge already appeared: Write a piece of source code, so that after running the code, it prints out exactly (i.e. not longer, not shorter) the source code itself. The code can be in any programming language, but preferably in commonly used ones, such as the C famil...
stackexchange_codegolf
The edit distance between two strings is the minimum number of single character insertions, deletions and substitutions needed to transform one string into the other. This task is simply to write code that determines if two strings have edit distance at most 3 from each other. The twist is that your code must run in l...
stackexchange_codegolf
I want an n*n table that is filled with black or white and the following conditions are satisfied in it: All cells of a 2*2 square in this table should not be the same color. All black and white cells must be connected horizontally or vertically. Acceptable examples: Can anyone design a function that takes n as inpu...
stackexchange_codegolf
Background A matryoshka doll (or Russian nesting doll) is a set of dolls that fit inside of each other. I've accidentally mixed up my collection of matryoshka dolls and I don't remember which one goes inside which. Objective Given a list of unique strings, sort them into nested matryoshka dolls. Each string is an indiv...
stackexchange_codegolf