instruction stringlengths 34 53.1k |
|---|
Inspired by this video by Ben Eater. This challenge forms a pair with Decode USB packets.
The USB 2.0 protocol uses, at a low level, a line code called non-return-to-zero encoding (specifically, a variant called NRZI), in which a stream of bits is encoded into a stream of two electrical level states J and K. Encoding w... |
The Collatz sequence
Given a positive integer \$a_1\$, the Collatz sequence with starting value \$a_1\$ is defined as
\begin{equation}
a_{n+1} =
\begin{cases}
a_n/2 & \mathrm{if}\ a_n\ \mathrm{is}\ \mathrm{even} \\
3a_n+1 & \mathrm{if}\ a_n\ \mathrm{is}\ \mathrm{odd}.
\end{cases}
\end{equation}
It is conjectured that, ... |
5 Years ago, this happened, and then it became sort of a meme.
Challenge
The Challenge today is, to check if a "magic square" is a valid parker square.
What is a Real Magic square?
All the numbers must be natural or sometimes 0
The sum of rows, columns and diagonals must be same.
There must be no repeating numbers
Wh... |
Sandbox
Given a boolean matrix representing my grass field, sheep length \$n\$ and wool thickness \$k\$, you will have to count my sheep.
A sheep is a single independent unbroken line of sheep length \$n\$ and thickness \$k\$.
#|##|# | #
#| | #|#
are all valid sheep for \$n=2,k=1.\$
##|###|## | ##
##|###| ## | ## ... |
Background
The fixed-point combinator \$\textsf{fix}\$ is a higher-order function that computes the fixed point of the given function.
$$\textsf{fix}\ f = f\ (\textsf{fix}\ f)$$
In terms of programming, it is used to implement recursion in lambda calculus, where the function body does not normally have access to its ow... |
Risky is a new language of mine, which features an interesting form of tacit programming. In this challenge, you'll take a Risky program as input, and visualize the parsing.
No knowledge of Risky is needed for this challenge, but it's a pretty interesting language so I'd recommend trying it :p.
Task
Risky's parsing is ... |
Multi-dimensional chess is an extension of normal chess that is played on an 8x8x8x8... "board".
In normal 2D chess, a knight's move is a movement by a vector of \$ \begin{bmatrix} \pm 2 \\ \pm 1 \end{bmatrix} \$ or \$ \begin{bmatrix} \pm 1 \\ \pm 2 \end{bmatrix} \$, as long as it doesn't cause the knight to go outside... |
Task
Given a square array of 0s and 1s, determine whether or not there exists a path of 1s connecting the leftmost and rightmost columns. A path can take steps of one unit up, down, left or right, but not diagonally. Every symbol on the path must be a 1, and it must start somewhere in the first column and end somewhe... |
Intro
You like cats. Naturally, you like cat’s games in tic-tac-toe. So, you’ve come up with a little party trick.
You ask someone what square on the board they want you to make a move in. And you ask someone else on which turn they want you to make that move. You also let that person decide whether you play Xs or Os. ... |
Mr. Binary Counterman, son of Mr. Boolean Masker & Mrs. Even Oddify, follows in his parents’ footsteps and has a peculiar way of keeping track of the digits.
When given a list of booleans, he counts the 1s and 0s separately, numbering the 1s with the odds & the 0s with the evens.
For example, when he looks at 1 1 0 0 1... |
We'll call the consecutive distance rating of an integer sequence the sum of the distances between consecutive integers. Consider 2 9 3 6 8 1.
2 9 3 6 8 1
<----5---->
<-2->
<--3-->
\$2\$ and \$1\$ are consecutive integers, and their distance apart in the sequence is \$5\$.
\$2\$ and \$3\$ are consecutive integers, a... |
Consider a binary operator \$*\$ that operates on a set \$S\$. For simplicity's sake, we'll assume that \$*\$ is closed, meaning that its inputs and outputs are always members of \$S\$. This means that \$(*, S)\$ is a magma
Let's define some basic terms describing the properties of \$*\$. We can say that \$*\$ can have... |
Background
Binomial transform is a transform on a finite or infinite integer sequence, which yields another integer sequence. The binomial transform of a sequence \$\{a_n\}\$ is given by
$$s_n = \sum_{k=0}^{n}{(-1)^k \binom{n}{k} a_k}$$
It has an interesting property that applying the transform twice will yield the ori... |
Given a list of coordinate pairs, output the Trapezoidal Riemann Sum of the values given between the first and last x-coordinates.
You will be given a sorted list of coordinate pairs, like this:
[
[1,2],
[3,5],
[5,11]
]
Note that x-coordinates will always be in increasing order, ys may not.
My way to do this is ... |
Your challenge is to write a function/program that takes a matrix of integers m and a number n as input and:
Splits m into n by n chunks
Replaces each chunk with the most common value in that chunk (In case of a tie, any of the tied values is fine).
Outputs the resulting matrix.
Note: You can take either the size ... |
Task
Given a list of nodes representing a binary tree of positive integers serialized depth-first, return a list of nodes representing the same tree serialized breadth-first. To represent an absent child, you may use null, 0, 'X', Nothing, [], or any other value that is distinct from your representation of a node's val... |
Inspired by the problem with the same name on Puzzling SE by our very own Dmitry Kamenetsky.
You are to find the largest number that only uses every digit pair once, in a given base. For example, in ternary we have 2212011002.
Challenge: Given a base from 2-10, output the largest number in that base with no repeating d... |
Introduction
In a standard* (e.g. not 2020) tax year, estimated payments are due quarterly according to the schedule outlined in Publication 505.
Payment Period
Due Date
January 1 – March 31
April 15
April 1 – May 31
June 15
June 1 – August 31
September 15
September 1 – December 31
January 15
* Saturd... |
Inspired by Wzl
Determine if a given square binary matrix has exactly one row or column consisting of entirely 1s, and the rest of the matrix is 0s.
For example, these are all true:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1
0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 ... |
If you have ever looked at an objdump of a C++ program, you have likely seen something like this:
_ZN3foo3bar3bazI6sampleEE3quxvi3foo
This is a C++ mangled symbol, which encodes the namespaces, classes, and function/template arguments, using the Itanium ABI.
Specifically, it is for the following function:
void foo::ba... |
Background
So, nowadays the popular Prisoner's Dilemma variant is the Prisoner's Trilemma, where there are three options. I can easily see that being increased, so I figured
Why settle for three options, when we can have INFINITE options?
Therefore, I created the Floating Point Prisoner's ?Lemma.
Equations:
Each roun... |
Related: Counting polystrips
Background
Link-a-Pix is a puzzle on a rectangular grid, where the objective is to reveal the hidden pixel art by the following rules:
Connect two cells with number N with a line spanning N cells, so that the two cells are at the two ends of the line.
The number 1 is considered connected t... |
Print the following text and nothing else:
<html>
<body>
<p>HTML is kinda annoying</p>
</body>
</html>
I'm happy I'm not a web developer.
The catch? Your code must fit the template: print(<?>), where ? can be any group of characters. You can paste your completed code (with the print(<>) part) into this Scast... |
(Based on this closed challenge, related)
Given an integer n > 1, draw a grid composed of the characters: "-" "+" and "|". However, since I want the grid to look nice, the horizontal component should be 2 wide.
Trailing spaces for each line are not required.
Examples:
n = 2
|
--+--
|
n = 3
| |
--+--+--
| ... |
In November 2019, Alon Ran published a particularly lovely sequence in the OEIS, A329126:
\$a(n)\$ is the lexicographically earliest string of digits which yields a multiple of \$n\$ when read in any numeric base.
1, 110, 101010, 111100, 100010001000100010, 1111110, 10000010000010000010000010000010000010, 11111111000,... |
The Len(language,encoding) family of languages is a variety of Lenguage derivatives. To encode a program into a Len language, you replace every character with its representation in a certain encoding, then turn that into a giant integer.
Your challenge is to write a function or program that encodes your language into a... |
Sandbox
Inspired by a Codingame challenge I tried (and failed at) about a month ago.
Given a binary tree of words, say:
HELLO
/ \
WORLD EATING
/ / \
ARCH IDAHO GUARD
/
DOOZY
/
... |
This is an ascii-art challenge where you will draw ascii-art showing a person "jumping" off the top of a building.
The building
Input given will be a group of rectangular buildings. You may assume buildings are not "stacked on top of each other", hence only one row of buildings. This is the standard format of a buildi... |
Your challenge is to construct a proper quine using as few distinct characters as possible.
Scoring
Your score is equal to the number of distinct characters in your code, aiming to minimise this. Standard quine rules apply.
|
According to Wikipedia,
In mathematics, a natural number \$n\$ is a Blum integer if \$n = p \times q\$ is a semiprime for which \$p\$ and \$q\$ are distinct prime numbers congruent to \$3 \bmod 4\$. That is, \$p\$ and \$q\$ must be of the form \$4t + 3\$, for some integer \$t\$. Integers of this form are referred to a... |
There's only one question for machine-language golfing, and it's for the ia32 and amd64 architectures. Here's one for a predecessor of them: the Zilog Z80!
The ISA is available here.
As usual, if your tip is only applicable to a certain environment/calling convention, please indicate that in your answer.
Only one tip ... |
Given a positive integer \$n\$, output \$n\$ 2D bool images with the same width and height such that:
Each image should be 4-connected, i.e. for each two pixels that are true, you can start from one and go up, down, left and right for some times to the other pixel, only passing through true pixels.
Each image should h... |
Say I have a pile of boxes:
AAA
BBB
I can create it in two steps:
BBB
↓
(empty)
---
AAA
↓
BBB
But with this:
AB
BA
I need three steps:
A
↓
(empty pile)
---
BB
↓
A
---
A
↓
B
BA
Your challenge
Given a pile of boxes, output the minimum number of steps needed to create that pile.
A step consists of dropping a ro... |
Desmos is mainly used as an online graphing calculator, but its graphical and mathematical functionalities can also be applied in certain coding challenges.
I know not that many people use Desmos on this site, but for the people that do, what are some tips for golfing in Desmos?
As usual, please keep the tips somewhat ... |
The task is to provide code that evaluates to 0.5 numerically, i.e. the output must be recognized by your chosen language as a numeric value (Number, float, double, etc), not as a string. The catch, the characters 0 through to 9 cannot be used.
PLEASE NOTE: This IS NOT a golfing challenge, this is a popularity contest,... |
Background
Minkowski addition is a binary operation on two sets of points (usually geometric objects) in the Euclidean space. The Minkowski sum of two sets \$A\$ and \$B\$ is formally defined as follows:
$$ A+B = \{\mathbf{a}+\mathbf{b}\,|\,\mathbf{a} \in A,\ \mathbf{b} \in B\} $$
To say in plain English, given the ori... |
Think of cleave as the conceptual inverse of map. If map applies a function to each number in a list...
map([1, 2, 3], x -> x * 5) -> [5, 10, 15]
then cleave applies each function in a list to a number.
cleave(5, [x -> x * 2, x -> x - 1, x -> x * x]) -> [10, 4, 25]
More formally, given:
\$n\$, an integer, and
\$L\$, a... |
You are given a polynomial function, in the following format:
\$x = (c_0 * y^0) + (c_1 * y^1) + (c_2 * y^2) + ... + (c_n * y^n)\$
where \$c_n\$ stands for the coefficient of the \$n^{th}\$ power of \$y\$
You have to plot the equation on a \$10 * 10\$ ASCII matrix. The value must be floored to an integer before plotting... |
Recursively prime-encoded integers
Consider \$11681169775023850 = 2 \times 5 \times 5 \times 42239 \times 5530987843\$. This isn't a nice prime factorisation, as \$42239\$ and \$5530987843\$ make it difficult to store this factorisation in a small manner. Being primes, we can't then factorise them, but we can factorise... |
Write a program which takes two arrays of positive integers as input. One of them (your choice which) will have one item missing compared to the other. Your program must figure out what is missing.
Rules
You can choose which array has one missing: You can take ordinary then missing or vice versa.
Arrays may contain dup... |
I like my job, but sometimes it can get a bit tedious and boring. As motivation, I want to know how many hours of work are left before I finally get my two days of weekend and relaxation.
I work every day from Monday to Friday, totalling 38.5 hours, starting at 9am and ending at 6pm.
Every day - except Friday - I get ... |
Background
As far as we can tell from trying everything (besides cheating with ZWSPs), you can't type
`\
in Stack Exchange chat. However, you can type
\`
by doing
`\\``.
So, if you want to tell someone in chat how to type backslash-backtick, you'd need to type out
`\`\\`\``
to format
`\\``
into a codeblock.
Challenge
Y... |
Background
A checkered tiling of a rectangular grid is a tiling using some polyominoes, where each region can be colored either black or white so that no two polyominoes sharing an edge has the same color. In graph-theoretic terms, the chromatic number of the adjacency graph is 2.
Terminology adapted from a Fillomino v... |
The input for the continuous knapsack problem is as follows.
For each item 1...n we are given a positive weight and profit. Overall we are also given a positive capacity which is the maximum weight we can carry.
The goal is to pick items so that the profit is maximized without exceeding the capacity. This is hard if ... |
Given a string which is guaranteed to be either odd, even, square, cube, prime or composite, your program or function must return an integer \$100\le N\le 999\$ which meets this description.
Rules
Your code must be deterministic.
The choice of the integers is up to you. However, the six answers must be distinct. (For ... |
The setting
"Well I actually wrote the sql library they, the maintainers actually.."
"Right, but do you have any experience working with django?"
" ...no I don't use frameworks"
After the phone interview is over, you feel like you really need a coffee. While the brew is heating, you check your messages on BusinessBook.... |
Input a non-empty array with \$n\$ positive integers. Test if the input array contains every integer in \$1\cdots n\$.
In case you prefer 0-indexed numbers, you may choose to input an array of non-negative integers, and test if the input array contains every integer in \$0\cdots (n-1)\$ instead. All testcases and formu... |
Challenge
Create the image of a pride flag (rainbow flag), i.e. a six coloured striped flag (from top to bottom): red, orange, yellow, green, blue, and violet.
Output
Example (R)
barplot(rep(1, 6), horiz = TRUE, axes = FALSE, space = 0, border = NA, col = c("darkviolet", "blue", "darkgreen", "yellow", "orange", "red")... |
Your task is, to count how many pluses I have.
What Pluses?
The no plus: 0 Points
-
The naïve Plus: 1 Point
+
The double Plus: 2 Points
+
+++
+
The mega double plus: 3 Points
+
+++
+
+ + +
+++++++++
+ + +
+
+++
+
Pluses of higher order than 3 must be ignored.
Rules
Input will ... |
Given an array \$A\$ of size \$n\$.
You have to find the number of subsets such that their product is in the form of \$p_1 \times p_2 \times p_3 \dots\$
where \$p_1, p_2, p_3, \dots\$ are prime numbers. No prime number should appear more than once, i.e. the product is "squarefree".
Example:
Lets pick an array \$A\$ of ... |
Consider, for a given positive integer \$k\$, the sequence \$(a, a+1, a+2, ..., a+k)\$, where \$a\$ is some positive integer. Is there ever a pair \$a, k\$ such that for each element \$a+i\$ in the sequence, either \$\gcd(a, a+i)\$ or \$\gcd(a+i, a+k)\$ are greater than 1?
This was investigated by Alan R. Woods as part... |
Take an array of nonnegative integers, such as [1, 0, 0, 1, 2, 4, 2, 0]. Then, draw that as a mountain where the integers represent altitude:
x
x x
x x
xx x
You may use any printable non-whitespace character in place of x, and adding padding or whitespace after lines or the output is fine... |
This time, you are working on a regex. Your regex is meant to approximately full-match the base-10 representations of primes \$0 \le p < 1000\$, while ignoring any non-numeric string or composite in the range. You can full-match 2, 53 or 419, but not 0, 82 or example.
The approximately is important -- a minimum of 900 ... |
Most Unicode characters have full names, for example ” is "RIGHT DOUBLE QUOTATION MARK". You can find a useful reference here, just type in the character you want to find the full name of and look in the DESCRIPTION column.
Your challenge is to write a program or function that outputs itself as a string of these. You c... |
As some of you may remember, Peter, who was a picky eater is now puzzled Peter.
This time Peter got some puzzles as a present from his Aunt. He has tried a lot, but has failed to solve the puzzles. Peter needs your help to solve them.
Each one of the puzzle has 2 pieces. To solve the puzzle, you must tell the number of... |
Totally not inspired by Lyxal repeatedly mentioning elevators in chat :P
Challenge
In short: simulate some people filling up an elevator and then leaving it.
The elevator is simplified as a grid, where each person can occupy one cell of the grid. The height and width of the grid is the input parameter. The width is alw... |
To get this sequence I just made up, which will subsequently be referred to as TSIJMU, consider the harmonic series:
\$ \frac{1}{2} + \frac{1}{3} + \frac{1}{4} ...\$
But what if you only add a term if it doesn't make the sum so far over 1, and otherwise subtract? Let's see an example here, starting at \$\frac{1}{2}\$:
... |
Your task is to create either a console "app" or a function which allows the user to bet on certain numbers or retire / claim rounds.
Bets
Your program or function will prompt for a command after an action, and the bet is the most important, crucial to the operation of the app.
A bet looks something like this:
bet 5
b... |
Challenge
Given two positive integers \$1 \le m \le 12\$ and \$1\le d \le 31\$, representing a month and days into the month, output the amount of days that have passed since January 1st, on a non-leap year. You can assume that the number of days passed will always be constrained by the number of days in the month (so ... |
Background
Hamiltonian circuit problem is a decision problem which asks whether a given graph has a Hamiltonian circuit, i.e. a cycle that visits every vertex exactly once. This problem is one of the well-known NP-complete problems.
It is also known that it remains so when restricted to grid graphs. Here, a grid graph ... |
The name of the challenge was prompted by this GIF and the GIF also gave me the idea.
Your challenge today is to take a input guaranteed to be \$2<=n<=100\$ and output a sequence of x and - characters.
The output for a number N represents a sequence of operations applied to 1 where x means "multiply by 2" and - means "... |
I have to fill in 2fa codes all day. They're 6-digit strings. One day I noticed that not once did any of these codes contain 6 unique digits, like 198532 There was always at least one double, like 198539 (here it's 9).
For any given uniformly random string of \$N\$ digits in the set \$\{0,1,2,3,4,5,6,7,8,9\}\$, what is... |
Your toy in this challenge is a special abacus of 4 rows and 8 positions per row. There's one bead on the first row, 2 beads on the 2nd row, 3 beads on the 3rd row and 4 beads on the 4th row. Beads on a same row are glued together, which means that they can only be moved as a block.
Below is a valid configuration of th... |
As in this question, your task – should you choose to accept it – is to calculate the date of Easter Sunday according to the Gregorian Computus (as used in the Catholic Church and most others) when provided with only a year number as input, in as few characters as possible without relying on Easter-specific date functi... |
Background
A Medusa have released a dangerous Hydra which is revived unless the exact number of heads it have is removed. The knights can remove a certain number of heads with each type of attack, and each attack causes a specific amount of heads to regrow. The knights have hired you to write a program or function that... |
Challenge: Given an expressions made of additions and multiplications, output an expression that is a sum of products. The output must be equivalent to the input modulo the law of distribution. For example, \$1 + ((2 + 5\times 6) \times(3+4))\$ becomes \$1 + 2 \times 3 + 2 \times 4 + 5\times6\times3 + 5 \times 6 \times... |
Inspired by this 3Blue1Brown video
Given a square matrix \$ M \$, compute its matrix exponential \$ \exp(M) \$, which is defined, using an extension of the Maclaurin series for \$ e^x \$, as
$$ \exp(M) = \sum_{r=0}^\infty \frac {M^r} {r!} = M^0 + M^1 + \frac 1 2 M^2 + \frac 1 6 M^3 + \cdots + \frac 1 {n!} M^n + \cdots ... |
Giuga numbers (A007850) are composite numbers \$n\$ such that, for each prime factor \$p_i\$ of \$n\$, \$p_i \mid \left( \frac n {p_i} -1 \right)\$. That is, that for each prime factor \$p_i\$, you can divide \$n\$ by the factor, decrement it and the result is divisible by \$p_i\$
For example, \$n = 30\$ is a Giuga num... |
I wrote this function in 48 bytes and I wonder, is there any way to write this code 2 characters shorter?
p=lambda n,c:(n*c)[:n//2]+(n*c)[:n//2+n%2][::-1]
The point of the function is to create a palindrome of length n by using all the characters from the string c. Example: n = 3, c = 'ab'. Result is 'aba'.
Is there s... |
Because ARM is the July 2021 LoTM, I figured I'd create the tips thread.
ARM is probably the most successful architecture for the digital world. From mobile phones to supercomputers, ARM is everywhere! Consequently, let's have a thread where we can help each other shorten our ARM code.
One tip per answer, and no stupid... |
Everyone knows, that you can leave out the multiplication symbol (\$\times\$, or *) in
a*b
23*a
(2+3)*a
a^(b*c)
(a+b)*(c+d)
but not in
2*3 => you don't want it to be 23
a*23 => most mathematicians just don't do it
a^2*b => now it's (a^2)*b, if you remove the *, it's a^(2b)
a/2*b => now it's (a/2)*b, if you remove th... |
Create a function that accepts a list of dates (unsorted with possible duplicates) and returns the days of the week in one of the following formats:
A format similar to MTWTFSS or SMTWTFS (i.e. beginning with Monday or Sunday), with non-days replaced by an underscore _, illustrated below.
WEEKDAY if all the dates are ... |
The Lost Numbers are 4, 8, 15, 16, 23, 42. Your goal is to create an expression to output them all.
Your allowed characters are 0123456789, ^+-*/, (), % for modulo and n as the single variable allowed. Modified PEMDAS ()^*/%+- is the precedence and / is normal division (3/2 = 1.5). 0^0 = 1 although division by 0 is und... |
A screen consists of some LED segments like such:
The screen can be split into several(maybe one) component. Each component is a segment like above, with varying lengths. These components can be used to display any amount, including 0, of digits, as long as the component is large enough.
Every digit except 1 needs two... |
When you export data in JSON from Facebook, the multi-byte Unicode characters are broken. Example Unicode characters and their representation inside JSON:
'\u00c2\u00b0' : '°',
'\u00c3\u0081' : 'Á',
'\u00c3\u00a1' : 'á',
'\u00c3\u0089' : 'É',
'\u00c3\u00a9' : 'é',
'\u00c3\u00ad' : 'í',
'\u00c3\u00ba' : 'ú',
'\u00c3\u00... |
Challenge
Given two lists of strings where each string is of length 50 and each list is also of length 50 generate the shortest regex you can that fully matches all the strings in the first list and does not match any of the strings in the second list.
Scoring
Your score will be the average length of the regexes your p... |
When Alice was touch typing on her QWERTY keyboard (Figure 1), she accidentally shifted both of her hands rightwards by one key, so q became w, w became e, etc. (p became [). Spaces were not affected because the space bar was quite big.
Your task is to help her fix her message using the shortest number of bytes, i.e. u... |
Given a boolean function with inputs, check if it's possible to only use IMPLY gate to express it.
There's no extra limitation on how you use this gate, and you can use each input for any amount of times. See examples below:
\$\begin{matrix}
\text{Expression}&&&&&\text{Solution}&\text{Your output}\\
a&0&0&1&1&a&\text{t... |
A complete Boolean function is a function such that, an amount of them can be used to express any Boolean function. For example, NAND \$\left[\begin{matrix}\text{input1}&0&0&1&1\\\text{input2}&0&1&0&1\\\text{output}&1&1&1&0\end{matrix}\right]\$ is complete. Inputs may be reused any number of times, and the functions ca... |
Key links:
Troll question
Chat room
Game
Controller Interface
Dwarf league table
<script src="https://ajfaraday.github.io/Thud/dist/data/tables.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><table> <thead> <tr> <th>Client</th> <th>Wins</th><th>Loses</th> <th>S... |
Key Links
Dwarf question
Chat room
Game
Controller Interface
Troll league table
<script src="https://ajfaraday.github.io/Thud/dist/data/tables.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><table> <thead> <tr> <th>Client</th> <th>Wins</th><th>Loses</th> <th>Sc... |
Background
We've had challenges before on Fibonacci
coding and Zeckendorf
representation. These representations follow naturally from Zeckendorf's
theorem, which states
that every positive integer can be represented uniquely as the sum of one
or more distinct, non-consecutive Fibonacci numbers. For example:
$$
\begin... |
The purpose of this challenge is to solve the original first Project Euler problem, but as the title suggests in constant time (with respect to the size of the interval).
Find the sum of all the multiples from a list of numbers in some defined range, in such a way that the running time of your program runs in constant... |
Imagine you are sitting at a park. Suddenly your car gets hijacked and being driven in different directions. Here are the directions, arrows show which direction goes towards where:
South
|
V
East-> <-West
^
|
North
After being driven, the car stops. Now you have to find out ho... |
Originally from a CMC I proposed for the last BMG event
Challenge
Given a non-negative integer \$n\$, create a 2D array of size \$2^n × 2^n\$ which is generated in the following manner:
Divide the matrix into four quadrants of size \$2^{n-1} × 2^{n-1}\$.
Visiting order of the four quadrants is defined to be the Z-shap... |
I'd like to roll up the ability scores for my Dungeons and Dragons character. But I'd also like them to be balanced (and slightly better than average).
Typically, a character's stats are created by rolling four 6-sided dice, adding together the three highest results, and doing this 6 times. A 6 sided die has the number... |
You are a package handler for Big CompanyTM and your job is to load boxes into a truck. These are special, stretchy trucks: their length can be adjusted at will. But stretching trucks are expensive, so keep the truck lengths as short as possible!
The Challenge
Write a full program or function that, when given the truck... |
Let \$R, C\$ be positive integers and let \$0 < s \leq 1\$. Consider the \$R \times C\$ matrix \$\mathbf M\$ defined as
\begin{equation}
M(i,j) = \frac{\mathrm{mod}\,(j, i^s)}{R^s}, \quad i = 1, \ldots, R, \quad j = 1, \ldots, C
\end{equation}
where \$\,\mathrm{mod}\,\$ denotes the modulo operation: for \$a,b > 0\$ not... |
Background
Shadow transform of a 0-based integer sequence \$a(n)\$ is another 0-based integer sequence \$s(n)\$ defined with the following equation:
$$
s(n) = \sum_{i=0}^{n-1}{(1 \text{ if } n \text{ divides } a(i), 0 \text{ otherwise})}
$$
i.e. \$s(n)\$ is the number of terms in \$a(0), \cdots, a(n-1)\$ that are divis... |
Vyxal is a stack-based language, meaning that everything operates by popping and pushing values onto a stack. It has a bunch of useful flags, one of which is r.
Running a Vyxal program with the r flag causes functions to take their elements in reverse order.
For example, the program 5 3 - means: Push 5 to stack, push ... |
Consider a square grid on the plane, with unit spacing. A line segment of integer length \$L\$ is dropped at an arbitrary position with arbitrary orientation. The segment is said to "touch" a square if it intersects the interior of the square (not just its border).
The challenge
What is the maximum number of squares th... |
Gaussian integers are complex numbers \$x+yi\$ such that \$x\$ and \$y\$ are both integers, and \$i^2 = -1\$. The norm of a Gaussian integer \$N(x+yi)\$ is defined as \$x^2 + y^2 = |x+yi|^2\$. It is possible to define a Euclidean division for Gaussian integers, which means that it is possible to define a Euclidean algo... |
Your task is to print out this exact text:
-
||
-|-
|---
|-|--
-|-|--
-|-----
|-|-----
|---|-|--
-|-----|--
---|-|-----
|---|-|-----
|---|-----|--
-----|---|-|--
-|-|---|-------
------|---|-----
|-|---------|-|--
---|-----|---|----
-|-----|-|---------
|-|---|-|-----------
|-----------|---|-|--
-|-----|-|---------|--
--... |
Background
This is a follow up question to the question: Will the Hydra finally die?
As before a dangerous A Medusa have released a dangerous Hydra which is revived unless the exact number of heads it have is removed. The knights can remove a certain number of heads with each type of attack, and each attack causes a sp... |
This challenge was inspired by this tweet.
Idea
Consider a circle with n evenly spaced dots around the perimeter, where each dot has a postive integer value:
Now connect the dots with non-intersecting chords:
Next consider our score, which is the sum of the products of these pairs. When n is odd, the extra orphan do... |
Challenge
Given a graph (a structure consisting of nodes and vertices), classify it according to a few categories.
Specifically, you will be given an unweighted directed graph, which is a set of nodes and edges from one node to another (but not necessarily both ways). You can take this in any reasonable and consistent ... |
Lighthouses on an island have blink codes that let ships know which lighthouse they are seeing. Input should be strings of S and L. Here is a (Python) example of codes for 4 lighthouses as a list of strings:
['SLS', 'SLL', 'SSS', 'LSL']
where:
S = short ON (1 sec)
L = long ON (3 sec)
Long and short ON's are both follo... |
The language
Splinter is an esoteric programming language where data is stored in 'splinters'. There are three different types of syntax:
Simple character output: \character, outputs a character
Splinter storage: (splinter name){code}, stores the code into the splinter with the correct name for later use as is. No... |
The word "levencycle" is inspired by cyclic levenquine challenge.
Definitions
A 1-dup permutation of order \$n\$ is some permutation of \$1, \cdots, n\$ plus one duplicate number in the range.
For example, 1-dup permutations of order 3 include 1, 3, 2, 2 and 3, 2, 1, 3. There are 36 distinct 1-dup permutations of order... |
The Torian, \$x!x\$, of a non-negative integer \$x\$ can be recursively defined as
$$
x!0 = x \\
x!n = \prod^x_{i=1} i!(n-1) = 1!(n-1) \times 2!(n-1) \times \cdots \times x!(n-1)
$$
The Torian is then equal to \$x!x\$ for a given \$x\$. This sequence begins \$0, 1, 2, 24, 331776, ...\$ for \$x = 0, 1, 2, 3, 4, ...\$
Al... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.