text
stringlengths
180
608k
[Question] [ For those who didn't know, **[Sigma](https://en.wikipedia.org/wiki/Sigma)** is a Greek letter which is heavily used in mathematics as the summation sign. Given a string representing an expression depending on \$k\$ that we will denote \$E(k)\$, compute the sum of the results for \$E(k)\$, for each \$k\...
[Question] [ Your task is to take a list of arguments that are either integers or operators, and parse them like so: 1. There is a current operator, which starts as +. 2. Each time an operator is found, the current operator will change to it. 3. The possible operators are: "+", "-", "\*", "/", and "%", which corres...
[Question] [ # Article Spinning with Spintax [Article spinning](https://www.google.ca/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=0CCQQFjAB&url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FArticle_spinning&ei=-C2EVYfsLoj1-QHrq7zwAQ&usg=AFQjCNGREvbaE6Y8WeFsVc73xXEWAndlkA&sig2=j5rz3g_FG9bqHZ8YeEAqAg) is a ...
[Question] [ I got an email from Hugo Pfoertner, an Editor-in-Chief at the On-Line Encyclopedia of Integer Sequences, with a terrific idea for a [fastest-code](/questions/tagged/fastest-code "show questions tagged 'fastest-code'") challenge, which will also help verify or expand the boundary of an open mathematical...
[Question] [ This is code golf. For this challenge, I will accept a method (you don't need a full program), but the method signature does count towards the byte count and I want to see the full signature (not a lamdba). The input for the method is an integer array with 81 elements. The output/return value from the ...
[Question] [ A hill number is a number that has **the same digit in the first & the last**, but that's not all. In a hill number the first digits are **strictly increasing** until the largest digit, and after the largest digit, the last digits are **strictly decreasing. The largest digit can be repeated but consecu...
[Question] [ Given a list of indices and zero or more lists of integers, output the lists of integers, sorted in ascending order, with the key priority from the first input. ## Example Let the keys input be `[1, 0, 2]`, and the lists input be `[[5, 3, 4], [6, 2, 1], [5, 2, 1]]`. Those lists need to be sorted by the...
[Question] [ ## 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,...
[Question] [ If the agent is at the origin it always moves right when you choose it. The goal is to get one agent to 10. The cost is the sum of the square of the total number of moves (left or right) taken by each individual agent until the first agent gets to 10. You want to minimise the expected cost Once you hav...
[Question] [ Let a counting tree be a rooted tree in which every node is labeled with the number of descendants it has. We can represent such trees as ragged lists with each node being represented by a list containing its label followed by its children. For example the following is a counting tree: ``` [5,[2,[0],[0...
[Question] [ [proposed by @Adám in chat](https://chat.stackexchange.com/transcript/message/62831208#62831208) Given an even number of finite points return a line \$y=mx+b\$ that evenly splits the points on both sides. ## Specs * Take a list of distinct points \$(x,y)\$ (or a list of x-coordinates and a list of y-co...
[Question] [ A [band matrix](https://en.wikipedia.org/wiki/Band_matrix) is a matrix whose non-zero entries fall within a diagonal *band*, consisting of the main diagonal and zero or more diagonals on either side of it. (The [main diagonal](https://en.wikipedia.org/wiki/Main_diagonal) of a matrix consists of all ent...
[Question] [ The game [shapez.io](https://shapez.io) has a huge variety of shapes you can produce, such as: [![enter image description here](https://i.stack.imgur.com/GbCUE.png)](https://i.stack.imgur.com/GbCUE.png) Each shape has a unique *short code*, for example the above is `CrWbScRu`. This means, going clockwi...
[Question] [ Your task is to write a program or function that takes as input a list of positive integers and determines if there are any two integers in the list, that both appear the same number of times. For example the list ``` [1, 2, 3, 2] ``` Has one 1 and one 3 so it satisfies the condition. But the list ``` ...
[Question] [ Given a number as input, print out its **collective sum** What is a collective sum? Consider the number `13214`, the input Looping through each of the digits starting from the left, we will be able to obtain its collective sum. `1` means look at the first digit, and add it to the sum, sum = 1 `3` means...
[Question] [ Grouping takes a list and splits it into new lists of equal adjacent elements. For example ``` [1,1,2,1,1] -> [[1,1],[2],[1,1]] ``` If you then take the length of these groups you get a new list of integers ``` [1,1,2,1,1] -> [2,1,2] ``` Your task is to write a program that takes a list of positive int...
[Question] [ Given a number \$n\$, we have its sum of divisors, \$\sigma(n)\ = \sum\_{d | n} {d}\$, that is, the sum of all numbers which divide \$n\$ (including \$1\$ and \$n\$). For example, \$\sigma(28) = 1 + 2 + 4 + 7 + 14 + 28 = 56\$. This is OEIS [A000203](https://oeis.org/A000203). We can now define the sum ...
[Question] [ ## Challenge Given two integer values \$a \ge 2\$ and \$0 \le b < a\$, generate a \$(2a-1) \times (2a-1)\$ matrix consisting of the integers 0, 1, and 2 as follows: 1. Create a checkerboard of 0s and 1s of the given size, corners being 0. 2. If \$b > 0\$, overwrite the checkerboard with 2s in the X sha...
[Question] [ ## Background The sequence in the title is [A245788](https://oeis.org/A245788) "n times the number of 1's in the binary expansion of n" ("times" here means multiplication), which starts like this: ``` 1, 2, 6, 4, 10, 12, 21, 8, 18, 20, 33, 24, 39, 42, 60, 16, 34, 36, 57, 40, 63, ...
[Question] [ A deck of cards is the Cartesian product of `S` suits and `R` ranks. Many, though not all, card games use `S=4` and `R∊{6,8,13}`. A hand of `H` cards is dealt from the deck. Its *distribution*, a.k.a. "hand pattern", is an array that describes how many cards you got from each suit, ignoring suit order ...
[Question] [ Given two positive integers `a` and `b`, output two positive integers `c` and `d` such that: * `c` divides `a` * `d` divides `b` * `c` and `d` are co-prime * the [least common multiple](https://en.wikipedia.org/wiki/Least_common_multiple) of `c` and `d` equals the least common multiple of `a` and `b`. ...
[Question] [ *Randomly inspired by [Numbers Increase While Letters Decrease](https://codegolf.stackexchange.com/q/138200/42963)* Given a list of mixed letters and integers (e.g., `['a', 2, 3, 'b']`) *increase* the letters by one position in the alphabet (wrapping at `z` to `a`) and *decrease* the numbers by 1. For ...
[Question] [ **Terminology** An increasing number is one where each digit is greater than or equal to all the digits to the left of it (ex. 12239) A decreasing number is one where each digit is less than or equal to all the digits to the left of it (ex. 95531) A bouncy number is any number that is not increasing or...
[Question] [ # Challenge The challenge is to write a code that takes a positive integer 'n' as an input and displays all the possible ways in which the numbers from 1 - n can be written, with either positive or negative sign in between, such that their sum is equal to zero. Please remember that you may only use add...
[Question] [ I have written [a few challenges](https://codegolf.stackexchange.com/search?q=user:31516%20[matrix]%20is:question) related to matrices, and common for all are that I use a format like the one below when representing the matrices, both in examples and in test cases: ``` 16 2 3 13 5 11 10 ...
[Question] [ The program must output the letter that is paired the most. For example, if your program was given the following string: ``` "Sally's friend Bobby searched for seashells." ``` it must output `L` because `"ll"` occurs twice, which is more frequent than the other pair `"bb"`. Rules: * If more than one l...
[Question] [ [F# solutions known inside 140 chars](http://trelford.com/blog/post/Sundays.aspx), and this is a [Rosetta Code](http://rosettacode.org/wiki/Find_the_last_Sunday_of_each_month) problem. Required result on stdout or in a string variable for input year `2014`: ``` 2014-01-26 2014-02-23 2014-03-30 2014-04...
[Question] [ ### Inspiration The longest words that can be typed with only the left hand on a standard QWERTY keyboard are "sweaterdresses", "tesseradecades", and "aftercataracts" ([Source: Wikipedia](https://en.wikipedia.org/wiki/Longest_word_in_English#Typed_words)). ### Challenge Given as input a "keyboard" \$K\...
[Question] [ # The challenge Given a positive integer `N`, compute the proportion of `N`-step walks on a plane that don't intersect themselves. Each step can have any of the `4` possible directions North, East, South, West. A walk intersects itself if it visits a previously visited point. # Examples * `N=1`: a sin...
[Question] [ A [superabundant number](https://en.wikipedia.org/wiki/Superabundant_number) is an integer *n* that sets a new upper bound for its ratio with the [divisor sum function](https://en.wikipedia.org/wiki/Divisor_function) σ. In other words, *n* is superabundant if and only if, for all positive integers *x* ...
[Question] [ I have a problem for a cyber club that asks you to print: ``` ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9876543210/.-,+*)('&%$#"! ``` Using Brainf\*\*k in 29 bytes or less without using the ',' character. I have a working code: ``` ++++++++++[>++++++>+++++++++<<-]>-->.<[>-.<-] ``` However my loop is too long, ...
[Question] [ You are given a single printable ASCII string containing no newlines, and a multiline "mold", containing spaces (), and hashes (`#`). You must go character by character in the string, and replace **hashes** using the characters from the string in left-right, top-bottom order. If the string is too short...
[Question] [ Write a program that takes in a string of the four characters `()[]` that satisfies these points: * Every left parenthesis `(` has a matching right parenthesis `)`. * Every left bracket `[` has a matching right bracket `]`. * Matching pairs of parentheses and brackets won't overlap. e.g. `[(])` is inva...
[Question] [ Note: the title was misspelled intentionally. Given a string s, swap the first vowel runs of every 2 words. For this challenge, y is considered a vowel. For example, given an input of "great day sir": ``` 1. Input: "great day sir" 2. Identify pairs of words: "[great day] [sir]" (No word for sir to pair...
[Question] [ ## What? Let's say I have this graph: ``` 1 \ \ 2 3 \ / \ / 4 ``` I can represent it in 2 ways: 1. A list of connected vertices. `[[1,3],[2,4],[3,4]]` 2. A boolean matrix which shows where edges are: ``` c |1 2 3 4 --|------- 1 |0 0 1 0 2 |0 0 0 1 3 |1 0 0 1 4 |0 1 1 0 ----- or ...
[Question] [ You are given an \$ 25 \times 25 \$ square lattice graph. You are to remove certain nodes from the graph as to *minimize* your score, based on the following scoring system: Your score will be the \$ \text{number of nodes removed} \$ \$ + \$ the \$ \text{size of the largest connected component} \$. In t...
[Question] [ # Objective Given a dimension of an SI unit, convert the Lorentz-Heaviside version of a Planck unit \$1\$ into SI metric. # What is a Planck unit? [Planck units](https://en.wikipedia.org/wiki/Planck_units) are a set of units of measurement. It defines five fundamental constants of the universe as dimen...
[Question] [ **Challenge:** In the programming language of your choice, accept an [**integer**](https://en.wikipedia.org/wiki/Integer) as input in base 10, and output it in [**the negadecimal notation**](https://en.wikipedia.org/wiki/Negative_base), which is also known as base -10 **Example algorithm:** [This is an...
[Question] [ Traveling with electronics is always fun, especially when you need an adapter to charge them. Your challenge is to make planning a trip a little easier by checking if a given plug will be compatible with a given socket. ### Challenge Given a plug type and a socket type, return a value that indicates wh...
[Question] [ Oh no! I have a theory test soon and I don't remember the scales yet! Help me remember my major scales by printing the following: ``` 7♯ - C♯ D♯ E♯ F♯ G♯ A♯ B♯ C♯ 6♯ - F♯ G♯ A♯ B C♯ D♯ E♯ F♯ 5♯ - B C♯ D♯ E F♯ G♯ A♯ B 4♯ - E F♯ G♯ A B C♯ D♯ E 3♯ - A B C♯ D E F♯ G♯ A 2♯ - D E F♯ G A B C♯ D...
[Question] [ A standard ruler of length *n* has distance marks at positions 0, 1, ..., *n* (in whichever units). A [sparse ruler](https://en.wikipedia.org/wiki/Sparse_ruler) has a subset of those marks. A ruler can measure the distance *k* if it has marks at positions *p* and *q* with *p*−*q*=*k*. ### The challenge...
[Question] [ A [triangular number](https://en.wikipedia.org/wiki/Triangular_number) is a number that can be expressed as the sum of consecutive positive integers, starting at 1. They can also be expressed with the formula `n(n + 1) / 2`, where `n` is some positive integer. A number's digitangular counterpart is cal...
[Question] [ This question is inspired by this [answer](https://codegolf.stackexchange.com/a/656/8555). Coincidentally, I used to use Ethiopian Multiplication when I was a kid, but had never known the name of the method until recently. Ethiopian multiplication is a method of multiplying integers using only addition...
[Question] [ Consider the natural sequence up-to 6 *(disregard 1)*: ``` 2,3,4,5,6 ``` We start scanning from the left (in this case from 2), search for a number divisible by 2 (here 4) and then remove both the numbers from the list (here 2 & 4), such that the list reduces to: ``` 3,5,6 ``` We continue the same pro...
[Question] [ Write a function which takes a single positive integer *n* and returns the period of the decimal representation of 1/*n*. Test cases: ``` 1 -> 1 # 1/1 = 1.0000...... = 1._0 2 -> 1 # 1/2 = 0.5000...... = 0.5_0 3 -> 1 # 1/3 = 0.3333...... = 0._3 7 -> 6 ...
[Question] [ **Challenge** The challenge is to write a program that takes the coefficients of any n-degree polynomial equation as input and returns the **integral** values of x for which the equation holds true. The coefficients will be provided as input in the order of decreasing or increasing power. You can assum...
[Question] [ If a positive integer \$N > 2\$ has (strictly) less prime factors (without counting multiplicities) than its successor and its predecessor, we will call it a *factor-poor number*. In other words, \$\omega(N) < \omega(N - 1)\$ and \$\omega(N) < \omega(N + 1)\$, where \$\omega(N)\$ is the number of uniq...
[Question] [ Compress a sparse matrix using [Compressed sparse row (CSR, CRS or Yale format)](https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_row_.28CSR.2C_CRS_or_Yale_format.29). These are all the same form of compression (ignore new Yale). Input may be any 2d data structure (list of lists, etc): e.g...
[Question] [ Your task is to take an encrypted string as input, and output the string decrypted, to reveal its hidden message. The strings, both the input and output, will contain characters from this list of 64 ASCII-characters (note the leading space): ``` !"#$%&'()*+,-./0123456789:;=?@[\]^_abcdefghijklmnopqrstu...
[Question] [ Write a function or complete program that takes a positive number `n` and performs `n` steps of an iterative algorithm for calculating π that has quadratic convergence (i.e. it approximately doubles the number of accurate digits at every iteration) then returns or prints out 2n correct digits (includin...
[Question] [ Starting with `/\` you can create a [Sierpinski triangle](http://en.wikipedia.org/wiki/Sierpinski_triangle) like pattern by adding a line beneath such that... 1. Any loose branch `/` or `\` splits again into two branches: `/\`. 2. Any collision of branches `\/` dies with nothing (but spaces) under it. ...
[Question] [ Einstein wrote a riddle. He said that 98% of the world could not solve it. I solved this riddle in about 25 minutes while on the train to work. It's basically just deduction. # The riddle > > There are 5 houses in 5 different colors in a row. > > In each house lives a person with a different nation...
[Question] [ In this challenge you are asked to find in *how many ways* we can express a positive integer `n` as the sum of two positive integers `k` and the `reverse of k`. Here is an example using `n = 1069` : `188 + 881 = 1069` `287 + 782 = 1069` `386 + 683 = 1069` `485 + 584 = 1069` `980 + 89 = 1069` ...
[Question] [ # Objective Generate the original scrambled list, from the movements that an [Insertion Sort](https://en.wikipedia.org/wiki/Insertion_sort) would do to sort it. The original list will have all numbers from `0` to `N-1`(inclusive) where `N` is the size of the input. # Input A list containing the necessa...
[Question] [ # The Challenge For this challenge, you are supposed to determine if a given number is in the Cantor set. So first, let's define the Cantor set. First, start with the numbers between 0 and 1. Any numbers outside this range are not in the Cantor set. Now, let's divide the numbers into three equal parts:...
[Question] [ # Guide the Alphabet Given an array of directions, where the directions are defined as follows: ``` NW N NE W . E SW S SE ``` Or as indexes (you may use these indices for directions instead of the strings above): ``` 0 1 2 3 . 4 5 6 7 ``` You may choose either format, supporting both is not req...
[Question] [ **Input:** Two integers n and k given in any form that is convenient for your code **Output** A random non-decreasing sequence of k integers, each in the range 1 to n. The sample should be chosen uniformly from all non-decreasing sequences of k integers with integers in the range 1 to n. The output can...
[Question] [ Japanese kana characters correspond to a single sound in the Japanese language. With the exception of ん (*n*), every other kana consists of a consonant part and a vowel part. There is a natural ordering to Japanese kana, a sort of "alphabetical order", which is typically arranged in a 10 by 5 table: ``...
[Question] [ Don't you hate it when you want to copy-paste a list of numbers (vector, array ...), from one program to another, but the format you have the numbers on doesn't match the format you need it on? For instance, in MATLAB you may have a space separated list like this: ``` [1 2 3 4 5] (you can also have...
[Question] [ Write a program that takes an input to STDIN and makes all of the lowercase letters (including accented letters) in the `2k-1`th word uppercase and all the uppercase letters (also including accented letters) in the `2k`th word lowercase (`k` is a positive integer). The program should not affect any oth...
[Question] [ # The task Given a multiline string with ascii art operators and numbers, parse the expression! # Possible symbols Numbers: (3x4) ``` / /| | --- ___ _| | --- ___ _| | --- | | |_| | | ___ |_ | --- ___ |_ | | --- ___ / / | ___ |_| | | --- ___ |_| | --- ___ | | | | --- ``` Operators: (3x...
[Question] [ # Introduction My car speedometer was hacked! Instead of showing me how fast i'm driving, it just shows: "Vroooom!" Please help me know how fast i'm going. # Challenge Take a string as input, and check if it matches the regex `/^[Vv]ro*m!$/m`. In English that means any line of the string must start wit...
[Question] [ We define the function **g** as **g(n) = n XOR (n \* 2)** for any integer **n > 0**. Given **x > 0**, find the smallest integer **y > 0** such that **gk(y) = x** for some **k > 0**. ## Example ``` x = 549 549 = 483 XOR (483 * 2) (as binary: 1000100101 = 111100011 XOR 1111000110) 483 = 161 XOR (161 ...
[Question] [ ## Overview Your goal is to implement RC4 encryption. RC4 encryption, invented by Ron Rivest (of RSA fame), was designed to be secure, yet simple enough to be implemented from memory by military soldiers on the battlefield. Today, there are several attacks on RC4, but it's still used in many places tod...
[Question] [ ## Binary trees A binary tree is a tree with nodes of three types: * terminal nodes, which have no children * unary nodes, which have one child each * binary nodes, which have two children each We can represent them with the following grammar, given in [BNF](https://en.wikipedia.org/wiki/Backus%E2%80%...
[Question] [ A [bag](https://en.wikipedia.org/wiki/Multiset), also called a multiset, is an unordered collection. You can call it a set that allows duplicates, or a list (or an array) that is not ordered/indexed. In this challenge, you are asked to implement bag operations: addition, difference, multiplication, div...
[Question] [ # Scralphabet A normal bag of Scrabble tiles contains the following letters (`?` is a blank tile, which can stand for any other letter): ``` AAAAAAAAABBCCDDDDEEEEEEEEEEEEFFGGGHHIIIIIIIIIJKLLLLMMNNNNNNOOOOOOOOPPQRRRRRRSSSSTTTTTTUUUUVVWWXYYZ?? ``` The letters have the following value: ``` {"A": 1,"B": 3,...
[Question] [ I want to play Dungeons and Dragons, but I don't have any dice! Your challenge is to roll some D&D dice. The input format specification in [Backus-Naur form](http://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form) is: ``` <valid-input> ::= <opt-integer> "d" <integer> <opt-modifier> <opt-integer> ::= |...
[Question] [ # Task Given a set of `n` unique elements and a multiset `l` of positive numbers that add up to `n`, find all the ways of partitioning those unique elements into disjoint sets with sizes given by the elements of `l`. (A multiset is a set that allows repeated elements) The point here is that we are taki...
[Question] [ **Input:** a sequence of uppercase letters (ASCII [65;90]) which is the ***N**th*\* lexicographical permutation of the multiset of its characters \*permutations are numbered from 0 or 1 upwards **Output:** base-10 integer ***N*** --- ### Rulez * **There might be duplicates** *(that's how this challenge...
[Question] [ What is the shortest way to see if an input is a wordinian using any programming language? A wordinian is a word that contains words of length 1 to the original word's length. For example, > > ## bin > > > 'I' is a word > > 'in' is a word > > 'bin' is a word > > > Or, > > ## stage > > ...
[Question] [ Dead code sits there doing nothing, staring at us knowing it will never be executed... but today we can take revenge. ## Specification The input will be a multiline string. Each line may either be an **assignment** or an **expression** . ### Assignment An assignment is of the form `<name> = number` whe...
[Question] [ We've had a few challenges for base conversion, but all of them seem to apply to integer values. Let's do it with real numbers! # The challenge Inputs: * A real **positive number** *x*, expressed in base 10. This can be taken as a double-precision float or as a string. To avoid precision issues, the nu...
[Question] [ The 80's TV series [*Knight Rider*](https://en.wikipedia.org/wiki/Knight_Rider_(1982_TV_series)) featured an intelligent, self-aware car called KITT. One distinctive aspect of the car was a front-mounted scanner bar that allowed KITT to "see" (and that looked [suspiciously](https://en.wikipedia.org/wik...
[Question] [ Did you know that a small number can *borrow* bits from a larger number? Here's an example. Let's say our two numbers 5 and 14. First, write them out in binary: ``` 5 14 000101 001110 ``` First we take the smallest *on* bit away from the larger number, and we give it to the smallest *off* bit on...
[Question] [ ## Background A classical [logic gate](https://en.wikipedia.org/wiki/Logic_gate) is an idealized electronic device implementing a Boolean function, i.e. one that takes a certain number of Boolean inputs and outputs a Boolean. We only consider two-input logic gates in this challenge. There are \$2^{2 \t...
[Question] [ I'm letting this one out of the sandbox. Hopefully it is well-written and make sense, feel free to improve. So in order to make 1+ more popular (and ease the creation of golfed 1+ text-printing programs) here comes the metagolf challenge: ## The 1+ Language 1+ is a fun [deque-based](https://en.m.wikipe...
[Question] [ ### Introduction When you are given a boring text, you just want to get it over with as quick as possible. Let's observe the following text: ``` Ens colligi timenda etc priorem judicem. De quascunque ii at contingere repugnaret explicetur intellectu. Adjuvetis hoc fortassis suspicari opportune obvers...
[Question] [ # Introduction A code page maps integer values to a specific character. We can visualize a code page like this: ``` +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F | +---+---+---+---+---+---+---+---+---+---+---+--...
[Question] [ # Introduction The [Hausdorff distance](http://en.wikipedia.org/wiki/Hausdorff_distance) measures the difference between two subsets of a metric space. Intuitively, a metric space is just some set with a built-in distance function; in this challenge, we will use natural numbers with the ordinary distan...
[Question] [ ## Description Given an object (json), write code to extract all the keys from it. This is a question that I really wanted to ask everybody for a long time ago but I did not have time to write it up. It can be helpful in some cases in your daily work. ## Rule: * You can use any parse function to get th...
[Question] [ *This challenge is related to some of the MATL language's features, as part of the [May 2018 Language of the Month](https://codegolf.meta.stackexchange.com/questions/16337/language-of-the-month-for-may-2018-matl) event.* *Associated challenge:* [Function clipboard: copy](https://codegolf.stackexchange....
[Question] [ ### Background If you do much code golfing, you're likely aware of the [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) operation. Given two integers, it gives another integer with `1`s in the bits where the two inputs differ. So, for example, `1010 XOR 0011 = 1001`. It turns out to b...
[Question] [ Many programming languages are written using solely printable ASCII, tabs and newlines. These 97 characters are then stored in 8-bit bytes (which are actually capable of holding 256 different characters!), which is just terribly inefficient - especially in code-golfing, where every byte counts! In this...
[Question] [ A very common need in algorithms classes and computer science in general is to iterate 4-directionally over a grid or matrix (such as in BFS or DFS). This seems to often result in a lot of clunky and verbose code with a lot of arithmetic and comparisons within loops. I've seen many different approaches...
[Question] [ ### Challenge Given a `n`-dimensional array of integers and a permutation of the first `n` natural numbers, permute the array dimensions accordingly. ### Details This challenge is inspired by MATLABs [`permute`](https://mathworks.com/help/matlab/ref/permute.html). [demonstration](https://tio.run/##y08u...
[Question] [ A "triplet bracket" (that I made up for this challenge) is one of the following: ``` (...+...) [...:...] {...|...} <...-...> ``` A balanced triplet bracket string (BTBS for short) is either an empty string, two BTBSes concatenated, or one of the above triplet brackets with each `...` replaced with a BT...
[Question] [ Consider the standard equilateral triangle, with nodes labeled using [barycentric coordinates](https://en.wikipedia.org/wiki/Barycentric_coordinate_system): ![](https://i.stack.imgur.com/URM7b.png) We can turn this 3 node triangle into a 6 node triangle by adding a new line of 3 vertices (one more than...
[Question] [ ### Goal Using the programming language of your choice, write the **shortest program** to eliminate comments from a string representing a C program. --- ### Input The string can be taken as any form of input, but it may also be taken as a variable. --- ### Instructions Two different kinds of comments a...
[Question] [ The video game [Minecraft](http://en.wikipedia.org/wiki/Minecraft) is all about placing and removing different types of blocks in the 3D [integer lattice](http://en.wikipedia.org/wiki/Integer_lattice) that makes up the virtual world. Each lattice point can contain exactly one block or be empty (an "[ai...
[Question] [ # Challenge This challenge will have you write a program that takes in two integers `n` and `m` and outputs the number non-intersecting loops on the `n` by `m` torus made by starting at `(0,0)` and only taking steps up and to the right. You can think of torus as the grid with [wraparound](https://en.wi...
[Question] [ Given an expression matching the regex `/^[-~]*x$/`, evaluate it in terms of `x` and output a string matching the regex `/^-?x[+-]\d+$/`. For example, the string `-~x` evaluates to `x+1`, while the string `-~-x` evaluates to `-x+1`, and the string `-~-~--x` evaluates to `x+2`. We start from `x` and eva...
[Question] [ When making a *Dungeons & Dragons* character, an alternative to [rolling ability scores](https://codegolf.stackexchange.com/questions/52906/roll-my-dd-characters-ability-scores) is to assign them within a power budget called point buy. Higher ability scores cost more points, especially towards the uppe...
[Question] [ This is the second in a series of puzzles that I will be posting every Monday at Midnight PST. The first puzzle is located [Here](https://codegolf.stackexchange.com/questions/54147/take-it-or-leave-it-a-game-show-for-computers). **Context:** > > A reclusive billionaire has created a game show to attra...
[Question] [ #### Background [*Scrabble*](https://en.wikipedia.org/wiki/Scrabble) is a word game in which players collaboratively build a board consisting of letter tiles that spell words. Each word must be connected to another word, and players gain points based on the letters they use and where they are placed. W...
[Question] [ Related: [Zeroes at the end of a factorial](https://codegolf.stackexchange.com/questions/79762/zeroes-at-the-end-of-a-factorial) Today, we are going to calculate how many zeroes are there at the end of \$n!\$ (the factorial of \$n\$) in base \$m\$. Or in other words: For given integers \$n\$, and, \$m\...
[Question] [ Given an integer from 1 to 999 inclusive, output a truthy value if it appears horizontally, vertically, or diagonally, either forwards or backwards, anywhere in the 3x3 square of digits 1-9 on a standard [number pad](https://en.m.wikipedia.org/wiki/Numeric_keypad): ``` 789 456 123 ``` If the number doe...
[Question] [ Suppose a codegolf challenge doesn't count whitespace in the length of your program. Cheat this system by encoding your script into whitespace, and golf a script which decodes and executes embedded whitespace. **Example** My solution to [JBernardo](https://codegolf.stackexchange.com/users/2212/jbernard...
[Question] [ I've recently stumbled upon a Russian site called [acmp.ru](https://acmp.ru/), in which one of the tasks, [HOK](https://acmp.ru/index.asp?main=task&id_task=14), asks us to find the LCM of two positive integers. The full statement, translated to English is as follows: > > The only line of the input con...
[Question] [ You teach a class of students with interesting preferences for how their chairs are arranged. There are 3 very specific requirements they have for how the chairs are arranged: 1. They most be arranged in a rectangle, even if it means some chairs go empty. 2. There must be as few empty chairs as possibl...