instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
I wrote this function in 48 bytes and I wonder, is there any way to write this code 2 characters shorter? p=lambda n,c:(n*c)[:n//2]+(n*c)[:n//2+n%2][::-1] The point of the function is to create a palindrome of length n by using all the characters from the string c. Example: n = 3, c = 'ab'. Result is 'aba'. Is there s...
stackexchange_codegolf
This is the robbers' thread of this challenge The cops will choose an OEIS sequence and write two full programs in two different languages that produces that nth item in the sequence when given an n via STDIN. The two programs must be anagrams of each other, meaning each can be rearranged from the other's letters. The...
stackexchange_codegolf
Given a string like [[[],[[]]],[]], made of only commas and square brackets, your challenge is to determine whether it represents a list. A list is either: [], the empty list At least one list, joined with commas and wrapped in square brackets. You may use any three characters instead of [,]. You may output as: Any ...
stackexchange_codegolf
The challenge is to write a program which will find the shortest (least number of characters) command which will navigate to a target directory, given a starting directory, assuming a standard linux file system. Take the following file system as an example, starting from ~: . ├── target └── test └── starting If th...
stackexchange_codegolf
Repost and improvement of this challenge from 2011 A vampire number is a positive integer \$v\$ with an even number of digits that can be split into 2 smaller integers \$x, y\$ consisting of the digits of \$v\$ such that \$v = xy\$. For example: $$1260 = 21 \times 60$$ so \$1260\$ is a vampire number. Note that the dig...
stackexchange_codegolf
Upside-Down Pyramid Addition is the process of taking a list of numbers and consecutively adding them together until you reach one number. When given the numbers 2, 1, 1 the following process occurs: 2 1 1 3 2 5 This ends in the number 5. YOUR TASK Given the right side of an Upside-Down Pyramid (Ascen...
stackexchange_codegolf
I call this sequence "the Jesus sequence", because it is the sum of mod.</pun> For this sequence, you take all the positive integers m less than the input n, and take the sum of n modulo each m. In other words: $$a_n = \sum_{m=1}^{n-1}{n\bmod m}$$ For example, take the term 14: 14 % 1 = 0 14 % 2 = 0 14 % 3 = 2 14 % 4 =...
stackexchange_codegolf
In this question, a game was devised in which players would face each other off pair by pair in the Prisoner's Dilemma, to determine which iterative strategy scored the highest against others. In this question, I devised a way for multiple people to play the Prisoners' Dilemma against each other all at the same time. I...
stackexchange_codegolf
Create a program that generates a drum fill. Your program will output a pattern of L (left hand hits), 'R' (right hand hits), and K for kick drum hits. Rules The pattern must never have more than 2 of the same hits consecutively. The pattern must be loopable, so it mustn't have more than 2 of the same hits when it lo...
stackexchange_codegolf
Task Write a program/function that when given 3 positive integers \$a, b\$ and \$m\$ as input outputs a positive integer \$x\$ such that \$a^x\equiv b\ (\text{mod}\ m)\$ or that no such \$x\$ exists. A reference implementation can be found here. Constraints You can expect \$a\$ and \$b\$ to be less than \$m\$. Scoring ...
stackexchange_codegolf
Back in the day, all the 1337 kids used text faders in chatrooms. I don't know about you guys, but I want to feel cool like they did. The only problem is that their old scripts and applications were heavily coupled to the software they were made for, so I can't just make use of this amazing functionality wherever I wan...
stackexchange_codegolf
Given a list of stack heights, calculate the number of ways those heights could have been arrived at by stacking blocks one at a time. Shortest code wins. Test cases: [2, 2] 6 [3,3,3] 1680 [1,5,9,1] 480480 [] 1 [10] 1 [2,2,2,10] 720720 Reference Python implementation: def stacking_count(stacks): if sum(stacks) ==...
stackexchange_codegolf
In graph theory, a Cactus is a connected graph such that any distinct two simple cycles in the graph share at most one vertex. Here is a Cactus with 3 simple cycles outlined with dashed lines. The following graph is similar to the one pictured above but is not a Cactus because the two vertices labeled in red are share...
stackexchange_codegolf
Your goal is to check whether a completed Minesweeper board is valid. This means that each number is a correct count of mines in cells adjacent to it, including diagonals. The board does not wrap around. As usual, you should give a function or program, and shortest code in bytes wins. See also past challenges to genera...
stackexchange_codegolf
This is a simple challenge: given n in any way practical (Function arg, stdin, file, constant in code) output the internal angles (NOT the sum of the internal angles, just one) of a regular polygon with n sides. The output can be in degrees, gradians or radians, and can be displayed in any way practical (Function retu...
stackexchange_codegolf
This is inspired by one of Downgoat's questions in Sandbox, where I suggested that he include April 31 as Pi day for people who use day/month format, only for him to inform me that there is no April 31! Given a date string in month/day format that might be invalid, output the correct date using rollover. (First rollove...
stackexchange_codegolf
In the US, clothing size sometimes has rough designations like M, L, XXL, etc. The US designation of the "men's jacket" category depends on the height of the person. So, in this challenge, you should implement this conversion, which is defined by the following table, taken from this site: US size Body height (cm) XXXS...
stackexchange_codegolf
What are your tips for code golfing using Clojure? The aim of this question is to collect a list of techniques that are specific to Clojure and can be used in general code-golfing problems.
stackexchange_codegolf
In elementary school, children learn about proper fractions, where the numerator is less than the denominator, and thus the value of the fraction is less than one. Later, they are taught about fractions where the value of the fraction is greater than one, and two different ways to express these fractions: mixed fractio...
stackexchange_codegolf
Information Create a diagonal line given its length (let’s call the variable, say, \$n\$ where \$n > 0\$) The diagonal line starts from the top left and goes to the bottom right. You must use the ASCII character \ for the line. The input number can be given from STDIN or if your program doesn’t support that, use a har...
stackexchange_codegolf
A standard, solved, 3×3×3 Rubik's Cube has 6 differently colored faces, where each face is a 3×3 grid of squares of one color. The white face is opposite the yellow, the red opposite orange, the blue opposite green, and when white points upward, red is to the left of blue: Imagine an ant sits on the center square of t...
stackexchange_codegolf
I have a hardware that has a 32-bit input register. The register has the following characteristics: The 32-bit register consists of eight 4-bit fields. Each 4-bit field holds a value in signed-magnitude; it can hold an integer between -7 and +7 inclusive, including -0 and +0 (signed zeroes). For example, the hexadeci...
stackexchange_codegolf
Given a non-empty list of integers, output every possible partitioning of the list where each partition is a non-empty sublist. So for the list [1, 2, 3, 4] the result is: [[1, 2, 3, 4]] [[1, 2, 3], [4]] [[1, 2], [3, 4]] [[1, 2], [3], [4]] [[1], [2, 3, 4]] [[1], [2, 3], [4]] [[1], [2], [3, 4]] [[1], [2], [3], [4]] The...
stackexchange_codegolf
Is it a good chord? Definition of a chord: We define a chord as three notes together. Definition of a note: We define a note as a number between 1 and 7, inclusive. As in music, we define 1 as do, 2 as re, 3 as fa, etc. However, the note names are not important. They will not be included in the question and likely not ...
stackexchange_codegolf
Cops' 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 input...
stackexchange_codegolf
Today you will be doing another palindrome challenge! So, your task today is to take a string, and determine the minimum amount of letters required to insert to turn it into a palindrome. For example, let's take the string fishes. In this, case the best way would be to add h if, so the result would be 3. fishe s h...
stackexchange_codegolf
Given a volume level V in the range 1-10. Your program should draw the following ASCII art. When V=1: \ | / When V=2: \ \ | | | / | / When V=3: \ \ | \ | | | | | / | | / | / And etc. Trailing spaces are allowed. This is a code-golf challenge so the shortest solution wins.
stackexchange_codegolf
Cops post A riffle shuffle is a way of shuffling cards where the deck is split into 2 roughly equal sections and the sections are riffled into each other in small groups. This is how to riffle shuffle a string: Split the string into equal sections. Reverse the string, and starting from the start of each string. Put ru...
stackexchange_codegolf
Brainfuck is an esoteric programming language that is Turing Complete, meaning you can't tell whether a given program will halt without running it. It's cell-based and has an infinite tape of cells, values containing an unsigned integer from 0 to 255, but if you give it arbitrary-size cells, just three is enough to mak...
stackexchange_codegolf
How to Given an integer n start with n ones (i.e. 4 -> 1 1 1 1). Then sum up the last n numbers, and repeat. For n = 4 this looks like this: Start with 1 1 1 1, sum up the last 4 numbers resulting in 1 1 1 1 4, then sum up the last 4 numbers resulting in 1 1 1 1 4 7, then sum up the last 4 numbers resulting in 1 1 1 ...
stackexchange_codegolf
You've gotten out of Earth's gravity well - good for you! However, you're feeling a bit uncomfortable in zero-gravity, and you want to replicate 1 \$g\$ of force in a centrifuge. Use the equation for force in a centrifuge: $$\text{RCF} = \frac{r_\text{m} \, \left(\frac{2 \pi N_\text{RPM}}{60}\right)^2}{g}$$ Where \$\t...
stackexchange_codegolf
Bowling Bowling is a game where, essentially, each player gets 10 turns to: Take 2 attempts at knocking down 10 pins arranged in a triangle. between turns the pins are reset from the 1st to the 2nd attempt the pins are left as-is The arrangement of the pins resembles the following scheme, with the pins numbered 0-9: ...
stackexchange_codegolf
The problem #6 of IMO 2009 reads: Let a 1, a 2, a 3, ..., a n, be distinct positive integers and let T be a set of n-1positive integers not containing a 1+a 2+a 3+...+a n, A grasshopper is to jump along the real axis, starting at the point 0 and making n jumps to the right with lengths a 1, a 2, a 3, ..., a n in so...
stackexchange_codegolf
Your task is to make a script with the shortest byte count, that reverses a word then replaces each letter with the next letter next in the alphabet. Examples: input: hi output: ji input: hello output: pmmfi input: test output: utfu A few notes: Should the letter's value be 27 (z+1), assume it is an a. Symbols, num...
stackexchange_codegolf
Your pyramid The pyramid I want you to build is made entirely of cubes. It has 24 layers, and the Nth layer from the top contains N2 cubes arranged in an N by N square. The pyramid looks like this: To build the pyramid, you will need a supply of cubes. You are given 4900 cubes arranged in a 70 by 70 square that looks ...
stackexchange_codegolf
In the video game Minecraft, the player can obtain experience points (XP) from various activities. In the game, these are provided as XP "orbs" of various sizes, each of which give the player various amounts of XP. The possible orbs are shown in the image below, along with the smallest and largest amount of XP that orb...
stackexchange_codegolf
Write a program, that sends its own source code over network. Network example is TCP/UDP or web socket. Ethernet, Bluetooth, Wi-Fi and internet over USB are allowed. No need to write receiver program. You can use any encoding protocol, but decoder will be realizable. Rules Network is not a stdout, screen, USB, UART, G...
stackexchange_codegolf
Let's parse and process Key-Language! Given the input of a sequence of keyboard keypresses and/or special keys, write a program, function, etc. that outputs the product when all the actions are processed based on the following keyboard: +-------------------------------------------------------+ | ~ | ! | @ | # | $ | % |...
stackexchange_codegolf
Your task is to write a program that takes an input image and run it through edge-detection to become an output image. The edge-detection works as follows (if unclear, see sobel edge detection): The value for a pixel is the total brightness of a pixel, so if it is in color, you will need to convert it to grayscale fir...
stackexchange_codegolf
Using the fewest Unicode characters, write a function that accepts three parameters: Total number of dominoes nth affected domino Topple direction of the affected domino (0 or L for left, 1 or R for right) Once a domino is toppled, it must also topple the remaining dominoes in the same direction. You should output th...
stackexchange_codegolf
Last time you made a square of text, but now, can you make a cube of text? The Challenge Given a string, output the string in the form of a cube. You can assume the string will always have 2 chars or more, and will only have printable ascii characters. How to Make a Text Cube Test Cases Input: Test Output: Test ...
stackexchange_codegolf
Given the equation of a non-parabolic conic section, output its characteristics. Spec Some info on conic sections: for more info visit Wikipedia From an equation of the form \$ax^2+bx+cy^2+dy+E=0\$, it is possible to derive the type of conic section using a combination of square completion and simple arithmetic. For t...
stackexchange_codegolf
Today's challenge is simple: Without taking any input, output any valid sudoku board. In case you are unfamiliar with sudoku, Wikipedia describes what a valid board should look like: The objective is to fill a 9×9 grid with digits so that each column, each row, and each of the nine 3×3 subgrids that compose the grid (...
stackexchange_codegolf
Introduction: A Dutch BSN (BurgerServiceNummer) is valid when it complies to the following rules: It only contains digits. The length should be either 8 or 9 in length. When the digits are indexed as A through I, the result of the following sum: 9xA + 8xB + 7xC + 6xD + 5xE + 4xF + 3xG + 2xH + -1xI (NOTE the -1 instead...
stackexchange_codegolf
Create a program that generates a drum fill. Your program will output a pattern of L (left hand hits), 'R' (right hand hits), and K for kick drum hits. Rules The pattern must never have more than 2 of the same hits consecutively. The pattern must be loopable, so it mustn't have more than 2 of the same hits when it lo...
stackexchange_codegolf
An aesthetically pleasing divisor tree is a tree of divisors of input n that, for any composite number m, has two children nodes that are the pair of divisors that are closest to the square root of m. The left node should be the smaller divisor of m and the right node should be the larger divisor of m. A prime number i...
stackexchange_codegolf
Recently there have been a couple of ASCII pet snake challenges (e.g. here) 0 0 0 0 0 000 00 0 00 000 0 0 000 0 0 0 00 0 000 This challenge is to take a randomly generated horizontal pet snake (height of five line...
stackexchange_codegolf
The recent volume of MAA's Mathematics Magazine had an article "Connecting the Dots: Maximal Polygons on a Square Grid" by Sam Chow, Ayla Gafni, and Paul Gafni about making (very convex) \$n^2\$-gons where each vertex is a different point of the \$n \times n\$ grid. One is not allowed to have two consecutive segments ...
stackexchange_codegolf
Challenge: Read input (within visible ASCII range) and output with a few modifications: In each set of 10 characters of the input randomly (50/50): replace one character* (with a random** one within visible ASCII range) (ex. lumberjack becomes lumbeZjack) or remove one character (ex. lumberjack becomes lmberjack) ...
stackexchange_codegolf
Display the 12 numbers on a clock face exactly like this: 12 11 1 10 2 9 3 8 4 7 5 6 To better see the grid, here's one with dots: ...........12............ ....
stackexchange_codegolf
This question is tricky (and in particular harder than Which big number is bigger?), for those who like more challenging puzzles. Input Integers a1, a2, a3, a4, a5, b1, b2, b3, b4, b5 each in the range 1 to 10. Output True if a1^(a2^(a3^(a4^a5))) > b1^(b2^(b3^(b4^b5))) and False otherwise. ^ is exponentiation in this...
stackexchange_codegolf
hgl has a "scan" function called sc. What it does in general is a little bit abstract, so we will just talk about one specific way you can use it. If we want to take a list of integers and get the partial sums of every prefix we can scan with + for sums and 0 as a starting value: ghci> sc (+) 0 [1,2,3,4,5,6] [1,3,6,10...
stackexchange_codegolf
Write a program/method that: Becomes a quine when the input matches the source code; Doesn't halt otherwise. This is code-golf, so shortest solution wins. Avoid any standard loopholes.
stackexchange_codegolf
Did you know that Heronian Tetrahedra Are Lattice Tetrahedra? A Heronian tetrahedron is a tetrahedron where the length of each edge is an integer, the area of each face is an integer, and the volume of the tetrahedron is an integer. It's always possible to place such a tetrahedron in space such that all of the vertic...
stackexchange_codegolf
Challenge Given a SE user's ID, output the sum of their reputation from across all of the Stack Exchange networks​ the user has signed up to. Rules If a user has 101 or less reputation on a site, count it as zero in the sum. You should not count Area 51 rep or hidden communities!! URL shorteners are disallowed. Example...
stackexchange_codegolf
This is a somewhat proof-golf-like cops-and-robbers challenge. This is the robbers' thread; the cops' thread is here. Robbers The cops will post abstract rewriting systems. Your task is to crack their submissions by proving that the target string either can or can not be reached from the source string by applying their...
stackexchange_codegolf
Common words should still be avoided to be used as passwords. This challenge is about coding a very simple program that munges a given password (Modify Until Not Guessed Easily). Input A word, which is a string written in the alphabet abcdefghijklmnopqrstuvwxyz. It does not matter if the letters are lowercase or upper...
stackexchange_codegolf
Looking at Arnauld's answer, it seems like this version is not really more difficult than the other version, so I made it an optional requirement of the other challenge The absolute value of a number \$x\$ is normally written as \$|x|\$. The left and right side of the absolute value uses the same symbol, so it is not i...
stackexchange_codegolf
Task: Given an array of numbers as input (you can choose what subset, such as integers or natural numbers), replace all items with the number of times they appear within the array. As an example, [1, 2, 2, 1, 4, 8, 1] would become [3, 2, 2, 3, 1, 1, 3]. You can take input/produce output as arrays, lists, tuples, or any...
stackexchange_codegolf
Your program must accept as input six numbers, which describe a triangle - for example, the inputs 80, 23, 45, 1, 76, -2 describe a triangle with vertices (80, 23), (45, 1), and (76, -2). The input must be given as six plain real numbers or as a list of six real numbers, in the order given in the example. Your task is ...
stackexchange_codegolf
Your friend Jack is a picky eater. He only likes certain foods, and he only likes to eat a certain amount of them each day. Despite this, Jack has very strict calorie and macronutrient goals that he strives to meet with his diet. To complicate things further, Jack's cravings change day by day, and he will only eat the ...
stackexchange_codegolf
Background We've had challenges before on Fibonacci coding and Zeckendorf representation. These representations follow naturally from Zeckendorf's theorem, which states that every positive integer can be represented uniquely as the sum of one or more distinct, non-consecutive Fibonacci numbers. For example: $$ \begin...
stackexchange_codegolf
The goal of this challenge is to take a positive integer n and output (in lexicographic order) all sequences \$S = [a_1, a_2, ..., a_t]\$ of distinct positive integers such that \$\max(S) = n\$. For example, for an input n = 3 your program should output the following eleven sequences in the following order: [ [1, 2, ...
stackexchange_codegolf
Task A pure mirror checkmate is a checkmate position, where the mated king is surrounded by 8 empty squares which are attacked or guarded by the winning side exactly once. You will be given a valid chess position where Black is in mate. Your task is to find if that mate is a pure mirror checkmate. Examples (click for l...
stackexchange_codegolf
Your task Given a integer input, \$ n \$ (such that \$ n > 1 \$), decide whether it can be written as the sum of (at least 2) consecutive square numbers. Test cases Truthy: Input Explanation 5 1 + 4 13 4 + 9 14 1 + 4 + 9 25 9 + 16 29 4 + 9 + 16 30 1 + 4 + 9 + 16 41 16 + 25 50 9 + 16 + ...
stackexchange_codegolf
Given a sequence of three integers, determine if the sequence is arithmetic (of the form [a, a+d, a+2*d]) or geometric (of the form [a, a*r, a*r^2]) by outputting a fourth term that completes it (a+3*d for arithmetic, a*r^3 for geometric). Examples: [1, 2, 3] -> 4 (This is an arithmetic sequence with a difference of 1)...
stackexchange_codegolf
Your challenge is very simple: output the previous answer, in reverse. However, as with this similarly-titled question, there's a catch: in this case, you cannot use characters from the answer before the last. For example: Let's say the first answer looks like this: 1 - Python print('hi!') And the second answer looks...
stackexchange_codegolf
Minecraft has a fairly unique lighting system. Each block's light value is either one less than the brightest one surrounding it, or it is a light source itself. Your task is to write a method that takes in a 2D array of light source values, and then returns a 2D array with spread out lighting, where 0 is the minimum v...
stackexchange_codegolf
Challenge Write code that outputs TeX (LaTeX) math-equation code (given below) that will typeset Sierpinski Triangle Fractal of 5 levels. Shortest code wins. Details TeX (and friends like LaTeX, etc.) is a sophisticated typesetting system. It can render arbitrary nested complex expressions for mathematical formulas. Co...
stackexchange_codegolf
Given a string of brackets tell the user whether or not the brackets are well matched or not. Brackets include []{}(). For example: () <---- Well Matched ([{}][]) <---- Well Matched ({)} <---- Not Well Matched ({]) <----- Not Well Matched This is a code-golf challenge so as always the shortest solution wins.
stackexchange_codegolf
This question was inspired this question and @orlp's comment and a lot of the explanation was copied from there. Write a GOLF assembly program that given two arbitrary size decimal integers a, and b from stdin outputs two decimal integers to stdout, Q and R such that b * Q + R = a. In other words write divmod with arb...
stackexchange_codegolf
The goal of this challenge is to fill a niche that is mostly lacking on this site. In my observations there most parsing verification challenges fall into two categories: Super easy parsing. This parsing can usually be done with a regex, and regex based answers usually do well. Super complex parsing. These are cha...
stackexchange_codegolf
Part 1 of the challenge revolved around converting the letters into specific unicode characters. Lore In this part we receive the output from the function made in Part 1, which now has to be arranged in an artistic manner. Aim Take 1 word as input which has already undergone transformation in the function made in Part ...
stackexchange_codegolf
This challenge is in honor of the tacky Christmas lights at my in laws' house. The challenge is to create a graphical output showing the decoration in "real time". The video (gif or other format) will have n-by-m vertical and horizontal "lights". 5 <= m,n <= 40. The frame size and resolution may vary dependent on n a...
stackexchange_codegolf
Introduction: The best options for the glass of your house will: 1. Let through as little heat as possible in both directions (insulation-value Ug). (2. Let through as much sunbeams as possible from the outside to the inside.) (3. Let through as much light as possible from the outside to the inside.) We only care about...
stackexchange_codegolf
Inspired by vi.sualize.us Goal The input is a grayscale image and the output is a black and white image. The output image consists of just one closed curve (loop) that is not allowed to intersect with itself or touch itself. The width of the line shall be constant throughout the whole image. The challenge here is findi...
stackexchange_codegolf
In: Enough memory and a positive integer N Out: N-dimensional N^N array filled with N, where N^N means N terms of N-by-N-by-N-by... Examples: 1: [1] which is a 1D array (a list) of length 1, containing a single 1 2: [[2,2],[2,2]] which is a 2D array (a table) with 2 rows and 2 columns, filled with 2s 3: [[[3,3,3],[3,3,...
stackexchange_codegolf
Background The systematic chemical symbol is defined as such for \$ 118 < n < 1000 \$: The first letter corresponds to the first digit, capitalized. The second letter corresponds to the second digit. The third letter corresponds to the third digit. This can be generalized for all \$ n > 0\$: For each digit, get the ...
stackexchange_codegolf
In this challenge you will receive as input a list of binary lists. The list represents a game board with each element representing a location on the board. The list at each location represents the tiles on the board, with a 0 being a white tile (□) and a 1 being a black tile (■). Each place can have any number of t...
stackexchange_codegolf
You may be aware of the famous old rhyme, "I before E, except after C". It is a rule taught to aid in the spelling of certain English words. Quoting Wikipedia: If one is not sure whether a word is spelled with the digraph ei or ie, the rhyme suggests that the correct order is ie unless the preceding letter is c, in wh...
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
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
Input Integers a1, a2, a3, b1, b2, b3 each in the range 1 to 20. Output True if a1^(a2^a3) > b1^(b2^b3) and False otherwise. ^ is exponentiation in this question. Rules This is code-golf. Your code must terminate correctly within 10 seconds for any valid input on a standard desktop PC. You can output anything Truthy ...
stackexchange_codegolf
Your task is simple: output the letter x a random number of times. Every possible length of xs must have a non-zero probability of being output. Of course, there must be some lengths whose probabilities tend to \$ 0 \$, in order for the total probabilities to sum to \$ 1 \$, but all must still be theoretically possible...
stackexchange_codegolf
What is the Fibonacci Rectangular Prism Sequence? The Fibonacci Rectangular Prism Sequence is a sequence derived from the Fibonacci sequence starting with one. The first 3 numbers of the Fibonacci sequence (starting with one) are 1, 1, and 2, so the first number of the Fibonacci Rectangular Prism Sequence is the square...
stackexchange_codegolf
Othello/Reversi is a board game in which players take turn placing pieces of a color (dark or light) on the 8x8 board. The possible moves are positions where there are one or more pieces of the opponent's color in a straight (horizontal, vertical, or diagonal) line between that position and a piece of the player's colo...
stackexchange_codegolf
Yesterday I asked this question about riffle shuffles. It seems that yesterdays question was a bit too hard so this question is a related but much easier task. Today you are asked to determine if a permutation is in fact a riffle shuffle. Our definition of riffle shuffle is adapted from our last question: The first ...
stackexchange_codegolf
Input The name of a file in the raster graphics format of your choice. The chosen format must support at least 8 bits per channel and 3 channels. Output A file in the same format, with the same dimensions and pixels as the first, but whose pixels are grouped in descending order of the number of times they occur, sorted...
stackexchange_codegolf
Task Given an image with a line on it, produce or display an image with the line extended till the edge of image. The line is black and the background is white. The image size is 100x100 The image comes in any reasonable format (e.g. jpg, png, ppm, bmp). Line format I'm using a simplified version of Bresenham's line al...
stackexchange_codegolf
Say I have an expression: 9 * 8 + 1 - 4 This expression can be interpreted in six different ways, depending on operator precedence: (((9 * 8) + 1) - 4) = 69 (* + -) ((9 * 8) + (1 - 4)) = 69 (* - +) ((9 * (8 + 1)) - 4) = 77 (+ * -) (9 * ((8 + 1) - 4)) = 45 (+ - *) ((9 * 8) + (1 - 4)) = 69 (- * +) (9 * (8 + (1 - 4))) = ...
stackexchange_codegolf
\$\newcommand{T}[1]{\text{Ta}(#1)} \newcommand{Ta}[3]{\text{Ta}_{#2}^{#3}(#1)} \T n\$ is a function which returns the smallest positive integer which can be expressed as the sum of 2 positive integer cubes in \$n\$ different ways. For example, \$\T 1 = 2 = 1^3 + 1^3\$ and \$\T 2 = 1729 = 1^3 + 12^3 = 9^3 + 10^3\$ (the ...
stackexchange_codegolf
Doorknobs are great and all, but when you open a door, it always dents the walls around it. I need you to take input of ASCII art of a room, like this: +---------+--X --X --+-----+ | \ \ |\ | \ | | \ \ | \ | \| | X | \ | X | / | | \ X | ...
stackexchange_codegolf
Fastest code is a scoring method on this site where the goal is to write code that is as fast as possible. From the tag wiki: The winner of a fastest-code challenge is determined by the runtime performance of the submissions. For fairness, all submissions should be benchmarked on the same machine, which usually means ...
stackexchange_codegolf
Part of Advent of Code Golf 2021 event. See the linked meta post for details. The story continues from AoC2018 Day 3. But you're not Bubbler, you're Lyxal! yeah, I know. After a long period of chaos, the Elves have finally agreed on how to cut the fabric. Unfortunately, the next day they have come up with how to utili...
stackexchange_codegolf
Description While support is getting better and better for people to write in various scripts around the world using unicode, and now you can even write in emojis as well, unfortunately most fonts[citation needed] are still missing Latin characters based on the double acute accent, which is required to write properly i...
stackexchange_codegolf
Background of Lucas Numbers The French mathematician, Edouard Lucas (1842-1891), who gave the name to the Fibonacci Numbers, found a similar series occurs often when he was investigating Fibonacci number patterns. The Fibonacci rule of adding the latest two to get the next is kept, but here we start from 2 and 1 (in th...
stackexchange_codegolf
There has recently been a big snow, and my driveway needs snow-blowing. If the snow-blower goes over some area that it has already snow-blowed, then that area will have snow blown onto it and need to be blown again. And of course, the snow-blower cannot start in the middle of the driveway, it needs to start from my gar...
stackexchange_codegolf
This is a code-golf question. Given integers s and n the task is to output all arrays of length n which take values from -s to s. The only twist is that you must output them in the following order. The all zeros array of length n. All arrays of length n with elements from -1 to 1 excluding any array you have outputt...
stackexchange_codegolf
There is a building with an infinite number of floors and you are the only passenger in an elevator which can lift an infinite number of people. You are going home, but before the elevator gets to your floor, the elevator stops at another floor to allow people to enter the elevator and input their destination floors. Y...
stackexchange_codegolf
This should be easy: given an arbitrary string, your program will give it a name. Requirements Your program will accept an input of a UTF8 string, and output a string representing the input's "name", how you define this name is arbitrary, but it must comply with some conditions. I/O Ranges The input will at most be 382...
stackexchange_codegolf