instruction stringlengths 34 53.1k |
|---|
inspired by thejonymyster's idea
Rules
This challenge is about finding languages that are very suitable for one task but quite the opposite in the other. The two tasks share a theme, but Task 1 is designed to be number-oriented while 2 is string-oriented. You can participate in three categories:
Numbers: Choose a lang... |
Given the diagonals of a matrix, reconstruct the original matrix.
The diagonals parallel to the major diagonal (the main diagonals) will be given.
Diagonals: [[5], [4, 10], [3, 9, 15], [2, 8, 14, 20], [1, 7, 13, 19, 25], [6, 12, 18, 24], [11, 17, 23], [16, 22], [21]]
Rules
The matrix will be non-empty and will consis... |
Input
A string of text.
Output
The string of text, however, every consonant is the next consonant in the alphabet, and every vowel is the next vowel in the alphabet (z becomes b, u becomes a). The case of the new letter should be the same as the letter it is replacing (a becomes e, A becomes E). If there are two conson... |
The wizard is determined to pose the most challenging challenge yet for which he believes the previous solution techniques will not work. He decides to go multidimensional.
If there is a number line with \$x = 10\$ then your task is to prove this. If you do so you win. In this situation, for your code to be correct, ... |
A composition of an integer \$n\$ is a representation of \$n\$ as a sum of positive integers. For example the eight compositions of 4 are as follows:
4, 3 + 1, 1 + 3, 2 + 2, 2 + 1 + 1, 1 + 2 + 1, 1 + 1 + 2, 1 + 1 + 1 + 1.
The challenge is to output the number of compositions of \$n\$ in which the greatest part is odd.... |
In chess, the Fool's Mate is the fastest possible way to reach checkmate. It is reached with Black's second move. In chess notation, one possible sequence of moves that achieves Fool's Mate is 1.f3 e6 2.g4 Qh4#.
This is not the only possible way to achieve this checkmate (in the same number of moves). There are three ... |
Carryless multiplication is an operation similar to binary long multiplication, but with XOR instead of addition:
1011 11
× 101 5
-----
1011
0
1011
------
100111 39
In this challenge, you'll be given a positive integer >= 2, and must return a list of all positive integers which are carryless factor... |
I recently stumbled across this image on wikimedia commons. It's a little bit of an information overload at first, but after examining it a bit it shows an interesting number system for writing nibbles.
Image created by user Watchduck.
First off a "nibble" is a 4 bit number which is really a number ranging from 0 to ... |
Write a program/function that finds the amount of fuel needed to escape Earth's gravity well given the exhaust velocity of the fuel and the amount of mass to transport using the Tsiolkovsky rocket equation:
$$\Delta v = v_\text{exhaust}\ln\dfrac{m_\text{start}}{m_\text{end}}$$
where
\$\Delta v\$ is the change in veloc... |
Description
All cubic equations can be solved, and every cubic has at least one solution. The goal of this challenge is to find the real solutions to a given cubic using inputs, and (obviously) the smallest program size.
Rules
The solution must find the real solutions of a cubic correctly, using any method. The cubic m... |
In this challenge you will take as input a non-empty list of binary values (these can be booleans or integers on the range 0-1), you should output all the ways to partition the list into non-empty sections such that no two adjacent equal values in the initial list are separated into different sections.
For example if t... |
Futoshiki is a logic puzzle where an \$n×n\$ Latin square must be completed based on given numbers and inequalities between adjacent cells. Each row and column must contain exactly one of each number from \$1\$ to \$n\$ while satisfying the inequalities.
In a solved Futoshiki puzzle any row (or column) forms a linear ... |
Take a list of 2-digit hexadecimal numbers as input, and output the binary value, replacing each 1 with an 'X', and each 0 with a space.
For example
Input = FF, 81, 47, 99.
FF = 11111111 in binary, so print XXXXXXXX
81 = 10000001 in binary, so print X X
47 = 01000111 in binary, so print X XXX
99 = 10011001 in ... |
User inputs an integer. Print out proper fractions using all positive integers up to the user's input, in ascending order.
Rule 1: Eliminate equal fractions.
Rule 2: Fractions should be in their simplest form.
Rule 3: Use "/" as a fraction symbol and next line (\n or \r as convenient) as a separator between fractions.
... |
A Tiefling is a character race, from Dungeons and Dragons, that has this list of possible traits:
small horns
fangs or sharp teeth
a forked tongue
catlike eyes
six fingers on each hand
goat-like legs
cloven hoofs
a forked tail
leathery or scaly skin
red or dark blue skin
cast no shadow or reflection
exude a smell of b... |
Given two arrays of non-negative integers \$A = [A_1,A_2,\ldots,A_n]\$ and \$R = [R_1,R_2,\ldots,R_n]\$ which are equal in length, return an array which has the element \$A_1\$ repeated \$R_1\$ times, then element \$A_2\$ repeated \$R_2\$ times, all the way up to \$A_n\$.
Standard loopholes are forbidden. As this is co... |
Given a binary message, and the number of parity bits, generate the associated parity bits.
A parity bit is a simple form of error detection. It's generated by counting the number of 1's in the message, if it's even attach a 0 to the end, if it's odd attach 1.
That way, if there's a 1-bit error, 3-bit error, 5-bit erro... |
Does anyone have tips on how to golf in this language? Please one tip per answer and avoid posting simple and general tips such as "remove whitespace".
Here is the github link and here is the esolang page.
|
Given an integer n >= 1 as input, output a sample from the discrete triangular distribution over the integers k, for 1 <= k <= n (1 <= k < n is also acceptable),
defined by p(k) ∝ k.
E.g. if n = 3, then p(1) = 1/6, p(2) = 2/6, and p(3) = 3/6.
Your code should take constant expected time, but you are allowed to ignore o... |
Print or return the following string:
zottffssentettffssenttttttttttttttttttttffffffffffffffffffffsssssssssssssssssssseeeeeeeeeennnnnnnnnno
This is the first letter of each of the numbers zero, one, two, all the way up to one hundred.
Standard I/O rules apply, but the output must be exactly as shown above, optionally ... |
You've gotten out of Earth's gravity well - good for you! However, you're feeling a bit uncomfortable in zero-gravity, and you want to replicate 1 \$g\$ of force in a centrifuge. Use the equation for force in a centrifuge:
$$\text{RCF} = \frac{r_\text{m} \, \left(\frac{2 \pi N_\text{RPM}}{60}\right)^2}{g}$$
Where
\$\t... |
This challenge, I hope, is simple to understand. Given a date-string (given in any format you prefer, so long as it has 4 digits of year and 2 digits of day and month), calculate the weekday for the particular date-string. You must output 7 different values, corresponding to the weekday you have calculated.
It's okay i... |
A partition of a list \$A\$ is a way of splitting \$A\$ up into smaller parts, concretely it is list of lists that when concatenated gives back \$A\$.
For example [[1],[2,3],[5,6]] is a partition of [1,2,3,5,6]. The trivial partition is a partition that "splits" the list into only one piece, so [[1,2,3,5,6]] is also a ... |
Given an alphabet represented as a nonempty set of positive integers, and a word made up of symbols from that alphabet, find that word's position in the lexicographically ordered set of all words, assuming words can't contain duplicate symbols.
Example
Consider the alphabet {1, 2, 3} and the word [2, 3, 1]. The set of ... |
Gematria is an ancient Jewish method to determine a numeric value of a letter sequence, using a fixed value for each letter. Gematria is originally applied to Hebrew letters, but for the context of this challenge, we'll use Latin script instead. There are many ways to implement Gematria in Latin script, but let's defin... |
inspired by Longest Increasing Substring
Task
Given a list of non-negative integers, output the length of its longest alternating subsequence.
An alternating sequence is a sequence of numbers which alternates between strictly increasing and strictly decreasing. [], [999], [9, 1], and [0, 5, 0, 3, 2, 4] are examples of ... |
In this challenge, you are going to take a number and turn it into a string, but not in the common way. You will use the aaaaa way!
The aaaaa way is simply replacing each digit of the input number with the letter at that position in the alphabet. For example, 11111 would become aaaaa and 21223 would become babbc. If th... |
In R print(x, digits=n) does something a little complicated.
It always shows all the digits to the left of the decimal point and then, if there are any digits to the right it rounds the whole number so that at most n digits are shown. However, leading 0s are not counted. Here are examples to show how the function work... |
I want to read two strings on separate lines, each string the same length and containing only 0's and 1's, and determine if the first is the one's complement of the second. How succinctly can this be done in Python3? (Sorry to specify the language, but this is for my son who's studying Python)
A list comprehension see... |
Discussion in courtrooms often occurs at a high speed and needs to be accurately transcribed in case the text of the decision is needed in future cases. For this purpose, the stenographers who transcribe court discussions use specially designed keyboards with a small set of buttons, which are pressed in groups to spell... |
The task is simple: given a 32 bit integer, convert it to its floating point value as defined by the IEEE 754 (32-bit) standard.
To put it another way, interpret the integer as the bit-pattern of an IEEE binary32 single-precision float and output the numeric value it represents.
IEEE 754 single precision
Here is a conv... |
Background
In 1960, the 11th General Conference on Weights and Measures defined the Système International d'Unités (SI) Units which scientists still use today.
The metre and the kilogram became standard units in that conference. These were based on powers of 10 (10, 100, 1000, etc.).
For example:
there are 100 centime... |
Given an input of a string, output the partial fraction in string form.
The partial fraction decomposition of a rational fraction of the form \$\frac{f(x)}{g(x)}\$, where \$f\$ and \$g\$ are polynomials, is its expression as:
$$\frac{f(x)}{g(x)}=p(x)+\sum_j\frac{f_j(x)}{g_j(x)}$$
In this case \$p\$ is 0, because we ass... |
Given an array of \$n\$ positive integers we will say its self-sum order is the number of ways to add elements from it to make \$n\$. We will count ways as distinct up to associativity. So \$1+(2+3)\$ and \$(1+2)+3\$ are not counted as separate ways to make 6, but \$2+4\$ and \$4+2\$ are counted as separate. Two sums... |
An alphadrome is a word in which each letter in the first half of the word "reflects" its alphabetical "opposite" in the second half of the word. Write a program or function that returns truthy if the given word is an alphadrome and falsey otherwise.
For example, BEEB is a palindrome. Its first letter B "reflects" its ... |
Determine whether a given sequence could be a winning sequence for the game shut the box.
Background
There are a few variants to this game, so I'll clarify the rules here. Play begins with 12 tiles (1 through 12) face up. Each turn the player rolls two six sided dice, and must then flip over one or more tile(s) which s... |
Ruby has a strange operator, .., called flip-flop (not to be confused with the range operator, which looks the same). Used in a loop, flip-flop takes two conditions as operands and will return false until the first operand is truthy, then return true until the second operand is truthy, whereupon it returns true one mor... |
Given a message, append checksum digits using prime numbers as weights.
A checksum digit is used as an error-detection method.
Take, for instance, the error-detection method of the EAN-13 code:
The checksum digit is generated by:
Multiplying each digit in the message alternating by 1 and 3 (the weights)
Summing it up... |
Let \$p(x)\$ be a polynomial. We say \$a\$ is a root of multiplicity \$k\$ of \$p(x)\$, if there is another polynomial \$s(x)\$ such that \$p(x)=s(x)(x-a)^k\$ and \$s(a)\ne0\$.
For example, the polynomial \$p(x)=x^3+2x^2-7x+4=(x+4)(x-1)^2\$ has \$1\$ and \$-4\$ as roots. \$1\$ is a root of multiplicity \$2\$. \$-4\$ is... |
MD5 checksums are relatively easy to crack. For this challenge you will create two separate programs, the first one writing Hello, World! and the second one writing Goodbye Cruel World! but with the source code having identical MD5 hashes.
The source code of both programs must not be identical.
The programs can use th... |
From the infinite triangular array of positive integers, suppose we select every 2nd numbers on every 2nd row as shown below:
$$
\underline{1} \\
\;2\; \quad \;3\; \\
\;\underline{4}\; \quad \;5\; \quad \;\underline{6}\; \\
\;7\; \quad \;8\; \quad \;9\; \quad 10 \\
\underline{11} \quad 12 \quad \underline{13} \quad 14 ... |
Given an integer \$ n \ge 1 \$, your task is to output an array \$ a \$ consisting of \$ n^2 + 1 \$ integers, such that all possible pairs of integers \$ (x, y) \$ satisfying \$ 1 \le x, y \le n \$ exist as a contiguous subarray in \$ a \$, exactly once.
For example, if \$ n = 2 \$, a valid output would be \$ (1, 1, 2,... |
This challenge requires a small amount of knowledge about chess. A description of the details required can be found at the bottom if you are not familiar with chess or want a refresher.
For a certain board configuration consisting only of queens we can say that each queens threat number is the number of other queens i... |
From the infinite triangular array of positive integers, suppose we repeatedly select all numbers at Euclidean distance of \$\sqrt{3}\$, starting from 1:
$$
\underline{1} \\
\;2\; \quad \;3\; \\
\;4\; \quad \;\underline{5}\; \quad \;6\; \\
\;\underline{7}\; \quad \;8\; \quad \;9\; \quad \underline{10} \\
11 \quad 12 \q... |
Write 2 programs in the same language which count the number of shared subsequences of consecutive elements from 2 given sequences.
For example, given "test" and "enter", there are 5 shared subsequences of consecutive elements:
t
t
e
e
te
One possible algorithm consists in counting, for each subsequence of consecutive... |
Given a matrix like this:
1 1 3 -2
3 -4 1 -1
1 1 1 0
0 -1 0 0
By taking a 2×2 "sliding sum", where the sum of every 2×2 region of the matrix is one element of the resulting matrix, we get:
1 1 1
1 -1 1
1 1 1
We can do this for sliding windows of any size. For example, a 1×3 sliding sum of the same input ... |
Introduction:
Some times using a 24-hour clock are formatted in a nice pattern. For these patterns, we'll have four different categories:
All the same (pattern A:AA or AA:AA):
0:00
1:11
2:22
3:33
4:44
5:55
11:11
22:22
Increasing (pattern B:CD or AB:CD, where D==C+1==B+2==A+3):
0:12
1:23
2:34
3:45
4:56
12:34... |
In this challenge we are going to consider lists of integers such that for every member \$x\$ at index \$i\$ then the indexes \$i+x\$ and \$i-x\$ have the value \$x+1\$ or are out of bounds for the list. We will call these trampoline lists.
If we play around with these for a while we can notice that if we start a list... |
Box blur is a simple operation for blurring images. To apply box blur, simply replace each pixel with the average of its and the surrounding 8 pixels' values. Consider, for example, the following example, in which each "pixel" has a one-digit value:
\begin{array} {|r|r|}\hline 1 & 1 & 1 \\ \hline 1 & 7 & 1 \\ \hline 1 ... |
Let \$n\$ be some positive integer. We say that \$n\$ is of even kind if the prime factorisation of \$n\$ (counting duplicates) has an even number of integers. For example, \$6 = 2 \times 3\$ is of even kind. Likewise, we say \$n\$ is of odd kind of the prime factorisation of \$n\$ has an odd number of integers, such ... |
I recently solved a coding challenge in one of the challenge papers that my IT teacher gave to us. It was a seemingly simple, but fun challenge, so I thought it will make fun golfing.
The task
Given an input of a 2x2 matrix that contains 4 strictly positive integers (i.e. non-negative and non-zero), like this:
$$\begin... |
Some chess variants use interesting non-standard pieces. In order to concisely describe new pieces or to describe pieces without requiring everyone to memorize a bunch of non-standard names some new notation can be invented.
In this challenge we are going to look at Parlett's movement notation and convert it to nice at... |
Your task
Given a string of lowercase letters, output the "alphabet checksum" of that string, as a letter.
Example
Let's say we have the string "helloworld". With a = 0, b = 1, c = 2 ... z = 25, we can replace all of the letters with numbers:
h e l l o w o r l d
7 4 11 11 14 22 14 17 11 3
Now, we can sum th... |
I got an email from Hugo Pfoertner, an Editor-in-Chief at the On-Line Encyclopedia of Integer Sequences, with a terrific idea for a fastest-code challenge, which will also help verify or expand the boundary of an open mathematical question in optimization.
Here's the idea: we want to confirm and extend OEIS sequences A... |
Given an integer \$n > 1\$, output a balanced binary tree with \$n\$ leaf nodes.
The tree should be constructed out of (space), \ and / (slashes). Each slash represents a branch.
A node is represented by adjacent slashes: /\. There must be a root node at the top of the tree (i.e. the first row of the output).
To con... |
Imagine that there are \$n\$ different types of objects \$O_1,O_2,O_3,\ldots,O_n\$ and they each have a conversion factor \$k_1,k_2,k_3,\ldots,k_n\$. You can, for any \$1\le i\le n\$, convert \$k_i\$ amount of \$O_i\$ into \$1\$ of any other type of object.
Task
Your objective is to output all the possible ending confi... |
You know those letterboards outside old-style cinemas which show upcoming films - perhaps you have a miniature one in your home?
If you've operated one, you'll know that you can normally add letters from either side of a row. But the slots (in which you slide letters) are thin, so it's impossible to swap the order of ... |
A Fermi-Dirac Prime is a prime power of the form \$p^{2^k}\$, where \$p\$ is prime and \$k \geq 0\$, or in other words, a prime to the power of an integer power of two. They are listed as integer sequence A050376. While a normal prime factorization generally does not contain a set of distinct primes (for example \$24=2... |
The cardinality of the set \$\mathbb Q\$ of rational numbers is known to be exactly the same as that of the set \$\mathbb Z\$ of integers. This means that it is possible to construct a bijection between these sets—a mapping such that each integer corresponds to exactly one rational number, and vice versa.
Provide such ... |
Given a string and a substring and a positive integer n.
Remove the n occurences of a substring from the end of the originally given string. If the substring is not present in the string or the number of times the substring appears is less than n, then the output is the original string. No space should be present in pl... |
Find the max number of Xs you can fit onto a rectangular tic-tac-toe board of length l and height h without ever having 3 consecutive Xs in a row diagonally, horizontally, or vertically.
This is a code-golf challenge so shortest code wins!
Input
A single line containing values l and h, representing the length and heigh... |
Write a program or function (hereafter "function") that returns or prints the source code of four new functions: Increment, decrement, undo, and peek.
The initial function contains an internal integer value of 0. Each of the returned functions contains a value based on that value, and each behaves differently:
Increme... |
The look-say sequence is a sequence of lists of numbers where each element is the previous element with run length encoding. Run length encoding is the process of grouping together like elements and then giving the element and the size of the group for each group. So for example:
1 1 1 2 2 1
To run length encode thi... |
Computers like binary. Humans like base 10. Assuming users are humans, why not find the best of both worlds?
Your task is to find the first n terms in the sequence A008559 where each term is the binary representation of the previous number interpreted as a base 10 number.
Input
An integer greater than 0. Note that the ... |
Python string parsing has quite a few edge cases. This is a string:
"a"
Putting 2 strings immediately after each other implicitly concatenates them, so this is also a string:
"a""a"
However, if you put 3 quotes in a row, it will create a "triple quoted string" which can only be ended by another 3 quotes in a row. A t... |
For the purpose of this challenge a rectangular piece of ASCII art is Mondrian if it looks the same upside down.
What does "looks the same" mean?
A feature is any orthogonally connected region of at last 5 characters. A Mondrian feature is any feature that appears in the same picture upside down. (This includes the pos... |
Your task
Given two positive integers \$x\$ and \$d\$ (such that \$d<x\$), output the 5th term of the \$d\$th difference of the sequence \$n^x\$
Example
Let's say we are given the inputs \$x=4\$ and \$d=2\$.
First, we get the series \$n^4\$:
\$0^4 = 0\$
\$1^4 = 1\$
\$2^4 = 16\$
\$3^4 = 81\$
...
These are the first 10... |
Based off a Scratch project
The pen extension in Scratch has a set pen color to () block. The () is normally a color dropdown, but you can also use the join()() block. In the join()() block, normally a hex value is in the first input, but the second is just an empty string.
However, many new Scratchers that want to t... |
Challenge: With any given number that has multiple digits, every digit in the number needs to repeatedly be summed together until the sum is a single digit number. To make things interesting, if there's a 0 in the number, then it must equal 26, because zero starts with the letter z, which is the 26th and final letter o... |
A bracelet consists of a number, \$\mathit{N}\$, of beads connected in a loop. Each bead may be any of \$\mathit{C}\$ colours. Bracelets are invariant under rotation (shifting beads around the loop) and reflection (turning the bracelet over).
Here are all \$11\$ bracelets with exactly two beads of each of three differe... |
Given a set of substrings, such as [ca, ar, car, rd], it's possible to create infinitely many strings by concatting them together. Some examples of this for the given substrings could be:
ca
caar
card
rdca
carrd
rdrd
...
One interesting property of this set of substrings is that any string can only be constructed in o... |
Your task
Take a list of strings as the input, and output the maximum average ord.
Example
Given the list ['hello', 'world', 'bye']:
The average ord of 'hello' is:
(ord(h) + ord(e) + ord(l) + ord(l) + ord(o)) / len('hello')
= 106.4
The average ord of 'world' = 110.4
The average ord of 'bye' = 106.7
The maximum ave... |
Your program should take as input a number n that is greater than 0 and output a bar composed of n // 8 ▉ characters (U+2588), as well as a final character which should be one of ▉ ▊ ▋ ▌ ▍ ▎▏(U+2589 to U+258F) representing n % 8. If n % 8 is 0, your program should not output any additional characters. This is difficult... |
A Young diagram is a rectangular binary mask whose every row and every column are sorted in descending order.
It is easy to check that every rectangular binary mask can be formed by xor-ing together a finite number of Young diagrams.
This decomposition is by no means unique, but there will be a minimum number of Young ... |
Write a script, program or function which takes one input of type string and outputs or returns some sort of indication wether the input string was 'hi whats up' (without the apostrophes) or not.
You can for example return true if it was and false if it wasn't. Or print something to the screen, like 1 or 0.
It just has... |
There exists a bijection between the natural and rational numbers that works (approximately) like this:
You create a 1-indexed 2-dimensional grid.
In every field of this grid with position (x, y), put the number x / y.
You start at (1,1) and iterate over the field in the following way:
However, this task is not abou... |
The pyramid begins with the row 1 1. We'll call this row 1. For each subsequent row, start with the previous row and insert the current row number between every adjacent pair of numbers that sums to the current row number.
$$
1\quad1\\
1\quad\color{red}{2}\quad1\\
1\quad\color{red}{3}\quad2\quad\color{red}{3}\quad1\\
1... |
Background
For the purposes of this challenge, we'll define a "perfect nontransitive set" to be a set \$A\$ with some irreflexive, antisymmetric relation \$<\$, such that for all \$a \in A\$ we have that \$|\{x \in A|x<a\}|=|\{x \in A|x>a\}|\$.
Okay, now in layperson's terms: \$A\$ is a set of elements with no duplicat... |
A near-repdigit number is a positive integer where all the digits are the same, except one. For example 101 and 227 are near-repdigits. A near-repdigit prime is a near-repdigit that is also prime. For example:
101, 113, 131, 151, 181, 191, 199, 211, 223, 227, 229, 233, 277, 311, 313, 331, 337, 353, 373, 383, 433, 443, ... |
Background
Boolean Algebra concerns representing values with letters and simplifying expressions. The following is a chart for the standard notation used:
Above is what actual boolean algebra looks like. For the purposes of this code golf, this is not the syntax that will be used.
Your Task
Given a string with three c... |
Background
HQ0-9+-INCOMPUTABLE?! is a half-joke programming language introduced in Internet Problem Solving Contest 2011, Problem H.
HQ9+ is an esoteric programming language specialized for certain
tasks. For example, printing “Hello, world!” or writing a quine (a
program that prints itself) couldn’t be any simpler. U... |
Given a non negative integer number tell if it can be erased by repeatedly removing all occurrences of the length of that number from it including overlapping matches.
Erasing means cancel all its digits.
For example the number 4440 is not lengthy because after removing all 4's you obtain 0 which cannot be erased.
Nei... |
There was a previous perceptron question but it was closed. Also it required a lot of extra stuff that's not normally part of the perception algorithm like I know it. This question will be much simpler
The Perceptron is a extremely basic classification algorithm. While it still has some limited use it's been mostly ove... |
A palindrome is a word that is its own reverse. I will define the left palindromic root of a word as the shortest prefix of the word for which the shortest possible palindrome that begins with that prefix is the original word. So the left palindromic root of racecar is race and the left palindromic root of ABBA is ABB.... |
Warning: Wouldn't you rather answer a challenge about ponies?1
If you have read The Hostile Hospital, you would know that the Baudelaire orphans, from one of the scraps of paper recovered from the Quagmire's notebooks, they discover a name, "Ana Gram". Later on, they realize that means the word "anagram", not a name.... |
The task
Most Casio calculators featured a variable M, which has 3 operators related to it: M, M+, and M-
M, as you can expect, returns the value stored in the variable.
M+ takes the number on the left and add it to M.
M- does the same thing as M+, but subtract instead.
To make the challenge just a bit more difficult, ... |
Given is a grid polygon by the list of its integer vertex coordinates arranged along the perimeter, in the form
\$(x_1,y_1), (x_2,y_2), \cdots , (x_n,y_n)\$ with \$n \ge 3\$.
The polygon is completed by connecting point \$n\$ to point \$1\$.
For simplicity, it may be assumed that the polygon is simple and does not have... |
Background
With the success of Simple Boolean Algebra Calculator, I present a more difficult problem.
Boolean Algebra concerns representing values with letters and simplifying expressions. The following is a chart for the standard notation used:
Above is what actual boolean algebra looks like. For the purposes of this... |
The famous game of Qwirkle has simple but intricate rules (See part 2 of this question for a summary of the rules!)
The Challenge
You are somehow (text input, function parameter, whatever) given a board of a Qwirkle game, like a snapshot from any current timeframe within a game. This board can be anything from complet... |
Your task
Given a numerical string or integer \$\ge 0\$ (which may have leading zeros), convert it to letters using the below rules.
Rules
Loop through the digits:
If the digit is 0 or 1, combine it with the next digit and output that letter of the alphabet (0-indexed).
If the digit is 2, combine with the next digit O... |
The Cabbage, Wolf, Goat riddle with a twist!
Backstory:
There’s an intergalactic river than needs to be crossed! Being a space-ferryman you’ve offered some aliens on your small space ferry that can only carry two entities: you and a passenger. However, you know that because politics, some of these aliens will instantly... |
Inspiration
There is a problem on the most recent AMC 12B test, the one held on November 16, 2022, which goes like this:
(AMC 12B 2022, Question 17)
How many \$4\times4\$ arrays whose entries are \$0\$s and \$1\$s are there such that the row sums (the sum of the entries in each row) are \$1\$, \$2\$, \$3\$, and \$4\$,... |
Input: A string
Output: The rarity of the string, as described below.
To find the rarity of a string, follow the steps below.
Start with 0.
Subtract 3 for each E, A, T, or O in the string.
Subtract 2 for each I, N, S, or H in the string.
Subtract 1 for each R, D, L, or C in the string.
Add 1 for each W, F, G, or Y in ... |
Background and Rules
There is a variant of chess called atomic chess, which follows essentially the same rules as normal chess, except that pieces explodes other pieces around them when captured. In addition to checkmate, you can also win the game by blowing up the king.
When a piece captures another piece, all adjace... |
It frustrates me that when you say "base 16", the 16 is in base 10. We need a base neutral way of writing down numbers when favoring a specific base would be inappropriate.
How it works
We define <n> to be the nth prime. So <1>=2, <2>=3, <3>=5. Note that every positive integer can be uniquely represented by the product... |
The aim is to create an algorithm to detect that one of the string in a small list of strings contains %s, %d, %f, or %r. All sub-string will start by '%' and be 2 characters longs. Input string will be from 1 to 500 characters with a median of around 20 characters and contain zero to multiple of the possible sub-stri... |
(This is OEIS A057531.)
Your task
Given a positive integer, \$n\$, find the \$n\$th number where the digit sum equals the number of factors
Explanation
For example, let's take 22:
Its factors are \$[1, 2, 11, 22]\$ (length: 4).
Its digit sum is 4.
This means that it is a number where the digit sum equals the number of ... |
The challenge is to write a program which will find the shortest (least number of characters) command which will navigate to a target directory, given a starting directory, assuming a standard linux file system.
Take the following file system as an example, starting from ~:
.
├── target
└── test
└── starting
If th... |
Your task
Given a string, output the range of ASCII values.
Example
Let's say we have the string Hello.
We get the ASCII values:
H = 72
e = 101
l = 108
l = 108
o = 111
Now, we get the range (max - min):
111 - 72 = 39
Our answer is 39.
Test cases
Input Output
Hello, World! 82
aaaaa 0
Code Golf ... |
I like to play (The Settlers of) Catan on Board Game Arena with totally random number tokens. These tokens determine the production rate of the terrain tiles beneath:
There are 18 number tokens, two each of 3, 4, 5, 6, 8, 9, 10, 11 and one each of 2 and 12. A valid arrangement of these tokens on the board (19 hexes in... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.