instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
What general tips do you have for golfing in Retina? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Retina (e.g. "remove comments" is not an answer). Please post one tip per answer. For reference, the online compiler is here. @Sp3000 pointed out there i...
stackexchange_codegolf
When Alice was touch typing on her QWERTY keyboard (Figure 1), she accidentally shifted both of her hands rightwards by one key, so q became w, w became e, etc. (p became [). Spaces were not affected because the space bar was quite big. Your task is to help her fix her message using the shortest number of bytes, i.e. u...
stackexchange_codegolf
Multi-level marketing related challenge. A peer wants to get rewarded. So it attracted N investors (N>=1), each i-th investor invested x[i]. When a total sum exceeds threshold x[0]+x[1]+...+x[N-1] >= T a peer could be rewarded. But only if a following conditions are satisfied: Minimum amount of investors should be gre...
stackexchange_codegolf
Related: Counting polystrips Background Link-a-Pix is a puzzle on a rectangular grid, where the objective is to reveal the hidden pixel art by the following rules: Connect two cells with number N with a line spanning N cells, so that the two cells are at the two ends of the line. The number 1 is considered connected t...
stackexchange_codegolf
Given a string of the characters +=- where there is at least one =, insert positive integers between all the symbols and at the start and the end such that the math equations are satisfied. For example, given the input +-=-= you need to insert positive integers A through F like this A+B-C=D-E=F such that the equation...
stackexchange_codegolf
Introduction I don't see many regex challenges on here, so I would like to offer up this deceptively simple one which can be done in a number of ways using a number of regex flavours. I hope it provides regex enthusiasts with a bit of fun golfing time. Challenge The challenge is to match what I've very loosely dubbed a...
stackexchange_codegolf
Behold! The Crystal Maze™ Time Matrix! 0 1 2 3 4 5 6 7 8 9 10 1 0 5 10 15 20 25 30 35 40 45 50 2 0 10 20 30 40 50 60 70 80 90 100 3 0 15 30 45 60 75 90 105 120 135 150 4 0 20 40 60 80 100 120 140 160 180 200 5 0 25 50 75 100 125 150 175 200 2...
stackexchange_codegolf
Convert a string containing digits as words into an integer, ignoring leading zeros. Examples "four two" -> 42. "zero zero zero one" -> 1. Assumptions Submissions can assume that: The input string is comprised of space-separated digit words. All words are valid (in the range "zero".."nine") and lowercase. Behaviour ...
stackexchange_codegolf
There was a prior question about golfing an HQ9+ compiler that translates HQ9+ code into the language it is written in, but that was closed as a duplicate of the interpreter challenge because converting an interpreter to a compiler is seen as trivial. This question is based on the closed one, but has some changes. Writ...
stackexchange_codegolf
There are two inputs, the first input is a map in 2D array, where 2 represents an obstacle and 0 represents a regular ground, and 1 represents the player's location (implies that the player is standing on ground), the second input is the player's movement range. A player can move on the map (horizontally, vertically, b...
stackexchange_codegolf
OG post Task In this challenge, you will be given an string emoticon, and your task will be to output its happiness. How? An emoticon will always have eyes and mouth. It can also include eyebrows and nose. Each part will influence the overall happiness rating, which is the sum of happiness ratings of all parts. Emotic...
stackexchange_codegolf
The turtle wants to move along the grid to get to his food. He wants to know how many moves it will take for him to get there. As well since he is slow he has teleporters set up around his domain that he will utilize if it shortens his path. Or avoid them if it lengthens his path. Meet the turtle The turtle lives on a...
stackexchange_codegolf
Background A ray of light is fired from the top left vertex of an MxN Chamber, where M a denotes the width and N denotes the height of the chamber. The ray of light advances one grid space per second. Given that T is the number of seconds to be simulated, calculate the number of reflections in this time frame. For exam...
stackexchange_codegolf
Challenge Description You have to show a simulation of rain in terminal. In the example given below its adding 100 raindrops at random (use the default random function which your language offers) coordinates, waiting for 0.2 seconds and then redrawing again until the given time expires. Any character can be used for r...
stackexchange_codegolf
The bank has been broken into, and all the local mafia thugs have an unusual alibi: they were at home playing Connect 4! In order to assist with the investigation, you are asked to write a program to validate all the Connect 4 boards that have been seized in order to check that the positions are indeed positions from ...
stackexchange_codegolf
Challenge Build the Wheat Wizard's stove using 2-input NAND gates. The solution with the fewest NAND gates wins. Externally, it works in the following way: (the first line is added from the original spec for physical output) It has 10 levels, from 0 to 9. The display has 9 lights, and if the current level is L, exactl...
stackexchange_codegolf
Background Shadow transform of a 0-based integer sequence \$a(n)\$ is another 0-based integer sequence \$s(n)\$ defined with the following equation: $$ s(n) = \sum_{i=0}^{n-1}{(1 \text{ if } n \text{ divides } a(i), 0 \text{ otherwise})} $$ i.e. \$s(n)\$ is the number of terms in \$a(0), \cdots, a(n-1)\$ that are divis...
stackexchange_codegolf
Given a non-negative integer, return the absolute difference between the sum of its even digits and the sum of its odd digits. Default Rules Standard Loopholes apply. You can take input and provide output by any standard Input / Output method. You may take input as a String, as an Integer or as a list of digits. Th...
stackexchange_codegolf
Task Given an \$m\times n\$ binary ascii "photo", return the negative of the photo Example: # # # # # # # # -> ## ## # # # ### # # # ## ## General rules: This is code-golf, so the shortest answer in bytes wins Standard rules and default I/O rules apply Your output characters must be the same as your in...
stackexchange_codegolf
Given an integer n, decompose it into a sum of maximal triangular numbers (where Tm represents the mth triangular number, or the sum of the integers from 1 to m) as follows: while n > 0, find the largest possible triangular number Tm such that Tm ≤ n. append m to the triangular-decomposition representation of n. subt...
stackexchange_codegolf
I need to call my friends but the buttons of my cordless phone are not working properly. The only buttons I can press are [Up], [Down] and [Call]. [Up] and [Down] can be used to navigate in my recent calls and [Call] can be used to call the selected name. My phone has a list that holds N recent calls, and I know that a...
stackexchange_codegolf
The challenge Your task is to animate Adve the Adventurer moving through a creepy (i.e. Halloween) maze. Adve is a •; he's character fluid, though, so he does not mind being represented by a different character. To animate Adve, you print out each frame; a frame is the map with his current location in it. Adve moves on...
stackexchange_codegolf
This is an answer chaining puzzle, where each answer must add on to the last. The \$n\$th submission must output its own source code in the \$n\$th language and the \$n−1\$ languages before it. A language can be either a dialect or a major version of a language, so Python version 2.121 is only counted as version 2 and ...
stackexchange_codegolf
Given the following Python 3 script: def greet(): print("Hello, world!") greet() Prepend some lines to this text file so that it can be both executed as a Python program as well as compiled and run as a C++ program producing the same output Hello, world! (including the newline at the end): $ python3 bilingual.py....
stackexchange_codegolf
Every positive integer can be expressed as the sum of at most three palindromic positive integers in any base b≥5.   Cilleruelo et al., 2017 A positive integer is palindromic in a given base if its representation in that base, without leading zeros, reads the same backwards. In the following, only base b=10 will be c...
stackexchange_codegolf
A donut distribution (for lack of a better term) is a random distribution of points in a 2-dimensional plane, forming a donut-like shape. The distribution is defined by two parameters: the radius r and spread s, in which the distance to the origin follows a normal (Gaussian) distribution around r, with a standard devia...
stackexchange_codegolf
Background Often, when storing a number in binary with some maximum, we simply round the maximum to the next power of two then allocate the number of bits nececairy to store the whole range. Lets call the result of this method \$S(x, m)\$ where x is the number and m is the maximum. While not bad, the naive has a few bi...
stackexchange_codegolf
Your toy in this challenge is a special abacus of 4 rows and 8 positions per row. There's one bead on the first row, 2 beads on the 2nd row, 3 beads on the 3rd row and 4 beads on the 4th row. Beads on a same row are glued together, which means that they can only be moved as a block. Below is a valid configuration of th...
stackexchange_codegolf
Web safe colors are in intervals of 51, they include 0, 3, 6, 9, c, and, f as digits in hex (such as #993333), or 0, 51, 102, 153, 204, 255 in decimal. Your task today is convert a given color to a web safe one. You may read more about web safe colors on Wikipedia. Input You will take in 3 integers between 0, 255 inclu...
stackexchange_codegolf
Almost equivalent to Project Euler's first question: If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. Challenge: Given a positive integer N and a set of at least one positive inte...
stackexchange_codegolf
Your task is to given two integer numbers, a and b calculate the modular multiplicative inverse of a modulo b, if it exists. The modular inverse of a modulo b is a number c such that ac ≡ 1 (mod b). This number is unique modulo b for any pair of a and b. It exists only if the greatest common divisor of a and b is 1. Th...
stackexchange_codegolf
Introduction Briscola is one of Italy's most popular card games. It is a trick-taking card game, like Bridge. Briscola is well known for its bizarre point system. In this challenge, given two cards, you will output whether the first one scores more, less, or the same number of points as the second in Briscola's point s...
stackexchange_codegolf
Part of Advent of Code Golf 2021 event. See the linked meta post for details. The story continues from AoC2015 Day 5, Part 2. Santa needs help figuring out which strings in his text file are naughty or nice. He has already tried two sets of rules, but they're totally ad-hoc, cumbersome, and janky, so he comes up with ...
stackexchange_codegolf
Task Write a program or function that takes as input a time in UTC, and outputs the equivalent time in 5 different cities around the world. The cities displayed are up to the programmer, but the time must be different in each city. To prevent golfers from using overly obscure city names, the city names used must appear...
stackexchange_codegolf
Let \$ A \$ represent the alphabet, such that \$ A_1 = \$ a and \$ A_{26} = \$ z. Let's define that a word \$ W = w_1 w_2 ... w_n \$ (where \$ w_c \in A\$) is in standard order if and only if: \$ w_1 = A_1 \$, and for \$ 2 \le i \le n \$, if \$ w_i = A_x \$ then \$ w_j = A_{x-1} \$ for some \$ j < i \$ and some \$x\$....
stackexchange_codegolf
inspired by this chat conversation A satisfying number is a number whose decimal representation is of the form abx, with the following properties: x is the longest trailing repeating suffix, or the last digit if there is no repetition at the end (123333 -> 3333, 545656 -> 5656, 123 -> 3) b is the single digit prior to...
stackexchange_codegolf
This challenge is inspired by this Oliver Sacks quote: “At 11, I could say ‘I am sodium’ (Element 11), and now at 79, I am gold.” ― Oliver Sacks I want you you find numbers in a string and replace them with their corresponding elements' symbols. (1 is H, 2 is He, 3 is Li, etc.) There are a few rules to follow: Sin...
stackexchange_codegolf
Given a positive integer n, simplify the square root √n into the form a√b by extracting all square factors. The outputted a,b should be positive integers with n = a^2 * b with b as small as possible. You may output a and b in either order in any reasonable format. You may not omit outputs of 1 as implicit. The outputs...
stackexchange_codegolf
This is the robbers' thread to a cops-and-robbers challenge. Click the link to find the cops' thread. In the cops' thread of this challenge, answerers will be writing programs which output two numbers, \$x\$ and \$y\$. As robbers, your goal will be to crack their submissions. To do this, you find a program in the ...
stackexchange_codegolf
Given a number N, output/return X so that N+X is a palindrome, where |X| has to be as small as possible. Palindrome: A number is a palindrome, if its sequence of digits is the same when reading them from left to right as when reading from right to left. 95359 and 6548456 are symmetric, 123 and 2424 are not. Numbers wit...
stackexchange_codegolf
In Minecraft, pistons are blocks that can move other blocks. However, they can only move at most twelve blocks, and won't work at all if any obsidian is in the way. Also, slime blocks are sticky and stick to other blocks, except for obsidian. Your challenge Take as input a 5x5 matrix or similar, containing one piston a...
stackexchange_codegolf
Background We will be using a 3x3 cube for this challenge. Rubik's cubers have their own notation for movements on the cube: Each of the 6 faces has a clockwise turn notated with a single capital letter: UDLRFB. There are three additional letters MES denoting the three center slices. Counterclockwise rotations have a ...
stackexchange_codegolf
Given two positive integers, \$A\$ and \$B\$, illustrate their least common multiple by outputting two lines of dashes (-) with length \$\text{lcm}\$\$(A, B)\$ after replacing every \$A\$th dash in the first line and every \$B\$th dash in the second line with vertical bars (|). In this way, the end of each line will be...
stackexchange_codegolf
The day of the week and month of the year seem to get a lot of attention but no one seems to care about the week of the year. I believe it's time to change that, so your job is to write a program or function that when given a date outputs an integer between 1 and 53 corresponding to the current week of the year. For th...
stackexchange_codegolf
Background I have a collection of "weekday socks", which are seven pairs of socks labeled by the days of the week. When I wash my socks, they end up in a pile, and I must arrange them into the correct pairs before putting them into the closet. My strategy is to pull one random sock from the pile at a time and put it on...
stackexchange_codegolf
An Izhikevich neuron is a simple yet quite effective model of a biological neuron, designed for use in a discrete time-stepping simulation. In this golfing challenge, you will be implementing this model. Parameters This model involves only 7 variables organized into 2 differential equations, compared to the dozens of p...
stackexchange_codegolf
Write a program or function that takes in a positive integer N and outputs the first N numbers of this amplifying zigzag pattern, using only the lines needed: 26 25 27 . 10 ...
stackexchange_codegolf
Game The game is simple. Test the user's response time by asking them to enter the correct value that is displayed on the screen in the shortest time possible. Each round of the game will be as follows: Show Value ----> Get Response ----> Check Response ----> Report Response Time Example ROUND ONE --------- COMPUTER ...
stackexchange_codegolf
As code-golfers, we're not used to releasing (surely). We're gonna need a few tools to help us do that. Of course, to help marketing a new release, we need a nice and shiny Release Version. Who doesn't get excited when they hear about version 3.0.0? Task Your task will be to write a program/routine/... to increment a v...
stackexchange_codegolf
Introduction There comes a point in childhood when you think you've mastered adding and multiplying, then someone comes along and informs you that: a * b + c = (a * b) + c != a * (b + c), and that it wasn't as simple or linear a process as you were earlier taught. You learn that there exists something called the order ...
stackexchange_codegolf
Input A single-character string containing an uppercase or a lowercase letter from the English alphabet. Alternatively, you may handle only uppercase or only lowercase letters as input. Output This 3x3 typeface of the input letter (source), with two distinct, printable ASCII characters of your choice (excluding tabs a...
stackexchange_codegolf
Input A string that contains at most one of each of the letters A, B, and C. They may be in any order. The empty string is valid input. Note: A previous version of this challenge used the letters LEJ instead of ABC and they may still be used if desired. Output A string of the A, B, C letters that were not present in th...
stackexchange_codegolf
We consider two integers to be similar if, when written in decimal, have the same length, and if we compare characters in any two positions for both decimal strings, the comparison results (less, equal or greater) must be the same in both strings. Formally, for two number that can be written as decimal strings \$a_1a_2...
stackexchange_codegolf
Gemtext is a very simple markup format used by the alternative web protocol Gemini. Write a Gemtext to HTML converter. From the Wiki: A line of text is a paragraph, to be wrapped by the client. It is is independent from the lines coming before or after it. A list item starts with an asterisk and a space. Again, the r...
stackexchange_codegolf
Suppose we have two different types of coin which are worth relatively prime positive integer amounts. In this case, it is possible to make change for all but finitely many quantities. Your job is to find the largest amount that cannot be made with these two types of coin. Task Input: A pair of relatively prime integer...
stackexchange_codegolf
How to Given an integer n start with n ones (i.e. 4 -> 1 1 1 1). Then sum up the last n numbers, and repeat. For n = 4 this looks like this: Start with 1 1 1 1, sum up the last 4 numbers resulting in 1 1 1 1 4, then sum up the last 4 numbers resulting in 1 1 1 1 4 7, then sum up the last 4 numbers resulting in 1 1 1 ...
stackexchange_codegolf
Background I was working on a StackOverflow helper program (that sends me notifications) when I noticed something rather interesting in StackOverflow's Network tab: StackOverflow uses WebSockets (not too surprising, but good to know)! For this challenge, we will be conquering StackOverflow's web socket server. This p...
stackexchange_codegolf
Some built-in functions in PHP return mixed types, like file_get_contents that returns both string or false. Union structs in C can be used to simulate this, but is there a way to make it polyglot, that is, can be run in both PHP and C without (major) modification? Macros is often one way. $result === false can be rep...
stackexchange_codegolf
Introduction I can type at a moderate pace, using the QWERTY keyboard layout. But if a word like yellowwooddoor has a ton of repeated letters, it takes a bit longer to type it. Even worse is when a word like "jump" has the same finger used for multiple different consecutive letters. Here's how long it takes me to type ...
stackexchange_codegolf
In this challenge, your input is an integer value. Your task is to find the sum of the range of the sum of the range of n. Examples: Input -> Output 1 -> 1 2 -> 6 3 -> 21 4 -> 55 5 -> 120 6 -> 231 7 -> 406 8 -> 666 9 -> 1035 10 -> 1540 This challenge should be fairly simple to co...
stackexchange_codegolf
Requirement: Write a program (in any language) that counts the number of lines of code in files matching *.sh in the directory tree starting from the directory that the program is executed in, excluding lines that are empty, only contain whitespace, or are just single-line comments (a line which the first character tha...
stackexchange_codegolf
This challenge was greatly inspired by this Stack Overflow post. Challenge Given a bunch of clients in terms of when they enter a room and when they exit it, determine the period(s) of time when the room has a maximum number of people. The time resolution should be to the minute. For example, if there are three clients...
stackexchange_codegolf
Challenge Create a function or program that, when given an integer size, behaves the following way: If size is equal to 1, output ┌┐ └┘ If size is greater than 1, apply the following substitutions : Source Target ┌ ┌┐└┌ ┐ ┌┐┐┘ └ ┌└└┘ ┘ ┘┐└┘ Note: this is basically a Unicode box-drawing version of the...
stackexchange_codegolf
This serves as a catalog for tips related to golfing in Burlesque. Burlesque is a lazy, esoteric programming language. It's mostly used on anarchy golf while popularity on Codegolf is not as high. However, this catalog is intended to be used by people golfing on anarchy golf as well. Please only mention tricks and not...
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
For a given positive integer, try to find out the smallest possible rotation resulted by rotating it 0 or more bits. For example, when the given number is 177, whose binary representation is \$10110001_{(2)}\$: \$ 10110001_{(2)}=177 \$ \$ 01100011_{(2)}=99 \$ \$ 11000110_{(2)}=198 \$ \$ 10001101_{(2)}=141 \$ \$ 00011...
stackexchange_codegolf
First 15 numbers of the A046173: 1, 99, 9701, 950599, 93149001, 9127651499, 894416697901, 87643708742799, 8588189040096401, 841554882220704499, 82463790268588944501, 8080609891439495856599, 791817305570802005002201, 77590015336047156994359099, 7603029685627050583442189501 Your task is simple, output the first 20 numbe...
stackexchange_codegolf
Due to technical limitations of Stack Exchange, the title is rendered incorrectly. The correct title for this challenge is Make a Word Icicle! Word Icicle Word cicle ord cicle ord icle ord i le or i le or i l or l or r Today's challenge is to make icicles out of t...
stackexchange_codegolf
For a given number n, output an strictly decreasing array whose sum is n and its lexicographical order is the smallest for any possible outputs Smallest lexicographical order means that for or sum n=9 the following strictly decreasing arrays are possible: [[9],[8,1],[7,2],[6,3],[5,4],[6,2,1],[5,3,1],[4,3,2]]. Putting t...
stackexchange_codegolf
Groups are a widely used structure in Mathematics, and have applications in Computer Science. This code challenge is about the fewest # of characters to create a group table for the additive group Zn. How the table is constructed: For Zn, the elements are {0, 1, 2, ..., n-1}. The table will have n rows and n columns. F...
stackexchange_codegolf
Interpret DOGO DOGO is a lesser known programming language. While the original DOGO (a joke language from a Usenet post) has never been implemented, a language resembling it has been created. The commands for the language are: +===========+================================================================+ | Command | ...
stackexchange_codegolf
Given a list of positive integers that contains at least 3 distinct entries, output a permutation of that list that isn't sorted in ascending or descending order. Examples 1,2,3 -> 2,1,3 or 3,1,2 or 1,3,2 or 2,3,1 1,2,3,3 -> 2,1,3,3 or 3,1,2,3 or 1,3,2,3 etc.. Thanks @Arnauld and @NoOneIsHere for the title!
stackexchange_codegolf
Disclaimer: This is heavily inspired by "Polyglot the OEIS!" but fixes the problem that lead to closure (see the output section) and was re-posted as to not invalidate answers. Introduction We all know and love the on-line encyclopedia of integer sequences (OEIS). So what if we made an off-line version of the interesti...
stackexchange_codegolf
Today's challenge is simple: Without taking any input, output any valid sudoku board. In case you are unfamiliar with sudoku, Wikipedia describes what a valid board should look like: The objective is to fill a 9×9 grid with digits so that each column, each row, and each of the nine 3×3 subgrids that compose the grid (...
stackexchange_codegolf
From Wikipedia: The centroid of a non-self-intersecting closed polygon defined by n vertices (x0,y0), (x1,y1), ..., (xn−1,yn−1) is the point (Cx, Cy), where and where A is the polygon's signed area, In these formulas, the vertices are assumed to be numbered in order of their occurrence along the polygon...
stackexchange_codegolf
Given one line that consists of only letters, process as following: You maintain a string that's empty at the beginning. If the next input character is in the string, remove it from the string. If the next input character isn't in the string, append it to the string. Output the final state of the string. You can saf...
stackexchange_codegolf
Happy New Year 2024! 2024 is a tetrahedral number. A tetrahedral number is a number that can be represented in the form \$n(n+1)(n+2)/6\$ for some positive integer \$n\$. Or, equivalently, they are the sum of the first \$n\$ triangular numbers. They are also the number of objects in a triangular pyramid which has \$n\$...
stackexchange_codegolf
Given a string of ASCII letters (upper and/or lower case), output the raw MathJax required to display that string bifurcating at each character, into superscripts and subscripts. For example, the inputs cat and horse would result in outputs which MathJax renders as the following, respectively: Note that only one inpu...
stackexchange_codegolf
Challenge Create a function or program that, when given an integer size, behaves the following way: If size is equal to 1, output ┌┐ └┘ If size is greater than 1, apply the following substitutions : Source Target ┌ ┌┐└┌ ┐ ┌┐┐┘ └ ┌└└┘ ┘ ┘┐└┘ Note: this is basically a Unicode box-drawing version of the...
stackexchange_codegolf
Context (Feel free to skip, doesn't really matter for the algorithmic explanation of the task) European Portuguese is a fairly complicated language to learn, mostly because of its grammar. One particular annoying thing is conjugating the verbs correctly: We have this mechanism that, when we have a verb followed by a no...
stackexchange_codegolf
Task Given a string of English names of digits “collapsed” together, like this: zeronineoneoneeighttwoseventhreesixfourtwofive Split the string back into digits: zero nine one one eight two seven three six four two five Rules The input is always a string. It always consists of one or more lowercase English digit nam...
stackexchange_codegolf
Your task is to accept as input two "ASCII Art"s, and align each piece of art next to each other horizontally. For example, say you have two strings, "abc\ndef" and "123\n456". You need to align them horizontally to produce the string "abc123\ndef456". I'm calling this "aligning horizontally" because while the inputs, ...
stackexchange_codegolf
Challenge Generate two \$16 \times 16\$ grids, each initially filled with "@" symbols and spaces. Each cell in the grids should be independently filled with an "@" or a space, with each character having an equal probability (\$50\%\$) of being chosen for each cell. This ensures that both grids start off identically, wi...
stackexchange_codegolf
Your goal is to alternate uppercase and lowercase letters, while ignoring non-alphaneumeric characters. Input => Output abc => aBc OR AbC a c => A c OR a C abc123abc => AbC123aBc OR aBc123AbC Shortest answer wins.
stackexchange_codegolf
Given some raw HTML, sanitize it by formatting the spaces, as defined below. Output rules: Like many challenges, this one is inspired by XKCD. First, "untag" all tags with nothing but spaces in them. (<i>te<b> </b>xt</i> becomes <i>te xt</i>). If a tag has nothing in it (like <b></b>, simply delete it and move o...
stackexchange_codegolf
A completely even number is a positive even integer whose divisors (not including 1) are all even. Some completely even numbers are: 2 (divisors: 2, 1) 4 (divisors: 4, 2, 1) 16 (divisors: 16, 8, 4, 2, 1) 128 (divisors: 128, 64, 32, 16, 8, 4, 2, 1). Some non-completely even numbers are: 10 (divisors: 10, 5, 2, 1) 12 ...
stackexchange_codegolf
Your task Randomly pick and print "Joe Mama" or "Joe Biden" in as little bytes as possible. Rules No trailing lines, spaces, or anything else weird like that No election fraud! Both "Joe Mama" and "Joe Biden" must have equal chaces of winning Prize The winner will get a spot in https://github.com/Sid220/joe-mama-or-j...
stackexchange_codegolf
Your task is to get two numbers, and output the digit sum of them. We'll define digit sum as the following: take the decimal (base 10) digits of each of them, and pad with 0s the shortest number (e.g. [1,9], [0, 7]) sum the digits as vectors (e.g. [1, 16]) convert the number back from base 19, and output it (e.g. 1*19...
stackexchange_codegolf
Challenge Given the Cartesian coordinates of two or more distinct points in Euclidean n-space (\$\mathbb{R}^n\$), output the minimum dimension of a flat (affine) subspace that contains those points, that is 1 for a line, 2 for a plane, and so on. For example, in 3-space (the 3-dimensional world we live in), there are a...
stackexchange_codegolf
Write the shortest code measured by byte count to generate an ASCII grid composed of rhombi, given the following parameters: m - number of complete rhombi in one row n - number of rows s - side of the smallest rhombus r - level of nesting - how many rhombi are there inside the "base ones" (which are fonud between the...
stackexchange_codegolf
You will receive an integer less than 2000000000 and bigger than -2000000000 and you have to test what type(s) of number this is out of: Factorial Square Cube Prime Composite Triangular Positive Negative Here is a definition of all the different types of numbers: Factorial - A number That is equal to the product of a...
stackexchange_codegolf
Write a program or function that takes an input greater than or equal to 2. It should output a truthy or falsy value corresponding to whether the input is a Lucas number or not. You may take input from STDIN, or whichever source is most suitable to you. This question is different to this one because this question is sp...
stackexchange_codegolf
Consider the following probability puzzle. We start with a string of bits all set to 0. At each step we choose a bit uniformly and independently at random and flip it. The value your code has to compute is the probability of getting to the all 1s bit string before you get back to the all 0s bit string. Let \$n\$ be the...
stackexchange_codegolf
Recamán's Sequence is defined as follows: \$a_n=\begin{cases}0\quad\quad\quad\quad\text{if n = 0}\\a_{n-1}-n\quad\text{if }a_{n-1}-n>0\text{ and is not already in the sequence,}\\a_{n-1}+n\quad\text{otherwise}\end{cases}\$ or in pseudo-code: a(0) = 0, if (a(n - 1) - n) > 0 and it is not already included in the sequ...
stackexchange_codegolf
With this challenge we pay homage to everyone around the whole world fighting against the coronavirus crisis; particularly represented are the people tied to medicine, as the Rod of Asclepius is a symbol associated with medicine and health care. For that matter, we resort to some ASCII art found at asciiart.eu (wrongfu...
stackexchange_codegolf
Some sleep commands implement a delay of an integer number of seconds. However, 2³² seconds is only about 100 years. Bug! What if you need a larger delay? Make a program or a function which waits for 1000 years, with an error of less than ±10%. Because it's too time-consuming to test, please explain how/why your soluti...
stackexchange_codegolf
This is the Grid Game: It's a game based on cellular automata, where the aim is to remove all of the pieces belonging to your opponent. How it works: There are two kinds of piece in the game, cities and walkers. Each player starts with one city (marked with C and a number, which is it's health), which will regularly ...
stackexchange_codegolf
Related: Sort these bond ratings Credit rating agencies assign ratings to bonds according to the credit-worthiness of the issuer. The rating business is mostly controlled by "Big Three" credit rating agencies (i.e. Fitch Ratings, Moody's, and Standard & Poor's (S&P)), which use a similar tiered rating system. Task For ...
stackexchange_codegolf
Given two integers, s and e, print the title of Black Mirror series #s episode #e. Expected output is as below, case sensitive. Output for blank cells and invalid inputs is unspecified. e↓s→ 1 2 3 4 5 ...
stackexchange_codegolf
You place a standard die at the origin of a 2D grid that stretches infinitely in every direction. You place the die such that the 1 is facing upwards, the 2 is facing in the negative y direction, and the 3 is facing in the positive x direction, as shown in the figure below: You then proceed to execute a series of move...
stackexchange_codegolf