instruction_seed stringlengths 292 48.7k | found_ngrams listlengths 0 21 |
|---|---|
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... | [] |
Challenge
Write a function/program that outputs either the n'th element, or the first n elements, in the well known number sequence:
1, 2, 4, 8, 16 ...
Oh, wait... I forgot the first few numbers:
1, 1, 1, 1, 2, 4, 8, 16 ...
Heck, I'll add a few more for good measure:
1, 1, 1, 1, 2, 4, 8, 16, 33, 69, 146, 312... | [] |
Here is continuation of this question, this time lets compress/generate Mario in colors!
Image size is 64x64 (above one is zoomed). The required output is valid <img ...> tag with exact same image in dataURI form, working on chrome, firefox and safari (and IE4 - joke ;). In snippet below you can find example tag in r... | [] |
The previous neural net golfing challenges (this and that) inspired me to pose a new challenge:
The challenge
Find the smallest feedforward neural network such that, given any 4-dimensional input vector \$(a,b,c,d)\$ with integer entries in \$[-10,10]\$, the network outputs \$\textrm{sort}(a,b,c,d)\$ with a coordinate-... | [
[
408,
90,
1653,
11035,
1291,
4833,
59,
2359,
26056,
7265,
90,
1653,
15170
],
[
59,
408,
90,
1653,
11035,
1291,
17960,
2359,
26056,
7265,
90,
1653,
15170
]
] |
We haven't had any nice, easy challenges in a while, so here we go.
Given a list of integers each greater than \$0\$ and an index as input, output the percentage of the item at the given index of the total sum of the list.
Output should be whatever the natural representation for floats/integers is in your language (una... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
21, 21, 23, 20, 5, 25, 31, 24, ?
Inspired by this Puzzle, given an integer \$n>0\$ , print out the following sequence until you reach a non-Integer (spoilered, in case you want to solve the puzzle yourself first)
\$a_0 = n\$
\$a_{4k+1} = a_{4k} \cdot(4k+1) \$
\$a_{4k+2} = a_{4k+1} + (4k+2)\$
\$a_{4k+3} = a_{4k+2} - (... | [] |
Fermat's polygonal number theorem states that every positive integer can be expressed as the sum of at most \$n\$ \$n\$-gonal numbers. This means that every positive integer can be expressed as the sum of up to three triangle numbers, four square numbers, five pentagonal numbers etc. Your task is to take a positive int... | [] |
Convert a large int (e. g. 1234567890) into a string containing the usual decimal prefixes k, M, G, T, etc. for kilo, mega, giga, tera, etc. The result shall be groups of three digits, interspersed by the prefixes (e. g. 1G234M567k890), so that it is easy to glance the order of magnitude of the number without counting... | [] |
Inspired by this lumosity mini game, Pinball Recall
We start with a rectangular grid (viewed from above) with several bumpers as follows. Entrances/exits are numbered counter-clockwise starting from the leftmost of the bottom of the grid, as number 0.
24 23 22 21 20 19 18 17 16 15
25 . . . . . / . . . . 14... | [] |
The Hadamard transform works similarly to the Fourier transform: it takes a vector and maps it to its frequency components, which are the Walsh functions. Instead of sine waves in the Fourier transform, the Walsh functions are discrete "square waves" so to speak. This makes it easier to compute.
The size of a Hadamard ... | [] |
We all know the age-old debate - should strings be length-prefixed or should they be null-terminated? Well, you've run into a blob of binary data and apparently whoever made it decided that the best solution would be a compromise and length-terminated their strings.
For the purposes of this challenge, a length-terminat... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
The Objective
Build a random number generator whose range is \$\left[0,1\right) \cap \mathbb{Q} .\$
This is, build a random number generator that can produce any value that's:
at least \$0 \,;\$
not \$1\$ or greater; and
expressible as the ratio of two integers.
What's the fuss?
This RNG is weird. Its range is nowhe... | [] |
Inspired by this challenge from puzzling.SE.
Polyominoes are fun - you can fill all sorts of shapes with them. But as soon as you have limits on what polyominoes you can use, you sadly start running into shapes you can't fill.
Today we'll be looking at the L tromino - a shape made up of three conjoined squares, in such... | [] |
Back again, stealing another question from stackoverflow.
You are given a list of integers >= 0. Generate in order square 1-matrices where the side length is given by the list entry of the current index and fill the rest with 0s.
So given a list 2,4,1,3 print this to stdout:
1 1 0 0 0 0 0 0 0 0
1 1 0 0 0 0 0 0 0 0
0 0 ... | [] |
You are given a matrix of forward and back slashes, for instance:
//\\
\//\
//\/
A slash cuts along the diagonal of its cell corner-to-corner, splitting it in two pieces.
Pieces from adjacent (horizontally or vertically) cells are glued together.
Your task is to count the number of resulting pieces. For the same examp... | [] |
The (slightly harder, but still easy) sequel of Generate input for this hardware.
Background
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... | [
[
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... |
You probably know what a Turing Machine is but do you know what is a Turning Machine (lathe)?
Ok you already know.. and what about a Golf Turning Machine ??
Ok I tell you..
A Golf Turning Machine is a full program or function taking a list/array (or any convenient method) representing the Profile (P) of a turned piece ... | [] |
Input
This task takes no input.
Output
Your code should compute and print (or return)
\$\pi^y\$ for all \$y = \frac11, \frac12, \frac13, \frac14, \frac15, \frac16, \frac17, \frac18, \frac19, \frac1{10}, \frac1{11}, \frac1{12}\$. The first 20 digits of the output (truncated and without any rounding) should be correct i... | [] |
In convolutional neural networks, one of the main types of layers usually implemented is called the Pooling Layer. Sometimes, the input image is big (and therefore time consuming especially if you have a big input set) or there is sparse data. In these cases, the objective of the Pooling Layers is to reduce the spatial... | [
[
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... |
Background
A spanning tree (Wikipedia) of an undirected graph is a subgraph that is a tree which includes all of the vertices of the original graph. The following is an example of a spanning tree of a 4-by-4 grid graph.
Task
Given two positive integers w and h, output any valid spanning tree of the grid graph which ha... | [] |
Introduction
The Fibonacci sequence is a mathematical sequence in which each term is the sum of the \$2\$ terms before it; the first two terms are \$0\$ and \$1\$. The first few terms are \$0, 1, 1, 2, 3, 5, 8, 13\$. However, it is possible to make variations of this sequence, where each term is the sum of the, say \$3... | [
[
220,
16,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220
],
[
16,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
20
],
[
11,
220,
16,
11,
220,
17,
11,
220,
18,
11... |
Print the ASCII version of a random grid.
################################################################################
# # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # #
# # ############# # # ... | [] |
I have a piece of paper whose shape is a regular n-gon with side length 1. Then I fold it through some of its diagonals. What is the area of the shape formed by the (former) edges of the regular polygon?
Illustration
Suppose n = 8, i.e. an octagon-shaped paper. Let's name the vertices from A to H (left picture). Then I... | [] |
Description
Your input is a list of integers \$[a_1, \dots, a_n]\$.
A magic triplet is a triplet \$(a_i, a_j, a_k)\$ of values from this list, such that
the indices \$\{i, j, k\}\$ are all distinct,
the values are in ascending order (\$a_i \leq a_j \leq a_k\$), and
the sum of two of the values equals the third.
Your ... | [] |
Introduction
The Cartesian product of two lists is calculated by iterating over every element in the first and second list and outputting points. This is not a very good definition, so here are some examples: the Cartesian product of [1, 2] and [3, 4] is [(1, 3), (1, 4), (2, 3), (2, 4)]. The product of [1] and [2] is [... | [] |
Background
The Look and Say Sequence is built up by reading off the digits of previous entries in the sequence, counting the number of digits in groups of the same digit. For example:
1 => 11 # (one 1)
11 => 21 # (two 1s)
21 => 1211 # (one 2, then one 1)
1211 => 111221 # (one 1, then one 2, then two 1s)
This sequence ... | [] |
Disclaimer: This challenge inspired by me trying to find pairs in a large pile of socks.
Disclaimer: This is looking for a very different process and output to Help me sort my socks!. Please don't claim it as a duplicate until you've read both ;)
So, I have a huge pile of socks. Of course I keep them categorized by c... | [] |
Please note: this is a restricted-source challenge — see details below!
Each natural number \$n\$ has 10 faces: its decimal representations in bases \$1\$ through to \$10\$. For example, the 10 faces of \$12\$ are \$[111111111111, 1100, 110, 30, 22, 20, 15, 14, 13, 12]\$, and the 10 faces of \$4\$ are \$[1111, 100, 11,... | [
[
220,
15,
11,
220,
16,
11,
220,
16,
11,
220,
18,
11,
220
]
] |
I have a fixed length vector of 4 elements. The inputs of which are always 0 or 2^n for n = 1 to 15 (so n = 0 excluded i.e. 2^0 = 1 will not appear)
x = [32, 4, 4, 8]
the result should be
x = [32, 8, 8, 0]
The way it works is that values that are the same will get combined, but one it's combined it can not be combined... | [] |
Write a function or program which takes as input a set of distinct, non-negative integers \$\{x_1, \ldots, x_n\}\$ and outputs the smallest gap between any two values in the set, i.e. \$\min_{i\neq j}|x_i-x_j|\$.
Scoring
This is not code golf. Your score is the smallest gap of the set of code points of characters in yo... | [] |
Inspired by Help me pair my socks, and the fact that I have some pairs of socks where the left sock is distinct from the right.
Background
Again, I have a huge pile of socks. And a machine that can give the list of labels of the socks for me. This time, the labels follow these rules:
Some socks have left and right ve... | [] |
Introduction
An elementary cellular automaton is a cellular automaton that is 1-dimensional and has 2 states, 1 and 0. These cellular automata are categorized based on a simple code: the Wolfram code, invented by Stephen Wolfram (yes, the Wolfram | Alpha guy). It works like this:
First, you the set of all possible sta... | [] |
Introduction
Big 2 is a card game popular in East Asia and South East Asia, in which 4 players are dealt 13 cards each (ie, an equal division of a standard deck without jokers). The goal is to empty your hand before any of the other players. Players take turns playing combinations of a Big 2 subset of standard poker ha... | [] |
Golfeek is the working name of an esolang I'm occasionally working on. One distinctive feature of this language is that each statement is encoded as a sequence of bits rather than a sequence of bytes.
Instead of just showing a long binary sequence, the 'gutter' of the source editor contains a representation of each sta... | [] |
Flip flop is a memory / arithmetic game that I played in high school. Some number of players stand in a circle. The players take turns. On the nth turn, the current player checks:
What is the largest power of 7 dividing n?
How many instances of the digit 7 does the decimal representation of n contain?
What is the larg... | [] |
The \$d\$-dimensional vector space \$\mathbb{F}_2^d\$ over the field with two elements \$\mathbb{F}_2\$ is the set of vectors of \$d\$ bits. Addition of vectors is bitwise xor. A linear dependence is a set of vectors whose total (xor them all together) is \$0\$. Every set of \$d+1\$ vectors in \$\mathbb{F}_2^d\$ contai... | [] |
The Challenge
Given a finite list of integers, split it into the fewest partitions possible such that no partition contains a number more than once.
Rules
Input can be in any format and any order.
Output can be in any format, as long as it's clear that each group is separate.
This is code-golf, so lowest score wins!
Ex... | [] |
\$GF(9)\$ or \$GF(3^2)\$ is the smallest finite field whose order isn't a prime or a power of two. Finite fields of prime order aren't particurlarly interesting and there are already challenges for \$GF(2^8)\$ (link) and \$GF(2^{64})\$ (link).
Challenge
First define nine elements of the field. These must be distinct in... | [] |
(Inspired by the Keg utility of this challenge)
Given a non-empty input string, e.g. s c 1= e(a"E"), split the input into even-odd chunks.
Example (Feel free to suggest more)
I can only think of this test case, fee free to suggest more.
This input string, when mapped to its code points, yields the list [115, 32, 99, 32... | [] |
If \$f,g\colon \mathbb{Z}_{\geq 1} \to \mathbb{R}\$, the Dirichlet convolution of \$f\$ and \$g\$ is defined by
\$ \qquad\qquad\qquad \displaystyle (f*g)(n) = \sum_{d|n}f(d)g(n/d).\$
This question asked about computing Dirchlet convolution of functions.
The identity element of the Dirichlet convolution is the functi... | [
[
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
]
] |
As the trip through the solar system on your way to rescue Santa gets a little droll, so perhaps some optimizations to your Intcode Computer are in order. Namely, making it as small as possible because you've got nothing better to do with your time.
Check out Advent of Code if you haven't already, the guy that makes th... | [] |
Given a sequence \$S\$ with length \$n\$ of exactly one each of whole numbers from \$1\$ to \$n\$, your task is to return a number \$\sigma\$ indicating how shuffled it is.
Definition of shuffledness
Humans perceive shuffling randomness locally [Citation Needed], so the shuffledness of a sequence is based on the abilit... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220
]
] |
Significantly harder version of Spanning tree of a rectangular grid.
Background
A spanning tree (Wikipedia) of an undirected graph is a subgraph that is a tree which includes all of the vertices of the original graph. The following is an example of a spanning tree of a 4-by-4 grid graph.
Task
Given two positive intege... | [] |
Given a sequence of base-10 digits, output the longest list of integers that contains all the digits exactly once, in the order in which they appeared in the input, without repeating any integers.
Examples
Input: 12345
Output: [1, 2, 3, 4, 5]
Input: 12123
Output: [1, 2, 12, 3]
Input: 10010
Output: [100, 1, 0]
Input:... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
In this task you are expected to provide a list output given an input tq program. The tq programs will not contain whitespace inside them.
What is tq, in the first place?
tq is a lazy-evaluated language that is designed with the idea that array items should be accessable during the definition of them. In tq, there is n... | [] |
Challenge
Write a program or function that converts a 32 bit binary number to its quad-dotted decimal notation (often used for representing IPv4)
Quad-dotted decimal
A quad-dotted decimal is formed like so:
Split the binary representation into its 4 individual bytes
Convert each byte into denary
place "." between each... | [] |
Given two nonempty arrays of natural numbers \$a\$ and \$b\$, return the shortest nonempty array of pairs of natural numbers \$q\$ such that the sequence of first elements of \$q\$ consists of a whole number of repeated copies of \$a\$, and the sequence of second elements of \$q\$ consists of a whole number of repeated... | [
[
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
]
] |
If \$f(x) = x + \sum_{i>1} a_ix^i\$ and \$g(x)=x+\sum_{i>1}b_ix^i\$ then there is a composite power series \$f(g(x))\$ also of this form. Given a power series \$f\$ the goal is to find a compositional inverse \$f^{-1}\$ so that \$f(f^{-1}(x))=x\$.
One approach to this is recursive: start with a guess \$g_1(x)=x\$ for t... | [
[
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
]
] |
In musical notation, groups of notes shorter than one beat are joined together by a line at the bottom called a beam. Here are a few bars of music with the beams highlighted:
(Taken from Second Suite in F by Gustav Holst; you can hear how these notes sound at 0:13 in this video.)
You may notice that beam #6 is above t... | [] |
The challenge - given a numeric list L and an integer N as inputs, write a function that:
finds the bucket sizes for L such that it is split into N whole buckets of equal or near-equal size, and
returns for each element in L the minimum of that element's bucket.
Example -
L=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
N=... | [
[
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... |
The challenge is to implement a program or function (subsequently referred to as "program") that takes a nonnegative integer \$n\$ as input and returns \$n\over\sqrt{2}\$ (the input divided by the square root of two) as output, rounded to a nonnegative integer.
You may take your input and output in any reasonable forma... | [] |
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:
A number may only appear after all lower numbers have appeared
All numbers whi... | [] |
Challenge:
Your challenge is to write an interpreter for Whitespace. Given a string consisting of spaces, tabs, newlines, and potentially other characters, as well as possible inputs for the Whitespace program itself, output the result of the given Whitespace program.
Here is an overview of the Whitespace language and ... | [] |
Alice and Bob are perfect logicians trapped on an island with a puzzle generator. Although they can instantly solve the Riemann hypothesis and P=NP just by thinking about it, rather than doing anything useful, they amuse themselves by giving each other puzzles. The setup is as follows: a positive integer n is chosen by... | [] |
The sequence
Given an integer \$n>0\$, we define \$a(n)\$ as the lowest positive integer such that there exists exactly \$n\$ positive integers smaller than \$a(n)\$ whose sum of digits is equal to the sum of the digits of \$a(n)\$.
Edit: this sequence has since been published as A332046
First terms
n | a(n) | sum of... | [] |
Task
Given the x,y coordinates (coordinates are guaranteed to be integers) of the vertices of two simple polygons in clockwise or anti-clockwise order. Output a Truthy value if both the polygons are similar otherwise a Falsy value
A simple polygon is a polygon that does not intersect itself and has no holes. That is, i... | [] |
CodeDrawing one-liner
Teaser
Behold this formidable drawing:
Can you draw this in a single stroke? Give it a try.
Can you do this one, now:
Give it a try.
How it works
These "make this drawing with one pen stroke" problems are graph-theory problems with a rather simple solution. For each vertex, compute its degree. I... | [
[
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
]
] |
Context
In this challenge, a random walk is a stochastic process in which a particle at a position with integer coordinates (or a drunk man) moves at each integer time step (that is, at t = 1, 2, 3, ...) by taking a step of size 1 to any of its neighbouring positions, with the direction of the step being aligned with t... | [] |
Background
We define a circular step sequence of order \$n\$ as follows:
$$
a_1, a_2, \dots, a_n = \text{Permutation of } 1 \dots n \\
b_i = \min ( |a_{i+1} - a_i|, n-|a_{i+1} - a_i| ), 1 \le i < n \\
\text{Circular step sequence} \stackrel{\text{def}}{=} b_1, b_2, \dots, b_{n-1}
$$
Informally, it is the \$n-1\$ distan... | [
[
64,
62,
16,
11,
264,
62,
17,
11,
1124,
67816,
11,
264,
1089
]
] |
My robot for generating Mad Libs-style sequence challenges has gone rogue! To defeat it, I need you to write code that can solve all the challenges it can crank out.
Your input is three selections for the blanks A, B, C, each from (1,2,3), specifying the sequence challenge to solve, and the number \$n\$ that's the inpu... | [
[
220,
16,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220
],
[
16,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
20
],
[
11,
220,
16,
11,
220,
17,
11,
220,
18,
11... |
This is a simple game of getting rid of those damn numbers.
You start with the numbers from 1 to 19, written in a grid of 9 by 3:
1 2 3 4 5 6 7 8 9
1 1 1 2 1 3 1 4 1
5 1 6 1 7 1 8 1 9
You may notice that the number 10 is missing, this because the number zero would be hard to get rid of later on.
The two rules are:
I... | [] |
Task
Given a set of n unique elements and a multiset l of positive numbers that add up to n, find all the ways of partitioning those unique elements into disjoint sets with sizes given by the elements of l.
(A multiset is a set that allows repeated elements)
The point here is that we are taking everything in the output... | [] |
Given an positive integer n (including 0 if you decide to support it), output all numbers in the generated sequence up to the index n. For the current test cases of the current challenge numbers are one-indexed. Feel free to submit 0-indexed answers though.
Base sequence
We start from this sequence (NOT, but quite simi... | [] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.