instruction_seed stringlengths 292 48.7k | found_ngrams listlengths 0 21 |
|---|---|
It is possible (Wikipedia reference) to compute the square root of any number in a digit by digit fashion using a simple (I had learned it in primary school) algorithm.
Challenge:
read a positive integer from the user, in base 10, no error check;
compute the square root of that integer using a digit-by-digit algorithm... | [] |
Let's consider the sequence \$S\$ consisting of one \$1\$ and one \$0\$, followed by two \$1\$'s and two \$0\$'s, and so on:
$$1,0,1,1,0,0,1,1,1,0,0,0,1,1,1,1,0,0,0,0,...$$
(This is A118175: Binary representation of n-th iteration of the Rule 220 elementary cellular automaton starting with a single black cell.)
Given \... | [] |
I have a problem, which I haven't found a solution for. Solutions to the first part are well documented, but I have yet to find anyone who has solved the second part. I call this the "Dobble" challenge...
Challenge 1
Using the numbers 1 - 57, populate 57 arrays. Each array must have 8 numbers in it, with no duplicates.... | [] |
TLDR: Sort your input according to a new English alphabet somewhat based on Chinese stroke count methods.
Background: In a Chinese glossary/index, finding terms that are contained within the book is different from English because Chinese doesn't have an alphabet like English, instead they are sorted by stroke count. (一... | [] |
A centered polygonal number is a positive integer given by the number of vertices when a point is surrounded by (increasingly larger) polygons with the same number of sides, as shown below. For example, \$p_5(3) = 1 + 5 + 10 + 15 = 31\$ is a centered pentagonal number formed by taking a vertex and adding three layers o... | [] |
When studying numerology, you can say two words (strings consisting entirely of letters) are compatible if they produce the same number under the following operation (let's use the string hello as an example):
Map each letter to a number according to the following, ignoring case:
1 2 3 4 5 6 7 8 9
a b c d e f g h i
j ... | [] |
Here's an easy one, with just enough complexity to make golfing non-trivial.
Input
A list of non-negative numbers representing people waiting in line for Thanksgiving dessert. The first (leftmost) number is first in line, and the list can contain repeats (think of each number as a person's first name):
Note: Pie not... | [] |
Background:
A sequence of infinite naturals is a sequence that contains every natural number infinitely many times.
To clarify, every number must be printed multiple times!
The Challenge:
Output a sequence of infinite naturals with the shortest code.
Rules:
Each number must be separated by a (finite) amount of visible... | [] |
The Problem:
You receive a (section of) a Conway's Game of Life grid. Your task is to output whether it represents a still-life (subsequent generations are identical to the current grid), a oscillator of period up to 4 (every nth generation is identical to the current grid), or something else.
The remainder of the inf... | [] |
This challenge is inspired by the AoC 2020, Day 14 - Part II, created by Eric Wastl and his team, which asks to output the possible binary values from a bitmask.
Let's say we've a bitmask like "10X0X0", then we've to find the possible binary values that can be generated by replacing an X with either 0 or 1. Here I've 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
],
[
220,
16,
11,
220,
17,
11,
220,
18,
11,
220... |
I will preface this by saying that I made this for fun; I have absolutely no formal knowledge on cryptography or error correction. Do not use this algorithm in anything remotely important.
I was kind of bored a few days ago, so I decided to write a simple function to take some data and return an easily memorable (but 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... |
Create the shortest function, program, or expression that calculates a sequence of squarefree palindromic numbers.
A squarefree number is one which is not evenly divisible by a square number (i.e. does not contain a repeated prime factor). For example, \$44 = 2^2 \times 11\$ is not squarefree, whereas \$66 = 2\times3\t... | [] |
A newspaper is made of several sheets; for the purposes of this question, each sheet of newsprint holds four pages of the final newspaper. Here is an example of three sheets of newsprint making up a newspaper with twelve pages:
___________
|2 | 11|
| ___|_____|_
| |4 | 9|
|_| ___|_____|_
| |6 | 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
],
[
220,
16,
11,
220,
17,
11,
220,
18,
11,
220... |
A palindromic number, as a refresher, is any number which reads the same forward as backwards. However, what about palindromes in other bases?
Input
Any integer b where b > 1.
Output
All integer base 10 numbers from 0 to 1000 inclusive that are palindromes in base b. The output can either be a list of integers, or inte... | [] |
Your goal is to make a function that takes the coordinates of a cell in 2D space and a distance \$r\$ and returns the coordinates of all cells in the input coordinate's von Neumann neighborhood of radius \$r\$. That is, all cells at most \$r\$ away in Manhattan distance.
For example, given the following cell coordinat... | [] |
Given a binary sequence of finite length, find the starting position where this sequence first appears in the binary digits of π (after the decimal). You can assume that an answer exists for any input sequence.
The binary digits of π start with
11.001001000011111101101010100010001000010110100011...
and digits will be ... | [] |
Interval notation is a way to write complicated range bounds more conveniently and concisely than writing an inequality. The challenge, should you choose to accept it, is to write a program or function that interprets a subset of interval notation. In this subset, intervals are a comma-separated pair of integers delimi... | [] |
Inspired by a recent challenge involving Fibonacci numbers in which OEIS was mentioned, I would like to present a challenge of creating a function that generates a wide array of different linear integer sequences, depending on user input.
Specifically, the user should provide three inputs:
the kernel (a representation... | [
[
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,
17,
11,
220,
18,
11,
220,
19,
11... |
Your program should take two lists, where each entry (a positive integer) represents the number of members of some group, as input. These lists will have the same sum but may have different lengths.
Your mission, should you choose to accept it, will be to pair up members of the first list with members of the second, ou... | [] |
Do you know the game Battleship? Well, I want to play with my little brother, but before we can begin we need to set up our ships on the board. This is your input.
Now, we need to check that the ships that we set up are valid. This is where you come in to help. Your task is to write a program or function which checks w... | [] |
This problem will have you analyzing circles drawn on the grid, with the gridlines drawn at integer values of \$x\$ and \$y\$.
Let \$\varepsilon\$ be a very small number (think, \$\varepsilon = 0.0001\$). If we paint a filled-in circle of radius \$\varepsilon\$ centered at the origin, it will require paint to be in \$4... | [] |
Related: Landau's function (OEIS A000793)
Background
Landau's function \$g(n)\$ is defined as the largest order of permutation of \$n\$ elements, which is equal to \$\max(\operatorname{lcm}(a_1,a_2,\cdots,a_i))\$ where \$a_1,a_2,\cdots,a_i\$ is an integer partition of \$n\$.
We can extend this to define "iterations" of... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
Background
A little while ago, someone posted an interesting puzzle on Math.SE:
What is the smallest digraph (directed graph) G where the following eight graphs are all distinct:
G, the original graph
Reflexive closure of G
Symmetric closure of G
Transitive closure of G
Reflexive symmetric closure of G
Symmetric tran... | [
[
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
]
] |
Background
An L-shape is defined as a polyomino which can be made by extending two rectangular legs in orthogonal directions from a full square (called a pivot). The size of the square should be at least 1, and the lengths of the two legs should also be at least 1.
These are some examples of L-shapes:
Pivot size 1, two... | [] |
Sandbox, Codidact
A rewrite of this question with a simpler input format and guidelines.
Challenge
Deadfish uses a single accumulator, on which all commands are to be performed.
It has the following commands:
Command
Description
i
increment the accumulator
d
decrement the accumulator
s
square the value of t... | [] |
Given a rod of length n inches and a list of prices that contains prices of all pieces of size smaller than n. Determine the maximum value obtainable by cutting up the rod and selling the pieces. For example, if length of the rod is 8 and the values of different pieces are given as following, then the maximum obtainabl... | [] |
An unrooted binary tree is an unrooted tree (a graph that has single connected component and contains no cycles) where each vertex has exactly one or three neighbors. It is used in bioinformatics to show evolutionary relationships between species.
If such a tree has \$n\$ internal nodes, it necessarily has \$n+2\$ leav... | [] |
Background
Elias omega coding is a universal code which can encode positive integers of any size into a stream of bits.
Given a positive integer \$N\$, the encoding algorithm is as follows:
Start with a single zero in the output.
If \$N=1\$, stop.
Prepend the binary digits of \$N\$ to the current output.
Let \$N\$ be ... | [] |
Given an array \$A\$ of positive integers between \$1\$ and \$9\$ inclusive and a positive integer \$n\$, remove all integers in \$A\$ which appear more than \$n\$ times.
For example:
[1,2,3,2,3,2,4,1,2], n = 2
Occurrence: 1 1 1 2 2 3 1 2 4
Keep? 1 1 1 1 1 0 1 1 0
Kept values: [1,2,3,2,3, 4,1 ]... | [] |
Given a non-empty sequence of non-negative integers, output any permutation of it in which no two adjacent elements have a sum that is divisible by 3. If it is impossible, either crash the program, return an empty sequence, or output nothing.
The asymptotic time complexity must be linear in the size of the input sequen... | [] |
All integers \$n > 0\$ can be expressed in the form
$$n = \prod_{\text{prime } p} p^e = 2^{e_2} 3^{e_3} 5^{e_5} 7^{e_7} \cdots$$
This form is also known as it's prime factorisation or prime decomposition, and each integer has a unique prime factorisation.
As the bases are fixed, it is possible to reconstruct an integer... | [] |
Background
For the purpose of this challenge, all numbers and their string representations are assumed to be in decimal (base 10). I tried to find proper terminology for this challenge, but I do not think there is any, so I made it up.
A self-replicating number is a number that appears as a substring in any of its mult... | [] |
The primorial \$p_n\#\$ is the product of the first \$n\$ primes. The sequence begins \$2, 6, 30, 210, 2310\$.
A Fortunate number, \$F_n\$, is the smallest integer \$m > 1\$ such that \$p_n\# + m\$ is prime. For example \$F_7 = 19\$ as:
$$p_7\# = 2\times3\times5\times7\times11\times13\times17 = 510510$$
Adding each num... | [] |
Create all arrays of non-negative integers of length N where the array sum is equal to T. The output order of arrays does not matter.
Possible solutions are e.g.
N = 5, T = 2:
1 1 0 0 0
1 0 1 0 0
1 0 0 1 0
1 0 0 0 1
0 1 1 0 0
0 1 0 1 0
0 1 0 0 1
0 0 1 1 0
0 0 1 0 1
0 0 0 1 1
2 0 0 0 0
0 2 0 0 0
0 0 2 0 0
0 ... | [] |
Related: Zeroes at the end of a factorial
Today, we are going to calculate how many zeroes are there at the end of \$n!\$ (the factorial of \$n\$) in base \$m\$.
Or in other words: For given integers \$n\$, and, \$m\$. Calculate the integer \$p\$ which is the highest power of \$m\$ dividing \$n!\$: \$p \in \mathbb{N}_0... | [] |
This fastest-code challenge is based partly on this MSE question and exists to extend some OEIS sequences, and create others. If I extend or create sequences based on this challenge, I'll link to this challenge so that folks can see where the values come from. If you'd like direct credit, include your first and last na... | [] |
In this code golf challenge, you'll be computing the placement of (open) circles of areas \$\pi, 2\pi, 3\pi, \dots\$ when greedily placed along integer points in a square spiral in such a way that no two overlap.
A square spiral is a sequence in \$\mathbb Z^2\$ that starts at \$(0,0)\$ and successively wraps around the... | [] |
Fibonacci coding is a universal code, which can encode positive integers of any size in an unambiguous stream of bits.
To encode an integer \$ n \$:
Find the largest Fibonacci number less than or equal to \$ n \$; subtract this number from \$ n \$, keeping track of the remainder
If the number subtracted was the \$ i \... | [] |
AND THE WINNER IS....
Command Master's "Ball Pulling"!
Note: Competition is over, but more submissions are welcome!
Ball game is a game I invented where two players start with 100 energy each. Every turn, each player independently chooses an amount of energy to spend. Whoever spends more energy brings the ball 1 uni... | [] |
Introduction
Note that I learned it from a Numberphile Video, where Neil Sloane explains it better. I recommend you to watch his Video. But for a quick Introduction:
The Levine Sequence is made from the Levine's Triangle, which is made as follows:
First you have \$0\$ ones, and \$1\$ twos.
Then you read the list back... | [] |
Ash has a bit of an interesting float division algorithm. It's designed to never return NaN, and things like signed zero and infinity need to be handled.
How it works:
Assume the inputs are positive for the rules below. One input being negative will always result in the output being negative, and both being negative wi... | [] |
Background
Flow Free is a series of puzzle games whose objective is to connect all the same-colored pairs of dots on the grid. Flow Free: Warps introduces the "warping" mechanic: a line connecting two dots can go through the border of the grid, which makes it re-enter through the opposite side of the grid (torus topolo... | [] |
Inspired by this question on Stackoverflow.
The task
Let's have two lists/arrays of integers: L1 and L2 of equal length. You need to identify in L2 the position of first occurrence of each number and remove from L1 the values on the corresponding positions. Then print/output the modified L1.
Any reasonable input/ouput... | [] |
An \$n\times n\$ Latin Square is a grid containing exactly \$n\$ distinct values where the values in each row and column are distinct. For example,
$$\begin{matrix}
A & B & C \\
C & A & B \\
B & C & A \\
\end{matrix}$$
is a Latin square as no row or column contains a repeated value.
You are to take a positive integer \... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
The age-old question - is it better to walk or run? There are two trains of thought. If you run, you cause the rain to effectively hit you from the front, which increases your surface area and basically causes you to run into the raindrops, getting hit with more water. However, if you walk, you spend longer in the rain... | [
[
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 list of positive digits, return that list with consecutive elements grouped together. For example:
[1, 2, 3, 5, 6, 5, 4, 4, 1] -> [[1, 2, 3], [5, 6, 5, 4], [4], [1]]
Essentially, all adjacent elements whose absolute difference is 1 should be grouped together.
The input array will only ever contain positive dig... | [
[
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... |
This challenge is inspired by the game No More Jockeys.
The input is a list of tuples of natural numbers (potentially including 0), in some appropriate input format. Starting with player 0 and alternating with player 1, each player chooses some number which is contained within at least one remaining tuple, and all tupl... | [] |
Given a list of non-negative integers, return whether or not that list is all the same number.
Rules
Input and output can be taken/given in any reasonable and convenient format
Truthy/Falsey values can be represented as any value of your choice as long as it's reasonable and relatively consistent (e.g. 1 for falsey an... | [] |
Gelatin is a worse version of Jelly. It is a tacit programming language that always takes a single integer argument and that has 7 (or maybe 16) commands. You are to take in a Gelatin program and its argument and output the result.
Gelatin
Gelatin programs will always match the following regex:
^[+_DSa\d~]*$
i.e. they... | [] |
a.k.a. You Can Output Anything With Labyrinth Or Hexagony™
Challenge
In a recent restricted-source challenge, I could print any character with only half of the allowed digits with very small character count, by abusing the "digit commands" and modulo-256 output function. Now, it's about time to make a general metagolfe... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
Bob has a startup that is developing a product that uses “advanced AI” and “black magic” to automatically code-golf computer programs. Unfortunately, Bob is running out of cash and desperately needs money from investors to keep his company running. Each investor that Bob has contacted wishes to schedule a meeting with ... | [] |
Introduction
In this TED-Ed video (which I'd recommend watching first), a puzzle is presented. 27 unit cubes must be painted with one of red, green, or purple on each face, so that they can be reassembled into a large 3x3x3 cube that shows only red on the outside, then a different arrangement that shows only green, and... | [] |
Gelatin is a worse version of Jelly. It is a tacit programming language that always takes a single integer argument and that has 7 (or maybe 16) commands.
Gelatin
Gelatin programs will always match the following regex:
^[+_DSa\d~]*$
i.e. they will only contain +_DSa0123456789~ characters. The commands in Gelatin are:
... | [] |
A challenge many developers face when drawing a graph from scratch to plot some data is generating its ticks. In below graph, there are 6 horizontal ticks (1750, 1800, 1830, 1860, 1880 and 1900) and 11 vertical ticks (0, 10, 20, 30, 40, 50, 60, 70, 80, 90 and 100).
The horizontal bounds of the above graph goes from 17... | [] |
Background
The Collatz (or 3x+1) map (A006370) is defined as the following:
$$
a(n) =
\begin{cases}
n/2, & \text{if $n$ is even} \\
3n+1, & \text{if $n$ is odd}
\end{cases}
$$
Now, let's define the sequence \$s_0\$ as the infinite sequence of positive integers \$1, 2, 3, 4, \cdots\$, and define \$s_k\$ as the result... | [
[
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... |
Inspired by a discussion from the Esolangs.org unofficial Discord Server.
Instructions
A chess cycle is an arrangement of a chess board where each piece must attack one other piece, and only one other piece, and each piece is attacked exactly once.
The effective idea to to "connect" pieces with each other, forming a si... | [] |
Background
Inspired by this video by Matt Parker
A Faro shuffle is a perfect riffle shuffle where the deck is exactly interleaved with its other half. This is how to perform one:
the deck of 52 cards is split into two piles of 26 cards each
the two piles are interleaved. In the case of an "in" shuffle, the bottom card... | [
[
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
]
] |
Introduction
When playing Mario Kart the other day, an interesting question popped up when a Grand Prix with my 2 roommates, 9 AI drivers and myself seemed to be fairly close and therefore exciting until the very end.
We asked ourselves: How close can the point difference between first and last place (#1 and #12) after... | [] |
Lucky numbers (A000959) are numbers generated by applying the following sieve:
Begin with the list of natural numbers:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, ...
Now, remove every second element (\$n = 2\$, the smallest element in the list aside from 1):
1, 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
]
] |
Given:
a blackbox function \$f : \mathbb N \to \mathbb N\$,
a list of positive integers \$L\$, and
a list of indices \$I\$,
apply \$f(x)\$ to the elements of \$L\$ at the indices specified in \$I\$.
For example, \$f(x) = x^2, L = [7, 6, 3, 9, 1, 5, 2, 8, 4]\$ and \$I = [3, 5, 8]\$ (using 1 indexing), we apply \$f(x)\... | [] |
Related: Calculate \$f^n(x)\$, Polynomialception
Challenge
Given a polynomial \$f(x) = a_0 + a_1 x + a_2 x^2 + \cdots + a_k x^k\$ of order \$k\$, we can compute its composition with itself \$f\left(f(x)\right) = f \circ f(x) =: f^2(x)\$, which evaluates to another polynomial of order \$k^2\$.
The challenge is to revers... | [] |
Inspired by this: http://nolandc.com/smalljs/mouse_reveal/ (source).
A valid answer:
Takes a number
\$w\$ and (assumed non-negative) integer \$x\$.
Starts with an integer list with a length of \$2^w\$, initially filled with zeroes.
For each number \$n\$ from \$0\$ to \$w-1\$ (inclusive), divides the list into sub-list... | [] |
Given a non-empty list of integers between 1 and 9 inclusive, find the longest contiguous sublist such that the number of occurrences of each element (of the sublist) within the sublist is equal (not the number of consecutive occurrences, just the total count). You may return any non-empty subset of the solutions.
Exam... | [] |
In this king-of-the-hill challenge, you will be making a python 3 bot to play the card game judgement!
Sandbox
Rules
Judgement is a hand based game similar to games like rummy. In each round,
7 cards are dealt to each player, a trump suit is chosen (trump suits are chosen sequentially from the list Spades/Hearts/Diamon... | [] |
An addition-subtraction chain, is a sequence \$a_1, a_2, a_3, ... ,a_n\$, such that \$a_1=1\$ and for all \$i > 1\$, there exist \$j,k<i\$ such that \$a_i = a_j \pm a_k\$.
Your task, is given a number \$x\$, find the shortest addition-subtraction chain, such that \$a_n = x\$.
Rules
You can assume the input is a valid ... | [] |
Do you know the optical effect of a tridimensional hand painted whit horizontal lines?
Examples
This challenge consists of making something like that effect with ascii, and transforming one 2d input into a "3d" output.
The algorithm
To perform this transformation, you first replace all 1 with a ¯ and all 0 with a _. In... | [] |
There is a boy named Peter. Peter is a picky eater and doesn't like to eat the same kind of cookie again on the same day.
Peter gets a present, The present is a box of cookies! The box contains \$K\$ types of cookies. Also, it contains different amount of each type of cookie.
Peter, being the picky eater he is, Wants t... | [] |
Introduction
Dr. Leslie Lamport, of the eponymous Lamport one-time signature scheme, is getting rather old. But he can't die until his most famous algorithm gets all the kinks ironed out!
In particular, that scheme had one internal component he was never satisfied with:
We hope that someone can find a more elegant met... | [
[
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
Link-a-Pix is a puzzle on a rectangular grid, where the objective is to reveal the hidden pixel art by the following rules:
Connect two cells with number N with a line spanning N cells, so that the two cells are at the two ends of the line.
The number 1 is considered connected to itself (which makes it an e... | [] |
Task
Given a non-empty list of positive digits, group them into sublists of equal sum. You may output any subset of solutions with maximal number of sublists (equivalently, minimal sum).
The input may contain repeat elements. There may not exist any solution but the singleton list containing the input itself. The outpu... | [] |
Take this array:
[1, 2, 6, 4, 4, 1, 0, 0, 2, 0, 4, 1, 4, 2, 4, 8, 1, 2, 4]
There are quite a few places where [1, ..., 2, ..., 4] appears, where ... is any number of items. These include [1, 2, 6, 4], [1, 0, 0, 2, 0, 4], [1, 0, 0, 2, 0, 4, 1, 4], and [1, 2, 4]. The shortest of these is simply [1, 2, 4].
Task:
Given t... | [] |
Inspired by this Numberphile video.
What is planing?
In order to 'plane' a sequence of digits, you need to:
Identify the lengths of the 'runs' (adjacently repeated digits) in the sequence. Non-repeated digits count as runs of one.
Decrease the length of each run by one. Runs of length 1 become length 0.
Reconstruct t... | [] |
If you convert a chemical formula to lower case, it may become ambiguous: co can be both CO or Co.
Given an input consisting of a-z0-9, where 0 can only stand behind 0-9. Check whether it's ambiguous, unambiguous, or impossible. Return 3 different values for them. Shortest code wins.
Examples:
co - ambiguous
2h83o6... | [] |
Program the sequence \$R_k\$: all numbers that are sum of square roots of some(maybe one) natural numbers \$\left\{\sum_{i\in A}\sqrt i\middle|A\subset \mathbb{N}\right\}\$, in ascending order without duplication. Outputting zero is optional.
You should do one of:
Take an index k and output \$R_k\$, either 0 or 1 inde... | [] |
Given an integer \$1 < n < 10 \$ generate a table like below.
For \$n = 5\$,
1 2 3 4 5
2 2 3 4 5
3 3 3 4 5
4 4 4 4 5
5 5 5 5 5
For \$n = 8\$,
1 2 3 4 5 6 7 8
2 2 3 4 5 6 7 8
3 3 3 4 5 6 7 8
4 4 4 4 5 6 7 8
5 5 5 5 5 6 7 8
6 6 6 6 6 6 7 8
7 7 7 7 7 7 7 8
8 8 8 8 8 8 8 8
Shortest code wins! Trailing whitespace allowed
... | [] |
But Is It Art? is an esolang created by ais523, where one step is break the program into orthogonally connected "tiles":
A BBBB
A B B
AA CC
A CC
Each separate letter shows a different tile. Interestingly, programs in But Is It Art? only rely on the orientations of the tiles themselves, not their placement. This means... | [] |
Multi-dimensional chess is an extension of normal chess that is played on an 8x8x8x8... "board".
In normal 2D chess, a knight's move is a movement by a vector of \$ \begin{bmatrix} \pm 2 \\ \pm 1 \end{bmatrix} \$ or \$ \begin{bmatrix} \pm 1 \\ \pm 2 \end{bmatrix} \$, as long as it doesn't cause the knight to go outside... | [] |
Mr. Binary Counterman, son of Mr. Boolean Masker & Mrs. Even Oddify, follows in his parents’ footsteps and has a peculiar way of keeping track of the digits.
When given a list of booleans, he counts the 1s and 0s separately, numbering the 1s with the odds & the 0s with the evens.
For example, when he looks at 1 1 0 0 1... | [] |
Background
Binomial transform is a transform on a finite or infinite integer sequence, which yields another integer sequence. The binomial transform of a sequence \$\{a_n\}\$ is given by
$$s_n = \sum_{k=0}^{n}{(-1)^k \binom{n}{k} a_k}$$
It has an interesting property that applying the transform twice will yield the ori... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
16,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,... |
Your challenge is to write a function/program that takes a matrix of integers m and a number n as input and:
Splits m into n by n chunks
Replaces each chunk with the most common value in that chunk (In case of a tie, any of the tied values is fine).
Outputs the resulting matrix.
Note: You can take either the size ... | [] |
Inspired by Wzl
Determine if a given square binary matrix has exactly one row or column consisting of entirely 1s, and the rest of the matrix is 0s.
For example, these are all true:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1
0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 ... | [] |
In November 2019, Alon Ran published a particularly lovely sequence in the OEIS, A329126:
\$a(n)\$ is the lexicographically earliest string of digits which yields a multiple of \$n\$ when read in any numeric base.
1, 110, 101010, 111100, 100010001000100010, 1111110, 10000010000010000010000010000010000010, 11111111000,... | [] |
Background
Minkowski addition is a binary operation on two sets of points (usually geometric objects) in the Euclidean space. The Minkowski sum of two sets \$A\$ and \$B\$ is formally defined as follows:
$$ A+B = \{\mathbf{a}+\mathbf{b}\,|\,\mathbf{a} \in A,\ \mathbf{b} \in B\} $$
To say in plain English, given the ori... | [] |
Recursively prime-encoded integers
Consider \$11681169775023850 = 2 \times 5 \times 5 \times 42239 \times 5530987843\$. This isn't a nice prime factorisation, as \$42239\$ and \$5530987843\$ make it difficult to store this factorisation in a small manner. Being primes, we can't then factorise them, but we can factorise... | [] |
Input a non-empty array with \$n\$ positive integers. Test if the input array contains every integer in \$1\cdots n\$.
In case you prefer 0-indexed numbers, you may choose to input an array of non-negative integers, and test if the input array contains every integer in \$0\cdots (n-1)\$ instead. All testcases and formu... | [] |
Given an array \$A\$ of size \$n\$.
You have to find the number of subsets such that their product is in the form of \$p_1 \times p_2 \times p_3 \dots\$
where \$p_1, p_2, p_3, \dots\$ are prime numbers. No prime number should appear more than once, i.e. the product is "squarefree".
Example:
Lets pick an array \$A\$ of ... | [] |
As some of you may remember, Peter, who was a picky eater is now puzzled Peter.
This time Peter got some puzzles as a present from his Aunt. He has tried a lot, but has failed to solve the puzzles. Peter needs your help to solve them.
Each one of the puzzle has 2 pieces. To solve the puzzle, you must tell the number of... | [] |
Totally not inspired by Lyxal repeatedly mentioning elevators in chat :P
Challenge
In short: simulate some people filling up an elevator and then leaving it.
The elevator is simplified as a grid, where each person can occupy one cell of the grid. The height and width of the grid is the input parameter. The width is alw... | [] |
I have to fill in 2fa codes all day. They're 6-digit strings. One day I noticed that not once did any of these codes contain 6 unique digits, like 198532 There was always at least one double, like 198539 (here it's 9).
For any given uniformly random string of \$N\$ digits in the set \$\{0,1,2,3,4,5,6,7,8,9\}\$, what is... | [] |
A complete Boolean function is a function such that, an amount of them can be used to express any Boolean function. For example, NAND \$\left[\begin{matrix}\text{input1}&0&0&1&1\\\text{input2}&0&1&0&1\\\text{output}&1&1&1&0\end{matrix}\right]\$ is complete. Inputs may be reused any number of times, and the functions ca... | [] |
I'd like to roll up the ability scores for my Dungeons and Dragons character. But I'd also like them to be balanced (and slightly better than average).
Typically, a character's stats are created by rolling four 6-sided dice, adding together the three highest results, and doing this 6 times. A 6 sided die has the number... | [] |
This challenge was inspired by this tweet.
Idea
Consider a circle with n evenly spaced dots around the perimeter, where each dot has a postive integer value:
Now connect the dots with non-intersecting chords:
Next consider our score, which is the sum of the products of these pairs. When n is odd, the extra orphan do... | [
[
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
]
] |
Challenge
Given a graph (a structure consisting of nodes and vertices), classify it according to a few categories.
Specifically, you will be given an unweighted directed graph, which is a set of nodes and edges from one node to another (but not necessarily both ways). You can take this in any reasonable and consistent ... | [] |
The Torian, \$x!x\$, of a non-negative integer \$x\$ can be recursively defined as
$$
x!0 = x \\
x!n = \prod^x_{i=1} i!(n-1) = 1!(n-1) \times 2!(n-1) \times \cdots \times x!(n-1)
$$
The Torian is then equal to \$x!x\$ for a given \$x\$. This sequence begins \$0, 1, 2, 24, 331776, ...\$ for \$x = 0, 1, 2, 3, 4, ...\$
Al... | [] |
Related: What's my telephone number? which asks to calculate the terms of A000085, the number of possible ordinal transforms of length n.
Background
Ordinal transform is a transformation on an integer sequence. For a sequence \$a=(a_0, a_1, a_2, \cdots)\$, the \$n\$-th term of the ordinal transform \$ord(a)_n\$ is defi... | [
[
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 screen consisted of some LED segments like such:
_ _ _ _ _
|_|_|..._|_|_|
|_|_| _|_|_|
However, some of the LEDs are broken, and it's possible that only these are left:
_ _
_|_|
|_|_|
Now, you're required to output all integers possibly expressed on this screen. An integer, something matching RegEx /^0$|^-?... | [] |
Given an array of integers. Find out its longest sub-array (contiguous subsequence) whose sum is 0.
The sub-array for output may be an empty array.
Input
Input an array of integers.
Output
Output the longest zero sum sub-array. If there are multiple such arrays, output any one of them.
Output Format
You may output in o... | [] |
Background
A Jordan matrix is a block-diagonal matrix where each block on the diagonal has the structure of
$$
\begin{bmatrix}
\lambda & 1 & 0 & \cdots & 0 \\
0 & \lambda & 1 & \cdots & 0 \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
0 & 0 & 0 & \lambda & 1 \\
0 ... | [] |
Consider the following binary matrix:
$$\begin{matrix}
1 & 0 & 1 \\
1 & 0 & 0 \\
0 & 1 & 1
\end{matrix}$$
The (1-indexed) co-ordinates of the \$1\$s here are \$(1,1), (1,3), (2,1), (3, 2), (3, 3)\$. We can also notice that there are three "shapes" of \$1\$s in the matrix, made of orthogonally connected \$1\$s:
$$\begin... | [] |
This is similar in concept to this challenge, but that is pretty restrictive on input and output and I think opening up these restrictions would lead to a completely different set of solutions that would be interesting in their own right.
Background
Set is a card game in which players compete to construct sets of thre... | [] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.