instruction stringlengths 34 53.1k |
|---|
For example, how many adjacent swaps are at least needed to convert some string such as BVVKCV to one without any instances of VK?
Input-length of the string will be within the range 1 <= length <= 200.
VK will be hardcoded across all test cases.
Input string examples:
Input: VKVKVVVKVOVKVQKKKVVK
Output: 8
Input: VV... |
Sum-It is a language I created (quite late) for the Language Design Contest in TNB, for which the theme was "Range". Naturally I interpreted this as "Mountain Range" and created a language about mountains.
Sum-It code takes the form of several ASCII art mountains, using only the / and \ characters. The mountains are th... |
Given a word (or any sequence of letters) as input, you must interpolate between each letter such that each adjacent pair of letters in the result is also adjacent on a QWERTY keyboard, as if you typed the input by walking on a giant keyboard. For example, 'yes' might become 'ytres', 'cat' might become 'cxzawert'.
Rule... |
After all assignments are submitted, a dictionary is created that maps student number to the hash of their file.
This dictionary, or hashmap, or mapping (whatever your language calls it) will look as follows:
{100: "aabb", 104: "43a", 52: "00ab", 430: "aabb", 332: "43a"}
The key is the student number, and the value is ... |
Given a positive integer, output a truthy/falsy value as to whether the number can eat itself.
Rules
Leftmost is the head, rightmost is the tail
If the head is greater than or equal to the tail, the head eats the tail and the new head becomes their sum.
If \$sum \ge 10 \$ then the head is replaced by \$sum \mod 10\$.
\... |
Given some finite list, return a list of all its prefixes, including an empty list, in ascending order of their length.
(Basically implementing the Haskell function inits.)
Details
The input list contains numbers (or another type if more convenient).
The output must be a list of lists.
The submission can, but does not... |
Consider a string like:
a.push(c.push("a",["ad","bd",2,{"ard",duo}]).pop().replace(2,"tg").enc([3,{2,adf},"atr"],5)
Write a program that will verify whether a string is correctly bracketed. A correctly bracketed string can be defined as one in which all brackets are terminated (closed), and the inner brackets are term... |
Satisfying Rounding
You know when you're in science class, and asked to round to 2 sig figs, but your answer is 5.2501...? You should round to 5.3, but that's just so unsatisfying! By rounding to 5.3, you're off by a whole 0.05, which is a large amount compared to 0.1 (the place value you're rounding to)! So help me ro... |
Steganography hides a given message inside a given carrier, producing a package that does not look suspicious. For this challenge, you will write a program that takes an ASCII message and an ASCII carrier as input, and return or print a package that is identical to the carrier except characters corresponding to the mes... |
The challenge here is to take a string and output all its rotations, by repeatedly moving the first character to the end, once per character in the string, ending with the original string:
john -> ohnj, hnjo, njoh, john
You may also cycle in the other direction, moving characters from the end:
john -> njoh, hnjo, ohnj... |
Problem:
Find the number of leading zeroes in a 64-bit signed integer
Rules:
The input cannot be treated as string; it can be anything where math and bitwise operations drive the algorithm
The output should be validated against the 64-bit signed integer representation of the number, regardless of language
Default code... |
Paterson's worms are a kind of cellular automaton that exist on an infinite triangular grid and, every step, they turn in some direction and move one unit. Their defining properties are that they can never go over the same spot twice, and whenever they encounter the same surroundings, they make the same decision. A wor... |
Introduction:
I have loads of different ciphers stored in a document I once compiled as a kid, I picked a few of the ones I thought were best suitable for challenges (not too trivial, and not too hard) and transformed them into challenges. Most of them are still in the sandbox, and I'm not sure yet whether I'll post al... |
Write a regular expression substitution string which can base64 decode a string using only a regular expression engine built into the language. Eg:
# Example in python
import re
print(re.sub(..., ..., "SGVsbG8gd29ybGQK")) # "Hello world\n"
# ^^^ ^^^
# These count towards your byte count, the... |
Your task is to fill the bucket with numbers upto a given input.
Rules
Numbers occupy the leftmost position then rightmost, then leftmost and so on.
After overflow, the numbers start to gather around the bucket in a similar manner. They occupy position diagonally.
The examples should make it clear what the expected out... |
The Challenge:
For an input of one letter X (upper or lower case from A to Z) and one digit N (0-9) print the corresponding letter X made of N * X.
The letter has to be from this list:
AAA BBBB CCCC DDDD EEEEE FFFFF GGG H H
A A B B C D D E F ... |
Given an input string consisting of only letters, return the step-size that results in the minimum amount of steps that are needed to visit all the letters in order over a wrapping alphabet, starting at any letter.
For example, take the word, dog. If we use a step-size of 1, we end up with:
defghijklmnopqrstuvwxyzabcde... |
Challenge:
Given two inputs, x and y, round x to one less significant figure, then repeat until it has y number of unrounded digits left. (the decimal point does not count as a digit)
Input & Output
Input can be a combination of strings and integers, e.g. you can have the input as a string and the output as an int, o... |
Given a positive integer input n seconds, output the time in human readable format.
The time will be considered from 00:00:00, 1st January, 1 A.D.
Leap years must be taken into account.
Assume that the gregorian calendar was followed since the beginning.
(Gregorian Calendar: Every year that is exactly divisible by four... |
Ex :-
Input:
n = 12, k = 5
Output:
ans = 2
Sorted list S: ["1", "10", "11", "12", "2", "3", "4", "5", ...., "9"]
ans = 2
|
There are some iron particles on a board. We pass a current carrying wire through that board and the particles form circles. Show these circles if input given is the position of the wire.
Consider the board to be a grid of size 7x7 (fixed)
No extra white spaces are allowed.
Input can be 0-indexed or 1-indexed. (0-index... |
Question: Print out all the coordinates of a NxN grid. Preferably in C, however other languages also accepted
Input: N (integer)
Output: for N=3, a 3x3 grid:
0,0
1,0
2,0
0,1
1,1
2,1
0,2
1,2
2,2
|
For a computer vision app I want to do a mapping of an image, in such a way that every pixel fit hilbert curve, instead of conventional layout. So task could be as follows:
Task description
Given square 2D image A with side 2^^N, (N>0), with common Z-order, or row-major representation of pixels in RAM. I need to run ... |
This challenge is about printing a series of growing ASCII-art arrows. I'll describe the pattern in words, but it might be easier to look at what the start of this series looks like:
>
<
->
<-
-->
<--
--->
<---
---->
<----
----->
<-----
------>
<------
...
An arrow with length n contains an arrowhead (< or >) and n-1 ... |
Background
OEIS sequence A272573 describes a spiral on a hexagonal grid as follows:
Start a spiral of numbers on a hexagonal tiling, with the initial hexagon as a(1) = 1. a(n) is the smallest positive integer not equal to or previously adjacent to its neighbors.
The sequence begins
1, 2, 3, 4, 5, 6, 7, 4, 6, 8, 5, 9,... |
Credit to Geobits in TNB for the idea
A post without sufficient detail recently posited an interesting game:
2 children sit in front of an array of candy. Each piece of candy is numbered 1 to x, with x being the total amount of candy present. There is exactly 1 occurrence of each number.
The goal of the game is for the... |
Suzhou numerals (蘇州碼子; also 花碼) are Chinese decimal numerals:
0 〇
1 〡 一
2 〢 二
3 〣 三
4 〤
5 〥
6 〦
7 〧
8 〨
9 〩
They pretty much work like Arabic numerals, except that when there are consecutive digits belonging to the set {1, 2, 3}, the digits alternate between vertical stroke notation {〡,〢,〣} and horizontal stroke notat... |
The Korean language has two sets of numerals, a native Korean numerals and Sino-Korean numerals.
The native Korean numerals are mostly used for numbers under 100, such as age and time.
The Sino-Korean numeral system, which is based on the Chinese numeral system as its name says, is used in most of the time.
It uses 4-d... |
I'd love to take a number and know how many syllables are in it, when spoken in English.
Let's limit this to positive integers which are less than one thousand.
I'm British, so we're going to follow the hundreds column with an 'and' when there are any non-zero digits after it.
The Challenge
Write some code which will ... |
Given a list of floating point numbers, standardize it.
Details
A list \$x_1,x_2,\ldots,x_n\$ is standardized if the mean of all values is 0, and the standard deviation is 1. One way to compute this is by first computing the mean \$\mu\$ and the standard deviation \$\sigma\$ as
$$ \mu = \frac1n\sum_{i=1}^n x_i \qquad ... |
Imagine we have some polyomino and would like to uniquely identify them, however the polyominos can be rotated, so blindly hashing them won't give us the same fingerprint for a piece and a rotation thereof (in general).
For example if we have the L-tetromino
x
x
xx
we would like it to have the same fingerprint as any ... |
If 1 is not counted as a factor, then
40 has two neighboring factors (4 and 5)
1092 has two neighboring factors (13 and 14)
350 does not have two neighboring factors
(out of its factors 2, 5, 7, 10, 14, 25, 35, 50, 70, and 175,
no two are consecutive)
The proportion of positive integers that have this property
is the... |
Given \$k\$ arrays of length \$n\$, output the maximum sum possible using one element from each array such that no two elements are from the same index. It is guaranteed that \$k\le n\$.
Input
A nonempty list of nonempty arrays of integers.
Output
An integer that represents the maximum sum.
Examples
Input -> Output
[[1... |
Tournament over!
The tournament is now over! The final simulation was run during the night, a total of \$3*10^8\$ games. The winner is Christian Sievers with his bot OptFor2X. Christian Sievers also managed to secure the second place with Rebel. Congratulations! Below you can see the official high score list for the to... |
This is a code-challenge with a custom scoring system, where the lowest score wins.
Introduction
Many smartphones allow to enter text by swiping your finger across the 2D virtual keyboard. This technology is usually combined with a prediction algorithm that outputs a list of guessed words, sorted from most likely to le... |
Challenge
Given a list of unique colour names as input, sort them in the order that they first appear in Joseph's Amazing Technicolour Dreamcoat.
Example
Input: green, blue, red, brown
Output: red, green, brown, blue
The full list of colours, in order, is:
1. red
2. yellow
3. green
4. brown
5. scarlet
6. black... |
Someone gave my wife a decorative calendar consisting of four cubes. Here it is showing today's date (as of the posting of this challenge) on the front:
When I first saw it, I looked at it from the wrong angle (from directly above) and couldn't figure out why it gave this information:
[["February", "January"], [3], [7... |
I've recently been indulging myself in some nostalgia
in the form of Bookworm Deluxe:
In case you haven't seen it before,
it's a word game where the goal is to connect adjacent tiles to form words.
In order to determine whether a string is a valid word,
it checks it against its internal dictionary,
which is stored in ... |
A pandigital number is an integer which contains every digit from 0 to 9 at least once. 1234567890, 1902837465000000, and 9023289761326634265 are all pandigital. For the purposes of this challenge, numbers such as 123456789 are not pandigital, since they do not contain a 0, even though 123456789 = 0123456789.
A diverse... |
The Corpus are a fictional faction from the popular video game Warframe who have a somewhat interesting language.
Whilst other factions in the game such as the Grineer have some logic behind their language, the Corpus is simply a lossy substitution of the English language.
All Corpus words are the same as their English... |
In set theory, the natural numbers \$\mathbb{N} = \{0, 1, 2, 3, ...\}\$ are usually encoded as pure sets, that is sets which only contain the empty set or other sets that are pure. However, not all pure sets represent natural numbers. This challenge is about deciding whether a given pure set represents an encoding of n... |
Let's have string multiplication to take a string and a positive number and concatenate that string that many times. In Haskell:
0 * s = ""
n * s = s ++ ((n - 1) * s)
Your task is to write a program that outputs a number \$n > 0\$. When you double your program (with the described procedure) the new program should ou... |
Input
A binary matrix \$M\$ representing the walls of a dungeon.
The position \$(x,y)\$ of the player within the dungeon.
The direction \$d\$ that the player is currently facing (0 = North, 1 = East, 2 = South, 3 = West)
Output
A pseudo-3D representation of the walls that are in the field of view of the player, as an... |
Inspired (you don't need to know them for this challenge) by the Pumping Lemma for various languages, I propose the following challenge:
choose some basis \$B \geq 2\$ and an integer \$n \geq 0\$
write a program/function \$P\$
partition* \$P\$ into some strings \$s_i \neq \epsilon\$, st. \$P = s_n | \cdots | s_i | \cd... |
The day this post was published was Christmas Eve. Tomorrow will be Christmas. Yesterday was Christmas Eve Eve. In two days it will be
Christmas Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Ev... |
This is a "counterpart" of another puzzle, Eight coins for the fair king on Puzzling.SE.
You can read the above puzzle for the background. The details about this puzzle are as follows.
A set of 8 kinds of coins of different values are created, the king wants you to find out the maximum N such that any number of price f... |
Using FTP's ASCII mode to transfer binary files is a bad idea. It is likely to corrupt your data. Badly. Let's simulate this corruption!
Your task is to write a program which takes a file as input and outputs the corrupted version of the file. Because how exactly your file gets corrupted is dependent on both the FTP cl... |
Graph theory is used to study the relations between objects. A graph is composed of vertices and edges in a diagram such as this:
A-----B
| / \
| / \
| / E
| / /
|/ /
C-----D
In the above diagram, A is linked to B and C; B is linked to A, C, and E; C is linked to A, B, and D; D is linked to C and... |
A natural number (written in the decimal base) is qualified as digisible if and only if it fulfills the following 3 conditions:
none of its digits is zero,
all the digits that compose it are different,
the number is divisible by all the digits that compose it.
The challenge is to output all the digisibles (there are ... |
Migrated from chat
Given two non-empty non-negative integer matrices A and B, answer the number of times A occurs as a contiguous, possibly overlapping, submatrix in B.
Examples/Rules
0. There may not be any submatrices
A:
[[3,1],
[1,4]]
B:
[[1,4],
[3,1]]
Answer:
0
1. Submatrices must be contiguous
A:
[[1,4],
[3,1]]... |
Given a non-empty matrix of non-negative integers, answer which unique rows contribute most to the sum total of elements in the matrix.
Answer by any reasonable indication, for example a mask of the unique rows order of appearance (or sort order), or indices (zero- or one- based) of those, or a submatrix consisting of ... |
Introduction
Often, people refer to dates as the "second Friday in August, 2018" or the "fourth Sunday in March, 2012". But it's hard to tell what date that is! Your task to is to write a program that receives a year, a month, a day of the week, and an integer, and output that date.
Challenge
For input, you will get a... |
Let's define the a function on natural numbers \$n\$, written as base 10 digits \$d_k\; d_{k-1}\; \dotsc\; d_1\; d_0\$, as follows:
As long as there are equal adjacent digits \$d_i\;d_{i-1}\$, replace them by their sum \$d_i+d_{i-1}\$ from left to right. If there were any such digits, repeat the same procedure.
In othe... |
Introduction
All the possible moves and their combinations of a Rubik's Cube form a group. A group in general is a set with some binary operation defined on it. It must contain a neutral element with respect to this operator as well as inverses for every element of the set. For instance the integers \$\mathbb Z\$ with ... |
GHC command line errors can be horrible, lets make them as bad as possible. To disincentivize very long programs use the following formula to calculate your "score".
(# of bytes of GHC output) / 2^(8 + # of bytes of code)
Template Haskell is banned as there is probably a TH configuration where you can replicate an err... |
Three positive integers A, B, C are ABC-triple if they are coprime,
with A < B and satisfying the relation : A + B = C
Examples :
1, 8, 9 is an ABC-triple since they are coprime, 1 < 8 and 1 + 8 = 9
6, 8, 14 is not because they are not coprime
7, 5, 12 is not because 7 > 5
You can see this Frits Beukers 2005 presenta... |
Your task is to determine the length of the longest descent down a "mountain" represented as a grid of integer heights. A "descent" is any path from a starting cell to orthogonally adjacent cells with strictly decreasing heights (i.e. not diagonal and not to the same height). For instance, you can move from 5-4-3-1 but... |
Write a program which removes any common leading spaces from the input string. For example, if the least indented line started with 3 spaces, and every other line has >= 3 leading spaces, then remove 3 spaces from the beginning of each line.
The indentation consists solely of spaces, and the string will not contain any... |
Surreal Numbers are one way of describing numbers using sets. In this challenge you will determine the value of a surreal number.
Intro
A surreal number consists of two sets: a left and right. The value of the surreal number must be greater than all numbers in the left set and less than all numbers in the right set. We... |
Oreoorererereoo
Given an input string that is similar to the word "oreo", give an ASCII representation of the cookie that is as wide as the input string (to ensure cookie stability).
Rules
The input is lowercase, a non-empty string with no whitespace containing any combination of the strings "o" and "re", and contain... |
Introduction:
I have loads of different ciphers stored in a document I once compiled as a kid, I picked a few of the ones I thought were best suitable for challenges (not too trivial, and not too hard) and transformed them into challenges. Most of them are still in the sandbox, and I'm not sure yet whether I'll post al... |
TL;DR for those not interested: Look at the test cases at the bottom. Have a program/function that outputs the 2D list displayed for the given input.
Introduction:
On November 15th, 2018 puzzle designer Raphaël Mouflin revealed his Triangularity puzzle. Here is a picture of that puzzle:
As you can see, the shape is a ... |
2019 has come and probably everyone has noticed the peculiarity of this number: it's in fact composed by two sub-numbers (20 and 19) representing a sequence of consecutive descending numbers.
Challenge
Given a number x, return the length of the maximum sequence of consecutive, descending numbers that can be formed by t... |
Write a program that takes in a string and spells that word out using the NATO Phonetic Alphabet.
The mapping is as follows:
'A' -> 'Alfa'
'B' -> 'Bravo'
'C' -> 'Charlie'
'D' -> 'Delta'
'E' -> 'Echo'
'F' -> 'Foxtrot'
'G' -> 'Golf'
'H' -> 'Hotel'
'I' -> 'India'
'J' -> 'Juliett'
'K' -> 'Kilo'
'L' -> 'Lima'
'M' -> 'Mike'... |
Introduction
This is a little challenge with the goal of identifying repeated pattern "blocks" in a string, and outputting them with their frequency of occurence from left to right.
A friend asked me this question and I realized it wasn't as simple as tossing what you've seen into a hash table and popping them off if p... |
Multi-level marketing related challenge.
A peer wants to get rewarded. So it attracted N investors (N>=1), each i-th investor invested x[i]. When a total sum exceeds threshold x[0]+x[1]+...+x[N-1] >= T a peer could be rewarded. But only if a following conditions are satisfied:
Minimum amount of investors should be gre... |
Background
Inspired by a now deleted question by John Burger from which I quote:
Now obviously no human made this mistake. It's a mis-decode of something - perhaps the ISBN? My question is: does anyone know of an existing algorithm that was so messed up it would invent an entirely new calendar?
TFeld ingeniously com... |
Given a list of strictly positive integers, go through each distinct number and replace all occurrences of it with successive indices (zero or one based) of a new series.
Examples
[] → []/[]
[42] → [0]/[1]
[7,7,7] → [0,1,2]/[1,2,3]
[10,20,30] → [0,0,0]/[1,1,1]
[5,12,10,12,12,10] → [0,0,0,1,2,1]/[1,1,1,2,3,2]
[2,7,1,8,2... |
An Séimhiú agus an tUrú
In Irish Gaelic (Gaeilge) there are a number of ways that the start of a word can be changed. The most common of these are lenition (an séimhiú) and eclipsis (an t-urú)
Lenition involves adding the letter h as the second letter. For example, the word "bean" (woman) would be lenited to "bhean".
E... |
Given a range and a list thereof, while keeping the existing intervals in the list unchanged, split the additional range into sub-intervals and add them to the list, such that all the ranges in the final list are disjoint and contain all numbers present in the input ranges.
The goal is to create an insertInterval(inte... |
I don't know if something like this exists already (and I'm not finding the right key words) but if not, it felt like it could be an interesting coding puzzle.
The challenge is, to take an arbitrarily nested list (no more than 2 deep), and display the content in a terminal in 2 dimensions in a 'pretty' manner. Each 'to... |
As you probably know, a Fibonacci Number is one which is the sum of the previous two numbers in the series.
A Fibonacci Digit™ is one which is the sum of the two previous digits.
For instance, for the series beginning 1,1, the series would be 1,1,2,3,5,8,13,4,7,11,2... The change occurs after the 13, where, instead of ... |
Given a positive number \$n\$, find the number of alkanes with \$n\$ carbon atoms, ignoring stereoisomers; or equivalently, the number of unlabeled trees with \$n\$ nodes, such that every node has degree \$\le 4\$.
This is OEIS sequence A000602.
See also: Paraffins - Rosetta Code
Example
For \$n = 7\$, the answer is \... |
(Randomly inspired by https://codegolf.meta.stackexchange.com/a/17272/42963)
Given a rectangular matrix of digits (i.e., 0 - 9), output the "pieces" of the matrix as if the digits are connected together forming a single piece, in ascending order by the digits. The pieces are guaranteed to connect only orthongonally -- ... |
Given a unix timestamp as an input, give a datetime string, in a format like so: "YYMMDD.HHmm"
Rules
The input is a number (integer) of a millisecond-precise UNIX epoch time (milliseconds since 1970 January 1st 00:00:00.000 UTC).
The values must be padded with zeroes if they are 1 character instead of 2. (e.g.: for "D... |
Input:
An integer n
Two equal-sized square matrices (with their width/height being a multiple of n)
Output:
One of two distinct values of your own choice, one being for truthy results and one for falsey results (so yes, 1/0 instead of true/false are valid outputs for languages like Java, even though they're not consi... |
Write a program that accepts chess moves, validate them and shows the results.
The program should:
Check wheter or not a move is valid
Check if a king is in check or in checkmate
Process the changes in position of the pieces
Not procees invalid moves
Use the format shown below, but format can be changed freely if you ... |
The challenge is to implement a function or program that takes two numbers, \$x\$ and \$y\$ and return the result of \$x^y\$.
The program cannot use any other mathematical operation other than \$+\$ or \$-\$, so no multiplication or division. Functions built into languages are also not allowed.
The code in the least a... |
Write shortest possible code that will return true if the two given integer values are equal or their sum or absolute difference is 5.
Example test cases:
4 1 => True
10 10 => True
1 3 => False
6 2 => False
1 6 => True
-256 -251 => True
6 1 => True
-5 5 => False
The shortest I could come up with in python2 is 56 chara... |
Background: Too many illegal immigrants from Blandia are crossing the border to Astan. The emperor of Astan has tasked you with digging a trench to keep them out, and Blandia must pay for the expenses. Since all typists have been furloughed until the trench is arranged, your code must be as short as possible.*
Task: Gi... |
UTF-8 is a relatively simple way to encode Unicode codepoints in a variable-width format such that it doesn't easily confuse code that isn't Unicode aware.
UTF-8 overview
Bytes in the range of 1-0x7F, inclusive, are normally valid
Bytes with the bit pattern 10XX XXXX are considered continuation bytes, with the six lea... |
Inspired by a recent Daily WTF article...
Write a program or function that takes a GUID (string in the format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX, where each X represents a hexadecimal digit), and outputs the GUID incremented by one.
Examples
>>> increment_guid('7f128bd4-b0ba-4597-8f35-3a2f2756dfbb')
'7f128bd4-b0ba-45... |
Lets define a non-empty, unsorted and finite matrix with unique numbers as follow:
$$N = \begin{Bmatrix} 4&5&7\\1&3&6 \end{Bmatrix}$$
Lets define 4 matrix moves as:
↑* (up): Moves a column up
↓* (down): Moves a column down
→* (right): Moves a row to the right
←* (left): Moves a row to the left
The asterisk(*) repre... |
It is very hard to remember my password, so I came up with a way to generate a password.
The way I generate my password is from a word or a sentence, following these steps:
Start from left to right
Find the count of each letter
Put letter with its count in an order
Letters with higher repetition will be in the end
... |
Input:
An NxM grid or multi-line string (or other reasonable input-format), containing only printable ASCII (unicode range [32,126]).
Output:
The amount of closed polygons of the same character that can be found, with two special rules:
Spaces are wildcards and can be used (multiple times) for any character
o, O, and ... |
The bank has been broken into, and all the local mafia thugs have an unusual alibi: they were at home playing Connect 4! In order to assist with the investigation, you are asked to write a program to validate all the Connect 4 boards that have been seized in order to check that the positions are indeed positions from ... |
Introduction
In most interpreted languages, there is an operation that will run code generated at runtime. It generally requires alphanumeric characters to refer to this operation. Write a program, using as few alphanumeric characters as possible, that is able to download and execute any string in the language you're w... |
Given a binary 3D array, for each layer, cyclically rotate up each of its columns as many steps as indicated by the binary encoding of the columns of the layer above it, and then cyclically rotate left each of its rows as many steps as indicated by the binary encoding of the rows of the layer below it.
There will alway... |
This is a challenge in which two people, 1 and 2, are running for office. People deterministically vote in certain ways in the world of 1 and 2, which can allow for the candidates to figure out the results before the election.
NOTE: this is not meant to refer to any outside elections or other political events.
Two peop... |
Given an integer n, output the smallest prime such that the difference between it and the next prime is at least n.
For example, if n=5, you would output 23, since the next prime is 29, and 29-23>=5.
More Input/Output Examples
1 -> 2 (3 - 2 >= 1)
2 -> 3 (5 - 3 >= 2)
3 -> 7 (11 - 7 >= 3)
4 -> 7
5 -> 23
6 -> 23
7 -> 89
8... |
Suppose we have an array \$\texttt{ps}\$ of length \$n\$ with pointers pointing to some location in the array: The process of "pointer jumping" will set every pointer to the location the pointer it points to points to.
For the purpose of this challenge a pointer is the (zero-based) index of an element of the array, thi... |
This challenge is based on the following puzzle: You are given an n by n grid with n cells marked. Your job is to the partition the grid into n parts where each part consists of exactly n cells, each containing exactly one marked cell.
Example
Here is a puzzle on the left and its (unique) solution on the right:
Chall... |
This challenge takes place on a grid.
+----------+
| |
| |
| |
| |
| |
| |
| |
| |
| |
+----------+
This one's 10 x 10, but it can be any rectangular shape.
There are four directions on this grid. Up, down, left and right.
The task is to ... |
Challenge:
Given a matrix input, determine the amount of diagonals and anti-diagonals with duplicated numbers.
So if we have a matrix like this:
[[aa,ab,ac,ad,ae,af],
[ba,bb,bc,bd,be,bf],
[ca,cb,cc,cd,ce,cf],
[da,db,dc,dd,de,df]]
All diagonals and anti-diagonals would be:
[[aa],[ab,ba],[ac,bb,ca],[ad,bc,cb,da],[ae,... |
Golf a program or function which gives the \$n^{\text{th}}\$ location of the wildebeest who starts at square \$1\$ on an infinite chessboard which is numbered in an anti-clockwise square spiral, where the wildebeest always visits the lowest numbered square she can reach that she has not yet visited.
Inspiration: The Tr... |
The Challenge
Given an integer input x where 1 <= x <= 255, return the results of powers of two that when summed give x.
Examples
Given the input:
86
Your program should output:
64 16 4 2
Input:
240
Output:
128 64 32 16
Input:
1
Output:
1
Input:
64
Output:
64
The output may contain zeros if the certain power of... |
Introduction
Inspired by the very recent video The Trapped Knight - Numberphile, I came up with a challenge.
The trapped knight sequence is a finite integer sequence of length 2016, starting from 1, and has the following construction rules:
Write a number spiral in the following manner:
17 16 15 14 13 ...
18 5 4 3... |
Growing up, my first console game system was an Atari 2600 and I will always have a love for some of those games I so enjoyed as a child. Many of the graphics are still memorable, perhaps even iconic.
It turns out that these sprites are very simplistic bitmaps, 8 pixels wide with variable height where the binary repre... |
You have a little robot with four distance sensors. It knows the layout of a room, but it has no sense of orientation other than being able to lock onto the grid orientation. You want to be able to find out where the robot is based on the readings, but it can be ambiguous because of the limited sensors.
Challenge Expla... |
I was asked this question in an interview but I was unable to figure out any solution. I don't know whether the question was right or not. I tried a lot but couldn't reach any solution. Honestly speaking, nothing came to my mind.
Rocco numbers
A positive integer \$n\$ is a Rocco number if it can be represented either a... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.