text
stringlengths
180
608k
[Question] [ [1d version](https://codegolf.stackexchange.com/questions/100411/animate-finding-the-middle) Given a multidimensional array of positive integers where all dimensions are the same length, animate finding the centre of it. Simply output the array, then remove the first and last items of every array withi...
[Question] [ Find what is the distance for a given string to its closest palindrome of the same length. For this task I decided to give the characters further away from the string's center more weight (think of it as contributing more torque), proportional to their distance to the center. Let's define the palindrom...
[Question] [ # Challenge : Given a string split at specific positions and capitalize the first character of the given word. Capitalize the first word's first char if and only if it was already capitalized # Input : A string `s` and a character `c`. # Ouput : The string with each occurrence of `c` replaced with the...
[Question] [ # Task Given integers `x` and `y` which are both at least `2`, find the smallest positive number whose `y`-th power is divisible by `x`. # Example Given `x=96` and `y=2`, the output should be `24` since `24` is the smallest positive `n` satisfying `n^2 is divisible by 96`. # Testcases ``` x y output 2...
[Question] [ # Task Your task is to print or output all **positive** numbers in which every multi-digit substring in its decimal representation is also prime. If the number has at least 2 digits, this would imply that the number itself also needs to be prime. # Example * `6197` is in the sequence because every mult...
[Question] [ In a standard dice (die) the numbers are arranged so that opposite faces add to seven. Write the shortest possible program in your preferred language which outputs a random throw followed by 9 random tippings. A tipping is a quarter turn of the dice, e.g. if the dice is facing 5, all possible tippings ...
[Question] [ A [**Hankel matrix**](https://en.wikipedia.org/wiki/Hankel_matrix) is a square matrix in which each ascending skew-diagonal from left to right is constant, e.g.: $$\begin{bmatrix} a & b & c & d \\ b & c & d & e \\ c & d & e & f \\ d & e & f & g \end{bmatrix}.$$ Given a sequence of integers \$\{a\_n\}\$...
[Question] [ Given a pattern and a ragged list of positive integers, your task is to decide whether the pattern matches the ragged list. The pattern is also represented by a ragged list. But in addition to positive integers, it may contain a wildcard value. Here is the rule for matching: * A positive integer matche...
[Question] [ Let's begin with a thought experiment. You have a clock and a timer, in which you start the timer when the clock shows exactly `hh:mm.00`. * Clock: The clock employs 24-hour time. So the range of `hh` is `0<=h<23`. (Because `23` inputs are unsolvable, you aren't required to handle that) * Timer: It sta...
[Question] [ # The task Given an image as input, your task is to do the following: 1. Resize the image so it is **At least** 2 times smaller, but still has the same width/height ratio by taking every second (if resized to 2x) pixel in both horizontal and vertical directions and using those in the pixel art image. E...
[Question] [ Write a program that outputs a list of the number of occurrences of each unique character in its source code. For example, this hypothetical program `{Source_Print_1};` should produce this output: ``` ; 1 P 1 S 1 _ 2 c 1 e 1 i 1 n 1 o 1 p 1 r 2 t 1 u 1 { 1 } 1 ``` The formatting should match this examp...
[Question] [ ### Instructions Barry is a *not so good* backend developer in charge of a small API that should give you information about purchases made in a client's shop. However, he hasn't done a great job and your boss tells you to fix it client-side instead. Ideally you should receive comma-separated values suc...
[Question] [ The new weather predicting supercomputer has arrived, and it doesn't work. In the meantime your boss wants you to buy the technicians some time by faking the daily wind maps. **Your task is to draw a grid of arrows representing wind direction.** The grid is: * made up of 15px square tiles * 8 tiles by ...
[Question] [ Consider a square n by n grid graph that looks like this. ![grid graph](https://i.stack.imgur.com/N23X2.png) **It is important to notice that this graph is 11 by 11**. At any given point a man stands at an intersection and he only ever moves vertically or horizontally by one step at a time to the next ...
[Question] [ Write the shortest program that generates a [histogram](https://en.wikipedia.org/wiki/Histogram) (a graphical representation of the distribution of data). **Rules:** * Must generate a histogram based on the character length of the words (punctuation included) input into the program. (If a word is 4 let...
[Question] [ Write a program that accepts HTTP requests on any port of your choice above 1024, and responds to requests on any URL of your choice with its own source code. It must work with, at least, Firefox and Chrome. The code should be delivered ~~as `text/plain`~~ *(removed requirement because none of the answ...
[Question] [ Given a number \$n\$, you are to compute the sequence of positive numbers where for each number \$a\$, the \$n\$-times multiple \$n\cdot a\$ is missing. ### Example We always start with the sequence of all positive numbers: $$1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, \dots$$ For \$n=2\$, going left-to-right...
[Question] [ Part of [**Code Golf Advent Calendar 2022**](https://codegolf.meta.stackexchange.com/questions/25251/announcing-code-golf-advent-calendar-2022-event-challenge-sandbox) event. See the linked meta post for details. --- As soon as the Elves get bored with the [last week's game](https://codegolf.stackexcha...
[Question] [ A simplistic version of [English numeral calculator](https://codegolf.stackexchange.com/questions/12757/english-numeral-calculator) ### Task Write a program that takes a string as input and outputs the result of the expression. ### Rules The input string will be worded and not numeral. There will be no...
[Question] [ Given a 2D array of integers, let's sort its rows and columns in blocks. This means that you only have to sort a given row or column, but applying the transformations needed for sorting it to every other row or column in the 2D array. ### Rules * Input will be a 2D array of integers and a 1-indexed int...
[Question] [ # Background Skip to "Task" if you are familiar with Tic-Tac-Toe (I think most are!) [Tic-Tac-Toe](https://en.m.wikipedia.org/wiki/Tic-tac-toe) is a famous two-player game. It consists of a **3x3** board that is filled gradually by two players (clarifications below); The first player uses the character...
[Question] [ The Banach–Tarski paradox states that, given a ball in 3‑dimensional space, you can decompose the ball into a finite number of point subsets. These disjoint sets of points can then be reassembled to produce two copies of the initial ball. You would then, theoretically, have two identical balls. The pro...
[Question] [ A binary eye is an odd set of digits, with all of its digits except the center one set to 1 or 0, and the center one set to the opposite of the others. Thus, there are two binary eyes for a given odd number of digits: | x | eyes | | --- | --- | | 1 | 1,0 | | 3 | 101,010 | | 5 | 11011,00100 | | 7 | 1110...
[Question] [ An **alternating permutation** is a permutation of the first \$ n \$ integers \$ \{ 1 ... n \} \$, such that adjacent pairs of values in the permutation alternate between increasing and decreasing (or vice versa). Equivalently, it is a permutation where there are no "runs" of continuously increasing or...
[Question] [ I'd like to roll up the ability scores for my Dungeons and Dragons character. But I'd also like them to be balanced (and slightly better than average). Typically, a character's stats are created by rolling four 6-sided dice, adding together the three highest results, and doing this 6 times. A 6 sided d...
[Question] [ Check if two blocks of bits dovetail perfectly. # Specifications * A block of bits is a fixed sequence of 8 bits just like this for example : **11110101**. * For simplicity we refer to `truthy`/`falsey` values as `1`/`0` bits but they can be everything capable of representing those two states in a clea...
[Question] [ Given an integer array of at least two elements, output the **Matrix-Vector** (defined below) of the array. To compute the **Matrix-Vector**, first rotate through the size-`n` input array to create a matrix of size `n x n`, with the first element of the array following the main diagonal. This forms the...
[Question] [ You will be given a String consisting of printable ASCII (without newlines). Your task is to build a nice Stairway for my Castle. # How to build a nice Stairway? * First off, you should get all the rotations of the String. For example, the String `abcd` has the following rotations: `abcd, bcda, cdab, d...
[Question] [ Note: this is heavily inspired by *[this question](https://codegolf.stackexchange.com/questions/92944/hyperprogramming-nn-n%C3%97n-nn-all-in-one)*. # Task: Your task is to generate the `n`th prime, when each character of your program is repeated `n` times in place. Let's say your program is: ``` Derp `...
[Question] [ ## Details Write a function or program that, given an array (or list), containing only integers, returns or output an array with all sub-elements reversed. That is, reverse all elements of the deepest array, then the second deepest, etc. The dimensions need not be specified, but the function or program...
[Question] [ **Updated Results** # Introduction To celebrate Monster Hunter 4 Ultimate launch on new 3DS (February 13th), here's a King of the Hill themed on this game. You are a novice hunter, who'll take part in a tournament consisting of 5 consecutives hunts. At the end of these hunts, hunters will be ranked dep...
[Question] [ Almost every function can be expressed as a polynomial with infinite terms. For example, `e^x = 1 + x + x^2/2! + x^3/3! + x^4/4! + ...` For example, `sin(x) = x - x^3/3! + x^5/5! - x^7/7! + ...` The coefficients of the `n`-th terms form a sequence, and the corresponding function is called the **Generat...
[Question] [ Inspired by the [previous question](https://codegolf.stackexchange.com/questions/8369/generate-a-kolakoski-sequence). [Golomb's self-describing sequence](https://oeis.org/A001462) g(n) is a sequence where any natural number `n` is repeated within the sequence g(n) times. The first few numbers in the se...
[Question] [ What is the shortest program that can predict the next time Friday will fall on the 13th day of the month? * Must be an complete functioning program (not just a function/subroutine) * Must print out date in the following format: `YYYY-MM-DD` * Allow user to provide a start date either as a command line...
[Question] [ The Venetian election system was... [complicated](https://www.venetoinside.com/hidden-treasures/post/the-election-of-the-doge-of-the-republic-of-venice/). > > The Great Council came together and put in an urn the ballots of all the councilors who were older than 30. The youngest councilor went to St M...
[Question] [ The purpose of this challenge is to solve the original [first Project Euler problem](https://projecteuler.net/problem=1), but as the title suggests in [constant time](https://en.wikipedia.org/wiki/Time_complexity#Constant_time) (with respect to the size of the interval). > > Find the sum of all the mu...
[Question] [ I was in the bus today, and noticed this sign: ``` seated standing wheelchairs max1 37 30 00 max2 36 26 01 max3 34 32 00 ``` The number of seated passengers, standees, and wheelchairs all have to be no larger than some row in...
[Question] [ ## Definition If you take the sequence of positive integer squares, and concatenate them into a string of digits (i.e. `149162536496481100...`), an "early bird" square is one that can be found in this string ahead of its natural position. For example, 72 (the number `49`), can be found at an offset of ...
[Question] [ # Definitions * Two numbers are **co-prime** if their only positive common divisor is `1`. * A list of numbers is **mutually co-prime** if every pair of numbers within that list are co-prime with each other. * A factorization of number `n` is a list of numbers whose product is `n`. # Task Given a posit...
[Question] [ As in, the 5 speed transmission from the original VW Golf GTI. Print the transmission pattern in as few bytes as possible. Yes I know this isn't what it actually looks like but the GTI 5 speed shift knob pattern is a lot worse. ``` 1 3 5 | | | |--|--| | | | 2 4 R ``` [Answer] # [Japt](http...
[Question] [ ## Description "Imtiaz Germain primes" is not a technical name in Mathematics, but my weird creation, in the memoir of the famous mathematician Sophie Germain. These primes can be generated by the following process: ``` 1. Take a Safe prime 2. Apply 2p + 1 on it to obtain a composite number 3. Apply 2p...
[Question] [ Write a program/function that finds the amount of fuel needed to escape Earth's gravity well given the exhaust velocity of the fuel and the amount of mass to transport using the [Tsiolkovsky rocket equation](https://en.wikipedia.org/wiki/Tsiolkovsky_rocket_equation): $$\Delta v = v\_\text{exhaust}\ln\d...
[Question] [ # Background In programming, there is a recursive algorithm called [binary exponentiation](https://en.wikipedia.org/wiki/Exponentiation_by_squaring), which allows for large integer powers to be calculated in a faster way. Given a non-zero base \$x\$ and a non-negative exponent \$n\$, the algorithm goes...
[Question] [ A [Gray code](https://en.wikipedia.org/wiki/Gray_code) is a permutation on binary numbers where incrementing or decrementing a number only ever causes a single bit to change. For example, a Gray code for the binary numbers up to 7 (so, with 3 bits) are: ``` 000 001 011 010 110 111 101 100 ``` You can s...
[Question] [ We all know about the Fibonacci sequence. We start with two 1s and keep getting the next element with the sum of previous two elements. n-bonacci sequence can be defined in similar way, we start with `n` 1s and take the sum of previous `n` elements to get the next element. **Challenge** Given a positiv...
[Question] [ # Vowels rhyme: Apples and Bananas There is a traditional children's song that repeats the same text over and over, only each time every vowel is replaced with a random vowel, but constant across the current stanza. ## Challenge The objective is to propose the shortest code that performs such a transfo...
[Question] [ ## Challenge We all know about normal Christmas trees - but how about an [upside-down Christmas tree](https://www.thespruce.com/upside-down-christmas-trees-1976407)! This is a fairly easy, Christmas themed challenge. The objective of this challenge is to make me an ASCII upside-down Christmas tree. Her...
[Question] [ ## Task Given a representation of a line, output the number of [quadrants](https://en.wikipedia.org/wiki/Quadrant_(plane_geometry)) that that line passes through. ## Valid Representations of a Line You can represent a line as * Three signed integers `A`, `B`, and `C` which share no common factor and wh...
[Question] [ The Lehmer-Comtet sequence is a sequence such that **a(n)** is the **n**th derivative of **f(x) = xx** with respect to **x** as evaluated at **x = 1**. # Task Take a non-negative integer as input and output the **n**th term of the Lehmer-Comtet sequence. This is [code-golf](/questions/tagged/code-golf ...
[Question] [ Paul is one of your Belgian acquaintances, and he would like you to create a program that **outputs at least one of the following five strings**: ``` 12496=>14288=>15472=>14536=>14264 14264=>12496=>14288=>15472=>14536 14536=>14264=>12496=>14288=>15472 15472=>14536=>14264=>12496=>14288 14288=>15472=>145...
[Question] [ The [cosmic call](https://en.wikipedia.org/wiki/Cosmic_Call) is a message sent into space in 1999 and 2003. It's made of 23 127\*127px monochrome bitmap images, as detailed [here](http://blog.plover.com/aliens/dd/intro.html). Your mission is to write a program that displays the entire 127\*2921px messa...
[Question] [ Write a program using only [printable ASCII characters](https://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters) that takes no input. For reference, here are the 95 printable ASCII characters in order: ``` !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxy...
[Question] [ **Minimum Scalar Product** The inspiration for this code golf problem is from [Google's code jam competition](https://code.google.com/codejam/contest/32016/dashboard#s=p0). The premise behind the problem is, given the input of two vectors of varying lengths, find the minimum possible scalar. A scalar c...
[Question] [ There is an existing "game" where pirates rationally divide gold coins according to certain rules. Quoting from [Wikipedia](https://en.wikipedia.org/wiki/Pirate_game): > > There are 5 rational pirates, A, B, C, D and E. They find 100 gold coins. They must decide how to distribute them. > > > The pir...
[Question] [ I recently saw this Javascript code on StackOverflow for [merging two arrays](https://stackoverflow.com/questions/1584370/how-to-merge-two-arrays-in-javascript), and removing duplicates: ``` Array.prototype.unique = function() { var a = this.concat(); for(var i=0; i<a.length; ++i) { for...
[Question] [ Part of [**Code Golf Advent Calendar 2022**](https://codegolf.meta.stackexchange.com/questions/25251/announcing-code-golf-advent-calendar-2022-event-challenge-sandbox) event. See the linked meta post for details. --- It's Hanukkah! Unfortunately, it appears some of the candles in your menorah have been...
[Question] [ **This is the cops' challenge. To post a robber, go [here](https://codegolf.stackexchange.com/questions/241948/inject-arbitrary-code-into-a-compiler-robbers).** In this challenge, cops will invent a (likely simple) programming language, and write an interpreter, transpiler, or compiler that allows you ...
[Question] [ The [Corpus](https://warframe.fandom.com/wiki/Corpus) are a fictional faction from the popular video game [Warframe](https://www.warframe.com/) who have a somewhat interesting language. Whilst other factions in the game such as the Grineer have some logic behind their language, the Corpus is simply a l...
[Question] [ Swapping two elements in a vector/matrix is very simple in Octave: ``` x='abcde'; x([4,1])=x([1,4]) x = dbcae ``` Unfortunately, I have yet to find a way to do this inside an anonymous function. While the function below is syntactically correct, it only gives back the two elements that are swapped,...
[Question] [ Write a function or program that takes in a list and produces a list of the local extremes. In a list `[x_0, x_1, x_2...]` a local extreme is an `x_i` such that `x_(i-1) < x_i` and `x_(i+1) < x_i` or `x_(i-1) > x_i` and `x_(i+1) > x_i`. Notice that the first and last elements of the list can never be l...
[Question] [ Given a ragged list of positive integers return a full cycle of recursive rotations starting with the unchanged input and ending with the state immediately before revisiting the initial state. #### Examples: ``` [[2,3],4,5,5] -> [[2,3],4,5,5] , [4,5,5,[3,2]] , [5,5,[2,3],4] , [5,[3,2],4,5] [1,10,[2,2,4...
[Question] [ *(yes, "generating generating" in the title is correct :) )* # Context In middle (?) school we are taught about sequences and, in particular, we are taught about linear sequences where the `n`th term is generated with an expression of the form `an + b`, where `a` and `b` are some coefficients. In this ...
[Question] [ Taking some output from xxd and turning it into usable shellcode by hand is no fun, so your job is to automate the process. **Rules** Your submission can be a function, lambda, script, or any reasonable equivalent of those. You may print the result, or if your submission is a function/lambda then you m...
[Question] [ ### Objective Given a 2D array of any size, write a program or function to shift alternatively the columns and rows ### Example ``` a b c d e f g h i j k l m n o ``` All elements in the **first** column shift **down** one row, the **second** column shift **up** one row, the **third** shift **down** one...
[Question] [ Lets define a class of functions. These functions will map from the positive integers to the positive integers and must satisfy the following requirements: * The function must be Bijective, meaning that every value maps to and is mapped to by exactly one value. * You must be able to get from any positi...
[Question] [ Based on [this](https://codegolf.stackexchange.com/questions/119361/easier-communication-means-faster-coding-means-fewer-coders-means/119406), but I was asked[[​1​]](https://codegolf.stackexchange.com/questions/119361/easier-communication-means-faster-coding-means-fewer-coders-means#comment292359_11936...
[Question] [ A [heap](https://en.wikipedia.org/wiki/Heap_(data_structure)), also known as a priority-queue, is an abstract data type. Conceptually, it's a binary tree where the children of every node are smaller than or equal to the node itself. (Assuming it's a max-heap.) When an element is pushed or popped, the h...
[Question] [ The SUDSI sequence (**su**m, **d**ifference, **s**wap, **i**ncrement) is a curious integer sequence that appears to exhibit rather chaotic behavior. It can be generated as follows: Let *S* be an infinite list of the natural numbers: `1 2 3 4 5 6 ...`. Let *Si* denote the one-indexed *i*th element of *S...
[Question] [ ## Background *Inspired by [this video](https://www.youtube.com/watch?v=s9-b-QJZdVA) by Matt Parker* A [Faro shuffle](https://en.wikipedia.org/wiki/Faro_shuffle) is a perfect riffle shuffle where the deck is exactly interleaved with its other half. This is how to perform one: * the deck of 52 cards is ...
[Question] [ You will be given a square matrix of integers **M** and another positive integer **n**, strictly smaller than the size of **M**. Your task is to generate all square sub-matrices of **M** of size **n**. For the purposes of this challenge, a *square sub-matrix* is a group of **adjacent** rows and column...
[Question] [ A Hilbert Curve is a type of space-filling curve, and it basically maps a line to a plane. Each point in the line corresponds to just one point in the plane, and each point in the plane corresponds to just one point on the line. Shown are iterations 0 through 4 of the Hilbert Curve: Iterations 0 up to ...
[Question] [ *Longest day of the year - here's something to waste the extra time...* --- ## Overview Note this is not a popularity contest and not a graphical output challenge - you are only required to output a string of 65,536 zeroes and ones. The Stack Snippet at the bottom of the question will display this as a...
[Question] [ # Introduction Finding the *closest* power to a number is a common enough problem. But what if you need both the next-highest and next-lowest power? In this challenge you must find the closest powers to a given number - the 'power sandwich' if you will, where the given number is the filling and the pow...
[Question] [ # Objective You're on a nonempty list of integers that wraps around. You start at the leftmost entry of the list, and keep jumping to the right to the amount of the integer entry you're at. Eventually, you'll end up in a cycle. The objective is to output the length of this cycle. # I/O format Provided ...
[Question] [ ## The Challenge Given an input string (or array) consisting of `<` and `>`, output a sequence (array or string) of integers such that: * the operators are all correct when applied in order between consecutive numbers in the output * all integers are positive (1 or greater) * the sum of the integers is...
[Question] [ ## Challenge This is a simple challenge. Given **two positive integers** `w` and `h` create an ASCII fence with a width of `w` and a height of `h`. The fence should be constructed using the following rules: * The `+` character will represent a post. * The `-` character will be used to represent the wid...
[Question] [ [Zeckendorf's theorem](https://en.wikipedia.org/wiki/Zeckendorf%27s_theorem) shows that every positive integer can be uniquely represented as a sum of non-adjacent Fibonacci numbers. In this challenge, you have to compute the sum of two numbers in Zeckendorf representation. --- Let Fn be the *n*-th Fib...
[Question] [ ## Challenge Write a program to compute the the first N (<= 10^3) digits of [e](http://en.wikipedia.org/wiki/E_%28mathematical_constant%29). Your program should take an integer **N** as input. **Input:** ``` 100 ``` **Output:** ``` 2.718281828459045235360287471352662497757247093699959574966967627724076...
[Question] [ Given a non negative integer number tell if it can be erased by repeatedly removing **all** occurrences of the length of that number from it **including overlapping matches**. * Erasing means cancel all its digits. For example the number *4440* is not lengthy because after removing all 4's you obtain *...
[Question] [ I recently solved a coding challenge in one of the challenge papers that my IT teacher gave to us. It was a seemingly simple, but fun challenge, so I thought it will make fun golfing. ## The task Given an input of a 2x2 matrix that contains 4 strictly positive integers (i.e. non-negative and non-zero),...
[Question] [ ## Background "Fly straight, dammit" ([OEIS A133058](https://oeis.org/A133058)) is a sequence of integers, which has these rules: * \$a\_0 = a\_1 = 1\$ * \$a\_n = a\_{n-1}+n+1\$ *if* \$gcd(a\_{n-1}, n) = 1\$ * *Otherwise,* \$a\_n = \frac{a\_{n-1}}{gcd(a\_{n-1}, n)}\$ In pseudocode: ``` a[0] = a[1] = 1 ...
[Question] [ ## Introduction: Since it's almost Halloween, I was just thinking of some random Halloween-themed challenges. Eventually I was reading through [Frankenstein's wikipedia page](https://en.wikipedia.org/wiki/Frankenstein), and came across the following text: > > ### The creature > > > Part of Frankenst...
[Question] [ Given a binary number, your task is to create a 'branch' of that number, with a depth of 2. For example, given `0` as input, you should output exactly this: ``` /000 /00 / \001 0 \ /010 \01 \011 ``` This should be fairly self explanatory of how the branches should be created. Depth ...
[Question] [ What general tips do you have for golfing in [Nim](http://nim-lang.org/ "Nim programming language")? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Nim (e.g. "remove comments" is not an answer). Please post one tip per answer. [Ans...
[Question] [ We all often hear the idiom "walk through the array" to mean "map the function over the following array". However, I need it done (now!), so I want you to *run* through the array. ## How do I run? Imagine there's a wild pack of [wolves](https://codegolf.stackexchange.com/questions/25347/survival-game-c...
[Question] [ Write the shortest program to print the non-trivial powers ≤ 2^12 in order non-trivial power means the base and exponent are > 1 Leading whitespace is optional When there are multiple solutions, the order is not important, so `16 = 4^2, 2^4` is ok Sample output: ``` 4 = 2^2 8 = 2^3 ...
[Question] [ Suppose we have a sequence \$P\$. Every element \$P\_n\$ represents the distance between the \$n^{th}\$ prime number and the average of the next two prime numbers. For example, \$P\_1\$ would be the distance between the first prime number (2) and the average of the next two prime numbers (3 and 5), so ...
[Question] [ Your input is a non-empty set of non-empty sets of positive integers. For example: ``` {{1}, {2, 3}, {2,4}, {1,4}} ``` Your task is to output the maximal number of elements that can be picked from the sets with the following conditions: * You can only pick at most 1 element from a set * You can't pick ...
[Question] [ [Risky](https://github.com/Radvylf/risky) is a new language of mine, which features an interesting form of tacit programming. In this challenge, you'll take a Risky program as input, and visualize the parsing. No knowledge of Risky is needed for this challenge, but it's a pretty interesting language so...
[Question] [ # Task Given a positive integer number and a threshold, split into every possible way without generating any numbers above the threshold. # Examples > > Input: **15008** > > Threshold: **400** > > > Valid Output: `[[1, 5, 0, 0, 8], [15, 0, 0, 8] [1, 50, 0, 8], [150, 0, 8]]` Invalid outputs: * ...
[Question] [ *I will preface this by saying that I made this for fun; I have absolutely no formal knowledge on cryptography or error correction. Do not use this algorithm in anything remotely important.* I was kind of bored a few days ago, so I decided to write a simple function to take some data and return an easi...
[Question] [ You are given an array **A** of **n** strictly positive integers, with **n ≥ 2**. Your task is to map each entry **Ai** to: * **1** if **Aj mod Ai** is odd for each **j** such that **1 ≤ j ≤ n** and **j ≠ i** * **2** if **Aj mod Ai** is even for each **j** such that **1 ≤ j ≤ n** and **j ≠ i** * **0** ...
[Question] [ As a follow up to my previous challenge [Count to 20 with Words!](https://codegolf.stackexchange.com/questions/133564/count-to-20-with-words/), we will once again be using the word list from that challenge to perform another task. This time, you will be exclusively using: [https://github.com/Magic Octo...
[Question] [ # Background The *parity of a permutation*, [as defined by wikipedia](https://en.wikipedia.org/wiki/Parity_of_a_permutation), is as follows: > > The sign or signature of a permutation σ is denoted sgn(σ) and defined as +1 if σ is even and −1 if σ is odd. > > > The sign of a permutation can be explic...
[Question] [ This problem is from [Five programming problems every Software Engineer should be able to solve in less than 1 hour](https://blog.svpino.com/2015/05/07/five-programming-problems-every-software-engineer-should-be-able-to-solve-in-less-than-1-hour) which itself is an interesting read. The first few probl...
[Question] [ A Spirograph is a toy that draws hypotrochoids and epitrochoids. For this challenge, we'll just focus on the hypotrochoids. From [Wikipedia](http://en.wikipedia.org/wiki/Hypotrochoid): > > A hypotrochoid is a roulette traced by a point attached to a circle of radius **r** rolling around the inside of...
[Question] [ **Closed**. This question needs to be more [focused](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** Update the question so it focuses on one problem only by [editing this post](/posts/6798/edit). Closed 6 years ago. [Improve this question](/po...
[Question] [ Given an alphabet represented as a nonempty set of positive integers, and a word made up of symbols from that alphabet, find that word's position in the lexicographically ordered set of all words, assuming words can't contain duplicate symbols. ## Example Consider the alphabet `{1, 2, 3}` and the word ...
[Question] [ This puzzle is derived from [CodinGame](https://www.codingame.com) SamSi's "Heart of the City" puzzle. ## Description You decide to take a walk in an `n` \* `n` tile city and go to the center tile. All of the buildings are infinitely small, but you have super vision and can see everything close up and ...
[Question] [ # Task Given a list of space-delimited integers as input, output all unique non-empty subsets of these numbers that each subset sums to 0. --- ## Test Case Input: `8 −7 5 −3 −2` Output: `-3 -2 5` --- ## Winning Criterion This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-gol...