instruction stringlengths 34 53.1k |
|---|
"All roads lead to Rome" is a saying that essentially means there are plenty of different ways of achieving an objective.
Task
Your task is to write a program that finds a set of link connections from one Wikipedia page to the Wikipedia page about Rome.
Notice that it is not enough to find the word Rome with a hyperlin... |
Introduction
The \$n\$-ellipse is a generalization of the ellipse with possibly more than two foci. Specifically, given \$n\$ points on the plane, called foci, the \$n\$-ellipse is the set of points of the plane whose sum of distances to the \$n\$ foci is equal to a constant \$t\$.
This challenge is about plotting the ... |
Given a strictly positive integer n (therefore 0 isn't a valid test case), produce an approximate triangle of height n.
A non-programmatic process of drawing the picture
Initially we start with the base of the triangle.
|
So, we want to draw a triangle of a height of 5. First we know that all the |'s align on a straig... |
Task
Your task is to take a character in:
AÁÀÃÂBCÇDEÉÊFGHIÍJKLMNOÕÓÔPQRSTUÚVWXYZaáàãâbcçdeéêfghiíjklmnoõóôpqrstuúvwxyz
and turn it into a characters in:
AAAAABCCDEEEFGHIIJKLMNOOOOPQRSTUUVWXYZaaaaabccdeeefghiijklmnoooopqrstuuvwxyz
by the obvious operation: dropping the accents in the letters.
Input
A character in any se... |
Miller-Rabin test
Given a base \$b\$ and an odd number \$n\$:
Write \$n\$ as \$2^{s}\times d + 1\$ where \$d\$ is odd
\$n\$ is a strong probable prime if either:
\$b^d\equiv 1 \pmod n\$
\$b^{d\cdot2^r}\equiv -1 \pmod n\$
for any non-negative \$r\$ strictly less than \$s\$.
A strong probable prime which is composite ... |
Sometimes I make bad jokes... And a bad joke I like to make involves interpreting exclamation marks in sentences as the factorial sign.
Task
Your task is to write a program that receives a sentence and applies the factorial joke to the sentence.
The "factorial joke" consists of looking for exclamation marks "!" and doi... |
Task
Given an integer matrix M and a modulus m, find an inverse of M modulo m. If the matrix M is not invertible modulo m, the behaviour is left unspecified.
Matrix inverse
If M is a square matrix, its inverse exists if and only if its determinant is not 0. Similarly, when we are talking about matrices modulo m, the in... |
I'm recieving 2-dimensional positions of two objects as a string with this format: x1,y1,x2,y2. The string is recieved from a readline call (replaced in the snippet with a prompt).
In order to get the horizontal and vertical position differentials, I'm writing the following code:
[x1,y1,x2,y2]=prompt("Please enter th... |
My robot for generating Mad Libs-style sequence challenges has gone rogue! To defeat it, I need you to write code that can solve all the challenges it can crank out.
Your input is three selections for the blanks A, B, C, each from (1,2,3), specifying the sequence challenge to solve, and the number \$n\$ that's the inpu... |
Write the shortest program that prints, in order, a complete list of iPhone iterations, according to this site:
iPhone
iPhone 3G
iPhone 3GS
iPhone 4
iPhone 4S
iPhone 5
iPhone 5c
iPhone 5s
iPhone 6
iPhone 6 Plus
iPhone 6s
iPhone 6s Plus
iPhone SE
iPhone 7
iPhone 7 Plus
iPhone 8
iPhone 8 Plus
iPhone X
iPhone XR
iPhone XS... |
Challenge
You will be given a string as an argument. You need to convert that string to upper case. But you can't use any built in method or function nor any external programs.
Rule
No use of built in methods or functions or external programs. Only arithmetic, bitwise, logical operators, regex, replace, split, join, A... |
She said s(he) be(lie)ve(d), he said sbeve.
Input
A non-empty string, s. It's guaranteed that s will have only printable ASCII characters and at least one word (defined as [A-Za-z0-9]+) in parentheses, and all parentheses will be closed respectively.
Output
A string containing all non-whitespace characters (whitespa... |
Correct a single-letter typo in a fixed text.
Input: The paragraph below but with exactly one typo, where a single letter a-zA-Z is replaced by a different letter a-zA-Z. To be clear, the letter isn't replaced everywhere it appears, but just in that one place. For example, the first word "In" might become "IZ". Non-let... |
Background
In JIS X 0208 a 94 by 94 map (kuten (区点)) is defined to encode Chinese characters (kanji), phonetic moras (kana) and other symbols. Along with this standard there are 3 different encodings that maintain 1-1 correspondences with the map, namely JIS, Shift_JIS and EUC. These encodings take 2 bytes for each cha... |
Write a program or function that fulfills the following
Scores less than 101 bytes under normal code-golf rules
Takes no input1 and always outputs a single integer.
Every integer is a possible output.
Your score will be the probability of the most frequent integer occurring, with a lower scoring being the goal. That... |
There are 5 different "special characters": % & # $ !
These special characters are in a string with numbers. Like so: "5 ! 60%2$5.3" (valid). You must determine the validity of the string and there are certain rules in order to determine validity of the string.
Rules:
These special characters can exist in a string... |
In this challenge you will take a an ascii art image of a highway like so
| | | | | |
| | | |
| | | | | |
| | | |
| | | | | |
| | | |
| | | | | |
And you need to put rain across its lanes like so
|\\\|\\\| |\\|\\|
|\\\\\\\| |\\\\\|
|\\\|\\\| |\\... |
This is a simple game of getting rid of those damn numbers.
You start with the numbers from 1 to 19, written in a grid of 9 by 3:
1 2 3 4 5 6 7 8 9
1 1 1 2 1 3 1 4 1
5 1 6 1 7 1 8 1 9
You may notice that the number 10 is missing, this because the number zero would be hard to get rid of later on.
The two rules are:
I... |
Task
Given a set of n unique elements and a multiset l of positive numbers that add up to n, find all the ways of partitioning those unique elements into disjoint sets with sizes given by the elements of l.
(A multiset is a set that allows repeated elements)
The point here is that we are taking everything in the output... |
There are 10 types of people in the world, those who understand binary and those who do not.
Where are you? Let's see!
Challenge
Your task is to convert a decimal integer to binary, only using a set of arithmetic operators (+, -, *, / and %). You can use conditional statements, loops and variables. (No bitwise operator... |
This challenge initially appeared in this challenge as a an extra brain teaser. I am posting it with permission from the original author so that we can have a formal competition.
Your task here will be to implement a function1 that forms a permutation on the positive integers. This means that each positive integer ... |
[Question inspired by Can you calculate the average Levenshtein distance exactly? . Thank you Anush. ]
The longest common substring between two strings is the longest substring which is common to both. Please note this is not the same as the longest common subsequence whose fastest algorithm takes quadratic time.
The ... |
You have a square board with a bunch of items laid out on it in one of a \$3 \times 3\$ grid of cells and you want to lift it up using balloons, but you can only attach balloons to the corners of the board. Your task is to determine the minimum number of balloons in each corner to make sure the board won't tip over in ... |
Given an positive integer n (including 0 if you decide to support it), output all numbers in the generated sequence up to the index n. For the current test cases of the current challenge numbers are one-indexed. Feel free to submit 0-indexed answers though.
Base sequence
We start from this sequence (NOT, but quite simi... |
Task
Given a input string s which contains only printable ascii characters output all strings which contain only printable ascii characters and are strictly smaller than s in any order
String a is strictly smaller than a string b if either of the following is true:
len(a) < len(b)
len(a) == len(b) and string a is lexi... |
Inspiring myself on a recent challenge, we ought to compute a sequence that is very close to A160242.
Task
Your task is to generate the sequence \$ \{s_i\}_{i=0}^\infty \$:
1, 2, 1, 1, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, ...
Which is more easily understandable in this format:
1 2 1
1 2... |
Your task is to write a program or function that takes as input a list of positive integers and determines if there are any two integers in the list, that both appear the same number of times.
For example the list
[1, 2, 3, 2]
Has one 1 and one 3 so it satisfies the condition.
But the list
[3, 2, 2, 1, 2, 3]
does not... |
I am quite proficient in C++ and Java and want to learn competitive programming to participate in contests like Google codejam and other online contests held on sites like CodeChef and Codeforces. I would like to get information about any free resources including websites and courses to learn the "sport". Book suggesti... |
This challenge like some of my previous challenges will have you counting free polyforms, which are generalizations of Tetris pieces.
This code-golf challenge will have you count polyomino-like polyforms on hypercubes. In particular, this challenge is to write a program that takes in three parameters:
n, which represe... |
We know that not all fractions have a terminating binary representation. However every fraction can be written as a leading portion followed by a repeating portion. For example \$1/3\$ starts with \$0.\$ and then just repeats \$01\$ endlessly. This corresponds to the bar notation taught in primary school. For examp... |
Note: Bot Factory KoTH (2.0) is now posted; you're probably looking for that one instead!
In this challenge, bots (consisting of JS functions) move around an infinite factory (playing field), collecting characters (UTF-16). These characters can be used to build worker bots, or droppedfor other bots to pick up.
Results
... |
The system
Assume the Earth is flat and that it extends infinitely in all directions. Now assume we have one infinitely long train railway and n trains in that railway. All trains have different speeds and all trains are going in the same direction. When a faster train reaches a slower train, the two trains connect (be... |
Background
Binary Sudoku, also known as Takuzu, Binario, and Tic-Tac-Logic, is a puzzle where the objective is to fill a rectangular grid with two symbols (0s and 1s for this challenge) under the following constraints:
Each row/column cannot have a substring of 000 or 111, i.e. one symbol cannot appear three times in ... |
Challenge
Your task is to generate a string using this sequence:
1,1,2,1,1,2,3,2,1,1,3,2,4,2,3,1,....
Which is more understandable in this format:
1
1 2 1
1 2 3 2 1
1 3 2 4 2 3 1
1 4 3 2 5 2 3 4 1
The pattern increases the number of Digits in the string by two for each increment in the Value of N
For each integer val... |
Challenge
Your goal is to write a function that puts quotes around a sequence of capital letters in a string.
So some examples (everything on the left (before function) and right (after function) are STRINGS):
Hello the name's John Cena -> "H"ello the name's "J"ohn "C"ena
I got BIG OLD truck -> "I" got "BIG" "OLD" truc... |
Challenge
Print the numbers:
1
22
333
4444
55555
666666
7777777
88888888
999999999
In that order.
I/O
Takes no input. The numbers can have any delimiters desired (or none). That includes lists, cell arrays, .jpeg, etc.... Example outputs:
122333444455555666666777777788888888999999999
[1,22,333,4444,55555,666666,77777... |
This challenge is inspired by @LuisMendo's MATL answer to my "binary multiples" challenge.
Task
Pick a code-golf challenge that is open and that has been posted before this one; let me call it the "linked challenge". The linked challenge must be a challenge whose task involves producing output.
Write the shortest code ... |
This code-golf challenge will have you computing OEIS sequence A300154.
Consider a spiral on an infinite hexagonal grid. a(n) is the number of cells in the part of the spiral from 1st to n-th cell that are on the same [row*] or diagonal (in any of three directions) as the n-th cell along the spiral, including that cel... |
Here are the first 100 numbers of a sequence:
1,2,33,4,55,66,777,8,99,11,111,12,133,141,1515,1,11,18,191,22,222,222,2232,24,252,266,2772,282,2922,3030,31313,3,33,33,335,36,377,383,3939,44,441,444,4443,444,4455,4464,44747,48,499,505,5151,522,5333,5445,55555,565,5757,5855,59559,6060,61611,62626,636363,6,66,66,676,66,666,... |
Identify each letter of the English alphabet with the number denoting its position in the alphabet, that is,
a = 1, b = 2, c = 3, ..., z = 26
(no distinction between lower and upper case letters is made). Every other character is identified with 0.
The "sum" of a word is the sum of its characters, for example: the su... |
Introduction
The current coronavirus disease is officially named COVID-19, from the 3 words corona virus disease, and the year 2019. (Technically it's coronavirus, making 2 words, but whatever...)
Given this example, we can apply this naming convention to name other potential diseases.
Challenge
You will be given 3 wor... |
In this challenge, bots must survive as long as possible. In each turn, the bot with the most HP is eliminated.
This challenge is inspired by the Smallest unique number KoTH.
Results
After 100,000 rounds:
Jack: 63390
The Follower: 4942
The Algorithm: 2452
The Randomiser: 140
Toe Tipping: 0
EZ: 0
The Average: 0
LowProfi... |
Goal
Write a program or function that returns the day of the week for a date, eg.
01/06/2020 -> Mon
However, it's unknown if the date is in the format mm/dd/yyyy or dd/mm/yyyy. If you can be certain of the day of the week, return it. If there is uncertainty, return an error.
02/07/2020 -> Err (Thu? Fri?)
Input... |
Pure data is a graphical programming language designed for audio processing. This makes it unsuitable for most general programming but especially unsuitable for code-golf.
It would then be nice to have a tips question so that people can get a first foot up in this language.
What tips are there for golfing in Pure Data... |
Symja is a "computer algebra language & Java symbolic math library for Android NCalc calculator". It's a fun little language, so I'm wondering if y'all have any tips for golfing in Symja.
As per usual, "remove comments", etc, isn't really an answer. It turns out that there is no comment system in Symja, so "remove com... |
Context
When I was a little kid, I watched a Disney movie where Goofy told his son "Boy, even a broken clock is right two or three times a day." (see this youtube clip, courtesy of @Arnauld).
Rationale
Given the previous statement, we wish to look at a clock that is stopped and answer the following question: is this cl... |
Let's consider the sequence of the binary representation of positive integers (without any leading zero):
1 2 3 4 5 6 7 8 9 10 11 12 ...
1 10 11 100 101 110 111 1000 1001 1010 1011 1100 ...
If we join them together, we get:
1101110010111011110001001101010111100 ...
If we now look for the pattern... |
A directed graph G is given with Vertices V and Edges E, representing train stations and unidirectional train routes respectively.
Trains of different train numbers move in between pairs of Vertices in a single direction.
Vertices of G are connected with one another through trains with allotted train numbers.
A hop is ... |
Natural numbers ≡ \$\mathbb{N}≡\{0,1,2,...\}\$
The submission can be either a program or a function, both cases will henceforth be referred to as "function".
The task is to golf the shortest function \$\mathbb{N}^n→\mathbb{N}\$, i.e. a function that maps \$n\$ natural numbers (with \$n>0\$ being a number of your choosi... |
In the shortest amount of code in any programming language, filter out the duplicate items in an array of which the order is irrelevant.
Here are some test cases:
[1, 2, 2, 3, 1, 2, 4] => [1, 2, 3, 4]
['a', 'a', 'b', 'a', 'c', 'a', 'd'] => ['a', 'b', 'c', 'd']
I also should note that there currently aren't any open q... |
Context
The water buckets riddle or the water jugs riddle is a simple riddle that can be enunciated in a rather general form as:
Given \$n > 0\$ positive integers \$a_1, a_2, \cdots, a_n\$ representing the capacities (in units of volume) of \$n\$ buckets and a positive integer \$t \leq \max(a_1, a_2, \cdots, a_n)\$, fi... |
Sequel of Counting valid Binary Sudoku rows.
Background
Binary Sudoku, also known as Takuzu, Binario, and Tic-Tac-Logic, is a puzzle where the objective is to fill a rectangular grid with two symbols (0s and 1s for this challenge) under the following constraints:
Each row/column cannot have a substring of 000 or 111, ... |
Challenge
You will be given a string that can contain lowercase letters, uppercase letters, or spaces. You have to turn the vowels (a, e, i, o, u) in the string to upper case and consonants to lower case. This applies whether or not the letter was originally upper case or lower case. Spaces remain as is. Note that "y" ... |
Given N integers, output the sum of those integers.
Input
You may take the integers in any reasonable format, including:
stdin
arguments
an array or list
Rules
Your code must not include the characters + or -.
Standard loopholes apply. Take note of Abusing native number types to trivialize a problem.
This is code-... |
Objective
Simulate an edge-triggered D Flip-Flop.
What is D Flip-Flop?
A D flip-flop is an electronic digital device that outputs an inputted data (abbr. D) with synchronization to a clock (abbr. CLK). Usually CLK is a uniform pulse, but in this challenge, CLK may be not uniform.
Input
A bitstring with length \$n\$ wil... |
Given a string as an input (which can be any acceptable/convenient format in your language), implement pendulum encoding. The test cases are split into individual items (which aren't quoted) for a visually appealing explanation.
How do I do that?
The current iteration index starts at 0.
If the iteration index is even,... |
Submit a well-formed program or function with usual I/O rules which satisfy the input, output, and algorithm conditions below. Shortest submission (in bytes) wins. As always, standard loopholes are forbidden.
In short: Two distinct 8-bit integer inputs must produce two 8-bit integer outputs so that all four numbers are... |
Task
Your task is to make the smallest function/program that can, when gives an number N, return/print:
the number of possible choices a, b such that \$1 \leq a < b < N\$ and a and b have exactly one common digit in base 10 (there exists a digit, and only one digit, which appears both in a and b, for example 12 and 23,... |
Setup
Take the following 4x4x4 cube along with a 2D view of 3 of its faces, with a common 1x1x1 cube highlighted:
The arrows represent the points of view that generated the V1, V2 and V3 faces drawn underneath the big cube.
Given an arrangement of some 1x1x1 cubes inside the main cube we can try and identify it with o... |
Construct a full program which outputs Hello, World!. The score of your submission will be equal to the sum of all of the ASCII values of the distinct characters. The lowest score wins!
Rules
It must be a full program which takes no input
It must only print to STDOUT, nothing else
It must be strictly less than 1000 by... |
Given required values for an expression with 2 variables, output a short expression which fulfill these values
Input
You may take the input in any reasonable format, e.g. f(x,y)=z, {(x, y): z}, [[[x,y],z]], but please write what format is your input is taken in
Output
Your output needs the be a valid infix expression f... |
Chef Avillez is about to cook us some really nice meal. He is just waiting for us to give him some ingredients and to request a meal.
Task
Given a list of ingredients (strings matching /[a-z]+/) and a requested meal (string matching /[a-z][a-z ]*/) output the integer amount of meals Chef Avillez can make.
Algorithm
Eac... |
Task
Your task is to draw these beautiful oak trees:
1 ->
@@@
@@@@@
@|.|@
_|_|_
2 ->
@@
@@@@@@
@@@@@@@@
@@| .|@@
| |
__|__|__
3 ->
@@@@@
@@@@@@@@@
@@@@@@@@@@@
@@@| |@@@
@| .|@
| |
___|___|___
4 ->
@@
@@@@@@@@
@@@@@@@@@@@@
@@@@@@@@@@@@@@
@@@@| |@@@@
@@| .|@@
| |
| ... |
Task
Write a function/full program that will be able to produce two different sequences of integers in [0, ..., 9]. You will take an input seed to decide whether to output your specific sequence or the common one. For that matter, you must choose one non-negative integer, let us call it k. When the input seed is equal ... |
In this challenge, all bots are wizards. At the beginning of each round, they create a wand which has a certain chance of successfully stunning another wizard. They then fight, by choosing one bot to attack in each turn. The last bot remaining wins.
Results
500 games, 1000 rounds each
Revenge!: 132101.68886125216
JustE... |
This challenge is inspired by Fortran's idiosyncratic implicit typing rules. Your task will be to determine the data type of the object GOD according to the implicit typing rules explained below.
Background
Fortran 77 has six data types: CHARACTER, COMPLEX, DOUBLE PRECISION, INTEGER, LOGICAL, and REAL. Any object not e... |
Objective
Given a dimension of an SI unit, convert the Lorentz-Heaviside version of a Planck unit \$1\$ into SI metric.
What is a Planck unit?
Planck units are a set of units of measurement. It defines five fundamental constants of the universe as dimensionless \$1\$.
What is a dimension?
There are five types of fundam... |
(yes, "generating generating" in the title is correct :) )
Context
In middle (?) school we are taught about sequences and, in particular, we are taught about linear sequences where the nth term is generated with an expression of the form an + b, where a and b are some coefficients. In this challenge, we will deal with ... |
Given a compressed string \$s\$ made of printable ASCII characters (32 to 126), your task is to print or return the original text by applying this simple decompression algorithm:
Start with \$k=0\$
Look for the first occurrence of the digit \$k\$ in \$s\$ and the sub-string \$s'\$ consisting of the \$2\$ characters pr... |
Task
A date can be compactly represented in a 6-character string in the format ddmmyy where the first two characters (dd) represent a day, the 3rd and 4th characters (mm) represent a month and the last two characters (yy) represent a 20XX year. Given a string with 6 characters in [0-9] determine if it represents a vali... |
In this challenge, submissions will be programs or function which, when given an emoticon such as :-), :(, or :D, will rate their happiness from 0 to 3.
An emoticon will be one of the following:
:(: 0
:|: 1
:): 2
:D: 3
Emoticons may also have noses (a - after the :).
Test cases:
:( -> 0
:-| -> 1
:D -> 3
:-) -> 2
:|... |
Inspired by I reverse the source code, ...
Your task, if you wish to accept it, is to reverse text and mirror select characters. Yes, yes, I know. Very surprising.
Input
A string, stdin, an array of characters, or any other source of text. All characters of the input are guaranteed to be in the printable ASCII range (3... |
Objective
Given a nonempty multiset of Rock, Paper, and Scissors, output the winning figure according to the special rule.
Background
For a multiplayer RPS, if all three figures come out, usually it's considered a draw. But by that rule, the probability to draw would dramatically increase when there are many and many p... |
These are the classical puzzles:
You need to boil eggs for exactly 9 minutes, or else the visiting Duchess will complain, and you will lose your job as head chef.
But you have only 2 Hourglasses, one measures 7 minutes, and the other measures 4 minutes. How can you correctly measure 9 minutes?
(taken from here)
Let's... |
Task
A Rotate-Left-Double number in base \$n\$ is a number \$m\$, when its base-\$n\$ digits are rotated left once, equals \$2m\$. The base-\$n\$ representation of \$m\$ cannot have leading zeros.
One example in base 7 is the number 480, or \$1254_7\$. When rotated left once, the value becomes \$2541_7 = 960\$.
Given t... |
The edit distance between two strings is the minimum number of single character insertions, deletions and substitutions needed to transform one string into the other.
This task is simply to write code that determines if two strings have edit distance exactly 2 from each other. The twist is that your code must run in l... |
As input you will receive
An integer \$a\$
A list of integers that is infinite and strictly-monotonic1.
Your program should check in finite time if \$a\$ appears the list.
You should output one of two distinct values. One if \$a\$ appears in the list and the other if \$a\$ does not.
This is code-golf so answers wi... |
Objective
Given an Arabic string consisting of ISO/IEC 8859-6 Arabic letters (U+0621–063A, 0640–064A), decode it to Arabic Presentation Forms-B (U+FE70–FEFF).
Behavior of Arabic letters
ISO/IEC 8859-6 Arabic letters change their displayed form to letters in Arabic Presentation Forms-B, which are categorized to isolated... |
Write a program that takes in two non-negative integers S and N in that order. S represents the side length of a square grid of . characters. N represents the number of those .'s that need to be changed to x's. You may assume N is no greater than S squared.
Your program needs to output this S×S square of .'s and N x's ... |
The challenge
Make 2 programs which convert decimal to and from base 94, or a bidirectional program.
Base 94?
Base 94 is like any other base, but instead of 0 to 9 and letters, it uses ASCII characters 33 to 126. Not 127 because chr(127) is DEL. Not 32 because that's a space.
Examples
0 - ! or empty string
1 - "
93 - ~... |
For this challenge, submissions should be a program or function shaped like a right triangle, which produces a right triangle of the same size.
What is a right triangle?
For this challenge, a right triangle consists of 1 or more lines, each containing a number of characters (assume all non-newline characters are the sa... |
The challenge:
Given four coordinates, each in x y form, your job is to find out whether or not the given coordinates form a rectangle, and output a truthy/falsey.
Rules:
For the sake of simplicity, squares, lines (two identical pairs of coordinates) or dots (all four of the coordinates are the same) are all counted a... |
Introduction:
Although it seems challenges scored by least unique characters have been attempted, there are few which were well-received. I think it's a potentially interesting scoring criterion, as long as different languages aren't competing with each other (as with code golf).
Challenge:
Create a basic FizzBuzz prog... |
Task
For a given base \$n \ge 3\$, find the smallest positive integer \$m\$, when written in base \$n\$ and rotated right once, equals \$2m\$. The base-\$n\$ representation of \$m\$ cannot have leading zeroes.
The corresponding OEIS sequence is A087502, and its base-\$n\$ representation is A158877 (this one stops at \$... |
You can depict a triangular number, T(N), by writing one 1 on a line, then two 2's on the line below, then three 3's on the line below that, and so on until N N's. You end up with a triangle of T(N) numbers, hence the name.
For example, T(1) through T(5):
1
1
22
1
22
333
1
22
333
4444
1
22
333
4444
55555
To keep t... |
As we all know, most Pokemon are created by combining some English (or Japanese) words; these words are the Pokemon's "etymology." For example, "charmander" is "char" and "salamander" put together.
Your task is, given a Pokemon's etymology and number, output the original Pokemon name. A short answer will be able to com... |
The goal of this challenge is to extend the On-Line Encyclopedia of Integer Sequences (OEIS) sequence A038375.
Maximal number of spanning paths in tournament on n nodes.
A tournament on \$n\$ vertices is a directed graph where for each pair of vertices \$(v_i, v_j)\$ there is either a directed edge \$v_i \rightarrow ... |
We consider two integers to be similar if, when written in decimal, have the same length, and if we compare characters in any two positions for both decimal strings, the comparison results (less, equal or greater) must be the same in both strings.
Formally, for two number that can be written as decimal strings \$a_1a_2... |
Chat room: https://chat.stackexchange.com/rooms/106513/easter-bunny-challenge
Git repo: https://github.com/AJFaraday/easter_bunny_hunt
The garden is a 2-dimensional grid with 49 rows and 49 columns.
The Easter Bunny™️ is in the center of the garden, minding his own business, holding on to 100 Easter eggs. He'll hop awa... |
A prime number is a positive integer that has exactly two divisors 1 and the number itself. For example number 7 is a prime since it is divisible by 1 and 7. Number 1 is not a prime since it has only one divisor. Write a program or function that produces all even prime numbers.
This is a code golf challenge, shortest a... |
Let's say you have a stack, which at the start contains a b c in this order (a is on the top). You are given the required output stack, in any reasonable format (a list, a string, etc.), e.g. [a, c, b] (here a is on the top, below it c and below it b). You can also take the input reversed if you want, e.g. [b, c, a] wh... |
Your task is to create a program or function which randomly errors. Specifically, there must be a nonzero probability of erroring, but also a nonzero probability of running without error.
An error is anything that causes a program to terminate abnormally, such as dividing by zero or using an uninitialized variable. Thi... |
Here in Russia, we have a little-known card game with the name, when translated directly, means Rooster.
The cards used are two full 54-card decks of playing cards from 2 through aces, with jokers. The game for each player divides into two stages. In the first stage, each player has 14 cards dealt, and with those cards... |
The challenge today is to write a program that outputs a known proverb, Where there is a will, there is a way., that means if someone is determined to do something, he will find a way to accomplish it regardless of obstacles.
Output
It has to be exactly the same, including the space bar and punctuation and excluding th... |
Chat room: https://chat.stackexchange.com/rooms/106513/easter-bunny-challenge
Git repo: https://github.com/ajfaraday/easter_bunny_hunt
The garden is a 2-dimensional grid with 49 rows and 49 columns.
The Easter Bunny™️ is in the center of the garden, minding his own business, holding on to 100 Easter eggs.
Unfortunat... |
Here's an interview question I've seen on a few sites. People claim that an O(n) solution is possible, but I've been racking my brain these last 2 days and I couldn't come up with a solution, nor find one anywhere on the web.
Given an array of integers, find two disjoint, contiguous subarrays such that the absolute dif... |
A very simple challenge today. Output a truthy value whether the ASCII character (or it's code) supplied is a brainfuck instruction (one of +-,.<>[]), and a falsy value if it's a comment (everything else).
Input
+
#
<
>
.
P
,
Output
true
false
true
true
true
false
true
|
Inspired by this glove-themed 538 Riddler Express Puzzle.
Task
You are given a positive integer n, and a list A = [a_1, a_2, ..., a_k] of k distinct positive integers.
Then a restricted composition is an ordered list P = [p_1, p_2, ..., p_m] where each p_i is a (not necessarily distinct) member of A, and p_1 + p_2 + ..... |
Background
An Eisenstein integer is a complex number of the form \$ z = a + b\omega \$ where \$a, b\$ are integers and \$\omega\$ is the third root of unity \$\frac{1-\sqrt3i}{2}\$. The Eisenstein integers can be viewed as the triangular lattice points, as shown in the image below (from Wikipedia):
Following the trian... |
Surprised that we don't have a symmetric difference challenge yet.
Given two lists only containing positive integers, return all items among these two lists that aren't contained in both of the lists.
Rules
From the set definition:
A set is a collection of definite distinct items.
So you can assume the items in the ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.