instruction stringlengths 34 53.1k |
|---|
You work at a bakery, and every day you make pastries. You make 100 of each of several different types. However customers are less predictable. Some days they order all of one kind of pastry and you run out, some days they order hardly any and you have some left over. So your boss has made up a chart which tells you ho... |
Given a list of countries in alphabetical order, put them in the same order as they are given in the song "Yakko's World".
Specifically, you are given the following list of countries* exactly:
Abu Dhabi, Afghanistan, Albania, Algeria, Algiers, Angola, Argentina, Australia, Austria, Bahamas, Bahrain, Bangladesh, Barbado... |
For a given positive integer, try to find out the smallest possible rotation resulted by rotating it 0 or more bits.
For example, when the given number is 177, whose binary representation is \$10110001_{(2)}\$:
\$ 10110001_{(2)}=177 \$
\$ 01100011_{(2)}=99 \$
\$ 11000110_{(2)}=198 \$
\$ 10001101_{(2)}=141 \$
\$ 00011... |
In this challenge you will be tasked with implementing a sequence of natural numbers such that:
Each number appears a natural number of times
No two numbers appear the same number of times
No two numbers appear in the sequence next to each other more than once.
For some examples, the sequence
1,2,3,1,4,5,1,6,7,1,8,9,... |
Your task
Given a integer input, \$ n \$ (such that \$ n > 1 \$), decide whether it can be written as the sum of (at least 2) consecutive square numbers.
Test cases
Truthy:
Input Explanation
5 1 + 4
13 4 + 9
14 1 + 4 + 9
25 9 + 16
29 4 + 9 + 16
30 1 + 4 + 9 + 16
41 16 + 25
50 9 + 16 + ... |
Your function must accept 2 strings which are correct numbers. It needs to sum them up (without rounding and floating point errors) and return the result (which is also a correct number) without any leading zeros in the integer part, trailing zeros in the decimal part and without minus if the answer is 0 i.e. -0 is not... |
Task
Write a polyglot in two languages that when run, outputs the name of the language it is run in. Additionally, this program must also output the other language's name if the source code is reversed
Example:
Program ABC in language foo outputs foo. ABC in language bar outputs bar. CBA in language foo outputs bar, an... |
Suppose we have a sequence \$P\$. Every element \$P_n\$ represents the distance between the \$n^{th}\$ prime number and the average of the next two prime numbers.
For example, \$P_1\$ would be the distance between the first prime number (2) and the average of the next two prime numbers (3 and 5), so
\$P_1 = \frac{3+5}{... |
Given as input a list of positive integers, your task is to determine if every integer present has exactly two neighbors in the list. The neighbors of a integer \$x\$ are the distinct integers that appear next to an \$x\$ anywhere in the list. For example in the list:
[1,3,4,4,3,2,1]
The number 3 has 3 neighbors 1, 4... |
The city defines a dog as any living entity with four legs and a tail. So raccoons, bears, mountain lions, mice, these are all just different sizes of dog.
Given an ASCII-art image of an animal, determine if that animal is a dog.
Rules
An animal is a dog if it has four legs and a tail.
The foot of a leg starts with one... |
There is a 1x1x1 cube placed on a infinite grid of 1x1 squares. The cube is painted on every side, so it leaves a mark on the grid when it moves.
The sides of the cube are colored 6 distinct colors, re-presentable with any 6 distinct values. A 7th value represents a blank space.
The cube can roll around the grid. Ever... |
Traditionally when you compare two strings you use lexicographical comparison. That can be described by the recursive algorithm:
$$
f(x, y)=
\left\{\begin{array}[rr] \\
\mathrm{EQ} & \mathrm{if}\,\mid x\mid=0\,\mathrm{and}\,\mid y\mid=0 \\
\mathrm{GT} & \mathrm{if}\,\mid x\mid>0\,\mathrm{and}\,\mid y\mid=0 \\
\mathrm{L... |
The task is to count the number of disjoint 11 blocks in a 64-bit word, using the minimum number of straight-line instructions. That is, how many nonoverlapping neighbored pairs of 1-bits can be found.
Examples
(imagine leading zeros to fill up to 64 bits)
Input Output
111111 3
1110111 2
111100... |
Yesterday, as part of a IQ-style test, I got this interesting question:
The time on a 24-hour clock is 11:43. What is the least number of minutes I should wait before the same digits are on the screen again (in any valid 24-hour time order)?
The answer's 91 minutes, if you were wondering!
This stuck in my mind, and ... |
I have encountered this type of puzzle, that usually involves apples, several times. It goes as follows:
There is a certain number of apples in a basket. Ava takes a third of the apples. Bob takes a quarter of the apples that are left. Finally, Dennis takes one-sixth of the apples left. In the end, there are 10 leftov... |
Given an atomic number in the inclusive range [1,118], write the shortest program/function that outputs one of {2,8,18} if the element with that atomic number follows the duplet, octet, or 18-electron rule, respectively.
Notes
The Octet/Duplet/18-electron rule is a rule of thumb that describes how many electrons is ne... |
It can be proven that there's exactly one string of infinite length that remain same after base64 encoding Vm0wd2QyUXlVWGxWV0d4V1YwZ...
Given a position, output the character on that position.
Your program would be run on AMD Ryzen 5 5500U@4GHz given 4GB memory and 1 minute (may decrease if RAM turns out to be hard lim... |
Your task is to generate an emoticon of three characters, the first character being one eye, the second the mouth, and the third another eye. Each eye is a random one of these characters: $'*+-;O^`ox~, and the mouth is a random one of these: ,-._coux.
Each eye and the mouth must be on the same general level. These eyes... |
plorcly borglar is a "mod" created by jan Misali for the constructed language toki pona that makes words sound funny.
It involves substituting the 14 toki pona letters for funnier versions plus 2 extra rules. The substitutions are:
toki pona letter
plorcly borglar letter
m
bl
n
gl
p
b
t
pl
k
cl
s
scr... |
Ptolemy's Almagest contains a table of chords that effectively served as the world's only comprehensive trigonometric table for over a millennium. In modern form it looks like this:
\begin{array}{|l|rrr|rrr|}
\hline
{}\,\,\,\,\,\,\,\,\,\, \tfrac12 & 0 & 31 & 25 & 1 & 2 & 50 \\
{}\,\,\,\,\,\,\, 1 & 1 & 2 & 50 & 1 & 2 &... |
Given a base as input, output all pan-digital numbers. A number is pan-digital if it includes every digit in that base at least once, possibly multiple times. Every number is considered to contain an infinite number of leading 0s.
sequence rules apply. Given a base, you may either:
Given an index, output the n-th pan-... |
Write a program that, for any \$n\$, generates a triangle made of hexagons as shown, \$2^n\$ to a side. The colors are to be determined as follows.
We may give the triangle barycentric coordinates so that every hexagon is described by a triple \$(x,y,z)\$ with \$x+y+z=2^n-1\$. (The three corners will be \$(2^n-1,0,0)\$... |
A Latin square of order n is text which is arranged as a square of n lines by n columns, contains n different characters, and each character appears once in each line and column. For example, here is a Latin square of order 9:
Code gOlf
ode gOlfC
de gOlfCo
e gOlfCod
gOlfCode
gOlfCode
OlfCode g
lfCode gO
fCode gOl
M... |
You are the treasurer and you have received information that a counterfeit coin has entered the treasury. All you know is that the counterfeit coin is lighter than the original.
Knowing how many coins you have in total and using only a balance scale, you need to determine the minimum number of weighings to determine wh... |
Let's say you are given an integer array. Create a function to determine the largest sum of any array's adjacent subarrays. For instance, the contiguous subarray with the largest sum is [4, -1, 2, 1] in the array [-2, 1, -3, 4, -1, 2, 1, -5, 4].
You can employ a variant of Kadane's algorithm to resolve this issue. The ... |
You are given a matrix of size m x n where each cell can contain either 1 or 0. You need to find the largest square submatrix that contains only 1's. The output should be the area of the largest square submatrix.
For example, given the following matrix:
1 0 1 1 1
1 0 1 1 1
1 1 1 1 1
1 0 0 1 0
The largest square submat... |
Write a program that takes an undirected graph and finds the minimum cut, i.e., the set of edges that, if removed, would disconnect the graph into two or more connected components. The program should have a time complexity of \$O(n^2m)\$, where n is the number of vertices and m is the number of edges in the graph.
One ... |
Define the (unnormalised) Willmore energy of a surface as the integral of squared mean curvature over it:
$$W=\int_SH^2\,dA$$
For surfaces topologically equivalent to a sphere \$W\ge4\pi\$, and \$W=4\pi\$ iff it is actually a sphere. Thus the energy quantifies how spherical a surface is.
In September 2020 I asked on Ma... |
proposed by @Adám in chat
Given an even number of finite points return a line \$y=mx+b\$ that evenly splits the points on both sides.
Specs
Take a list of distinct points \$(x,y)\$ (or a list of x-coordinates and a list of y-coordinates), output a possible \$(m,b)\$ pair
Half of the points should be true for \$y>mx+b\... |
This challenge is simple: Take a path to an png image file as input and overwrite that file with a copy of itself rotated 90 degrees clockwise. You may assume that the file has dimensions of 128x128 pixels. You may not use image metadata modifications (like Exif) to rotate the image; the pixels themselves must be trans... |
Description
The Gameboy stores tiles as 2 bit-per-pixel 8x8 images, thus 16 bytes. Every two bytes is a complete row with all of the Low-bits of each pixel in the first byte, and all of the High-bits of each pixel in the second.
Input
Input will be exactly 16 bytes, received through Standard IO in one of the following... |
Your function must accept one string and return the opposite
The opposite string is a string where all characters go in reverse order, all letters are replaced with the opposite mirror letter from the English alphabet and are changed in case, and all digits are replaced with opposite mirror digits
opposite mirror for l... |
Given an ASCII art with simple closed paths using | and - (pipes and dashes), output a random point inside the boundary.
Eg. given:
---- ----
| |- --- => |12|- ---
| | | | |345| |6|
----- --- ----- ---
Any point 1-6 should have an equal probability of being printed.
Specs
T... |
Let a counting tree be a rooted tree in which every node is labeled with the number of descendants it has.
We can represent such trees as ragged lists with each node being represented by a list containing its label followed by its children. For example the following is a counting tree:
[5,[2,[0],[0]],[0],[0]]
However ... |
There are multiple ways to represent a 3D rotation. The most intuitive way is the rotation matrix –
$$A=\begin{bmatrix}A_{11}&A_{12}&A_{13}\\A_{21}&A_{22}&A_{23}\\A_{31}&A_{32}&A_{33}\end{bmatrix}$$
rotates a point \$p=(x,y,z)^T\$ by left-multiplication: \$p'=Ap\$. This is however inefficient since a 3D rotation has on... |
Every odd degree polynomial has at least one real root. However this root does not have to be a rational number so your task is to output a sequence of rational numbers that approximates it.
Rules
Your input is an odd degree polynomial \$f\$ with integer coefficients in any reasonable format.
You must output a sequen... |
Your task is to create a program or function, that when given an input list of nonnegative integers of length \$l \ge 2\$ and a nonnegative integer \$c\$ where \$2 \le c \le l\$, group the list into \$c\$ "clusters." What this means is, the average (population) variance* of all the groups should be as low as possible.
... |
It can be easily proven using Hall's marriage theorem that given fixed \$n\$ and \$k<n/2\$, there is an injective (one-to-one) function from all \$n\$-bit strings with \$k\$ ones to \$n\$-bit strings with \$k+1\$ ones such that an input and its corresponding output differ by exactly one bit. For example, with \$n=5,k=2... |
It is well-known that a 3D rotation can always be represented by a quaternion. It is less well-known that a 4D rotation can always be represented by two quaternions, sending a point \$p=(a,b,c,d)^T\$ represented as the quaternion \$a+bi+cj+dk\$ to the point \$p'=xpy\$ for an appropriate choice of unit quaternions \$x,y... |
Given a list of fractions, group them so that each group sums to a whole number. This should be done in such a way to maximize the number of non-empty groups.
You may assume a solution exists. Order does not matter, both for the groups and their contents. You may output in any order.
Test Cases
Fractions
Groups
... |
The ubiquitous Catalan numbers \$C_n\$ count the number of Dyck paths, sequences of up-steps and down-steps of length \$2n\$ that start and end on a horizontal line and never go below said line. Many other interesting sequences can be defined as the number of Dyck paths satisfying given conditions, of which the Fine se... |
I was playing with the Fibonacci sequence in binary like so (note that the binary representations are written here from smallest bit to largest bit):
1 1
1 1
01 2
11 3
101 5
0001 ... |
In Haskell (and probably some other languages or something) zip is a function which takes two lists, and produces a list of tuples by pairing elements at the same index:
zip [1,2,3] [6,5,4] = [(1,6),(2,5),(3,4)]
If there are extra elements on one of the input lists those are trimmed off and don't appear in the result:... |
There is a building with an infinite number of floors and you are the only passenger in an elevator which can lift an infinite number of people. You are going home, but before the elevator gets to your floor, the elevator stops at another floor to allow people to enter the elevator and input their destination floors. Y... |
An intriguing MathsSE question asked if there were large N-queens solutions where no three queens lie on a line. That question's body included the unique 4×4 solution up to symmetries
. Q . .
. . . Q
Q . . .
. . Q .
and noted that there are no solutions for 5×5 to 7×7 because of knight lines. However, joriki over ther... |
I'm trying to shorten a bash solution to a Code Golf challenge, which requires an output of true or false. I've managed to condense the key piece of the code down to a substring check, to determine if the provided argument, $1, is a substring of a particular hard-coded fixed string, of the form:
[[ FIXEDSTRING = *$1* ]... |
Specifically, this references JavaScript, a programming language that happens to be one you can run on StackExchange/StackOverflow. However, you may use any programming language to do this challenge. This is not actual JS golfing, but merely a "code-golfable" challenge. Actual complete parsing of JS is not needed.
An e... |
I'm working from home and the heat of my laptop on my lap is the only thing keeping me warm. I have a Dell G3 Laptop with an NVidia GEForce GTX CPU.
I have tried writing a rust program with 5 threads that calculates and prints the Fibonacci sequence in an infinite unthrottled loop, but that only gave a bit of warmth, a... |
Given a non-empty string (or an integer, or a list/array if you prefer) composed exclusively of digits in the range [1-9], your task is to write a function (or a whole program) that applies a "Match-3 type of rule" from left to right and outputs the resulting string, like this :
[parameter] "12223" -> [returned value] ... |
Strangely never asked before, this question pertains to the generation of a list of prime numbers within a given range using the shortest possible code. Several algorithms, such as the Sieve of Eratosthenes and trial division, are known to be effective for this purpose, but require significant code length. Is there an ... |
Overview
As most of y'all who visit chat know, I am Russian by ethnicity[citation not needed]. Recently, I switched from a keyboard that maps the letters 1-to-1 (mnemonic) to Windows' default mnemonic keyboard. Here are the letter mappings:
"`" -> "ъ"
"q" -> "я"
"w" -> "ш"
"e" -> "е"
"r" -> "р"
"t" -> "т"
"u" -> "у"
"i... |
Challenge
Given a non-negative integer, find the sum of its digits.
Rules
Your program must take a non-negative integer as input.
Your program should output the sum of the digits of the input integer.
Your program should be able to handle inputs up to 10^100.
Examples
If the input is 123, the output should be 6 (1... |
There are 18 primes with distinct prime digits (A124674). Namely, they are:
\$2, 3, 5, 7, 23, 37, 53, 73, 257, 523, 2357, 2753, 3257, 3527, 5237, 5273, 7253, 7523\$
Your task is to output this sequence.
Rules
sequence rules apply. This means valid solutions may use any of the following formats:
Given some index \$n\$... |
Description
Given an unsorted array of integers, find the smallest positive integer that does not appear in the array. Your task is to write the shortest code possible to solve this problem.
Input
A non-empty or empty array of integers, where the integers may be negative, zero, or positive.
Output
The smallest positive... |
I have a follow-up question here from my previous question on Math SE. I am lazy enough to explain the content again, so I have used a paraphraser to explain it below:
I was considering arbitrary series, springing up as a top priority, when I considered one potential series in my mind. It is as per the following:
The ... |
Introduction
One question that I have come across recently is the possibility of dissecting a staircase of height 8 into 3 pieces, and then re-arranging those 3 pieces into a 6 by 6 square.
Namely, is it possible to dissect the following into 3 pieces:
x
xx
xxx
xxxx
xxxxx
xxxxxx
xxxxxxx
xxxxxxxx
And rearrange those 3 ... |
Typically, when we want to represent a magnitude and direction in 2D space, we use a 2-axis vector. These axes are typically called X and Y:
This isn't always convenient, however. The game BattleTech is played on a hexagonal grid, and it's convenient for the axes to line up with the sides of the hexagons. To represent... |
It seems we've managed to go all this time without a plain vanilla Number-To-Binary challenge! Whilst this will inevitably be only one element in many languages, it should put a few esolangs through their paces.
I truly looked for this challenge to no avail. If it already exists, comment as such and I'll delete this po... |
Generate the shortest possible code in any programming language that can generate all Pythagorean triples with all values not exceeding a given integer limit. A Pythagorean triple is a set of three integers \$(a, b, c)\$ that satisfy the equation \$a^2 + b^2 = c^2\$. The program should output the triples in any format,... |
Given a permutation, we can define its high-water marks as the indices in which its cumulative maximum increases, or, equivalently, indices with values bigger than all previous values.
For example, the permutation \$ 4, 2, 3, 7, 8, 5, 6, 1 \$, with a cumulative maximum of \$ 4, 4, 4, 7, 8, 8, 8, 8 \$ has \$1, 4, 5\$ as... |
Given a string of parentheses ( and ), find the length of the longest substring that forms a valid pair of parentheses.
Valid pairs of parentheses are defined as the following:
An empty string is a valid pair of parentheses.
If s is a valid pair of parentheses, then (s) is also a valid pair of parentheses.
If s and t a... |
Your function must accept two strings and return new string where are UTF-16 code of all symbols is the sum of UTF-16 codes of inputs symbols
If the resulting sum is greater than 65535 (maximum UTF-16 codepoint), take the sum modulo 65536
If there are more symbols in one string then sum with zero, codes of symbols wh... |
Challenge: Find the number of distinct words in a sentence
Your task is to write a program that takes a sentence as input and returns the number of distinct words in it. For this challenge, words are defined as consecutive sequences of letters, digits, and underscores ('_').
Input:
A string containing a sentence. The ... |
(Similar: Through the bases)
Normally, our number system is base ten, with the digits 0123456789. However, we can increase or decrease the base count (so hexadecimal uses 0123456789abcdef and octal uses 01234567.
Your goal is: given a string, interpret it in all bases 2-36 for which it's valid, compute the total, and e... |
I've looked and could not find a post for this, if there is one, I'll remove it quick! Related and also related
The goal is (hopefully) clear: create the shortest code (in bytes) that implements the AES256 ECB cipher mode. Either convert the result to Base64 or output a array of bytes. The input contains two parts. The... |
On Pomax's Primer on Bézier Curves this "fairly funky image" appears:
This is related to the fact that every cubic Bézier curve can be put in a "canonical form" by an affine transformation that maps its first three control points to (0,0), (0,1) and (1,1) respectively. Where the fourth and last control point lies afte... |
It's easier to put this into coding terminology, so here we go:
First find the average, median, mode, and range.
Then, put those values in another array, then find the new average, median, mode, and range.
Bonus -10 bytes (yeah, negative bytes, because there's already answers) for programs that can handle this many ti... |
I've been a fan of My Little Pony: Friendship Is Magic for a long time, and very early on I created a pony version of myself also called Parcly Taxel (warning: may be too cute to look at). The symbol below is her "cutie mark", which you will be drawing here:
Construction
All key points of the cutie mark lie on a rotat... |
Take the sequence of all natural numbers in binary, (1, 10, 11, ..) then write them vertically beside each-other like this (least significant bit on top; 0s have been replaced with spaces):
1 1 1 1 1 1 1 1 1
11 11 11 11
1111 1111
11111111
11
Notice there are areas of connected 1s in the... |
There's a lot of questions about Conway's Game of Life, but nothing about customization (Related: 2-Player Life). Given an input, determine the result on a 100x100 grid after some iterations. The input is given as a string. For example:
Using the character #, follow the following rules:
If there are 2 or 3 neighboring ... |
Nerdle is a Wordle variant, in which instead of words, the answers are equations. Each equation entered in the game must be a valid one.
Examples: 13³-1=2196, (1/1)²*8=8, (((3)))²=9
The task is to generate and output to a .txt file, one equation per line, all possible 10 character equations that could be an answer for ... |
SVG is an XML vector graphics markup language embeddable in web content.
Your tips should be at least somewhat specific to SVG.
Please post one tip per answer.
|
Write a program that takes a string as input and modifies it by reversing the string in its place by mirroring the position. The first position goes to last, second to second last and so it goes on. In simple words, the string would be mirrored.
"In Place" means the program should use \$O(1)\$ additional memory regardl... |
Voronoi diagram is a partition of a plane (or part of plane) into regions close to each of a given set of objects ("seeds").
Here we’ll be dealing with discrete arrays or even rather with ASCII-art:
2 2 4 4 4 4 1 1 1 1 1 1 1 3 3 3 3
2 2 4 4 4 1 1 1 1 1 1 1 3 3 3 3 3
2 2 4 4 4 1 1 1 1 1 1 3 3 3 3 3 3
2 2 2 4 1 1 1 1 1 1... |
We already have challenges dealing with simulating vanilla Conway's Game of Life, Wireworld and rule 110, but so far none corresponding to a (specific) non-totalistic rule. So here is one.
In June 2000 David Bell described the Just Friends rule, which uses the same square grid and two states as regular Life but has the... |
Description
In this challenge, you need to write a function that takes in a list of strings and returns the smallest string based on their ASCII value. You should assume that the input list contains only lowercase alphabetical strings.
Test Cases
["a", "b", "c"] => "a"
["hello", "world", "code"] => "code"
["aaa", "aa",... |
Write a program or function that takes in a string and outputs a count of each modern English alphabet letter in the string, case-insensitive.
Input: A string consisting of printable ASCII characters (code points 32-126).
Output: A list of pairs, where each pair consists of a letter and its count in the string. The lis... |
Description
"Imtiaz Germain primes" is not a technical name in Mathematics, but my weird creation, in the memoir of the famous mathematician Sophie Germain. These primes can be generated by the following process:
1. Take a Safe prime
2. Apply 2p + 1 on it to obtain a composite number
3. Apply 2p + 1 once more to obtain... |
Your function must accept three numbers in any order:
A signed real number (or ±Infinity) - The number (N) for which you have to generate a number from the range
A signed integer - Minimum of the range
A signed integer - Maximum of the range
Input:
The minimum of the range will always be less than the maximum of the... |
This question is an extension of Who's that Polygon? to arbitrary numbers of sides.
A fundamental polygon for a surface is an polygon with a prescribed pairing for all its \$2n\$ sides, each marked with an arrow, such that identifying the sides according to this pairing and the arrow directions produces the surface (up... |
This challenge arises from a claim made in a MathOverflow answer and a paper linked in that answer which seems to back up the claim:
Searching for triangular embeddings is much quicker than enumerating over all embeddings… In fact, Jungerman was able to find a triangular embedding of \$K_{18}-K_3\$ in about half an ho... |
We are going to bring down an imaginary building with a series of explosions. Our building is a 5x5 matrix of integers ranging 1-9, each representing a single brick.
The challenge is to set of a series of explosions to bring down our building as much as we can, why not! Each brick that is connected (horizontally, verti... |
Inspired by one of many bugs I ran into while implementing selection sort in trilangle.
Given a non-empty list of non-negative integers, "sort" the list using the following procedure:
Find and output the smallest value in the list.
If the list only has one element, stop.
Recurse on a sublist:
If the last element in t... |
Description
Write a program or function that takes in a positive integer \$n\$ as input and outputs all Sophie Germain primes that are safe primes less than or equal to \$n\$. A prime number \$p\$ is a Sophie Germain prime if \$2p+1\$ is also a prime. A prime number \$p\$ is a safe prime if \$p=2q+1\$, where \$q\$ is a... |
Dedicated to Martin Gardner, taken from his book
Background
In the old days, the Slavs had a divination method for finding out whether a girl would get married. The girl would clutch six straws in her hand so that the ends would poke out the top and bottom of her fist. Then her friend would join together the ends of pa... |
Develop a program to check if a given word is part of a language defined by the following rules:
The language has a set of rules.
The empty string is considered a valid word in the language.
Two words from the language can be concatenated to create a new word in the language.
If X is a word in the language, then "A" +... |
You're driving a car in an infinite city whose blocks are pentagons arranged in the order-4 pentagonal tiling. At each step, you proceed to the next intersection and choose whether to continue left, right, or straight. A sequence of choices that returns you to your initial state (street segment and direction) is called... |
This is a sequel to Ragged list pattern matching. In this challenge, the wildcard may match a sequence of items of any length instead of just a single item.
Given a pattern and a ragged list of integers, your task is to decide whether the pattern matches the ragged list.
The pattern is also represented by a ragged list... |
Problem author: https://stats.ioinformatics.org/people/5815
You are given a system with a hidden permutation of the numbers \$1, 2, 3, \ldots, n\$. Your task is to guess this permutation by asking the system a series of questions.
Each question consists of providing the system with a permutation of the numbers \$1, 2, ... |
(Inspired by this challenge.)
Given six real values in three pairs: \$(x_1, x_2), (y_1, y_2),\$ and \$(x_0, y_0)\$, where \$x_1 < x_0 < x_2\$ and \$y_1 < y_0 < y_2\$, create a function which maps between \$(x_1, x_2)\$ and \$(y_1, y_2)\$ which also passes through \$(x_0,y_0)\$. In other words, make some function
$$f: ... |
Imagine that a list of integers describes the heights of some two-dimensional terrain as seen from the side.
Stamina: [ 4 4 4 4 4 4 3 3 3 3 2 2 2 - ]
O
/|\
/ \
+---+ +---+
| | | |
+---+ ... |
Languages, such as C++, have introduced a new comparison operator: <=>.
This operator returns -1, 0, or 1† when comparing two items together:
−1 means the left-hand side is smaller,
0 when both values are equal,
+1 means the right-hand side is smaller.
Here is what I have been coming up with in x86-64:
556: 48 8b... |
Every integer can be expressed in powers of 2. You know this as the binary system
Assume you are given a set of k numbers (0 < k < 2^n).
You want to decide for this set whether every integer power of 2 up to 2^(n-1) occurs at least m times
One example:
n = 7 (2^n = 128, )
k = 5
set =
{100,
91,
88,
63,
44}
m = 3
Solut... |
Non-metals typically* have a fixed number of covalent bonds in every chemical they are part of. Given the number of bonds every element requires, output whether it's possible to construct a single molecule from the given chemicals, such that every atom has it's desired number of bonds.
In other words, output if it's po... |
Carry sort is an \$O(n)\$ "sorting" algorithm. Here's how it works. The algorithm moves left to right along a list. As it traverses a list it "carries" a single item, the largest item it has encountered so far. Once it encounters a larger item it picks up that item and drops the item it is already carrying in place. W... |
Description
a typeracer is an apps where user could type and evaluate their typing speed and accuracy.
Criteria
User could type "A quick brown fox jumps over the lazy dog."
A visual indicator of each wrong character typed.
A visual indicator of what characters to type.
A visual indicator of what has been typed
A visua... |
If \$R\$ runners were to run a race, in how many orders could they finish such that exactly \$T\$ runners tie?
Challenge
Given a positive integer \$R\$ and a non-negative integer \$0\leq T\leq {R}\$ produce the number of possible finishing orders of a race with \$R\$ runners of which \$T\$ tied.
Note, however, that run... |
I'm trying to solve a CSS challenge. It contains a rotated leaf shape (looks like an eye). Score for the challenge depends on amount of characters of the code. Here's my way to make a leaf shape:
div {
width: 200px;
height: 200px;
border-radius: 99% 0;
rotate: 45deg;
background: #d9d9d9;
}
<div></div>
He... |
In C++, there exists a a <=> b three-way comparison operator that, for numerical types, does the following:
If a < b, then return a negative number.
If a = b, then return a (mathematically speaking) sign-less number.
If a > b, then return a positive number.
The Challenge
Implement the shortest full program, function,... |
Given a string s consisting of characters a-z lowercase, generate 5 arrays a1, a2, a3, a4, and a5 of size n (length of s) where the i-th element of each array represents the index of the next occurrence of the i-th character in s, with the following conditions:
If no such occurrence exists, set the value to n (0-based... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.