instruction stringlengths 34 53.1k |
|---|
In calculus, the derivative of a mathematical function defines the rate at which it changes. The derivative of a function f(x) can be marked as f'(x), and these can sometimes be abbreviated to f and f'.
The derivative of the product of two functions fg is f'g + g'f. The derivative of three fgh is f'gh + fg'h + fgh'. In... |
This part is somewhat detached from the actual array manipulation side of the challenge, scroll down for an explanation that is much more array-based
You've been learning how to shuffle poker chips recently, but, as you're still learning, you don't always get the perfect alternating shuffle that you're aiming for. Inst... |
A few days ago I made a puzzle about moving people on an airplane. Now I am interested in the general version of this puzzle and the shortest code golf for it.
I will briefly summarise the puzzle here. A small airplane went through some heavy turbulence and all its N passengers ended up sitting in reverse order, ie., p... |
If you wanted to compute a very large long problem, that on a machine that you could buy today for an inflation adjusted price, will take some amount of years/decades. The issue is, if you only have that budget, and so can only purchase one machine. So if you purchase the machine now, it may actually take longer to com... |
Consider the equation $$\frac x {y+z} + \frac y {x+z} + \frac z {x+y} = n$$ for positive integers \$x, y, z\$ and \$n \ge 4\$. Your code will receive \$n\$ as an input, and output three integers \$x, y\$ and \$z\$ such that the equation holds. You may assume that a solution always exists.
Background
This equation is a ... |
Challenge:
Given two integers \$a\$ and \$b\$, with lengths \$A=length(a), B=length(b)\$, output an ASCII-art of the \$a^{th}\$ root of \$b\$, including the answer rounded to \$A\$ amount of decimal places.
The size of the ASCII-art root also depends on \$A\$ and \$B\$.
Example:
\$a=123\$, \$b=1234\$
____
123 /123... |
A binary matrix represents a shape in the plane. 1 means a unit square at that position. 0 means nothing. The background is 0.
For example, the matrix [[0,1,0],[0,0,1],[1,1,1]] represents the following shape:
o----o
|////|
|////|
o----o----o
|////|
|////|
o----o----o----o
|////|/... |
A binary matrix represents a shape in the plane. 1 means a unit square at that position. 0 means nothing. The background is 0.
For example, the array [[0,1,0],[0,0,1],[1,1,1]] represents the following shape:
o----o
|////|
|////|
o----o----o
|////|
|////|
o----o----o----o
|////|//... |
Connecting Dots
We define a type of question on the test, connecting the dots
Question parameters
There are two parameters. Suppose they are 5 and 4. The second one must be less than or equal to the first one.
Thus, the question will look like this:
*
*
*
*
*
*
*
*
*
Possible answer... |
Related challenge
A band matrix is a matrix whose non-zero entries fall within a diagonal band, consisting of the main diagonal and zero or more diagonals on either side of it. (The main diagonal of a matrix \$A\$ consists of all entries \$A_{i,j}\$ for which \$i=j\$.) For this challenge, we will only be considering sq... |
Haplology
Haplology is a linguistic term:
the omission of one occurrence of a sound or syllable that is repeated within a word, for example probly for probably.
For this challenge, it means specifically, replacing any sequences of two or more letters that are repeated two or more times with just one copy.
For example... |
Powers
We define an important power as a number that can be represented as \$ x^y \$ where \$ x ≥ 2 \$ and \$ y ≥ 2 \$.
Palindrome
We define an important palindrome as a number that is the same written forwards and backward, and is greater than 10. Thus, the last digit must not be 0.
Palindromic Power
We define a Palin... |
Is it a good chord?
Definition of a chord:
We define a chord as three notes together.
Definition of a note:
We define a note as a number between 1 and 7, inclusive. As in music, we define 1 as do, 2 as re, 3 as fa, etc. However, the note names are not important. They will not be included in the question and likely not ... |
This is different from Floating Point XOR, and more in the spirit of a comment by R.. GitHub STOP HELPING ICE on that challenge, but I thought of this idea independently.
Generalized XOR
The bitwise exclusive or (XOR) operation is usually considered in terms of integers, but it can be naturally generalized (extended, i... |
Challenge:
Given an integer \$n\$, guaranteed to be \$\geq2\$ and a power of 2, we are going to draw multiply boards either side-by-side or below one another, where the first has dimensions of \$n\$ by \$n\$; the second \$\frac{n}{2}\$ by \$\frac{n}{2}\$; the third \$\frac{n}{4}\$ by \$\frac{n}{4}\$; etc.; until the fi... |
The words "center a" probably give flashbacks to any decent HTML developer. Luckily, we are not working with divs, we are working with matrices.
Given a matrix where w=h, and given a "length" to extend it by, make a new matrix and center the old one in it, populating blank squares with the length. For example:
m = [
[1... |
Overview
I was playing with Desmos and discovered a really cool spiral:
Doing some research, I discovered that this spiral was the Archimedian spiral. Every point on the spiral is exactly \$\theta\$ away from the origin, where \$\theta\$ is the angle from the origin. That is, any point on the spiral has the polar coo... |
Implement a function or program that can run simplified BitCycle code. The functions you must implement are:
<^>v: Change the direction of a bit to the direction this is pointing.
+: Turn all 0s left and all 1s right.
\ and /: Reflect one bit 90 degrees, then become inactive. In regular BitCycle, this is displayed as -... |
King of the Hill: Greed Control
What is Greed Control
Greed control is a multiplayer round-based game
in which in every round, a player bet a number inside
a specific range, say 1~100. Say 2 people betted 100,
then they'd both get 100/2 which is 50 points in
the game. Basically, the players that choose the same
numb... |
The Task
The task is easy: given an Alpha-2 country code, output the Alpha-3 equivalent. The input may be in any case you choose, and the output in any consistent case of your choosing. Here are the codes:
[["AF", "AFG"], ["AX", "ALA"], ["AL", "ALB"], ["DZ", "DZA"], ["AS", "ASM"], ["AD", "AND"], ["AO", "AGO"], ["AI", "... |
The Narrative
You are a frog who is at the edge of a pond with waterlilies. You would like to cross the pond without getting wet, so you plan to jump from lily to lily. There is, however, one problem: you are a rare species of frog which can only jump one specific distance, and so you might not be able to cross the pon... |
Background
BitCycle is a two-dimensional Turing-complete programming language involves moving bits around a playfield.
Because I am too lazy to write BitCycle programs myself, you will be writing a program which outputs BitCycle programs for me! Unfortunately, the storage space on my computer is only about a bit, so yo... |
Given a set of positive integers \$ S \$, output the set of all positive integers \$ n \$ such that \$ n \$ can be made by summing a subset of \$ S \$ in more than one different way, i.e., that are the sums of more than one subset of \$ S \$.
To be clear, a subset of \$ S \$ means that you can't use numbers from \$ S \... |
In this challenge, you will create the shortest graphical program that displays exactly "Hello, world!"
You will need no input.
You might be asking yourself, "what does he mean by graphical?" Well, by graphical, I mean not writing to stdout. For example, look at my ES6 answer, which makes an alert box pop up rather tha... |
Related: Deck Names Friends or Foes Paying for Spells
The Magic: the Gathering card game has five colours of magical mana: white (W), blue (U), black (B), red (R), and green (G). Cards can be any of the \$2^5=32\$ subsets of these colours. Hereafter 'colours' refer just to the initials W, U, B, R, G.
The order that the... |
Given a multidimensional array, find the recursive alternating sum. An alternating sum is simply the sum of an array, where every other item (starting with the second) is negated. For example, the alternating sum of [7, 1, 6, -4, -2] is the sum of [7, -1, 6, 4, -2], or 14. In this challenge, you'll take the alternating... |
Here's an advanced version of the Count the Liberties challenge.
The definitions of the terms liberty and group are the same as the previous challenge, so have a look at the previous one for details, but briefly put,
A group is a group of stones that are connected horizontally or vertically.
Liberty is the number of e... |
King of the Cards
Code available here!
In this King of the Hill challenge, you must write a bot that can play Crazy Eights. This is a card game often played by children, in which the objective is to empty your hand.
How to Play
The game of Crazy Eights is deceptively simple. At the beginning of the game, each player ge... |
Design a function or program that, when run normally, outputs the triangular numbers. However, when any single character is deleted, the program/function should not function in the original programming language, but instead produce the triangular numbers in one other programming language.
Scoring
Your score will be the... |
Draw an "apartment" building according to the specifications below.
Basic Rules
Take, as input, the number of floors of the building.
Return a building with that many floors meeting the following specifications:
The building will be eight characters wide, with eight underscore characters (_) on top and eight dashes (-)... |
Definition of long text
Long text usually shows emphasis, for instance, loooooool or yaaaaaaaaaay. Usually the vowel is replicated many times. In this challenge we require:
At least 3 times, which means yaaay and yaaaay are allowed, but yay and yaay are not.
Consistent, which means that shoes can turn out be shoooeee... |
In Fewest (distinct) characters for Turing Completeness, the goal is to find the minimum number of characters which make a language Turing Complete...in other words, allow it to do any computation possible with any other language. In this challenge, we'll be doing somewhat of the opposite, and finding the minimum numbe... |
This is the robbers' challenge. The cops' one is here.
In Fewest (distinct) characters for Turing Completeness, the goal is to find the minimum number of characters which make a language Turing Complete...in other words, allow it to do any computation possible with any other language. In this challenge, we'll be doing ... |
The Zany Car Game is a tile matching game. You are given a number of tiles, with coloured cars split into a top and bottom half. To win the game, you need to find a square arrangement of the tiles so that only whole, correctly coloured cars are formed at each tile join , like the image below.
Challenge
Given a square ... |
For any ragged list its dimensions will be a list of non-negative integers defined as follows:
Elements that are not a list will have dimensions \$\textbf{[}\,\,\textbf{]}\$.
An empty list has dimensions \$[0]\$.
An \$n\$ dimensional list \$L\$ of length \$x\$ has dimensions \$x : k\$ where \$k\$ is the element wise m... |
Introduction
If \$\newcommand{\fib}{\operatorname{fib}}\fib(x)\$ calculates the \$x\$th Fibonacci number, write a program that calculates \$\fib(\fib(m))\$ for any integer value of \$m \ge 0\$. (Of course, there will be practical limits based on the language, so lesser limits are acceptable. Also, it's okay to stop at ... |
Given two positive integer fractions \$x\$ and \$y\$ such that \$x < y\$, give the fraction \$z\$ with the smallest positive integer denominator such that it is between \$x\$ and \$y\$.
For example \$x=2/5\$, \$y=4/5\$, the answer is \$1/2\$. Other fractions such as \$3/5\$ are also in between the two, but \$1/2\$ has... |
This is the reverse of this challenge.
Given an encoded list of codepoints and the characters used to encode it, you need to decompress it to its original string.
For example, given the encoded list [170, 76, 19, 195, 32] and the encoder characters " abcdefghijklmnopqrstuvwxyz", the output should be "the fox".
How, tho... |
Introduction
In chess, Knights can move two squares in one direction, and then one square in an orthogonal direction. On an x/y plane, these can be thought of as being a relative change of coordinates, such as (+1, -2).
Challenge
Your task is to output all 8 possible moves as pairs of relative x/y coordinates, in any o... |
A run ascending list is a list such that runs of consecutive equal elements are strictly increasing in length. For example [1,1,2,2,1,1,1] can be split into three runs [[1,1],[2,2],[1,1,1]] with lengths [2,2,3], since two runs are the same length this is not a run ascending list. Similarly [2,2,1,3,3,3] is not run as... |
Inspired by the recent 3Blue1Brown video
Consider, for some positive integer \$n\$, the set \$\{1, 2, ..., n\}\$ and its subsets. For example, for \$n = 3\$, we have
$$\emptyset, \{1\}, \{2\}, \{3\}, \{1,2\}, \{1,3\}, \{2,3\}, \{1,2,3\}$$
If we take the sum of these subsets, we can then ask ourselves the following ques... |
This challenge is about implementing Shm-reduplication, originating in Yiddish, where one takes a word, duplicates it, and replaces the first syllable in the second word with "Shm" in order to indicate that one does not care. Some examples include:
"Isn't the baby cute?", "Eh, baby shmaby"
"Come buy from my store, we ... |
Characters in strings are sometimes represented as their ASCII hexadecimal codes. Printable characters have two hex digits in their representation. Swapping those digits leads to another character, which will be our output.
The table of relevant character codes can be found on Wikipedia.
Details
Take a string as input... |
The sequence of Fibonacci numbers is defined as follows:
\$
F_0 = 0 \\
F_1 = 1 \\
F_n = F_{n-1} + F_{n-2}
\$
Given a Fibonacci number, return the previous Fibonacci number in the sequence. You do not need to handle the inputs \$ 0 \$ or \$ 1 \$, nor any non-Fibonacci numbers.
Errors as a result of floating point inaccu... |
We can arrange the positive integers like this:
1_| 2 | 5 | 10
4___3_| 6 | 11
9___8___7_| 12
16 15 14 13
That is, in L-shaped brackets expanding down and right infinitely.
Then, we can read it off with the antidiagonals:
1 2 5 10
/ / /
4 3 6 11
/ / /
9 8 7 12
/ / /
16 15 14 13
For the above, we rea... |
In this question I asked you to determine if a run ascending list could be made. It was code-golf so naturally most the answers are very slow. But what if we want it to be fast. In this challenge I ask you to solve the same task except your goal will be to minimize asymptotic time complexity.
Here's the challenge re... |
You are given 100 arrays/sets of 5-8 numbers between 1-20. If you combine all the arrays you will always get at least one of each number (1-20), so don't worry about an "unsolvable" case. The goal is to find the combination of arrays that minimizes duplicate numbers while still getting one of each number from 1-20.
Her... |
PROBLEM
For a list of numbers, list: Find the lowest possible integer, x, which is optimally close to the whole number even-harmonics of the values in list.
list has a length of n, and all of the values in list are <= 2000
x has a precision of 1.0 (integers only), and must be a value in the range [20, 100]
An even-har... |
Uilta is a minority tungusic language spoken in the far east of Russia.
A neat thing about Uilta is that it has pitch accent which can be predicted by a computer program. In this challenge we are going to take Uilta a word and determine where the accent peak is.
Let me explain how this can be done.
Phonemes
The first ... |
Whyte Notation is a classification method mainly for steam locomotive, that classifies by wheel arrangement. On a steam locomotive ( we're only focusing on non articulated locomotives here ), the wheels are generally disposed like this : you have a specific number of leading wheels, then a specific number of driver whe... |
Given a positive integer n, randomly output n non negative integers that sum to one hundred. n will be at most 200. The output should be present as a list of integers (not sorted).
Your random sample should be uniformly sampled from all lists of n non negative integers that sum to one hundred.
Your code should run in a... |
Intro
Imagine a list of elements and their outcomes when some non-commutative function is applied to them. For example, we will use the elements Rock, Paper, and Scissors, the outcomes Win, Lose, and Tie, and an operator * such that X*Y = what would happen if you played X against Y
As a list, you might write it this wa... |
Inspired/mostly copied but I don't think it's a dupe. Also Inspired.
In this challenge, you will create polyglots that include all languages from previous answers, and another language which you won't share and others must guess.
The first language prints 1, the second prints 2, etcetera.
For example, if the first answ... |
The Narrative
You are a bad musician. You never bothered to learn how to count rhythms. To remedy this shortcoming, you decide to write a program that will tell you how to count in any given time signature. You are still a bad musician, but you can at least pretend that you can count rhythms.
The Objective
Given a time... |
This challenge requires integration with C, so you can stop reading if you're not interested.
Matrix multiplication is a simple operation, but the performance depends a lot on how efficiently the code is written.
Let's compute m = x * y. The following code is the implementation of the textbook algorithm.
for (int i = 0... |
The "standard" polyhedral game dice have 4, 6, 8, 10, 12 and 20 sides. (Yes, I know that there are two 10-sided dice which together make a d100, but we're ignoring that right now.)
If I want to generate a random number between 1 and \$n\$ where \$n\$ is not one of those sides, I have a couple of options.
One option is ... |
Your challenge, should you choose to accept it, is to take as input:
A program in DirectionLang (as an ASCII string consisting of DirectionLang instructions)
A list of pairs of integers, henceforth known as the pretty places. This list may be taken in any reasonable format.
You should then output a truthy value if th... |
Given a word, decide if it is an ambigram.
When rotated:
b > q
d > p
l > l
n > u
o > o
p > d
q > b
s > s
u > n
x > x
z > z
Assume only lowercase letters as input.
Test input:
this,
another,
lll,
lol,
dad,
dab,
dap,
wow,
ooi,
lollpopdodllol,
Ones That Should Return Truthy Values:
lll,
lol,
lollpopdodllol,
Note tha... |
Problem
Assume you have a single 7-segment display without a decimal point, so 7 "lines" that can be labelled A through G as seen here.
This display will only show the numbers from 0 to 9 as usual, like so:
Any time this display changes from one number to another, some of its lights will have to change their state fr... |
Take as input an integer in any reasonable format.
Then, output all the proper sub-strings of the base-10 digits of that integer that are powers of two, in any reasonable format.
Test cases
10230 -> [1, 2]
13248 -> [32, 1, 2, 4, 8]
333 -> []
331 -> [1]
32 -> [2] # As 32 is not a proper sub-string, since it is the whole... |
J-uby is the Language of the Month for June 2022, so I'm looking for tips for golfing in it. As usual, please post one tip per answer, and avoid general tips such as "remove whitespace" or "avoid comments".
|
An alternating permutation is a permutation of the first \$ n \$ integers \$ \{ 1 ... n \} \$, such that adjacent pairs of values in the permutation alternate between increasing and decreasing (or vice versa).
Equivalently, it is a permutation where there are no "runs" of continuously increasing or decreasing values wi... |
Introduction
Time is a really simple concept. Seconds pass, one after the other, all the same. But humans love making it hard. This Stackoverflow question has gathered many answers and even though they are surprisingly long and complex, most of them will still fail for certain inputs. Can you format a number of seconds... |
Challenge
In this challenge, you have to fill an \$M\$ x \$N\$ rectangle grid with the most \$A\$ x \$B\$ rectangle pieces possible.
Requirements:
The sizes of the \$M\$ x \$N\$ rectangle grid is always bigger than the sizes of the \$A\$ x \$B\$ rectangle pieces. In other words, \$min(M, N) ≥ max(A, B)\$
You can freel... |
Robber's challenge
This cops-and-robbers challenge challenges the Cop to write a non-empty program that, when run, produces some non-empty output in language A, and, when reversed, produces some non-empty output in language B. The program may produce any output to STDERR when run in either language, but may not take in... |
Cops' challenge
This cops-and-robbers challenge challenges the Cop to write a non-empty program that, when run, produces some non-empty output in language A, and, when reversed, produces some non-empty output in language B. The program may produce any output to STDERR when run in either language, but may not take input... |
For this challenge a "binary tree" is a rooted tree where each node has 0 children (leaf) or 2. The children of a node are unordered, meaning that while you might draw the tree with left and right children there isn't a distinction between them and mirroring the tree or a sub-tree does not produce a new tree.
In this... |
aka. implement an easier version of 05ab1e's canvas element.
Description
The canvas element is used to draw ASCII lines on the screen.
The (easier version of the) canvas element takes a list of integers and returns a multi-line string (or a list of strings).
The integers map to the following directions:
7 0 1
↖ ↑... |
Lists can contain lists and we have nested lists. But we don't like nested lists and want to flatten them. By flattening I mean create a list which does not contain any list, but elements of lists it contained before. I'll explain it more.
Input
An arbitrary size list which has the below properties:
it can contain int... |
Given an integer \$N\$ consider a permutation \$p=p_1,p_2,p_3,\ldots\$ of \$1,\ldots,N-1\$. Let \$P = p_1 , p_1+p_2 \bmod N, p_1+p_2+p_3 \bmod N, \ldots\$ be its prefix sums modulo \$N\$. Sometimes \$P\$ will be a permutation of \$1,\ldots,N-1\$ itself.
For example, \$N=4: p=3,2,1 \rightarrow P=3,1,2\$
Negative example... |
The Mongolian language has "vowel harmony". In short the vowel harmony means that certain vowels are not allowed to be placed next to each other in a word. This means that suffixes of words have to care about the vowels present in the words they attach to and need to resolve to a vowel that matches the harmony of the... |
Related, but not dupe.
Challenge
A list of integers \$a_1, a_2, a_3, \dots, a_n\$ (\$ n ≥ 1 \$) is Fibonacci-like if \$a_i = a_{i-1} + a_{i-2}\$ for every \$i > 2\$. Note that every list that contains only 1 or 2 integers is Fibonacci-like.
For example, \$[1]\$, \$[6, 9]\$, \$[6, -4, 2, -2, 0, -2, -2, -4, -6, -10]\$, ... |
Given a list of positive integers such as [69, 420], your challenge is to generate the sequence of numbers that can be formed by concatenating numbers from the above set, in ascending numerical order.
For example, with [69, 420] the sequence begins:
69
420
6969
42069
69420
420420
Note that elements of the sequence sho... |
I have a set of colored plastic cups. They come in four colors: green, yellow, pink, and blue. When I put them on my shelf, I like to stack them in a certain pattern. Your job is, given a list of any number of four distinct values (to represent the four cup colors), output a visual representation of how I would stack t... |
Write a program or function which takes a string of text as input and outputs the number of non-alphabetical characters in it (standard I/O rules apply). A non-alphabetical character is any character not appearing in this string:
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
In terms of ASCII character codes, t... |
Today, you're going to be writing Polish. No, not Polish notation—Polish, the actual language spoken in Poland.
Given a number and a noun, output a Polish sentence telling me that there are that many of that thing, using the appropriate template below.
The input consists of an integer in the range from 0 to 200, and a ... |
Parenthetical names
Your challenge is to build a program that puts parentheses around the 'title' part of names. For example, Sonic the Hedgehog is converted to Sonic (the Hedgehog).
Rules:
Around every the that passes the following rules, an opening parentheses will be added before the the and a corresponding closing... |
Given a non-negative integer n, print the result of P(P(...P({}))), where the number of P's is n (P is the power set function).
0 => {}
1 => P({})
2 => P(P({}))
3 => P(P(P({})))
n => P(f(n-1))
input result
0 {}
1 {{}}
2 {{},{{}}}
3 {{},{{}},{{{}}},{{},{{}}}}
...
The result should only contai... |
This is a cross-post of a problem I posted to anarchy golf: http://golf.shinh.org/p.rb?tails
Given two integers \$ n \$ and \$ k \$ \$ (0 \le k \le n) \$, count the number of combinations of \$ n \$ coin tosses with at least \$ k \$ tails in a row.
For example, if \$ n = 3 \$ and \$ k = 2 \$, the answer is \$ 3 \$:
HHH... |
In this king-of-the-hill challenge, you will program a bot, consisting of a python function of the form
def BOTNAME(info, me, round):
pass # ... main body
Specifically, the function must run in python3.9. Each bot will be entered into the contest 10 times.
The arguments it take in are info, me, round. The three ar... |
Let \$Z\$ be either the integers, the positive integers, or the non-zero integers; pick whatever's convenient. Give two functions \$f\$ and \$g\$, each \$Z \to Z\$, such that:
\$f(g(a)) = g(f(a))\$, for infinitely many integers \$a\$, and
\$f(g(b)) \ne g(f(b))\$, for infinitely many integers \$b\$.
Rules
Many of the ... |
Given a multi-dimensional rectangular array of non-negative integers, pad it with the minimal number of zeroes so that only zeroes are "touching the edges" of the array, in every dimension.
The output must remain rectangular, have the same number of dimensions as the input, and be no smaller than the input.
Example
For... |
In this challenge you will be simulating a frog jumping from lily-pad to lily-pad in a pond. A frog's jump distance is uniquely determined by the size of the lily pad it jumps from. So for example there are lily-pads that let a frog jump 1 unit, lily-pads that let a frog jump 2 units etc. A frog can never jump more ... |
Introduction
A circle-tangent polynomial is a polynomial of degree \$N\ge3\$ or above that is tangent to the unit circle from inside at all of its N-1 intersection points. The two tails that exits the circle are considered tangent at their intersection points from inside as well. You may consider such polynomials are w... |
Say I have a ragged list, like:
[
[1, 2],
[3,
[4, 5]
]
]
And I want to iterate over each item and delete it one-by-one. However, I don't know the structure of the list.
So, I have to iterate over the list, with the following algorithm:
Look at the first item of the list.
If it's a list, concatenate it to t... |
Plot contrivance
You wake up to find that something has gone horribly wrong! Your time machine has malfunctioned and you are lost sometime between June 2022 and October 1991.
You check the computer that you keep on the desk to see what time it is, but alas the positron interference from your quantum undetangler has fr... |
This is my 12th question, so I thought of this idea.
Goal:
Output 12, with any preceding or trailing whitespace permitted
In as many languages as possible (where different versions or flags count as the same language)
Without using any numbers
The criteria for a valid programming language are the same as those of The ... |
Let us consider the following representation of the periodic table.
__________________________________________________________________________
| | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|--------------------------------------------------------------------------|
|1| 1... |
Given a string like [[[],[[]]],[]], made of only commas and square brackets, your challenge is to determine whether it represents a list.
A list is either:
[], the empty list
At least one list, joined with commas and wrapped in square brackets.
You may use any three characters instead of [,].
You may output as:
Any ... |
In set theory, a set is an unordered group of unique elements. A pure set is either the empty set \$\{\}\$ or a set containing only pure sets, like \$\{\{\},\{\{\}\}\}\$.
Your challenge is to write a program that enumerates all pure sets, in some order of your choice. Standard sequence rules apply - you may:
Output al... |
Unsurprisingly, fibonacci primes are primes that are also Fibonacci numbers. There are currently 34 known Fibonacci primes and an additional 15 probable Fibonacci primes. For the purpose of this challenge, the Fibonacci numbers are the sequence \$F_n\$ defined as \$F_1 = 1\$, \$F_2 = 1\$, and \$F_n = F_{n-1} + F_{n-2}\... |
A binary max heap is a rooted tree with integer labeled nodes such that:
No node has more than 2 children.
The label of every node is greater than all of its children.
We say a sequence of integers is heapable if there exists a binary max heap, whose labels are the sequence's elements, such that if \$p\$ is the paren... |
Inspired by wezl.
Your challenge is to take words (sequences of [a-zA-Z]) and truncate them to length 3. For example, never gonna give you up would become nev gon giv you up.
Words will not necessarly be delimited by spaces - for example, youtube.com/watch?v=dQw4w9WgXcQ will become you.com/wat?v=dQw4w9WgX. Input will b... |
Given a multidimensional, rectangular array and a list of dimensions, such as:
[ [1, 2],
[3, 4] ]
[3, 4]
Your challenge is to extend the matrix to the dimensions given in the list.
To extend an array to a length in a single direction, simply repeat its elements; for example, if we want to extend [1, 2, 3] to length... |
To increase data safety at our company, we are planning to start using Gray code numbers (where successive values differ by only one bit) instead of classical binary ones.
Please help us to make a program that converts numbers to Gray code (single number to single number), but the program needs to be safe as well. This... |
Background
In the online graphing calculator Desmos, there is a certain shape that appears in the lower left portion of the graph in many high detail graphs, which the Desmos community has dubbed "Bernard". You can see an example of it in this graph and an isolated version of it in this graph. This shape is a consequen... |
There are a bunch of different casing conventions, like camelCase, PascalCase, snake_case etc. It's annoying juggling all of these, so instead of choosing one like a sensible person, why not cursedly mix all of them together?
Your challenge is to, given a list of words (only containing lowercase letters), convert them ... |
I have recently been on a quest to create really really slow sorting algorithms that make Bogosort seem like it is the best.
The task is simple: Sort an array of integers in as long average time as possible, with the average Bachmann–Landau notation begin as high as possible, while keeping the best case performance fas... |
Given \$a\$ and \$b\$, both odd \$n+1\$-bit integers, compute \$a/b\$ to a precision of \$n+1\$ bits in the 2-adic integers. That is, compute \$c\$ such that \$a = bc\, (\mathop{\rm mod} 2^{n+1})\$. \$n\$ should be your language's native integer size, or if native integers are bigints, take it as a parameter. If your l... |
This is a simpler variant of my previous challenge Don't touch the walls!, as suggested by Jonah.
Given a multi-dimensional rectangular array of integers between 0 and 9, output all the elements which are "touching the edges".
Output is very flexible: it can be in any order, and may be flattened or partially nested, bu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.