text
stringlengths
180
608k
[Question] [ ## Background Roman numeral is a simple number system with the following properties: * Each symbol in the system maps to a specific value. (e.g. `I = 1, V = 5, X = 10, C = 100`) * The value of a Roman numeral can be evaluated as follows: + First, find all occurrences of adjacent pairs of symbols where...
[Question] [ The reverse-then-add (RTA) sequence is a sequence obtained by adding a number to its reverse, and repeating the process on the result. For eg., $$ 5 + 5 = 10 \Rightarrow 10 + 01 = 11 \Rightarrow 11 + 11 = 22 \Rightarrow 22 + 22 = 44 \Rightarrow\text{ }... $$ Thus, 5's RTA sequence contains 10, 11, 22,...
[Question] [ Pascal's Rhombus (which is actually a triangle) is obtained by adding in the pattern: ``` * *** x ``` instead of ``` * * x ``` This means that each cell is the sum of the three cells on the row directly above it and one cell on the row 2 above it. Just like Pascal's triangle the zeroth row has a...
[Question] [ A positive integer *n* can be represented as a *rectangle with integer sides* *a*, *b* such that *n* = *a* \* *b*. That is, the area represents the number. In general, *a* and *b* are not unique for a given *n*. As is well known, a rectangle is specially pleasing to the eye (or is it the brain?) when i...
[Question] [ [Khinchin's constant](http://en.wikipedia.org/wiki/Khinchin's_constant) is a curious mathematical constant that, [according to Wolfram MathWold](http://mathworld.wolfram.com/KhinchinsConstant.html), is *"notoriously difficult to calculate to high precision"*. Here it is to 100 digits: > > 2.6854520010...
[Question] [ A neat trick is if you ever need a nine-sided die, it is possible to make one using two six-sided dice using the numbers below. This is assuming you either have a way to rewrite the faces on the dice, or use some algorithm to map the numbers on a normal die onto these new numbers. ``` 0 0 3 3 6 6 -...
[Question] [ Output the infinite list of pairs of integers `(a, b)`, where both \$ a > 1 \$ and \$ b > 1 \$, ordered by the value of \$ a^b \$. When there are multiple pairs where \$ a^b \$ is equal, they should be ordered lexicographically. For example, \$ 2^4 = 4^2 = 16 \$, but `(2, 4)` should come before `(4, 2)...
[Question] [ # Introduction Write a program or function that, given the coordinates of where a dart lands on a dartboard, return the score of that dart. Dart coordinates are given as two integers, `x,y` measured from the center of the dartboard, with millimeter precision. ## How to score a dart Darts is a game play...
[Question] [ For this challenge, you should write a program or function which outputs the diagonals of a given square matrix. However, if you transpose the rows and columns of your solution's source code, it should instead become a program or function which returns the matrix's antidiagonals. Read on for specifics....
[Question] [ Consider an array of unique integers, with an arbitrary length greater than 2. It is sometimes possible to express elements of the array as the sum of at least two other elements. For example, if our array is `[2, 3, 1]`, we can express `3` as the sum `2+1`. However, we can't express either `2` or `1` ...
[Question] [ ## Background Sometimes when I'm golfing a program, I'm presented with the following situation: I have an integer value \$x\$ on some fixed interval \$[a, b]\$, and I'd like to test whether it's in some fixed subset \$S \subset [a, b]\$ with as few bytes as possible. One trick that sometimes works in a...
[Question] [ Given two polynomials `f,g` of arbitrary degree over the integers, your program/function should evaluate the first polynomial in the second polynomial. `f(g(x))` (a.k.a. the *composition* `(fog)(x)` of the two polynomials) ### Details Builtins are allowed. You can assume any reasonable formatting as in...
[Question] [ Everybody loves geometry. So why don't we try and code golf it? This challenge involves taking in letters and numbers and making shapes depending on it. # The Input The input will be in the form of `(shapeIdentifier)(size)(inverter)`. *But what are shapeIdentifier, size, and inverter?* The shape identi...
[Question] [ Consider a square block of text, N characters wide by N tall, for some odd integer N greater than 1. As an example let N = 5 and the text be: ``` MLKJI NWVUH OXYTG PQRSF ABCDE ``` Notice that this is the alphabet (besides Z) spiraled around counter-clockwise from the lower left corner. It's kind of lik...
[Question] [ # Challenge description We've had a few challenges involving the [Look-and-say sequence](https://en.wikipedia.org/wiki/Look-and-say_sequence). Quick reminder: * The sequence starts with `1`, * Subsequent terms of this sequence are generated by enumerating each group of repeating digits in the previous ...
[Question] [ A palindromic number (in case you don't know) is a number which reads the same backwards and forwards (example, 11). The first 15 non-palindromic numbers are: `10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26`. This is [A029742](http://oeis.org/A029742/list). I constantly need these numbers, ...
[Question] [ Given an integer ***p > 1***, find the smallest integer ***q > p*** such that the list of exponents in the prime factorization of ***q*** is the same of that of ***p***, no matter the order or the value of the prime factors. ## Examples The prime factorization of ***p = 20*** is ***22 x 51***. The smal...
[Question] [ The stock market is all about the speed of knowledge. Unlike previous challenges, **the current stock price is not random: it is determined by those playing the game.** If you can identify an under-priced stock before anybody else, then you've written yourself a money-making program. ***Price* refers t...
[Question] [ Your challenge is simple: GIven an integer **N**, ouput every list of positive integers that sums to **N**. For example, if the input was 5, you should output ``` [1, 1, 1, 1, 1] [1, 1, 1, 2] [1, 1, 3] [1, 2, 2] [1, 4] [2, 3] [5] ``` These lists do not have to be output in any particular order, nor do ...
[Question] [ ## Introduction Your mission in life is simple: Prove people wrong on the internet! To do this you usually carefully analyze their statements and point out the contradiction in them. It's time to automate this, but as we are lazy, we want to prove people wrong with the least effort (read: shortest ...
[Question] [ Polyglots are programs that are valid in multiple programming languages simultaneously. Most such polyglots are written in such a way that certain constructs of one language are interpreted as comments of another language (e.g. `#define` in C being interpreted as a comment in several scripting language...
[Question] [ The [PBM (Portable BitMap) format](http://en.wikipedia.org/wiki/Netpbm_format#PBM_example) is a very simple ASCII black and white bitmap format. Here's an example for the letter 'J' (copy-pasted from the wikipedia link): ``` P1 # This is an example bitmap of the letter "J" 6 10 0 0 0 0 1 0 0 0 0 0 1 0 ...
[Question] [ There are many challenges that say "interpret X", where X is a simple language. In my opinion, that is way too boring. To give all the procrastinating people on the internet something interesting to do, you can try to do this challenge: ## Challenge Choose a language `$LANG`. `$LANG` can be any turing ...
[Question] [ I'm not sure if this is the right place to ask, but I found this similar [question](https://codegolf.stackexchange.com/questions/145391/how-can-i-shorten-this-python-code) so I'll go ahead. I'm *very* new to code golfing, so keep your smothered laughs and throw-up emoji's to yourselves please ;). Anywa...
[Question] [ Given an array of integers **`a`** which contains *n* integers, and a single integer **`x`**; remove the fewest amount of elements from **`a`** to make the sum of **`a`** equal to **`x`**. If no combinations of **`a`** can form **`x`**, return a falsy value. As pointed out in a comment this is the maxi...
[Question] [ Most people here are familiar with seven segment displays, which are also used in matchstick puzzles. Below are the digits `0` through `9` and letters `a` through `z`, except `k,m,t,v,w`, written in this format. ``` _ _ _ _ _ _ _ _ | | | _| _| |_| |_ |_ | |_|...
[Question] [ This challenge is inspired by [this](https://codegolf.stackexchange.com/q/156856/31516), now deleted question. --- Take a positive integer **N** as input, and output a matrix with the numbers **1 .. N2** that follows the pattern below: Fill in the first row with **1 .. N** then fill the last row (row n...
[Question] [ Lets say your job is to paint poles, and a client asks you to paint a pole with 4 red sections and 3 yellow sections. You can do that pretty easily as follows: ``` r y r y r y r ``` With just yellow and red stripes. Now lets say your client asks you to paint a pole with 2 red sections, 2 yellow section...
[Question] [ Disclaimer: **No, this is not a joke challenge to reverse a string.** # Task There is only one operation to support: subtraction (`-`). You also only have two atoms to support: zero (`0`) and one (`1`). Here, the prefix notation `-AB` is equivalent to the postfix notation `AB-`, where `A` and `B` are e...
[Question] [ Write a program or function that takes in a positive integer N and recreates this pattern of circles scaled to fit an N×N pixel image: [![fancy circles](https://i.stack.imgur.com/ZSx88.png)](https://i.stack.imgur.com/ZSx88.png) This image is a valid output example for N = 946. In case it's not clear, a...
[Question] [ ## Challenge: Given two integers \$a\$ and \$b\$, with lengths \$A=length(a), B=length(b)\$, output an ASCII-art of the \$a^{th}\$ root of \$b\$, including the answer rounded to \$A\$ amount of decimal places. The size of the ASCII-art root also depends on \$A\$ and \$B\$. **Example:** \$a=123\$, \$b...
[Question] [ **This question already has answers here**: [Write the shortest self-identifying program (a quine variant)](/questions/11370/write-the-shortest-self-identifying-program-a-quine-variant) (48 answers) Closed 3 years ago. Write a program/method that: * Becomes a quine when the input matches the sou...
[Question] [ ## Input A non-empty shuffled string consisting of ASCII characters in the range \$[32..126]\$. ## Output The output is obtained by applying successive rotations to the input string. For each letter (`[a-zA-Z]`) in the input string, going from left to right: * if the letter is in upper case, rotate all...
[Question] [ [Minecraft 1.12](http://minecraft.gamepedia.com/1.12) will be released tomorrow, so let's celebrate! Write code that takes in a non-negative integer N which represents the number of items of something in [Minecraft](http://minecraft.gamepedia.com/Minecraft). Output it in a way more helpful to players, ...
[Question] [ We know that *f* is a polynomial with non-negative integer coefficients. Given *f(1)* and *f(1+f(1))* return *f*. You may output *f* as a list of coefficients, an ASCII formatted polynomial, or similar. Examples: ``` f(1) f(1+f(1)) f 0 0 0 1 1 1 5 75 2x^2 + 3 30...
[Question] [ Semordnilaps (also known as heteropalindromes, semi-palindromes, half-palindromes, reversgrams, mynoretehs, reversible anagrams, word reversals, or anadromes) are words which are also words when spelled backwards. A few examples are: * Ward <=> Draw * Mined <=> Denim * Parts <=> Strap Given a positive ...
[Question] [ **[World Bowling scoring](https://en.wikipedia.org/wiki/Ten-pin_bowling#World_Bowling_scoring)** Many people have gone to their local bowling center to play a few games of bowling, and many people continue to struggle to calculate their scores. World Bowling has introduced a simplified scoring system i...
[Question] [ Given a positive integer input **N**, output the two non-negative numbers, **a** and **b**, where **a < b**, with the lowest possible mean value that will result in the number **N** being part of the recurring relation sequence: ``` f(0) = a f(1) = b f(n) = f(n-2)+f(n-1) ``` ~~In case there are more th...
[Question] [ ## Background It's late Friday afternoon and you and your friends decide to hit the pub later that evening, but before going to the pub you figure you should have a few beverages. However, things escalate quickly; your friend Shaddock Pamplemousse won the lottery earlier this week and decided to bring ...
[Question] [ The [Caesar Cypher](http://en.wikipedia.org/wiki/Caesar_cypher) is a very simple substitution cypher where each letter is shifted by a fixed offset (looping around Z to A). Similarly, we can also a Caesar cypher for the set of printable ASCII characters. These are the 95 characters from code points 0x2...
[Question] [ Given a non negative integer number \$n\$ output how many steps to reach zero using radicals, divisions or subtractions. # The algorithm * Get digits count ( \$d\$ ) of \$n\$. * Try the following operations in order: $$\sqrt[d]{n}$$ $$n/d$$ $$n-d$$ * Take the first integer result not equal to \$n\$. ...
[Question] [ Given a matrix of size at least 3×3 formed by positive integers, determine if it contains at least one "U" pattern, defined as ``` + + + - - - + + + + - N - N - + + + - N - N - + + + - N N N - + + + + - - - + + ``` where * `N` is the same number, repeated in those seven positions * `-` (optional) repre...
[Question] [ You can depict a [triangular number](https://en.wikipedia.org/wiki/Triangular_number), T(N), by writing one 1 on a line, then two 2's on the line below, then three 3's on the line below that, and so on until N N's. You end up with a triangle of T(N) numbers, hence the name. For example, T(1) through T(...
[Question] [ # Introduction Connect Four is a game where you attempt to get four in a row: horizontally, vertically, or diagonally. In this code golf, we will be trying to find who won, given a game board. There will always be one winner, and only one winner. --- # Task Given a Connect Four board, figure out who th...
[Question] [ Lagrange's four square theorem tells us any natural number can be represented as the sum of four square numbers. Your task is to write a program that does this. Input: A natural number (below 1 billion) Output: Four numbers whose squares sum to that number (order doesn't matter) Note: You don't have to...
[Question] [ ## Background A **polyhex** of size \$n\$ is a contiguous shape made from joining \$n\$ unit regular hexagons side-by-side. As an example, the following image (from Wikipedia) contains all 7 distinct tetrahexes (polyhexes of size 4): [![enter image description here](https://i.stack.imgur.com/e2pqa.png)...
[Question] [ Let's define a *self-contained number* as a positive integer, whose digits appear in runs of length equal to themselves only. In other words, any decimal digit **d** (excluding **0**) occurs only in runs of length exactly **d**. # Task You can choose any of the three methods listed below: * Given an in...
[Question] [ Write a program to determine if a periodic sequence of positive integers has the property that, for every integer `n` occurring in the sequence, there are never more than `n` other integers between two consecutive occurrences of `n`. For example, `2, 3, 5, 2, 3, 6, 2, 3, 5, 2, 3, 6, ...` does have this...
[Question] [ # Objective Given an input list of `6` distinct digits, find 3 numbers `a`, `b` and `c` such that `a × b = c`, with `a` having 2 digits, `b` having 1 digit and `c` having 3 digits. In a more visual way, your program must arrange those 6 digits in the boxes of this image: [![enter image description here...
[Question] [ ## Background Programmers these days can't seem to keep their buffers straight! A common source of error is trying to use an array index that is too large for the buffer. Your task is to implement a buffer where large indices are reduced to a size that the buffer can handle. Because I decide exactly wh...
[Question] [ # The Challenge Write a program or function that takes two input integers, `i` and `j`, and outputs their greatest common divisor; calculated by using the [Euclidean algorithm](https://en.wikipedia.org/wiki/Euclidean_algorithm) (see below). --- # Input Input may be taken as a space-delimited string rep...
[Question] [ **Closed**. This question needs [details or clarity](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** Add details and clarify the problem by [editing this post](/posts/189537/edit). Closed 4 years ago. [Improve this question](/posts/189537/edit)...
[Question] [ Given a positive integer `n >= 1`, output the first `n` rows of the following structure: ``` # # # ### # # # # # ## ## ##### # # # # # # # # # # ### # ## ## ## # ## ### ### ####### ``` The `n`-th 1-indexed row is the binary representation of `n`, mirrored without copying the last c...
[Question] [ ## Background I want to buy an plot of land and build my house on it. My house should be rectangular, and as large as possible; however, the available plots have lots of rocky areas that I cannot build on, and I'm having trouble fitting a potential house on the plots. I want you to write a program that...
[Question] [ **NOTE:** This challenge is currently dead, as I'm unable to install the languages needed to run a match. If someone else has the time and interest to do it, I'm not opposed. **See the bottom of the post for a leaderboard.** This is a semi-cooperative king-of-the-hill challenge, where the bots construc...
[Question] [ Determine whether a given sequence could be a winning sequence for the game [shut the box](https://en.wikipedia.org/wiki/Shut_the_box). ## Background There are a few variants to this game, so I'll clarify the rules here. Play begins with 12 tiles (1 through 12) face up. Each turn the player rolls two s...
[Question] [ Your task is to take an ASCII art image and output it rotated clockwise by 45 degrees and scaled by a factor of \$\sqrt 2\$. The scaling comes from using a lattice pattern which introduces space between the characters. To explain it visually, a \$3 \times 3\$ block would be processed like so: ``` 123 4...
[Question] [ To increase data safety at our company, we are planning to start using Gray code numbers (where successive values differ by only one bit) instead of classical binary ones. Please help us to make a program that converts numbers to Gray code (single number to single number), but the program needs to be s...
[Question] [ This is a King of the Hill challenge in a round robin. It's a battle to find the best gunman of the west! To be able to compete in this contest you need to make two functions. The first one sets the attributes of your gunman and the second is the main logic function for the gunman. # Attribute Function...
[Question] [ The challenge - given a numeric list L and an integer N as inputs, write a function that: 1. finds the bucket sizes for L such that it is split into N *whole* buckets of equal or near-equal size, and 2. returns for each element in L the minimum of that element's bucket. Example - ``` L=[0, 1, 2, 3, 4, ...
[Question] [ This is a different type of compression challenge. In a normal [kolmogorov-complexity](/questions/tagged/kolmogorov-complexity "show questions tagged 'kolmogorov-complexity'") challenge, you are required to recreate a list exactly. Here, you are allowed to round the values in any way you wish. What's t...
[Question] [ ### Definition Let's call an (infinite) integer sequence universal if it contains every finite integer sequence as a contiguous subsequence. In other words, the integer sequence **(a1, a2, …)** is universal if and only if, for each finite integer sequence **(b1, …, bn)**, there is an offset **k** such ...
[Question] [ Every number can be represented using an infinitely long remainder sequence. For example, if we take the number 7, and perform `7mod2`, then `7mod3`, then `7mod4`, and so on, we get `1,1,3,2,1,0,7,7,7,7,....`. However, we need the *shortest* possible remainder subsequence that can still be used to dist...
[Question] [ A Caesar shift is probably something we're all familiar with. (You might be even doing it as a homework task. If so, please don't copy these answers, your teacher almost certainly doesn't want anything like the answers here.) Just in case you aren't, a Caesar shift is a very simple form of cipher. It ...
[Question] [ Given a real number `t` in `(-10^9,13)` (not including `-10^9` or `13`) as input, output `Γ(t)`, also known as the [Gamma function](https://en.wikipedia.org/wiki/Gamma_function), which is defined as follows: [![gamma function definition](https://upload.wikimedia.org/math/6/0/3/603515ff4df2cb431387e92bb...
[Question] [ This challenge was inspired by [this non-challenge about the natural logarithm base \$e\$](https://codegolf.stackexchange.com/q/261002/110698) and the following pandigital approximation to \$e\$ appearing on a [Math Magic page](https://erich-friedman.github.io/mathmagic/0804.html): $$\left|(1+9^{-4^{7×...
[Question] [ From the [Wikipedia article](https://en.wikipedia.org/wiki/Location_arithmetic): > > Location arithmetic (Latin arithmeticæ localis) is the additive (non-positional) binary numeral systems, which John Napier explored as a computation technique in his treatise Rabdology (1617), both symbolically and on...
[Question] [ **The Challenge:** Consider the function `F(N) = 2^N + 1` where `N` is a positive integer less than `31`. The sequence defined by this function is: ``` 3, 5, 9, 17, 33, 65, 129, 257, 513, 1025, 2049, 4097, 8193, 16385, 32769, 65537, 131073, 262145, 524289, 1048577, 2097153, 4194305, 8388609, 16777217, ...
[Question] [ You must write a program or function that sorts a nested list. Here are the rules for sorting a nested list: Let's take this list as an example: ``` ((5, 2), 2, 7, (2, 1, (3, 4)), 9) ``` Each element in this list has a "priority". An element counts as a number or a sublist. First, get the priority of e...
[Question] [ # Challenge Given a list of integers, return the list of these integers after repeatedly removing all pairs of adjacent equal items. Note that if you have an odd-length run of equal numbers, one of them will remain, not being part of a pair. ### Example: ``` [0, 0, 0, 1, 2, 4, 4, 2, 1, 1, 0] ``` First,...
[Question] [ # The cool stuff The following rosace can help calculate numbers modulo 7. [![enter image description here](https://i.stack.imgur.com/6b7cR.png)](https://i.stack.imgur.com/6b7cR.png) In order to do that, you must start at 0 and turn clockwise a number of steps given by the first digit. Then, for each s...
[Question] [ Generate the sequence *number of bases in which `n` is a palindrome* ([OEIS A126071](https://oeis.org/A126071)). Specifically, the sequence is defined as follows: given a number `n`, express it in base `a` for `a = 1,2, ..., n`, and count how many of those expressions are palindromic. "Palindromic" is ...
[Question] [ The cumulative sum of a vector is calculated by simply taking the sum of all previous elements. For instance: ``` vec = [1 1 1 -1 -1 -1 -1 -1 1 1 1 1 -1] cum_vec = [1 2 3 2 1 0 -1 -2 -1 0 1 2 1] ``` Now, impose an upper and a lower limit, meaning that you stop increasing the cumulati...
[Question] [ [Sieve of Eratosthenes](https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes?wprov=sfla1) is a method for finding prime numbers: take the sequence of all positive integer numbers starting from 2 then for each remaining number drop all its multiples. ``` 2 3 x 5 x 7 x 9 x 11 x 13 x 15 x 17 x ... 2 3 _ ...
[Question] [ # Introduction You can skip this part if you already know what a cyclic group is. A group is defined by a set and an associative binary operation \$\times\$ (that is, \$(a \times b) \times c = a \times (b \times c)\$. There exists exactly one element in the group \$e\$ where \$a \times e = a = e \times...
[Question] [ # Challenge description You have a music library with many tracks recorded by many bands, each of which has a name, like `Queen`, `Aerosmith`, `Sunny Day Real Estate`, `The Strokes` . When an audio player displays your library alphabetically by band name, it usually skips the `The` part, as many band n...
[Question] [ The [Fibonacci sequence](https://en.wikipedia.org/wiki/Fibonacci_number) is a well know sequence in which each entry is the sum of the previous two and the first two entries are 1. If we take the modulo of each term by a constant the sequence will become periodic. For example if we took decided to comp...
[Question] [ # Challenge Create a function or program that, when given an integer `size`, behaves the following way: If `size` is equal to 1, output ``` ┌┐ └┘ ``` If `size` is greater than 1, apply the following substitutions : | Source | Target | | --- | --- | | `┌` | `┌┐``└┌` | | `┐` | `┌┐``┐┘` | | `└` | `┌└``└┘`...
[Question] [ Your task is to generate a graph with 54 vertices, each corresponds to a facet on a Rubik's cube. There is an edge between two vertices iff the corresponding facets share a side. ### Rules * You may choose to output an adjacency list, adjacency matrix, edge list, or any reasonable format to represent a...
[Question] [ I did the IMC this year. Did anyone else here do it? In a UKMT Intermediate Maths Challenge paper, there are twenty-five questions. The first fifteen questions give you five marks if you get them right. For the other ten questions, you get six marks for getting them right. In the last ten questions, yo...
[Question] [ Define the function *f(n)* for a positive integer *n* as follows: * *n / 2*, if *n* is even * *3 \* n + 1*, if *n* is odd If you repeatedly apply this function to any *n* greater than 0, the result always seems to converge to 1 (though nobody's been able to prove that yet). This property is known as th...
[Question] [ Given an input string of length `2` or longer consisting solely of alphabetical characters `[A-Z]` or `[a-z]` (your choice if they're all uppercase or all lowercase), output a continuous string of characters forming a double diamond pattern. The input string starts on the center line and extends down-a...
[Question] [ Write a mathematical statement, using the symbols: * `There exists at least one non-negative integer` (written as `E`, existential quantifier) * `All non-negative integers`(written as `A`, universal quantifier) * `+` (addition) * `*` (multiplication) * `=` (equality) * `>`, `<` (comparison operators) *...
[Question] [ Given a string, return whether the string is a substring of the program's source code. Standard quine rules apply, meaning you cannot read your own source code. The length of the input is guaranteed to be less than or equal to the length of the program. You may return any two distinct values, not neces...
[Question] [ The beloved fish who swims through the code of [><> (an esoteric programming language)](https://esolangs.org/wiki/Fish) has been taken out of its natural environment. This change has rendered it incapable of moving around in the way it's used to: what used to be toroidal movement has been restricted to...
[Question] [ [Hearts](http://en.wikipedia.org/wiki/Hearts) is a trick-taking card game for 4 players. Each trick is taken by the player who played the highest card of the leading suit. At the end of each hand, the players incur a penalty score depending on the penalty cards they have taken; the task is to determine...
[Question] [ ## Task * Print 0 if an `n*m` maze cannot be solved * Print 1 if an `n*m` maze can be solved (in 1 or more ways) (so I'm not asking for paths but if it's possible to solve!!!) ## Example Input array(2d): ``` [[0,0,0,0,0,0,1],[0,0,0,0,0,1,0],[0,0,0,0,1,0,0],[1,0,0,0,0,0,0]] XXXXXXXXX XS XX X X X...
[Question] [ Your task is to find how many distinct Blackjack sequences can be found in an ordered list of 12 cards. A Blackjack sequence is defined as a sequence of consecutive cards whose sum of points is exactly 21. Points are counted according to the following table: ``` Symbol | Name | Points Symbol | Nam...
[Question] [ [There's a question on this site](https://codegolf.stackexchange.com/questions/5891/josephus-problem-counting-out "There's a question on this site that is similar to this one") that is similar to this question, but I have added a twist. You have three inputs, the number of people in the circle *n*, the...
[Question] [ **Overview:** From [Wikipedia](http://en.wikipedia.org/wiki/Egyptian_fraction): An Egyptian fraction is the sum of distinct unit fractions. That is, each fraction in the expression has a numerator equal to 1 and a denominator that is a positive integer, and all the denominators differ from each other. ...
[Question] [ The barfoos, a hypothetical alien species, go about charity in an interesting way. Every morning, barfoo Specialists come up with an ordered list of causes to donate to, and for each cause they recommend what quantity of resources should be donated. That wasn't the weird part. Here's the weird part: A ...
[Question] [ This challenge is about the number of orderings which contain at most \$n\$ classes and at most \$k\$ of the \$k^{\text{th}}\$ class. One way to represent such an ordering is as a sequence of positive integers with these three restrictions: 1. A number may only appear after all lower numbers have appea...
[Question] [ Most square numbers have at least 1 different square number with which their [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance) is exactly 1. For a given square \$x\$, each square that meets this condition is called a *Levenshtein neighbour* of \$x\$. For example, \$36\$ is a Le...
[Question] [ Given a sequence of bytes, output the SHA-256 hash value of the sequence. ## The SHA-256 Algorithm The following pseudocode is taken from the [Wikipedia page for SHA-2](https://en.wikipedia.org/wiki/SHA-2#Pseudocode). ``` Note 1: All variables are 32 bit unsigned integers and addition is calculated mod...
[Question] [ # Task Given an input list of integers **x1…xn**, compute a list of ranks **r1…rn** (a permutation of **{1…n}**) so that **xr1 ≤ xr2 ≤ … ≤ xrn**. Then, for each **xi**, replace its rank by the arithmetic mean of the ranks of all values in **x** that are equal to **xi**. (That is, whenever there is a ti...
[Question] [ **[Liar's Dice](http://en.wikipedia.org/wiki/Liar%27s_dice)** is a fairly simple dice game. I've seen a few different variations of the rules, but here is the version I'm most familiar with: * Each player starts with 5d6 * Except when tallying the dice at the end of a round, each player may see their o...
[Question] [ # Background In Bejeweled and similar games, the player must swap any two adjacent gems (no diagonals) in an 8x8 grid of gems in order to match three of the same color in a row. The gems can be matched horizontally or vertically. Gameplay continues until there no move exists that can be made resulting ...
[Question] [ Imagine a two-dimensional array of boolean values, where the 0s represent squares of grass on a rectangular plot of land and the 1s represent fences. Write a function that accepts the 2D array as an input and determines whether you can travel from any one area of grass to any other area of grass, using...
[Question] [ Create a program that prints the MD5 sum of its source in the form: ``` MD5 sum of my source is: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ``` No cheating - you can't just read the source file and compute its sum. The program must not read any external information. Of course you can use a MD5 library available ...
[Question] [ Given a rod of length n inches and a list of prices that contains prices of all pieces of size smaller than n. Determine the maximum value obtainable by cutting up the rod and selling the pieces. For example, if length of the rod is 8 and the values of different pieces are given as following, then the ...