instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Create a bootloader that executes given Brainfuck program. This is code-golf, so the program with least bytes wins. Being a bootloader, the size of the program is counted in non-zero bytes in the compiled code. Brainfuck 30000 8-bit overflowing cells. Pointer wraps over. Some notes about operations: Input must be read...
stackexchange_codegolf
Revised formatting and instructions Given a list of moves for a Cracker Barrel peg board game, or as @Steveverrill stated, Peg Triangle Solitaire: Game 1 Game 2 Game 3 1: 0 ,-1, -1 C, -1, -1 4, -1, -1 #starting point 2: 3, 1, 0 3, 7, C B, 7, 4 #jump_from, jump_over, jump_to 3: A, 6...
stackexchange_codegolf
I have a bunch of boards I need to stack in as small a space as possible. Unfortunately, the boards fall over if I stack them more than 10 high. I need a program to tell me how to stack the boards to take as little horizontal space as possible, without stacking boards more than ten high, or having boards hanging out ...
stackexchange_codegolf
INTRODUCTION I like Karma Fields : he's a music producer that creates original music tracks. His artwork also matches up really well his style. He has a logo witch I find really interessing : GOAL Your goal will be to reproduce that logo, graphically or in ASCII. Edit @NahuelFouilleul managed to provide a readable asc...
stackexchange_codegolf
Introduction There is a plantation defined by one big square-board like this one: The numbers inside each small square represents its area's value/cash/... The farmer needs help to find the N squares that connected (it means all N squares should have at least one shared border) give him the greatest value. For example...
stackexchange_codegolf
Write a function that gets as an input a sorted array of positive numbers A, and an additional number n. The Task is to print out all distinct subsets of A, that sum to n. Example: Input: A = [1,2,2,4,4] n = 9 Output: [1,2,2,4] [1,4,4] Bonus: -50% if your code doesn't store duplicate subset (the same subset but in d...
stackexchange_codegolf
Robber's challenge This cops-and-robbers challenge challenges the Cop to write a non-empty program that, when run, produces some non-empty output in language A, and, when reversed, produces some non-empty output in language B. The program may produce any output to STDERR when run in either language, but may not take in...
stackexchange_codegolf
For this challenge, you will be given a long string as an input. With this string, you must create a dictionary. Details: This dictionary will contain all the words from the string - a word being any sequence of letters surrounded by non-letter characters (ASCII). Letter case of the entries of the dictionary should alw...
stackexchange_codegolf
Given a non-empty string consisting of only lower and upper case alphabetical characters and spaces ([a-zA-Z ]), reduce it to a snippet of the alphabet, starting with the first character. To reduce a string, begin with the first alphabetical character, then remove every character after it that is not the next letter of...
stackexchange_codegolf
A complete deterministic finite automaton is a machine, with some states. Each state in the automaton has, for each character in the alphabet, a pointer to a state (not necessarily a different one). The automaton starts at some state, and then reads a string, character by character. For each character, the automaton mo...
stackexchange_codegolf
Given some positive integer n, design a protractor with the fewest number of marks that lets you measure all angles that are an integral multiple of 2π/n (each in a single measurement). Details As an output, you may output a list of integers in the range 0 to n-1 (or 1 to n) that represent the position of each mark. Al...
stackexchange_codegolf
Given a non-empty string containing only printable ASCII (codepoints 0x20 to 0x7E), write the shortest program or function that map the key to its value. Inside the string the key will always have a value and vice-versa. How the key is made: Start with an opening parenthesis ( Contains letters and/or numbers [a-zA-Z0-...
stackexchange_codegolf
You are the first engineer in a hot new startup, Lexographical. Our company is making waves by digitizing and indexing all words, real or not. The core of our product... Our secret sauce... Well, that's why we hired you :) Because we're bleeding edge, we're enforcing the latest standards. Even the latest ones aren't go...
stackexchange_codegolf
Related: Is this quadrilateral cyclic? Background A tangential quadrilateral is a quadrilateral which has an incircle: Examples include any square, rhombus, or a kite-like shape. Rectangles or parallelograms in general are not tangential. Task Given the four vertices of a quadrilateral (as Cartesian coordinates), dete...
stackexchange_codegolf
Introduction Let's draw some regular hexagons formed by hexagonal tiles, marking the vertices of the tiles with dots. Then we will count the number of dots. size 1: 6 dots . . . . . . size 2: 24 dots . . . . . . . . . . . . . . . . . . . . . . . . size 3: 54 dots . . . . . . ...
stackexchange_codegolf
Consider the standard equilateral triangle, with nodes labeled using barycentric coordinates: We can turn this 3 node triangle into a 6 node triangle by adding a new line of 3 vertices (one more than was present on a side of the original 3 node triangle), remove any internal edges (but not internal nodes) and re-norma...
stackexchange_codegolf
Given two strings of digits, determine which string, if any, has the earliest digit which is lower than the other string's digit at the same index. Do note that this differs from alphabetization, as shown in the following examples: Examples Given inputs 12345000 and 1233999999, the second string would have the earliest...
stackexchange_codegolf
Oh no! There are a bunch of meteoroids on my way through the universe ... what am I and my space ship, the SP4C3, supposed to do? I need to manoeuver my shuttle through these rocks or I am done for! Your Task Write a program that guides my shuttle through a map of asteroids, using as few bytes as possible since I don't...
stackexchange_codegolf
Your task is to print this exact text: az za abyz zyba abcxyz zyxcba abcdwxyz zyxwdcba abcdevwxyz zyxwvedcba abcdefuvwxyz ...
stackexchange_codegolf
Write a program which will take for input 2 integer arrays and return a truthy value if there exists an element which is present in both of arrays, or a falsy one otherwise. The obvious solution to this problem would be to iterate through each element in the first array and compare it against each element in the second...
stackexchange_codegolf
In this challenge, you will be given a text block, and you need to perform reflection on the text. Input: A string to be reflected. The text may not be supplied as an array whose elements are the lines of text. For example, "ab\ncd" and ['a','b','\n','c','d'] are allowed, but ['ab','cd'] or [['a','b'],['c','d']] are n...
stackexchange_codegolf
Consider a string like: a.push(c.push("a",["ad","bd",2,{"ard",duo}]).pop().replace(2,"tg").enc([3,{2,adf},"atr"],5) Write a program that will verify whether a string is correctly bracketed. A correctly bracketed string can be defined as one in which all brackets are terminated (closed), and the inner brackets are term...
stackexchange_codegolf
Curry is the Language of the Month this month and some users are starting to get into it, so let's get some tips together. Haskell and Curry are similar in a lot of ways and a lot of tips for Haskell work well in Curry and vice versa. So I'd like in this question to gather tips for code-golf in Curry, that would be use...
stackexchange_codegolf
Your assignment is to write a program of even length, that prints an ASCII-art square (described below), that increases its side length by 1 unit each time the original source code is pasted in the middle of the current code. It is quite hard for me to define this task very well, so I'll give you an example: Let's sa...
stackexchange_codegolf
Inspired by this challenge, which got closed. This is meant to be an easier, but no less interesting version of that. This is the cops thread of a cops-and-robbers challenge. For the robbers thread, see here. Cops will provide a program/function and a flag. Robbers will try to guess a password such that, when the passw...
stackexchange_codegolf
The Quine-McCluskey algorithm merges disjunctors in a disjunction like $$ \lnot x_0 \land \lnot x_1 \land \lnot x_2 \land \lnot x_3 \lor\\ x_0 \land \lnot x_1 \land x_2 \land \lnot x_3 \lor\\ \lnot x_0 \land x_1 \land x_2 \land \lnot x_3 \lor\\ \lnot x_0 \land \lnot x_1 \land \lnot x_2 \land ...
stackexchange_codegolf
Anyone got tips for golfing in Thue. One tip per answer, and no tips aplicable to all languages (like remove comments)
stackexchange_codegolf
Calculate the p-adic norm of a rational number Write a function or a program, that takes 3 integers m,n,p (where p is a positive prime) as input, that outputs the p-adic norm (denoted by |m/n|_p) as a (completely reduced) fraction. Fermat is known to have only very small margins, but what is rather unknown is that he o...
stackexchange_codegolf
I was browsing Stack Overflow when I saw this post in Puzzling in the hot network questions and decided to make a challenge out of it (all credit goes to the creator of the challenge). Overview A Chess Number is a number that, when converted to base 18, results in a valid chess coordinate pair, where the first characte...
stackexchange_codegolf
Reading a book is easy, but printing a book can be a bit tricky. When printing a booklet, the printer needs to have the pages arranged in a certain manner in order to be read from left to right. The way this is done is using a pattern like below n, 1, 2, n-1, n-2, 3, 4, n-3, n-4, 5, 6, n-5, n-6, 7, 8, n-7, n-8, 9, 10,...
stackexchange_codegolf
This is the Robbers thread. For the Cops challenge, see here As the robbers, your job is to crack the cops' answers. Choose an uncracked, unsafe cop answer and attempt to figure out which languages, in which order, the cop used. Note that a crack is valid even if the languages are different. So long as the the language...
stackexchange_codegolf
This challenge is not code golf. Please read the scoring before you attempt to submit an answer. You will be given a multi-line string as input. You should output the size of the largest contiguous chunk of non-space characters. Contiguous just means that the chunk is a single piece rather than multiple disconnect...
stackexchange_codegolf
using Prefixed Length Code We are going to implement a compression of text (string, array/list of characters/bytes) by simple substitution of each character by a binary code, based on the frequency of that character in the text. The characters that occur more frequently will be replaced by shorter codes. The resulting ...
stackexchange_codegolf
We define a map as a set of key-value pairs. For this challenge, you need to take each of the values and assign them to a randomly chosen key. You must randomly shuffle the values, and output the resulting map. This means that each time we run your program, we have a chance of getting a different output Each possibl...
stackexchange_codegolf
You are given an array A of length N and an array B of length N-1. You need to output array where items alternates: A[0], B[0], A[1], B[1], ..., B[N-2], A[N-1] Restrictions: N>0 Type of items is not specified, but code should work at least for unsigned integers. Sample input: A = [1,2,3,4] B = [7,8,9] Sample output:...
stackexchange_codegolf
Traditionally presents are kept secret in boxes wrapped in paper. Since the ice caps are melting Santa Claus has begun to investigate some ways they might make the whole gift wrapping operation a little more eco-friendly. The first thing they've decided to do is to put all presents in perfectly cubic boxes. This makes...
stackexchange_codegolf
It's been a while since I posted here, so here we go another day another challenge. Challenge : Given a number(n) split it into it's prime factors. Input : A positive non-zero integer greater than 2. Output : Decompose the number into it's prime factors and return the number of occurances of each prime in it. Ouput...
stackexchange_codegolf
Cops' thread In this thread, your task is to make a recursion-based program/function to generate any integer series. Robbers will try and find a shorter non-recursive solution over in the Robbers' thread. Challenge synopsis In many languages, recursive functions can significantly simplify a programming task. However, ...
stackexchange_codegolf
Inspiration. Posted with permission. Print one of the possible XKCD calendar "facts": You can get the raw text and structure from my APL reference implementation or from Explain XKCD's transcript (including the title text just under the illustration). Rules At every decision node, there must be an equal (pseudo-)rando...
stackexchange_codegolf
Write a program/function/script that takes a natural number i from 1 to 10 as input and outputs the URL of the Question with the i th hottest question on the Code Golf Portal The ordering should be like in https://codegolf.stackexchange.com/?tab=hot. For example: input 1 output https://codegolf.stackexchange.com/quest...
stackexchange_codegolf
This sentence employs two a’s, two c’s, two d’s, twenty-eight e’s, five f’s, three g’s, eight h’s, eleven i’s, three l’s, two m’s, thirteen n’s, nine o’s, two p’s, five r’s, twenty-five s’s, twenty-three t’s, six v’s, ten w’s, two x’s, five y’s, and one z. Such sentences are called autograms. Your task is to write a p...
stackexchange_codegolf
For more MtG-goodness: Magic: The Gathering Combat with Abilities Premise: In Magic: the Gathering, you cast spells by paying their mana cost by tapping lands for the required amount. These lands can produce one of the five colors which are: White (W) Blue (U) Black (B) Red (R) Green (G) The cost is made up of two...
stackexchange_codegolf
The Triforce is a fictional artifact in The Legend of Zelda, made of three identical-looking equilateral triangles representing power, wisdom and courage. Several games in the saga include an animation when the three parts finally join together. The purpose of this challenge is to draw a single 2D frame of such a simpl...
stackexchange_codegolf
Write code to generate a PDF file containing 6 bingo cards. Winner is the one that uses the shortest code and needs no actions except for installing a library and running the code. (No Save As PDF). Rules are as follows. The generated PDF file should display accurately in Adobe's PDF reader, Google Chrome and Moxilla ...
stackexchange_codegolf
(or: Output the plural demonym.) When in Rome, do as the Romans do. This is a well-known English phrase meaning that it’s best to follow what others are doing around you — to go with the flow. Today, you're going to rewrite the phrase to fit most (Western) place names. To get the name of a group that lives within a reg...
stackexchange_codegolf
The WannaCrypt ransomware has struck and it is attacking networks right, left and center. A network is defined by an m*n binary matrix (a), which has a a[i][j] = 1 if a computer is infected and a[i][j] = 0 if it is not. At the end of each hour, all computers that are a neighbour (which shares a side or a corner with) ...
stackexchange_codegolf
Conways' Game of Life is a well known cellular automaton "played" on an infinite grid, filled with cells that are either alive or dead. Once given an initial state, the board evolves according to rules indefinitely. Those rules are: Any live cell with 2 or 3 living neighbours (the 8 cells immediately around it) lives ...
stackexchange_codegolf
My little kid has a toy like this: This toy consists of 10 stackable little buckets, that we are going to number from 1 (the smallest one) to 10 (the biggest one). Sometimes he makes small piles and the toy ends up like this: We can represent schematically the piles like this: 1 6 4 9 2 7 5 10 3 8 -------...
stackexchange_codegolf
Two dimensional chiral objects are not chiral in three dimensional space. This is because you can flip them over which is equivalent to taking the mirror image unlike in two dimensions where only rotations in the plane of the object are allowed which cannot reproduce the effect of a mirror operation. In this challenge,...
stackexchange_codegolf
At the end of your interview, the Evil Interviewer tells you, "We make all of our applicants take a short coding test, to see if they really know what they are talking about. Don't worry; it's easy. And if you create a working program, I'll offer you the job immediately." He gestures for you to sit down at a nearby ...
stackexchange_codegolf
Test Driver • Challenge Discussion • Submit Adventurer (Image Source) Several rival adventurers are raiding the ruins for treasure, but they can only carry so much at a time and have their limits of endurance. They want to get the most valuable treasure and get out before they become too tired to continue. They are tr...
stackexchange_codegolf
A set of dominoes consists of tiles with two numbers on them such that every combination of integers from 0 to N are represented. Examples below refer to N=6 out of convenience, but N=9 and N=12 are also common. The orientation of the tiles does not matter (they are usually printed with dots rather than digits), so [1-...
stackexchange_codegolf
We've had challenges for SIGSEGV and SIGILL so why not... Write the shortest code that results in a Bus Error (SIGBUS) in any programming language. Your program can't call raise() or kill(getpid(),sig) or pthread_kill(pthread_self(),sig), or any other equivalent.
stackexchange_codegolf
Consider this nested array [[1,2,4],[1,2,3],[2,3]] In each subarray in which 1 appears, a 2 appears. You might say that 1's presence is dependent on 2's presence. The converse is not true, as 2 appears in a subarray without 1. Additionally, 3 is dependent on 2, and 4 is dependent on 1 and 2. Task Given a list of lists ...
stackexchange_codegolf
Background In JIS X 0208 a 94 by 94 map (kuten (区点)) is defined to encode Chinese characters (kanji), phonetic moras (kana) and other symbols. Along with this standard there are 3 different encodings that maintain 1-1 correspondences with the map, namely JIS, Shift_JIS and EUC. These encodings take 2 bytes for each cha...
stackexchange_codegolf
For this problem you are given an \$n \times n\$ matrix of integers. The task is to find a pentagon in the matrix with maximum sum. The pentagon must include part (or all) of the x and y axes as two of its sides starting from the top left cell. All the sides except one must be horizontal or vertical. The remaining si...
stackexchange_codegolf
Today your goal is to find integers a and b given non-negative integer n such that: You should write a program or a function that takes parameter n and outputs a and b in a format of your choice. Standard loopholes apply. Additionally, it's intended that you implement the above problem using basic arithmetic yourself....
stackexchange_codegolf
Given a matrix of integers, test if it's rank-one, meaning that every row is a multiple of the same vector. For example, in 2 0 -20 10 -3 0 30 -15 0 0 0 0 every row is a multiple of 1 0 -10 5. The same definition also works with columns in place of rows. Alternatively, a matrix is rank-one if it's ...
stackexchange_codegolf
Your task is to decipher a non-empty string consisting of printable ASCII characters in the range [32..126]. Reading the string character per character: each time you encounter a letter in lowercase, associate it with the next letter in uppercase, starting with 'A' each time you encounter a letter in uppercase, replac...
stackexchange_codegolf
This challenge sounds too simple to not already exist, so let me know if it is a duplicate. The task Print Hello, world! The rules Your code has to be in "byte order". This means that every character / byte has a higher or equal byte value than the preceding character / byte. Exceptions to this rule are the whitespace ...
stackexchange_codegolf
Background You're an attractive code golfer and quite a few people are asking you out. You don't have time to think about which days exactly you're available, so you decide to create a function the accepts a date and returns the days of that week. You then take those days of the week, insert it into your calendar progr...
stackexchange_codegolf
Task The task is very simple. Given a non-empty string containing numbers, uppercase and lowercase letters, output the sum of the remaining numbers. For example: a1wAD5qw45REs5Fw4eRQR33wqe4WE Filtering out all the letters would result into: 1 5 45 5 4 33 4 The sum of these numbers is 1 + 5 + 45 + 5 + 4 + ...
stackexchange_codegolf
Related: Determine the position of a non-negative number in the infinite spiral Wind me a number snake! Challenge: Given a grid, with an ID starting at the center and spiraling out, what is the ID given a position in the fewest number of bytes? Grid: +---------------+---------------+---------------+---------------+--...
stackexchange_codegolf
An Séimhiú agus an tUrú In Irish Gaelic (Gaeilge) there are a number of ways that the start of a word can be changed. The most common of these are lenition (an séimhiú) and eclipsis (an t-urú) Lenition involves adding the letter h as the second letter. For example, the word "bean" (woman) would be lenited to "bhean". E...
stackexchange_codegolf
(Title with thanks to @ChasBrown) Sandbox The Background This challenge is inspired by a question that I recently posted on Puzzling Stack Exchange. Please feel free to follow the link if you are interested in the original question. If not then I won't bore you with the details here. The Facts Every printable standard...
stackexchange_codegolf
Take the vector of unknowns , and apply some generic differentiable function . The Jacobian is then given by a matrix such that: For example, suppose m=3 and n=2. Then (using 0-based indexing) The Jacobian of f is then The goal of this challenge is to print this Jacobian matrix. Input Your program/function should ...
stackexchange_codegolf
Challenge You must write an encoder (and a separate decoder) which takes a string as input and outputs the string encoded in the style of a strand of DNA. DNA DNA is made up of four types of nucleotide: Adenine (A) Thymine (T) Cytosine (C) Guanine (G) Adenine and thymine pair up together to make AT or TA. Similarly, ...
stackexchange_codegolf
Based off a Scratch project The pen extension in Scratch has a set pen color to () block. The () is normally a color dropdown, but you can also use the join()() block. In the join()() block, normally a hex value is in the first input, but the second is just an empty string. However, many new Scratchers that want to t...
stackexchange_codegolf
The function TREE(k) gives the length of the longest sequence of trees T1, T2, ... where each vertex is labelled with one of k colours, the tree Ti has at most i vertices, and no tree is a minor of any tree following it in the sequence. TREE(1) = 1, with e.g. T1 = (1). TREE(2) = 3: e.g. T1 = (1); T2 = (2)--(2); T3 = (2...
stackexchange_codegolf
In CSS, colours can be specified by a "hex triplet" - a three byte (six digit) hexadecimal number where each byte represents the red, green, or blue components of the colour. For instance, #FF0000 is completely red, and is equivalent to rgb(255, 0, 0). Colours can also be represented by the shorthand notation which use...
stackexchange_codegolf
In Bloons Tower Defense 6, the strength of different bloons can be measured by their Red Bloon Equivalent (RBE), or the number of single pops it takes to completely defeat the bloon. The RBE for the bloon types are as follows (sourced from the wiki) Bloon RBE red 1 blue 2 green 3 yellow 4 pink 5 black...
stackexchange_codegolf
S. Ryley proved following theorem in 1825: Every rational number can be expressed as a sum of three rational cubes. Challenge Given some rational number \$r \in \mathbb Q \$ find three rational numbers \$a,b,c \in \mathbb Q\$ such that $$r= a^3+b^3+c^3.$$ Details Your submission should be able to compute a solution f...
stackexchange_codegolf
If you don't know already, a quaternion is basically a 4-part number. For the purposes of this challenge, it has a real component and three imaginary components. The imaginary components are represented by the suffix i, j, k. For example, 1-2i+3j-4k is a quaternion with 1 being the real component and -2, 3, and -4 bein...
stackexchange_codegolf
The task Write a program or function whose input is a list/array X of integers, and whose output is a list of sets of integers Y, such that for each element e in each set Y[i], X[e] = i, and such that the total number of elements in the sets in Y equals the number of elements in X. (This is basically the same operation...
stackexchange_codegolf
The Lost Numbers are 4, 8, 15, 16, 23, 42. Your goal is to create an expression to output them all. Your allowed characters are 0123456789, ^+-*/, (), % for modulo and n as the single variable allowed. Modified PEMDAS ()^*/%+- is the precedence and / is normal division (3/2 = 1.5). 0^0 = 1 although division by 0 is und...
stackexchange_codegolf
Given a positive integer number \$n\$ output its perfect radical. Definition A perfect radical \$r\$ of a positive integer \$n\$ is the lowest integer root of \$n\$ of any index \$i\$: $$r = \sqrt[i]{n}$$ where \$r\$ is an integer. In other words \$i\$ is the maximum exponent such that \$r\$ raised to \$i\$ is \$n\$: $...
stackexchange_codegolf
A lot of PPCG users helped with the creation of this challenge, both in chat and the Sandbox, specifically Martin Ender, AdmBorkBork, Emigna and user202729 Our community has found it necessary to create a set of languages designed specifically for golfing, "golfing languages" as we call them. Such languages have evolve...
stackexchange_codegolf
As input you will be given a ragged list of positive integers containing at least one integer at some level. For example: [[],[[1,2,[3]]],[]] You should output the depth of the least deep integer. For example if the input is just a list of integers, then the every integer is 1 level deep so the answer is 1. There m...
stackexchange_codegolf
The Matoran Alphabet is the alphabet used by many of the characters in the Bionicle universe. Your challenge is to create a program or function that takes a string as input and creates an image of the input written in the Matoran alphabet. The input will only consist of uppercase letters (A-Z), numbers (0-9), and spac...
stackexchange_codegolf
Inspired by this recent article telling of a French programmer who wrote a 487 byte 2-player (human vs. human) chess program in Assembly, I wondered how small chess programs could be in other languages. Details The program must only accept legal chess moves. Declaration of check/checkmate is not necessary (just desira...
stackexchange_codegolf
Task You are playing Hangman, and your opponent uses a simple but effective strategy: Each turn, from the remaining letters, they guess the letter that appears most frequently across all possible words. When multiple letters appear with the same maximum frequency, your opponent selects randomly among them. That is, yo...
stackexchange_codegolf
Inspired by this comment... Thanks to users Step Hen, Wheat-Wizard, and Dennis for helping my solidify the specification of this challenge before posting it! This is the Robber's thread! For the Cops' thread, go here In this challenge, you are tasked with running some code that makes it so that your language no longer...
stackexchange_codegolf
This was inspired by a now removed CS.SE question. Task Given two non-empty input strings A and B, output the smallest distance from A to a palindrome that contains B as a substring. Distance is defined by the number of character replacements (Hamming distance). Restrictions Sensible input: a palindrome exists. This m...
stackexchange_codegolf
In this challenge, all bots are wizards. At the beginning of each round, they create a wand which has a certain chance of successfully stunning another wizard. They then fight, by choosing one bot to attack in each turn. The last bot remaining wins. Results 500 games, 1000 rounds each Revenge!: 132101.68886125216 JustE...
stackexchange_codegolf
The cardinality of the set \$\mathbb Q\$ of rational numbers is known to be exactly the same as that of the set \$\mathbb Z\$ of integers. This means that it is possible to construct a bijection between these sets—a mapping such that each integer corresponds to exactly one rational number, and vice versa. Provide such ...
stackexchange_codegolf
A Bell number (OEIS A000110) is the number of ways to partition a set of n labeled (distinct) elements. The 0th Bell number is defined as 1. Let's look at some examples (I use brackets to denote the subsets and braces for the partitions): 1: {1} 2: {[1,2]}, {[1],[2]} 3: {[1,2,3]}, {[1,2],[3]}, {[1,3],[2]}, {[2,3],[1]}...
stackexchange_codegolf
What is Permutation Coefficient Permutation refers to the process of arranging all the members of a given set to form a sequence. The number of permutations on a set of n elements is given by n! , where “!” represents factorial. The Permutation Coefficient represented by P(n, k) is used to represent the number of ways ...
stackexchange_codegolf
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 this is a "compressor",...
stackexchange_codegolf
Your challenge today is to write a program or function which takes a list l and gives the positions in l at which each successive element of l sorted appears. In other words, output the index of the smallest value, followed by the index of the second smallest value, etc. You can assume that the input array will contain...
stackexchange_codegolf
Your program should take an array as input. The array: Will always be 1 dimensional Will only contain integers Can be empty The program should reverse the array, and then add up the elements to the original for example: Input: [1, 2, 3] Original: [1, 2, 3] Reversed: [3, 2, 1] [1, 2, 3] + + + [3, 2, 1] [1+3, 2+2,...
stackexchange_codegolf
Given an integer n, print out n * reversed(n) reversed(n) is the number you get when you reverse the digits of n. reverse(512) = 215 reverse(1) = 1 reverse(101) = 101 >>>>>>>> func(5) = 5*5 = 25 func(12) = 12*21 = 252 func(11) = 11*11 = 121 func(659) = 659*956 = 630004 Shortest code wins! Leaderboard var QU...
stackexchange_codegolf
Thanks to @ComradeSparklePony for the title. This challenge should be very simple. You are given three lists. The first is a list of first names, in title case. The second is a list of adjectives, in lower case. The third is a list of nouns, in lower case. Please randomly select a name, optional adjective, and noun, an...
stackexchange_codegolf
SAT is the problem of determining whether a boolean expression can be made true. For example, (A) can be made true by setting A=TRUE, but (A && !A) can never be true. This problem is known to be NP-complete. See Boolean Satisfiability. Your task is to write a program for SAT that executes in polynomial time, but may no...
stackexchange_codegolf
Given a pattern of squares on a grid, determine if it is possible to create that pattern with non-overlapping dominoes. In case you are not familiar, a domino is a rectangular shape created by joining exactly two squares at their edges. Examples For the pattern on the left, O represents an occupied cell on the grid and...
stackexchange_codegolf
EDIT: The incorrect A rhomb substitution has been fixed. Apologies to anoyone who had started working on a solution. Consider the following substitutions, where the substituted rhomb(us) is scaled up and shown in red: EDIT: Note the anchor points (circle) created where a corner of each new rhomb touches the substituted...
stackexchange_codegolf
So, I wrote myself a one-liner which printed out a snake on the console. It's a bit of fun, and I wondered how I might condense my code... Here's a (short) example output: + + + + + + + ...
stackexchange_codegolf
This is a copy cat question of Simplify ijk string applied to the other nonabelian group of order 8. See also Dihedral group composition with custom labels. Challenge Given a string made of r and s interpret it as the product of elements of the dihedral group \$D_8\$ and simplify it into one of the eight possible value...
stackexchange_codegolf
This challenge's concept is pretty simple. All you have to do is write a program that will compile as both valid C and valid C++! Well, there are some catches. The program must behave differently when compiled in each language. The program must have different output for each language in order to be considered "behaving...
stackexchange_codegolf
Introduction In this challenge, your task is to find generalized subsequences of strings. The subsequences are not necessarily contiguous, and they can also "wrap around" the string, going past its end and starting again from the beginning. You'll want to minimize the number of wraps, though. More formally, let u and v...
stackexchange_codegolf
Note to mods, if the title doesn't do justice, change it to whatever, I thought it was funny. You're tasked with hanging up the lights for this Christmas season, and your family has decided that for it to be a merry Christmas, you need to hang at least 2 Christmas lights on your house. So, your challenge is, given a n...
stackexchange_codegolf