instruction_seed
stringlengths
292
48.7k
found_ngrams
listlengths
0
21
For a computer vision app I want to do a mapping of an image, in such a way that every pixel fit hilbert curve, instead of conventional layout. So task could be as follows: Task description Given square 2D image A with side 2^^N, (N>0), with common Z-order, or row-major representation of pixels in RAM. I need to run ...
[]
Background OEIS sequence A272573 describes a spiral on a hexagonal grid as follows: Start a spiral of numbers on a hexagonal tiling, with the initial hexagon as a(1) = 1. a(n) is the smallest positive integer not equal to or previously adjacent to its neighbors. The sequence begins 1, 2, 3, 4, 5, 6, 7, 4, 6, 8, 5, 9,...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ] ]
The Korean language has two sets of numerals, a native Korean numerals and Sino-Korean numerals. The native Korean numerals are mostly used for numbers under 100, such as age and time. The Sino-Korean numeral system, which is based on the Chinese numeral system as its name says, is used in most of the time. It uses 4-d...
[]
Given a list of floating point numbers, standardize it. Details A list \$x_1,x_2,\ldots,x_n\$ is standardized if the mean of all values is 0, and the standard deviation is 1. One way to compute this is by first computing the mean \$\mu\$ and the standard deviation \$\sigma\$ as $$ \mu = \frac1n\sum_{i=1}^n x_i \qquad ...
[]
Imagine we have some polyomino and would like to uniquely identify them, however the polyominos can be rotated, so blindly hashing them won't give us the same fingerprint for a piece and a rotation thereof (in general). For example if we have the L-tetromino x x xx we would like it to have the same fingerprint as any ...
[]
If 1 is not counted as a factor, then 40 has two neighboring factors (4 and 5) 1092 has two neighboring factors (13 and 14) 350 does not have two neighboring factors (out of its factors 2, 5, 7, 10, 14, 25, 35, 50, 70, and 175, no two are consecutive) The proportion of positive integers that have this property is the...
[]
Tournament over! The tournament is now over! The final simulation was run during the night, a total of \$3*10^8\$ games. The winner is Christian Sievers with his bot OptFor2X. Christian Sievers also managed to secure the second place with Rebel. Congratulations! Below you can see the official high score list for the to...
[]
Input A binary matrix \$M\$ representing the walls of a dungeon. The position \$(x,y)\$ of the player within the dungeon. The direction \$d\$ that the player is currently facing (0 = North, 1 = East, 2 = South, 3 = West) Output A pseudo-3D representation of the walls that are in the field of view of the player, as an...
[]
This is a "counterpart" of another puzzle, Eight coins for the fair king on Puzzling.SE. You can read the above puzzle for the background. The details about this puzzle are as follows. A set of 8 kinds of coins of different values are created, the king wants you to find out the maximum N such that any number of price f...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ] ]
Let's define the a function on natural numbers \$n\$, written as base 10 digits \$d_k\; d_{k-1}\; \dotsc\; d_1\; d_0\$, as follows: As long as there are equal adjacent digits \$d_i\;d_{i-1}\$, replace them by their sum \$d_i+d_{i-1}\$ from left to right. If there were any such digits, repeat the same procedure. In othe...
[]
Your task is to determine the length of the longest descent down a "mountain" represented as a grid of integer heights. A "descent" is any path from a starting cell to orthogonally adjacent cells with strictly decreasing heights (i.e. not diagonal and not to the same height). For instance, you can move from 5-4-3-1 but...
[]
TL;DR for those not interested: Look at the test cases at the bottom. Have a program/function that outputs the 2D list displayed for the given input. Introduction: On November 15th, 2018 puzzle designer Raphaël Mouflin revealed his Triangularity puzzle. Here is a picture of that puzzle: As you can see, the shape is a ...
[]
Given a list of strictly positive integers, go through each distinct number and replace all occurrences of it with successive indices (zero or one based) of a new series. Examples [] → []/[] [42] → [0]/[1] [7,7,7] → [0,1,2]/[1,2,3] [10,20,30] → [0,0,0]/[1,1,1] [5,12,10,12,12,10] → [0,0,0,1,2,1]/[1,1,1,2,3,2] [2,7,1,8,2...
[]
Input: An integer n Two equal-sized square matrices (with their width/height being a multiple of n) Output: One of two distinct values of your own choice, one being for truthy results and one for falsey results (so yes, 1/0 instead of true/false are valid outputs for languages like Java, even though they're not consi...
[]
Given a binary 3D array, for each layer, cyclically rotate up each of its columns as many steps as indicated by the binary encoding of the columns of the layer above it, and then cyclically rotate left each of its rows as many steps as indicated by the binary encoding of the rows of the layer below it. There will alway...
[]
This challenge is based on the following puzzle: You are given an n by n grid with n cells marked. Your job is to the partition the grid into n parts where each part consists of exactly n cells, each containing exactly one marked cell. Example Here is a puzzle on the left and its (unique) solution on the right: Chall...
[]
Introduction Inspired by the very recent video The Trapped Knight - Numberphile, I came up with a challenge. The trapped knight sequence is a finite integer sequence of length 2016, starting from 1, and has the following construction rules: Write a number spiral in the following manner: 17 16 15 14 13 ... 18 5 4 3...
[ [ 11, 220, 16, 17, 11, 220, 16, 19, 11, 220, 16, 21, 11 ], [ 220, 16, 17, 11, 220, 16, 19, 11, 220, 16, 21, 11, 220 ] ]
A flow network is a directed graph G = (V, E) with a source vertex s ϵ V and a sink vertex t ϵ V, and where every edge (u, v) ϵ E on the graph (connecting nodes u ϵ V and v ϵ V) has 2 quantities associated with it: c(u, v) >= 0, the capacity of the edge a(u, v) >= 0, the cost of sending one unit through the edge We d...
[]
Your task, if you wish to accept it, is to write a program that outputs its own source code in the binary UTF-8 representation. Rules The source must be at least 1 byte long. Your program must not take input (or have an unused, empty input). The output may be in any convient format. Optional trailing newline is allow...
[]
You've probably heard of Fibonacci numbers. Ya know, that integer sequence that starts with 1, 1, and then each new number is the sum of the last two? 1 1 2 3 5 8 13... And so on. Challenges about Fibonacci numbers are pretty popular 'round here. But who says that the Fibonacci numbers have to start with 1, 1? Why cou...
[]
Single moves The board is an infinite 2 dimensional square grid, like a limitless chess board. A piece with value N (an N-mover) can move to any square that is a distance of exactly the square root of N from its current square (Euclidean distance measured centre to centre). For example: A 1-mover can move to any squar...
[]
Here's the challenge. Write some code to output all the integers in a range. Sounds easy, but here's the tricky part. It will start with the lowest number, then the highest. Then the lowest number which isn't yet in the array. Then the highest which isn't yet in it. Example: Lets take 1 to 5 as our start The numbers ...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ] ]
I recently decided to download some dictation software, in order to help with my writing. However, it doesn't work very well when I'm coding, since I have to change from saying words to symbols and back again. It's even worse when I'm coding in an esoteric language which is all symbols. In order to make my use of the d...
[]
Sorting makes no sense for a 2-dimensional array... or does it? Your task is to take an input grid and apply a bubble-sort-like algorithm to it until all values in the grid are non-decreasing from left to right and top to bottom along every row and column. The algorithm works as follows: Each pass goes row by row, top...
[]
Challenge Input: An integer \$b\$ between 2 and 62 (inclusive). Output: Count from \$1\$ to the equivalent of \$5000_{10}\$ in base \$b\$, using any reasonable representation for the digits. However: If the number is divisible by \$\lfloor b÷2+1\rfloor\$ (rounded down, e.g base 7 would be 7/2=3.5, 3.5+1=4.5, rounded t...
[ [ 425, 11, 356, 11, 422, 11, 468, 11, 434, 11, 479, 11, 472 ], [ 11, 422, 11, 468, 11, 434, 11, 479, 11, 472, 11, 358, 11 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, ...
Given a decimal number k, find the smallest integer n such that the square root of n is within k of an integer. However, the distance should be nonzero - n cannot be a perfect square. Given k, a decimal number or a fraction (whichever is easier for you), such that 0 < k < 1, output the smallest positive integer n such ...
[]
A jumping number is defined as a positive number n which all pairs of consecutive decimal digits differ by 1. Also, all single digit numbers are considered jumping numbers. eg. 3, 45676, 212 are jumping numbers but 414 and 13 are not. The difference between 9 and 0 is not considered as 1 The challenge Create a program ...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ] ]
So I ran into this progressive/idle game cleverly called Idle Dice. Has a variety of random effects applied to a pretty typical progression formula game. Warning, time sink! Play at your own risk. However after you have 5 dice (summed the usual way) along with some bonuses for various matches (pair, two pair, three of ...
[]
Given a truth table and two images, use the truth table as a bitwise operation to the two images. For example with the truth table: 1 0 1 0 0 0 1 0 (Note that the top is the first image and the left is the second) and the two images (0, 2, 4) (a 1x1 image, with the numbers being RGB values) and (30, 20, 10): You wou...
[]
Background For this challenge, a 'metasequence' will be defined as a sequence of numbers where not only the numbers themselves will increase, but also the increment, and the increment will increase by an increasing value, etc. For instance, the tier 3 metasequence would start as: 1 2 4 8 15 26 42 64 93 130 176 because:...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ], [ 220, 16, 11, 220, 17, 11, 220, 18, 11, 220...
In association football (also known as soccer), a penalty shoot-out is the second tie-breaker measure that may be used in a match which can't end in a tie, after extra time (i.e. association football overtime). In a penalty shoot-out, the main referee tosses a coin to determine at which goal the shoot-out happens, and ...
[]
Challenge This challenge will have you write a program that takes in two integers n and m and outputs the number non-intersecting loops on the n by m torus made by starting at (0,0) and only taking steps up and to the right. You can think of torus as the grid with wraparound both at the top and the bottom and on the si...
[]
Challenge: Input: A list of distinct positive integers within the range \$[1, \text{list-size}]\$. Output: An integer: the amount of times the list is riffle-shuffled. For a list, this means the list is split in two halves, and these halves are interleaved (i.e. riffle-shuffling the list [1,2,3,4,5,6,7,8,9,10] once wou...
[]
Rectangles have this nice property - an \$n \times m\$ rectangle consists of exactly \$n \times m\$ characters! A.. more interesting property is that the rectangles can be aligned nicely in a multiplication table - for example, a \$3 \times 3\$ table: # ## ### # ## ### # ## ### # ## ### # ## ### # ## ### Your challe...
[]
In Pascal's triangle each number is the sum of the two numbers directly above it, treating empty spots as zero: By rotating the triangle, we can cut out square matrices of varying sizes and rotations which I will call Pascal's matrices. Note that those matrices always need to contain the top \$1\$. Here are some examp...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ] ]
You will be given an ASCII text. This text may have zero, one or many appearances of a split a character (let's assume it will be the space character ) You will also be given an offset integer value (zero based) anywhere between zero and the length of the text. You should calculate the relative offset inside the one sp...
[]
Hehe, see what I did with the title? Anyways... Your job is to create a sudoku solver that accepts input in Morse code and creates output in Morse code. Here's the Morse code numbers for reference: 0: ----- 1: .---- 2: ..--- 3: ...-- 4: ....- 5: ..... 6: -.... 7: --... 8: ---.. 9: ----. Rules: The code must...
[]
Challenge: Input: A positive integer \$n\$ Output: Create a list in the range \$[1,n]\$, and join it together to a string (i.e. \$n=13\$ would be the string 12345678910111213). Now we output a triangle using the prefixes or suffixes of this string, in one of the following four orientations based on the input integer: ...
[]
Given a list of jobs, which must be done in order, with each taking a slot to do, how long will it take to perform them all if after doing a job the same job cannot be done for the next two slots (cooling off slots)? However, a different job can be assigned in this cooling off slots. For example, [9,10,9,8] => output: ...
[]
Challenge: Your program will take two integers n and k as input, and output the smallest integer greater than (but not equal to) n that contains at least k occurrences of the digit 5. You can assume 1 ≤ k ≤ 15 and 1 ≤ n < 10**15. This is a restricted-time challenge. Your program must run on TIO for all of the test cas...
[]
Inspired by this SO question. Challenge: Input: A string \$s\$ A character \$c\$ Output: Create a diamond-square ASCII art of the string in all four directions, with the first character of the string in the center and going outwards. Which is inside a square ASCII-art carpet, with the character as filler. This may so...
[]
The sorting algorithm goes like this: While the list is not sorted, snap half of all items (remove them from the list). Continue until the list is sorted or only one item remains (which is sorted by default). This sorting algorithm may give different results based on implementation. The item removal procedure is up to ...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ] ]
Introduction: I saw there was only one other badminton related challenge right now. Since I play badminton myself (for the past 13 years now), I figured I'd add some badminton-related challenges. Here the first one: Challenge: Input: Two integers Output: One of three distinct and unique outputs of your own choice. One ...
[]
Introduction (may be ignored) Putting all positive numbers in its regular order (1, 2, 3, ...) is a bit boring, isn't it? So here is a series of challenges around permutations (reshuffelings) of all positive numbers. This is the third challenge in this series (links to the first and second challenges). In this challen...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ], [ 220, 16, 11, 220, 17, 11, 220, 18, 11, 220...
Take a positive integer \$k\$ as input. Start with \$n := 1\$ and repeatedly increase \$n\$ by the largest integer power of ten \$i\$ such that \$i \le n\$ and \$i + n \le k\$. Repeat until \$n = k\$ and return a list of all intermediate values of \$n\$, including both the initial \$1\$ and the final \$k\$. During this...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ] ]
I recently had a problem to solve at work where I had two lists: a master list, and a smaller list that contains a subset of the items in the master list potentially in a different order. I needed to reorder the master list in such a way that the items in the subset would appear in the same order without changing the o...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ] ]
Given a date as input in any convenient format, output a calendar with that date as the exact center of a five-week window. The header of the calendar must include the two-letter abbreviations for the days of the week (i.e., Su Mo Tu We Th Fr Sa). Three-letter or other abbreviations of the days are not allowed. For exa...
[]
The Arecibo message is a 1974 interstellar radio message carrying basic information about humanity and Earth sent to globular star cluster M13 in the hope that extraterrestrial intelligence might receive and decipher it... The message consisted of 1,679 binary digits, approximately 210 bytes... The number 1,679 was ch...
[]
Problem You're stuck in a cabin in the middle of the woods, with only an old scrabble set to entertain yourselves. Upon inspection you see that the scrabble letters are so worn, that only the points for each letter are visible. Nonetheless you decide to play a game. You pull seven letters from the bag and place them o...
[]
The Idea We've done matrix spirals before, and full rotations, and even diagonal rotations, but not, as far as I can find, snake rotations! What is a snake rotation? Imagine the rows of a matrix snaking back and forth, with dividers between them like the dividers of long queue: +--------------+ 1 2 3 4 5|...
[]
Introduction: A 3x3x3 Rubik's Cube has \$43,252,003,274,489,856,000\$ possible permutations, which is approximately 43 quintillion. You may have heard about this number before, but how is it actually calculated? A 3x3x3 Rubik's Cube has six sides, each with nine stickers. Looking at the (external) pieces instead of sti...
[]
Introduction (may be ignored) Putting all positive integers in its regular order (1, 2, 3, ...) is a bit boring, isn't it? So here is a series of challenges around permutations (reshuffelings) of all positive integers. This is the sixth challenge in this series (links to the first, second, third, fourth and fifth chall...
[]
The challenge is simply; output the following six 2D integer arrays: [[ 1, 11, 21, 31, 41, 51], [ 3, 13, 23, 33, 43, 53], [ 5, 15, 25, 35, 45, 55], [ 7, 17, 27, 37, 47, 57], [ 9, 19, 29, 39, 49, 59]] [[ 2, 11, 22, 31, 42, 51], [ 3, 14, 23, 34, 43, 54], [ 6, 15, 26, 35, 46, 55], [ 7, 18, 27, 38, 47, 58], [10, 1...
[]
What is a Prime Square? A Prime Square is a square where all four edges are different prime numbers. But which ones? And how do we construct them? Here is an example of a 4x4 Prime Square 1009 0 0 3 0 1021 First we start from the upper left corner. We are working clockwise. We pick the smallest prime number having 4...
[]
Some divisors of positive integers really hate each other and they don't like to share one or more common digits. Those integers are called Hostile Divisor Numbers (HDN) Examples Number 9566 has 4 divisors: 1, 2, 4783 and 9566 (as you can see, no two of them share the same digit). Thus, 9566 is a Hostile Divisor...
[]
The dihedral group \$D_4\$ is the symmetry group of the square, that is the moves that transform a square to itself via rotations and reflections. It consists of 8 elements: rotations by 0, 90, 180, and 270 degrees, and reflections across the horizontal, vertical, and two diagonal axes. The images are all from this lo...
[]
I'm a big fan of number theory. A big thing in number theory is modular arithmetic; the definition being \$a\equiv b\mod m\$ if and only if \$m\mid a-b\$. A fun thing to do is raising to powers: especially when the modulus is a prime number. In particular, it has been proven that if \$a\$ and \$m\$ are relatively prime...
[]
Introduction In number theory, we say a number is \$k\$-smooth when its prime factors are all at most \$k\$. For example, 2940 is 7-smooth because \$2940=2^2\cdot3\cdot5\cdot7^2\$. Here, we define a \$k\$-smooth pair as two consecutive integers which both are \$k\$-smooth. An example of 7-smooth pair will be \$(4374,43...
[]
Background Ada is a programming language that is not exactly known for its terseness. However, its array literal syntax can in theory allow for fairly terse array specifications. Here is a simple EBNF description of the array literal syntax (passable to bottlecaps.de: array ::= positional_array | named_array positional...
[]
According to http://en.cppreference.com/w/cpp/language/integer_literal, integer literals consist of a decimal/hex/octal/binary literal and a optional integer suffix, that is obviously completely unnecessary, wastes precious bytes and is not used in this challenge. A decimal literal is a non-zero decimal digit (1, 2, 3,...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ], [ 220, 16, 11, 220, 17, 11, 220, 18, 11, 220...
Thanks, Uncle (the story) My slightly mad uncle recently left for the space colonies, and passed his pallet goods business to me. The rectangular warehouse is full of pallets of goods except for the one square by the door, and I've just received the first list of pallets ordered by customers to be sent out today. Fortu...
[]
It was a dark and stormy night. Detective Havel and Detective Hakimi arrived at the scene of the crime. Other than the detectives, there were 10 people present. They asked the first person, "out of the 9 other people here, how many had you already met before tonight?" The person answered "5". They asked the same questi...
[]
Warning: This is a bit lengthy I have decided to build my own random function I call it "Random Cake" This function should get an integer value between 0 and 99999 Ingredients 1 x DateTime function 1 x Sin : Radians 1 x Absolute Value 1 x π a dash of multiplication, division and addition Here is the recipe Reci...
[]
Your task is to, given two positive integers, \$x\$ and \$n\$, return the first \$x\$ numbers in the incremental ranges sequence. The incremental range sequence first generates a range from one to \$n\$ inclusive. For example, if \$n\$ was \$3\$, it would generate the list \$[1,2,3]\$. It then repeatedly appends the la...
[]
I'm stuck on a problem involving the Gale-Ryser Theorem. The problem's input gives me the row-wise sum of an hv-convex binary matrix(n*m). e.g. I get {4,3,2,2,1} in the input. It's the row wise sum of the following matrix: 1 1 1 1 1 1 1 0 1 1 0 0 1 1 0 0 1 0 0 0 To solve the problem, I have to fin...
[]
Challenge Bar Dice is a simple game played in a Bar with Dice (hence the name). You roll 5 six-sided dice and attempt to make the best hand. Scoring is based on amassing the largest number of dice with the same digits. Each hand must include at least a single "Ace", or one, in order to be a valid hand; Aces act as "w...
[]
The Nonary Game is a fictional game played in the video game trilogy of the same name. Your goal is to find how many players (at best) can escape a given game, in as few bytes of code as possible. Rules of the game There are 9 players, numbered 1 to 9. All players start in the same room. There are any number of doors,...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ] ]
The Sixers sequence is a name that can be given to sequence A087409. I learned about this sequence in a Numberphile video, and it can be constructed as follows: First, take the multiples of 6, written in base 10: 6, 12, 18, 24, 30, 36, ... Next, concatenate the numbers into a stream of digits: 61218243036... Finally, r...
[]
Introduction: A few days ago I read this post with the same title when I came across it in the HNQ. It asks if this claim of US presidential candidate Bernie Sanders is true or not: Today the world's richest 26 billionaires, 26, now own as much wealth as the poorest 3.8 billion people on the planet, half of the world'...
[]
In this simple but fun challenge, you were asked to determine if Jimmy would fall of their platform. Jimmy has three body parts /, o, and \ arranged like this /o\ Platforms are represented with -. Jimmy will fall off their platform iff they have two or more body parts that are not directly above a platform. Some exa...
[]
(a paradox, a paradox, a most ingenious paradox) This is the first part of a multipart series inspired by different R functions. The Task Given a dataset \$D\$ of positive integers, I need you to compute the 5 number summary of \$D\$. However, I'm working on large datasets, so I need your code to be as small as possibl...
[]
Task Given an input string of one or more ASCII characters which codepoints are between 0 and 128 (exclusive), do the following: Convert each character into its 7-bit ASCII code (if the ASCII code is less than 7 bits, put leading zero bits) Concatenate all bits (this results in 7*n bits where n is the number of charac...
[]
(we won't be finding a Find or catching a tryCatch, though) This is part two of a multi-part series of implementing some interesting R functions. Part one can be found here. The task: You are to implement R's match function in as few bytes as possible. Input: x, a possibly empty list/array of integers table, a possibl...
[]
Help! I seem to have an annoying echo in some of my arrays, and I'd like to get rid of it. When this occurs, the original array repeats itself somewhere in the middle causing the values to be added to each other. For example, the array [ 422, 375, 527, 375, 859, 451, 754, 451 ] contains an echo of itself like so: [ 4...
[]
Let's define a sequence: The n digit summing sequence (n-DSS) is a sequence that starts with n. If the last number was k, then the next number is k + digit-sum(k). Here are the first few n-DSS: 1-DSS: 1, 2, 4, 8, 16, 23, 28, 38, 49, 62, 70... 2-DSS: 2, 4, 8, 16, 23, 28, 38, 49, 62, 70, 77... 3-DSS: 3, 6, 12, 15, 21, 24...
[]
Given a two dimensional matrix of 0 and 1s. Find the number of island for 1s and 0s where neighbours are only in the horizontal and vertical. Given input: 1 1 1 0 1 1 1 0 output = 1 1 Number of 1s island = 1 xxx- xxx- Number of 0s island = 1 ---x ---x ------------------------------ Given input: 0 0 0 0 1 1 1 ...
[]
Given an addition pyramid \$P\$, determine whether it can be solved. An addition pyramid consists of layers, each having one number less than the one below it. Layer \$i\$ is symbolized as \$P_i\$. \$P_1\$ is the base layer, and \$P_{i+1}\$ is the layer atop \$P_i\$. The \$j\$th number of \$P_i\$ is denoted as \$P_{i,j...
[]
A grid-filling meander is a closed path that visits every cell of a square \$N \times N\$ grid at least once, never crossing any edge between adjacent cells more than once and never crossing itself. For example: Once filled, each cell of the grid can be represented by one of the following 8 tiles: Numbered this way, ...
[]
Not to be confused with Find the factorial! Introduction The factorial of an integer n can be calculated by $$n!=n\times(n-1)\times(n-2)\times(...)\times2\times1$$ This is relatively easy and nothing new. However, factorials can be extended to double factorials, such that $$n!!=n\times(n-2)\times(n-4)\times(...)\times4...
[]
(Inspired by the first problem solved in Stanford’s advanced data structures course.) Despite the academicese-heavy name, the problem we're going to solve is almost unbearably simple. We have a list of numbers. [31, 41, 59, 26, 53, 58, 97] We're going to cut some contiguous snippet out of that list of numbers. [31, 41...
[]
Introduction Given this visualization of a playing field: (0,0) +----------------------+(map_width, 0) | A | |-----+-----------+----| | D | W | B | |-----+-----------+----| | C | +----------------------+(map_width, map_height) (0, map_height) The entire map the game is ...
[]
I have a list of decimal digits: 4, 4, 4, 7, 7, 9, 9, 9, 9, 2, 2, 2, 4, 4 The list of decimal digits are known as items. We can form "chunks" from these items by grouping together identical and adjacent numbers. I want to assign each chunk a unique number, starting from 1, and increasing by 1 in the order the chunks ap...
[]
Instead of being a skillful warrior capable of slaying Hydras (see here and here), this time you are a warrior that has no prior knowledge on how to kill one or which weapons to use against the creature. In this problem, whenever you cut a single head off, two will grow in the same place. Since you don't have the mech...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ], [ 220, 16, 11, 220, 17, 11, 220, 18, 11, 220...
A sentence of number theory (for our purposes) is a sequence of the following symbols: 0 and ' (successor) - successor means +1, so 0'''' = 0 + 1 + 1 + 1 + 1 = 4 + (addition) and * (multiplication) = (equal to) ( and ) (parentheses) the logical operator nand (a nand b is not (a and b)) forall (the universal quant...
[]
Your task is to remove smallest amount elements from a list, so the most elements are on their corresponding place. The element is on it's corresponding place, when it's value is equal to it's position. Let's look at this example list: 1 5 3 2 5 This list has three elements on their corresponding place (1 on position ...
[]
Posted from here. This challenge is highly "distilled" from this question. Special thanks to @Akababa! In this task, you should insert an exclamation mark at the start of the string and after every character. Rules There will always be a non-empty-string input. The input will not contain tabs either. You can assume th...
[]
Given a strictly positive integer n, follow these steps: Create an array A with n 1s. If A only has one element, terminate. Otherwise, starting from the first element, replace each pair of A with its sum, leaving the last element as is if A's length is odd, and repeat this step. The output should contain A's state af...
[]
You have locked your bike with a combination lock of 3 digits. Now you want to go for a ride and need to unlock it with the help of following program. Input 1st parameter The digit combination of your lock in locked state. It must be different from the 2nd parameter (=the combination of unlocked state). (Or else your b...
[]
Given a list of positive integers, find the number of triangles we can form such that their side lengths are represented by three distinct entries of the input list. (Inspiration comes from CR.) Details A triangle can be formed if all permutations of the three side lengths \$a,b,c\$ satisfy the strict triangle inequal...
[]
Landau's function \$g(n)\$ (OEIS A000793) gives the maximum order of an element of the symmetric group \$S_n\$. Here, the order of a permutation \$\pi\$ is the smallest positive integer \$k\$ such that \$\pi^k\$ is the identity - which is equal to the least common multiple of the lengths of the cycles in the permutati...
[]
You have a bunch of heavy boxes and you want to stack them in the fewest number of stacks possible. The issue is that you can't stack more boxes on a box than it can support, so heavier boxes must go on the bottom of a stack. The Challenge Input: A list of weights of boxes, in whole kg. Output: A list of lists describi...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ] ]
Given a single letter from A to Z (except J and K) as input, output the smallest non-negative integer containing that letter in its written form. Assume numbers never contain the word "and", so 101 is "one hundred one", not "one hundred and one". Assume American (short-scale) counting, so one million is 10^6 and one bi...
[]
A number of programming languages construct large integers through 'concatenating' the digit to the end of the existing number. For example, Labyrinth, or Adapt. By concatenating the digit to the end, I mean that, if the existing number is \$45\$, and the digit is \$7\$, the result number is \$457\:(45 \times 10 + 7)\$...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ] ]
A bit floats from the LSB to the MSB moving one position each time until it floats to the top of the container: 0000 0001 0010 0100 1000 Once one bit floats to the top, another bit begins its journey and it stops when it meets other bit: 1001 1010 1100 This happens until the container is filled with bits: 1101 1110 1...
[]
I see your BIDMAS and raise you a BADMIS Challenge Given a set of numbers with operators between them: "5 + 4 * 9 / 3 - 8", return all the possible results of the expression for every permutation of the order of basic operations: [/, *, +, -]. Rules Standard loopholes forbidden I/O Input must be ordered with infix o...
[]
Interpret Volatile Volatile is a stack-based esolang made by A_/a'_'/A that only has 8 instructions and is turing complete. However, it is also non-deterministic... meaning that programs don't always give the same output. Your task is to interpret this language. Language specs Taken from the esolangs page: ~: Push a r...
[]
Output Distinct Factor Cuboids Today's task is very simple: given a positive integer, output a representative of each cuboid formable by its factors. Explanations A cuboid's volume is the product of its three side lengths. For example, a cuboid of volume 4 whose side lengths are integers can have sides [1, 1, 4], [1, 2...
[]
Your task is pretty simple. Given two floats, bitwise xor the binary representation of them, and output that as a float. For example, Normal: 16.7472 ^ 123.61 = 7.13402e-37 Binary: 01000001100001011111101001000100 ^ 01000010111101110011100001010010 = 00000011011100101100001000010110 Normal: 2.2 ^ 4.4 = 1.17549e-38 Bin...
[]
Many programming language provide operators for manipulating the binary (base-2) digits of integers. Here is one way to generalize these operators to other bases: Let x and y be single-digit numbers in base B. Define the unary operator ~ and binary operators &, |, and ^ such that: ~x = (B - 1) - x x & y = min(x, y) ...
[]
This question just trended over on code-review and I figured you might like it adapted as a codegolf challenge: You are given a non-empty list of x houses represented as booleans. Each day, the houses compete with adjacent ones. 1 represents an "active" house and 0 represents an "inactive" house. If the neighbors on bo...
[]