text
stringlengths
180
608k
[Question] [ # Credits This challenge originated from [@miles](https://codegolf.stackexchange.com/users/6710/miles). --- Create a function that computes the CRC32 hash of an input string. The input will be an ASCII string of any length. The output will be the CRC32 hash of that input string. # Explanation The algor...
[Question] [ # Introduction You're playing a matching game, in which coins are inserted at the top and fall to the bottom (onto the top coin) due to gravity. So this ``` O <- inserting this coin OO O OOOOO ``` will become this ``` O OO O OOOOO ``` Now imagine someone rotates the board clockwise. The following will ...
[Question] [ **Closed.** This question is [off-topic](/help/closed-questions). It is not currently accepting answers. --- This question does not appear to be about code golf or coding challenges within the scope defined in the [help center](https://codegolf.stackexchange.com/help/on-topic). Closed 1 year ago. ...
[Question] [ 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`,...
[Question] [ A cyclic [difference set](https://en.wikipedia.org/wiki/Difference_set) is a set of positive integers with a unique property: 1. Let `n` be the largest integer in the set. 2. Let `r` be any integer (not necessarily in the set) greater than 0 but less than or equal to `n/2`. 3. Let `k` be the *number of...
[Question] [ This question is heavily based off [this question](https://codegolf.stackexchange.com/questions/125879/find-all-the-anagrams), but should pose a number of additional difficulties. ## Your Task You must write a program or function that, when receiving a string, prints out all possible anagrams of it. Fo...
[Question] [ I made my own sequence recently (called the Piggyback sequence), and it works like this: `P(1)`, `P(2)` and `P(3)` = `1`. For all `P(n)` where `n>3`, the sequence works like this: ``` P(n) = P(n-3) + P(n-2)/P(n-1) ``` So, continuing the sequence: `P(4)` = `1 + 1/1` = `2` `P(5)` = `1 + 1/2` = `3/2` = `1...
[Question] [ There are N doors and K monkeys. Initially, all the doors are closed. **Round 1:** The 1st monkey visits every door and toggles the door (if the door is closed, it gets opened it; if it is open, it gets closed). **Round 2**: The 1st monkey visits every door and toggles the door. Then The 2nd monkey vi...
[Question] [ Inspired by [reddit](http://www.reddit.com/r/programming/comments/gvnfk/i_submit_a_hangman_game_i_made_in_c_about_15/). Write a program which plays [Hangman](http://en.wikipedia.org/wiki/Hangman_%28game%29). * The program chooses a random word from a list of N words, where N > 2. * The word list can b...
[Question] [ I know, a bit late. # Challenge Your challenge is, given a date, output if it's not an [Advent Sunday](https://en.wikipedia.org/wiki/Advent_Sunday), or the Advent Sunday of the year. # Rules * The \$4^\text{th}\$ Advent is determined by the Sunday before Christmas day (the \$25^\text{th}\$ of December)...
[Question] [ Your task is to create a good multiplication table for others to use. Given an integer \$n\$, generate a multiplication table that displays products up to \$n×n\$. You should start with \$2×2\$ as 1 times any number is itself and that is reflected in the row/column indices. Scientific notation and floa...
[Question] [ # Output Distinct Factor Cuboids Today's task is very simple: given a positive integer, output a representative of each cuboid formable by its factors. ## Explanations A cuboid's volume is the product of its three side lengths. For example, a cuboid of volume 4 whose side lengths are integers can have ...
[Question] [ *Based on a [chat message](https://chat.stackexchange.com/transcript/message/39355755#39355755)* ## The Challenge Given an input number \$n > 9\$, construct its reverse, ignoring leading zeros. Then, construct a list of all prime factors that the number and its reverse *don't* have in common. Multiply ...
[Question] [ ## Definitions * A **bijection** from a set `S` to a set `T` is a function from `S` to `T` such that one element in `T` is mapped by exactly one element in `S`. * A **bijection within a set** `S` is a bijection from `S` to `S`. * The **natural numbers** are the integers which are greater than or equal ...
[Question] [ You can decompose a number greater than 0 as a unique sum of positive Fibonacci numbers. In this question we do this by repeatedly subtracting the **largest possible** positive Fibonacci number. E.g.: ``` 1 = 1 2 = 2 3 = 3 4 = 3 + 1 12 = 8 + 3 + 1 13 = 13 100 = 89 + 8 + 3 ``` Now, I call a *Fibonacci p...
[Question] [ Your task is to convert a given **positive integer** from Arabic numeral to Roman numeral. Things get difficult when you count to 4000. The romans did this by adding a line above a symbol to multiply that symbol by `1 000`. However, overlines aren't exactly displayable in ASCII. Also, there are double ...
[Question] [ # The Challenge Write a program that can take an input of a single-line string containing any ASCII printable characters, and output the same string encoded in [Base85](https://en.wikipedia.org/wiki/Ascii85) (using a big-endian convention). You can assume that the input will always be ≤ 100 characters....
[Question] [ # The Question A *[Sophie Germain prime](http://en.wikipedia.org/wiki/Sophie_Germain_prime)* is a prime \$p\$ such that \$2p+1\$ is prime as well. For example, 11 is a Sophie Germain prime because 23 is prime as well. Write the shortest program to calculate Sophie Germain primes in ascending order # Ru...
[Question] [ # Input Two positive integers `a > b` # Output The smallest integer `c >= a` so that `c` can be factored into two parts with one part an integer power of two (that is at least two) and the other part no larger than `b`. # Examples If `b = 100` and `a = 101` , then the output should be 102 as 102 is 2 t...
[Question] [ Your task is to output a square sandbox of size `n+2` with `/` characters in the corners and `|` for the sides, and `-` for the top, with `n**2` layers of sand (`.`) overflowing out of the sandbox of width `n+2` # Testcases ``` 1 -> /-/ |.| /./ ... 2 -> /--/ |..| |..| /../ .... .... .... .... 3 -> /---...
[Question] [ A ***truncated square-pyramid*** of height \$h\$ has \$h\$ square layers where each layer has a side \$1\$ greater than the one above it, apart from the top layer which is a square of blocks with a given side length. Here is a truncated square-pyramid of height \$7\$ and top side-length \$4\$ viewed fr...
[Question] [ Given an integer **N** from 1-9, you must print an **N**x**N** grid of **N**x**N** boxes that print alternating 1s and **N**s, with each box having an alternating starting integer. **Examples** ``` Input: 1 Output: 1 Input: 2 Output: 12 21 21 12 21 12 12 21 Input: 3 Output: 131 313 131 313 131 ...
[Question] [ The *xorspace* of a set of integers is the set of all integers that can be obtained by combining the starting integers with the usual bitwise xor operator (`^`). For example, the xorspace of `(8, 4)` is `(0, 4, 8, 12)`: 0 is 4^4, 12 is 4^8, and no other numbers can be reached. Note that the starting nu...
[Question] [ An algebraic curve is a certain "1D subset" of the "2D-plane" that can be described as set of zeros `{(x,y) in R^2 : f(x,y)=0 }`of a polynomial `f`. Here we consider the 2D-plane as the real plane `R^2` such that we can easily imagine what such a curve could look like, basically a thing you can draw wi...
[Question] [ Given a string, consisting of a prefix and then "illion", convert this number into standard form. For example: ``` "million" -> 10^6 "trillion" -> 10^12 "quattuordecillion" -> 10^45 ``` The program needs to be able to handle input going up to Centillion, which is 10^303. A list of names and their stand...
[Question] [ You may have seen this one in *Die Hard: With a Vengeance*... This question is based on the famous 3 and 5 Litre Jug Puzzle, but with a slightly different slant. Golf up some code that when given an integer between 1 and 100 will provide you with the quickest instructions to measure out into a tank, th...
[Question] [ The smallest code that gives the area between the curve p(x) = a0 + a1\*x + a2\*x2 + ..., the line y = 0, the line x = 0 and the line x = C (i.e. something like this: ![wanted area](https://i.stack.imgur.com/0hj6T.png)) You can assume that p(x) >= 0 for x < C (bonus points if your code works for negati...
[Question] [ Sometimes I feel like the conversation is going down the wrong path and take it upon myself to steer it in another direction. And this conversation is going wrong real fast, so I need to change the subject in as few characters as possible.1 ## Task Given a list of sentences, return the sentences ordere...
[Question] [ You are given a non-empty list of positive integers. Your task is to figure out how many **distinct** numbers can be obtained by applying the following algorithm: 1. Remove either the first or the last item from the list and initialize **N** to the corresponding value. 2. Remove either the first or the...
[Question] [ You're organizing a treasure hunt for your friends. To conduct things more easily, you want to draw a map of all locations where you hid the precious objects. ## Input Any form of input denoting a list of points consisting of (nonnegative) x- and y-coordinate, `0 0` being the upper left corner is permi...
[Question] [ Given an integer `n`, return the number of ways that n can be written as a list of prime numbers. For example, `2323` can be written as `(2,3,23)`, `(23,23)` or `(2,3,2,3)` or `(23,2,3)`, so you would output `4`. If it can not be written in this way, you should output `0`. A prime number such as `019` ...
[Question] [ ## Challenge Given an input `n`, print an ASCII art cake `n` layers tall, viewed from the side, with two candles on top. Refer to the examples below for details. ## Output ``` >> cake(1) _|_|_ | | +-----+ >> cake(3) _|_|_ | | +---------+ | | +-------------+ | |...
[Question] [ ## The challenge Given an input string, and an integer *n* - truncate any runs of consecutive characters to a maximum of *n* length. The characters can be anything, including special characters. The function should be case sensitive, and *n* can range from 0 to infinity. Example inputs/outputs: ``` f("...
[Question] [ **This question already has answers here**: [Are the brackets fully matched?](/questions/77138/are-the-brackets-fully-matched) (48 answers) Closed 7 years ago. The contest is to make a program or function that takes an arbitrary string resembling source code and checks to see if the "braces" fol...
[Question] [ You will need to evaluate the definite integral (bounded by \$a\$ and \$b\$) of a certain polynomial function that takes the form of: $$\int\_a^b \left( k\_n x^n + k\_{n-1} x^{n-1} + \cdots + k\_2x^2 + k\_1x + k\_0 \: \right) dx$$ Normally, this can be done using the fundamental theorem of calculus and...
[Question] [ Leonardo of Pisa (ca. 1175 - ca. 1245) is better known as **Fibonacci**. But this is actually a short for the Latin "filius Bonacci" (the son of Bonacci) which was made up during the 18th century (according to [Wikipedia](https://en.wikipedia.org/wiki/Fibonacci)). In this challenge, you'll be given an ...
[Question] [ You will be given a 2-D array A of integers, and a length N. Your task is to find within the array the straight line (horizontal, vertical or diagonal) of N elements that yields the highest total sum, and return that sum. ### Example ``` N = 3, A = 3 3 7 9 3 2 2 10 4 1 7 ...
[Question] [ # Goal Sort a list of items ensuring that each item is listed after its specified dependencies. # Input An array of arrays of integers, where each integer specifies the 0-based or 1-based index of another item that this item must come after. The input may be an array or string or anything else human re...
[Question] [ **RTTTL**, or *Ring Tone Text Transfer Language* is a music format that was invented by Nokia ~~in the dawn of time when dinosaurs roamed the land~~. It allows for fairly crude pieces of music (no chords or anything), and the format is pretty simple which is why I think it's pretty cool. Take a look at...
[Question] [ The task is simply to see how much faster you can calculate n choose n/2 (for even n) than the builtin function in python. Of course for large n this is a rather large number so rather than output the whole number you should output the sum of the digits. For example, for `n = 100000`, the answer is `13...
[Question] [ With the recent [Python](https://codegolf.stackexchange.com/q/26323/8766) [bashing](https://codegolf.stackexchange.com/q/26371/8766), here's an attempt to show Python's strengths. Your challenge is to write a program that calculates the factorial of as high a number `n` as possible within 10 seconds. Y...
[Question] [ Write a brainfuck program of no more than 256 characters that takes as many steps as possible, but does not loop infinitely. The program may not take any input. More specifically: * Assume an infinite number of cells to the right. * A `<` when at the leftmost cell does nothing. * A `-` when cell value ...
[Question] [ Write a function that takes a number as an argument and makes it a palindrome by appending minimum number of digits. The number will be at max of 100 digits. ``` Sample Inputs 12 122 232 2323 1012121 Sample Outputs 121 1221 232 23232 101212101 ``` [Answer] ## Perl, 32 chars ``` s/((.)(?1)\2|.?)$/$...
[Question] [ *The absolute value of a number \$x\$ is normally written as \$|x|\$. The left and right side of the absolute value uses the same symbol, so it is not immediately obvious how to parse nested absolute values e.g. \$||1-2|+|3-|4-5|||\$* Your goal is to parse such an expression containing nested absolute ...
[Question] [ *Inspired by this Puzzling SE question: [All distances different on a chess board](https://puzzling.stackexchange.com/q/112705/25128).* ## Introduction Lets define a sequence \$a(n), n\geqslant 1\$ as how many pawns can you put on a \$n \times n\$ chessboard in such a way that all the distances between...
[Question] [ Write a program or function which takes three positive integers \$a, b, c\$ and returns/outputs one value if there is, and a different value if there isn't, a triangle on the square lattice, whose sides' lengths are \$\sqrt{a}, \sqrt{b}, \sqrt{c}\$. By "on the square lattice" I mean that its vertices a...
[Question] [ [*Migrated from chat*](https://chat.stackexchange.com/transcript/message/48293334#48293334) Given two non-empty non-negative integer matrices ***A*** and ***B***, answer the number of times ***A*** occurs as a [contiguous, possibly overlapping, submatrix](http://mathworld.wolfram.com/Submatrix.html) in...
[Question] [ # Definition * \$a(1) = 1\$ * \$a(2) = 2\$ * \$a(n)\$ is smallest number \$k>a(n-1)\$ which avoids any 3-term arithmetic progression in \$a(1), a(2), ..., a(n-1), k\$. * In other words, \$a(n)\$ is the smallest number \$k>a(n-1)\$ such that there does not exist \$x, y\$ where \$0<x<y<n\$ and \$a(y)-a(x...
[Question] [ [Fannkuch](http://3e8.org/pub/scheme/doc/lisp-pointers/v7i4/p2-anderson.pdf) is a classic benchmark program. The name comes from the German "Pfannkuchen"- pancakes- for the algorithm's resemblance to flipping stacks of pancakes. A Fannkuch sequence of *numbers* is formed as follows: > > Take a permuta...
[Question] [ Write a program that reads from stdin two integers, each newline terminated, hereafter called "number" and "radix", and: 1. Prints any fixed message you want if the number is a palindrome in that radix (e.g. `true`, `t`, `1`) 2. Prints any different fixed message you want if the number is not a palindr...
[Question] [ 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 co...
[Question] [ In this challenge, bots (consisting of JS functions) move around an infinite factory (playing field), collecting characters. These characters can be used to build worker bots, or dropped for other bots to pick up. This challenge is a modified redo of [Bot Factory KoTH](https://codegolf.stackexchange.co...
[Question] [ # Context In this challenge, a random walk is a stochastic process in which a particle at a position with integer coordinates (or a drunk man) moves at each integer time step (that is, at `t = 1, 2, 3, ...`) by taking a step of size `1` to any of its neighbouring positions, with the direction of the st...
[Question] [ Take a string as an input, and perform addition/subtraction of all the digits in the string and output the sum of those operations as the result. ## Rules * The digits in the string are read from left to right * If a digit (n) is odd, perform addition with the next digit (n + n1) * If a digit (n) is e...
[Question] [ A person has two first names if their last name is also a common first name. You are tasked with determining which full names in a list are two first names. ``` John Smith John Doe Luke Ryan Ryan Johnson Jenna Jackson Tom John ``` Any name that occurs in the first name column is potentially a first nam...
[Question] [ Andrew is a chemist, interested in the acidity of solutions and in agriculture. After months of research (Google is not his friend), he came up with the following table\* regarding the human-readable level of acidity in terms of the [pH (potential of Hydrogen)](https://en.wikipedia.org/wiki/PH#pH_in_so...
[Question] [ If you look at the Fibonacci Numbers, you will notice a pattern in their parity: `0, 1 , 1 , 2 , 3 , 5 , 8 , 13 , 21 , 34 , 55 , 89 , 144`. Every third number is even, and all the others are odd. This makes sense because an even plus an odd is odd, but an odd plus an odd is even and the sum for a term ...
[Question] [ For this challenge, we are writing the time in the following form: `hh:mm:ss` Some examples: > > `12:34:08` > > > `06:05:30` > > > `23:59:00` > > > The challenge is to output the time after an amount of *hours*, *minutes* and *seconds* have elapsed, with as starting time `00:00:00`. You can com...
[Question] [ Given a number, find an expression in words equaling that number, with a length of that number. Thus, to an input of `15`, you might output `sixteen minus one`, which has fifteen characters (not counting spaces). If multiple solutions exist, print whichever you want. If none exist, print `impossible` U...
[Question] [ # The Task: Given a `.txt` file with frames of ASCII art each separated by a `\n` (see this example if you are unclear) output a motion picture with frame with 1 frame per second. Note that there is a trailing `\n` on the final frame. Each frames dimensions will be: * X<80 * Y<20 # The Rules * The Prev...
[Question] [ ![Imgur logo](https://i.stack.imgur.com/KOU3H.png) Imgur is a free image hosting service. Many people use it. Here is an example of an imgur link: <https://i.stack.imgur.com/II8CA.png>. Write a program that continually outputs random (valid) imgur links. For example, here is some sample output of my pr...
[Question] [ There is a competition with \$n\$ participants in total. Alice is one of the participants. The outcome of the competition is given as a ranking per participant with a possibility of ties; e.g. there can be three participants who won 2nd place, and the next best participant gets the 5th place. More rigo...
[Question] [ Imagine there are \$n\$ people \$\{a\_1, a\_2, \ldots, a\_n\}\$ who enter a room in order and sit down in \$n\$ seats, arranged in a row. Each of these people belong to some gang, indicated by an integer \$\{1, 2, \ldots, k\}\$. These gangs hate the members of the other gangs, so they want to sit as fa...
[Question] [ ## Introduction Recently I was trying out one of the more obscure use-cases of a modern smartphone: Calling someone by number. While typing it in, I noticed that some of my phonebook entries were displayed, even though the number I was trying to call was different! After some experiments, I figured out...
[Question] [ # Definition [Wolstenholme's theorem](https://en.wikipedia.org/wiki/Wolstenholme%27s_theorem) states that: ![Wolstenholme's theorem](https://i.stack.imgur.com/GMruy.gif) where `a` and `b` are positive integers and `p` is prime, and the big parentheses thingy is [Binomial coefficient](https://en.wikiped...
[Question] [ [Related, but not dupe](https://codegolf.stackexchange.com/q/242935/108879). ## Challenge A list of integers \$a\_1, a\_2, a\_3, \dots, a\_n\$ (\$ n ≥ 1 \$) is Fibonacci-like if \$a\_i = a\_{i-1} + a\_{i-2}\$ for every \$i > 2\$. Note that every list that contains only 1 or 2 integers is Fibonacci-like...
[Question] [ # Setup Take the following `4x4x4` cube along with a 2D view of 3 of its faces, with a common `1x1x1` cube highlighted: [![enter image description here](https://i.stack.imgur.com/7HxCJ.jpg)](https://i.stack.imgur.com/7HxCJ.jpg) The arrows represent the points of view that generated the `V1`, `V2` and `...
[Question] [ If you remember back to your schooling years, you might remember learning about [Truth Tables](https://en.wikipedia.org/wiki/Truth_table). They seemed boring, but they are basis for logic and (some would argue) all computing... --- # Problem Your mission, should you choose to accept it is to write a pr...
[Question] [ This challenge is partly an algorithms challenge, partly an optimization challenge and partly simply a fastest code challenge. A cyclic matrix is fully specified by its first row `r`. The remaining rows are each cyclic permutations of the row `r` with offset equal to the row index. We will allow cyclic...
[Question] [ A [boolean circuit](http://en.wikipedia.org/wiki/Boolean_circuit) in TCS is basically a [DAG](http://en.wikipedia.org/wiki/Directed_acyclic_graph) consisting of And, Or, Not gates, and by what is known is "functional completeness" they can compute all possible functions. eg this is the basic principle ...
[Question] [ The [exponential generating function](https://mathworld.wolfram.com/ExponentialGeneratingFunction.html) (e.g.f.) of a sequence \$a\_n\$ is defined as the [formal power series](https://mathworld.wolfram.com/FormalPowerSeries.html) \$f(x) = \sum\_{n=0}^{\infty} \frac{a\_n}{n!} x^n\$. When \$a\_0 = 0\$, w...
[Question] [ Your task is to make a bidirectional compressor. It takes a list of bytes as input and returns a list of bytes as output. It has the property than whenever it is iterated twice it returns the original input. In other words, if `f` is your program as a function, then `f(f(x))=x` for all `x`. Now, since ...
[Question] [ *From [my CMC](https://chat.stackexchange.com/transcript/message/59600689#59600689).* Given a regex and a non-empty printable ASCII text, return one bit per character in the text, indicating the positions of beginnings of non-overlapping matches, and also the positions of beginnings of sequences that a...
[Question] [ We'll define the ***N***-exponential potential of a positive integer **M** as the count of prefixes of **MN** that are perfect **N**-powers. The prefixes of an integer are all the contiguous subsequences of digits that start with the first one, interpreted as numbers in base 10. For example, the prefix...
[Question] [ Last Thursday user [@SpookyGengar](https://codegolf.stackexchange.com/users/72476/spookygengar) delighted us with his/her first challenge about [Making Squared Words](https://codegolf.stackexchange.com/q/133650/70347). What if we double the number of sides? ### The challenge Take a string as input in a...
[Question] [ Your task is to calculate the square root of a positive integer without using any mathematical operators to change the number, such as: * Setting a variable (ex. squareRoot = 5) * Addition (A+B) * Subtraction (A-B) * Multiplication (A\*B) * Division (A/B) * Square, cube, fourth, etc. roots * Exponents ...
[Question] [ A binary matrix represents a shape in the plane. `1` means a unit square at that position. `0` means nothing. The background is `0`. For example, the matrix `[[0,1,0],[0,0,1],[1,1,1]]` represents the following shape: ``` o----o |////| |////| o----o----o |////| |/...
[Question] [ ## Challenge You have been given a string of digits 0-9.1 Your task is to shuffle this string, but every index must have a different value than it did before the string was shuffled. For example: ``` In : 287492 Out: 892247 ``` If this is not possible, return `false` or something similar. (`null`, `und...
[Question] [ For the purposes of the current challenge to "outline" a word means to surround it successively with its own letters, starting with the last one, and finally to replace the original word in the center with spaces: ``` oooooo onnnno on -> on no onnnno oooooo ``` ## Task:...
[Question] [ **421** is a rather popular dice game in France and some other European countries. It is mostly played in bars and pubs to determine who's going to buy the next round of drinks. The full game is usually played in two rounds, with tokens that each player tries to get rid of, but this is irrelevant here....
[Question] [ You have come across an old Indian manuscript, one that describes mounds of buried treasure. The manuscript also tells you the location of the treasure, except that some crucial numbers have been encoded indirectly into the text. You figure out that the text uses a 'Kaadi' system, a restricted subset o...
[Question] [ **Challenge** Given an integer **n ≥ 4**, output a permutation of the integers **[0, n-1]** with the property that no two consecutive integers are next to each other. The value of a permutation `pi` is the sum of `abs(pi[i] - i)` for all indices `i`. **Examples** * `(1, 3, 0, 2)` has value `6` * `(0, 2...
[Question] [ # Definition The maxima and minima of a given function are the largest and smallest values of the function either within a given range or otherwise within the entire domain of the function. # Challenge The challenge is to **find the local maxima and minima** of a given polynomial function **using any m...
[Question] [ The challenge is simple: **Create a pie-chart based on a number of input values.** The input will be a list of positive numbers, decimal or integers, and the output will be a pie-chart where each of the input values are represented by separate colors, and a percentage value outside each of the areas. *...
[Question] [ [Clock](https://en.wikipedia.org/wiki/Clock_Patience) is an interesting card game, as it requires no skill. It is a single player game, and the same card configuration always leads to a win or a loss. In this challenge, **you need to figure out whether a given card configuration wins or loses**. You ca...
[Question] [ Consider the process of: 1. Taking a non-negative integer N. e.g. `27`. 2. Spliting it into integers `N - floor(N/2)` and `floor(N/2)` (a 'bigger' and 'smaller' half) and writing them in that order. e.g.`27` becomes `14 13`. 3. Removing the space to join the integers into a new, much larger integer...
[Question] [ You are given a machine with two 16-bit registers, `x` and `y`. The registers are initialized `x=1` and `y=0`. The only operation the machine can do is addition modulo 65536. That is: * `x+=y` - `x` is replaced by `(x + y) mod 65536`; `y` is unchanged * `y+=x` - similarly for `y` * `x+=x` - `x` is repl...
[Question] [ An *Almost Equilateral Heronian Triangle* is a triangle with integer lengths of the form `n-1`, `n`, and `n+1` and also has integer area. The first few are: ``` 3, 4, 5 -> 6 13, 14, 15 -> 84 51, 52, 53 -> 1170 ``` **Quest**: Generate the shortest program that outputs the `n`th such triple. (Hin...
[Question] [ [Part I](https://codegolf.stackexchange.com/questions/259960/g%C3%B6del-encoding-part-i) Previous part was considered encoding of non-empty nested lists with a positive integer. Reminding the coding procedure \$G(x)\$: 1. If \$x\$ is a number, \$G(x) = 2^x\$ 2. If \$x\$ is a list \$[n\_0, n\_1, n\_2, n...
[Question] [ *Inspired by [Is this Flow Free puzzle trivial?](https://codegolf.stackexchange.com/questions/235848/is-this-flow-free-puzzle-trivial) by [@Bubbler](https://codegolf.stackexchange.com/users/78410/bubbler). Lengthy chunks of this challenge are borrowed from there. This may be one step of a solution for ...
[Question] [ ## Background [Combinatory logic](https://en.wikipedia.org/wiki/Combinatory_logic) is a system where a term is written using a finite set of combinators and function application between terms, and reduction rules are defined for each combinator. The well-known S and K combinators have the following red...
[Question] [ A Belphegor number is a number of the form \$(10^{n+3}+666)\*10^{n+1}+1\$ (`1{n zeroes}666{n zeroes}1`) where \$n\$ is an non-negative integer. A Belphegor prime is a Belphegor number that is also prime. The \$n\$ values of the first few Belphegor primes are `0`, `13`, `42`, `506` ([A232448](https://oe...
[Question] [ ## Definitions ### Quadratic residues An integer \$r\$ is called a [quadratic residue](https://en.wikipedia.org/wiki/Quadratic_residue) modulo \$n\$ if there exists an integer \$x\$ such that: $$x^2\equiv r \pmod n$$ The set of quadratic residues modulo \$n\$ can be simply computed by looking at the re...
[Question] [ Background: the Ramsey number \$R(r,s)\$ gives the minimum number of vertices \$v\$ in the complete graph \$K\_v\$ such that a red/blue edge coloring of \$K\_v\$ has at least one red \$K\_r\$ or one blue \$K\_s\$. Bounds for larger \$r, s\$ are very difficult to establish. Your task is to output the n...
[Question] [ ## Introduction Suppose I have a list of integers, say **L = [-1,2,2,1,2,7,1,4]**. I like having balance in my life, so I'm happy to see it has as many odd elements as even elements. What's more, it also has an equal number of elements in all modulo classes of 3 that it has elements in: ``` [-...
[Question] [ Lets take a set of integers greater than 1 and call it **X**. We will define **S(i)** to be the set of all members of **X** divisible by **i** where **i > 1**. Would like to choose from these subsets a group of sets such that * Their union is the set **X** * No element of **X** is in two of the sets. F...
[Question] [ Given an unordered collection of positive integers by any reasonable input method, return all of the sub-collections that have an odd number of odd elements (i.e. have an odd total). This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") so you should aim to minimize the b...
[Question] [ # The Task In this challenge, your task is to write some code which outputs one of its anagrams chosen randomly with uniform distribution but it should never output itself. --- ## Elaboration Given no input, your program should output any one of the anagrams of its source code. Your program should neve...
[Question] [ You are to create a program that creates exact clones of itself infinitely until stopped. Whatever is in the original program must be in the clones. In other words, the clones and original program are the same in every way except for that the clones don't have to be in the same type of file as the sour...
[Question] [ For a fixed n, consider the n by n [Toeplitz matrices](https://en.wikipedia.org/wiki/Toeplitz_matrix) with entries which are either 0 or 1. The aim is to find maximum determinant over all such Toeplitz matrices. **Task** For each `n` from 1 upwards, output the maximum determinant over all n by n Toepli...