instruction stringlengths 34 53.1k |
|---|
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... |
Robbers' Thread
Your challenge is to find an existing challenge, and implement it in a way such that certain inputs fail. At least one input must not produce the correct output (use the other submissions on the challenge as a reference for this, but be sure to double-check). This must fail consistently, and you must kn... |
Cops' Thread
Your challenge is to find an uncracked, unsafe cop on the cops thread, and find an input value for which their code does not do as specified by the challenge.
You must use values within the bounds specified by the cop and the challenge - if a float breaks their program but they specified integers only, it... |
Related: What's my telephone number? which asks to calculate the terms of A000085, the number of possible ordinal transforms of length n.
Background
Ordinal transform is a transformation on an integer sequence. For a sequence \$a=(a_0, a_1, a_2, \cdots)\$, the \$n\$-th term of the ordinal transform \$ord(a)_n\$ is defi... |
Robbers Thread
Cops, your task is to chose a program that prints a string (you can choose).
Although, if you change 1 character in your code, it should print another string.
But there's a twist: You should make your code hard to read, so that the robbers can't find your "changeable" character.
The winner cop is the use... |
Cops thread
Robbers, your task is to crack a cops answer. Reveal the character that should be changed and what it should be changed to too.
Please notify the cop if you cracked their challenge.
The robber winner is the user with the most cracks.
I will declare the winner cop and robber a week after this challenge is po... |
Flavortext
So...this is awkward. It seems I accidentally turned into a monkey last night after eating one too many banana sundaes. This has made many things inconvenient, especially typing. You see, monkeys only need the following characters: uppercase letters (A-Z), space, comma (,), exclamation mark (!), and question... |
Background
Polyagony is a family of hypothetical esolangs where the source code is laid out on a specifically shaped board before running it. It's similar to Hexagony, but various uniform tilings can be used instead of a simple hexagon. The shape of the board and the tiling used is defined by the "mode".
Mode 3/3,6 is ... |
A screen consisted of some LED segments like such:
_ _ _ _ _
|_|_|..._|_|_|
|_|_| _|_|_|
However, some of the LEDs are broken, and it's possible that only these are left:
_ _
_|_|
|_|_|
Now, you're required to output all integers possibly expressed on this screen. An integer, something matching RegEx /^0$|^-?... |
To celebrate the island's next Founder's Day, colored filters (fuchsia, chartreuse, and aquamarine*) have been installed in every lighthouse. All lighthouses begin operation with their fuchsia filter, and they are all on the same color cycle: FCA, FCA, ... Each lighthouse changes its color filter after every ON blink,... |
When this question was posted, it was caird coinheringaahing's birthday! (source: 1, 2, 3, 4) (It was also World Emoji Day.)
As a bit of some CGCC lore, caird's name came from a Jelly answer by Dennis (source) - the compressed form of "Code Golf" in Jelly is “½ċṭ6Ỵ», and if you insert a space (“½ċṭ6 Ỵ»), it becomes "ca... |
Given an array of integers. Find out its longest sub-array (contiguous subsequence) whose sum is 0.
The sub-array for output may be an empty array.
Input
Input an array of integers.
Output
Output the longest zero sum sub-array. If there are multiple such arrays, output any one of them.
Output Format
You may output in o... |
Summer Klerance, a senior in college, is what her teachers refer to as GBL*. Students in her probability class have been assigned individual problems to work on and turn in as part of their final grade. Summer, as usual, procrastinated much too long, and, having finally looked at her problem, realizes it is considerabl... |
Background
A Jordan matrix is a block-diagonal matrix where each block on the diagonal has the structure of
$$
\begin{bmatrix}
\lambda & 1 & 0 & \cdots & 0 \\
0 & \lambda & 1 & \cdots & 0 \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
0 & 0 & 0 & \lambda & 1 \\
0 ... |
Introduction
Let's draw some regular hexagons formed by hexagonal tiles, marking the vertices of the tiles with dots. Then we will count the number of dots.
size 1: 6 dots
. .
. .
. .
size 2: 24 dots
. .
. . . .
. . . .
. . . .
. . . .
. . . .
. .
size 3: 54 dots
. .
. . . .
... |
\$\left\{ n \atop k \right\}\$ or \$S(n, k)\$ is a way of referring to the Stirling numbers of the second kind, the number of ways to partition a set of \$n\$ items into \$k\$ non-empty subsets. For example, to partition \$\{1,2,3,4\}\$ into \$2\$ non-empty subsets, we have
$$\begin{matrix}
\{\{1\},\{2,3,4\}\} & \{\{2\... |
We have 3 dice in a square dish. The dish is 8 units wide and tall and each die is 3 units wide and tall. The dice are facing up each with a different number on their top face.
111..222
111..222
111..222
........
........
333.....
333.....
333.....
Then we play a game. At each step we can slide any 1 die in any card... |
Links
Chat room
The official game report
Github repo - In case of bugs to report
Here's the official score table:
<script src="https://ajfaraday.github.io/nose_poker/ogres.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><table> <thead> <tr> <th>Ogre</th> <th>Han... |
Background
In Haskell and many other functional languages, function application f(x) is simply written as f x. Also, this form of function application is left-associative, which means f x y z is ((f x) y) z, or ((f(x))(y))(z).
Haskell also has a binary operator called $. f $ x does function application just like f x, b... |
Hermite polynomials refer to two sequences of polynomials:
The "probabilist's Hermite polynomials", given by
$${He}_n(x) = (-1)^n e ^ \frac {x^2} 2 \frac {d^n} {dx^n} e ^ {-\frac {x^2} 2}$$
where \$\frac {d^n} {dx^n} f(x)\$ refers to the \$n\$th derivative of \$f(x)\$
The "physicist's Hermite polynomials", given by
$... |
The challenge is simple: Read 3 letters from a system input¹ and convert them to numbers (A-1, B-2, C-3...Z-26)². Print each of those numbers in the order the letters were inputted in, each on a new line and then the sum of all 3 numbers, on its own line as well.
NOTE: There will be no extra input characters, only 3 le... |
Given an input value \$n\$, construct an array of \$n\$ random 128 bit (unsigned) integers. The integers should be uniformly random.
Your code can use any in built random number generation function it has or you can implement your own. Clearly this challenge is harder (and more fun) in lower level languages.
|
Summer Klerance turned in her term assignment for this challenge. Her professor was miffed (but also amused) when he overheard a disgruntled classmate of Summer's saying she got her answers by simulation rather than by the probabilistic methods covered in the course. Summer received a note to see the prof during his ne... |
Given a long multi-sentence string, the goal is the count the occurrences of the following words: park, lake, Santa Fe.
The words can appear as substrings of other words, i.e, parked counts as an instance of park.
Santa Fe counts as one word (so the space matters). Both Santa and Fe appearing alone or out of order does... |
Find the moves that bring a chess squad to a given destination.
You control a chess squad consisting of a king and several other pieces, on a larger chess board. Your army is placed so that no piece is further than K=8 squares away (horizontally and vertically) from your king. You will receive a destination square for ... |
A001057 is one way to represent an integer as a natural number. It lists them according to the following pattern:
0, 1, -1, 2, -2, 3, -3, 4, -4, ...
In this challenge, you'll take two distinct integers as input and return which is at a higher index in this enumeration.
Take -2 and 1 as an example: -2 comes after 1, so... |
Write an \$n\$-bytes program \$AB\$ such that:
it outputs an integer \$x,\ 0\lt x\lt n\$;
both its \$x\$-byte prefix \$A\$ and \$(n-x)\$-byte suffix \$B\$, when run as programs, output \$AB\$.
\$A, B\$ and \$AB\$ should:
run in the same language
not take any input
use the same output method
This is code-golf, so th... |
Consider the following binary matrix:
$$\begin{matrix}
1 & 0 & 1 \\
1 & 0 & 0 \\
0 & 1 & 1
\end{matrix}$$
The (1-indexed) co-ordinates of the \$1\$s here are \$(1,1), (1,3), (2,1), (3, 2), (3, 3)\$. We can also notice that there are three "shapes" of \$1\$s in the matrix, made of orthogonally connected \$1\$s:
$$\begin... |
Background
Stick Bomber is a two-player game I just made up. Initially, some sticks are placed in one or more groups, and the sticks in each group are laid out in a straight line. So a configuration with three groups of 3, 5, and 8 sticks each may look like the following. For conciseness, we can call it a (3,5,8) confi... |
This is similar in concept to this challenge, but that is pretty restrictive on input and output and I think opening up these restrictions would lead to a completely different set of solutions that would be interesting in their own right.
Background
Set is a card game in which players compete to construct sets of thre... |
Background
Lambda calculus is a model of computation using lambda terms.
A variable \$x\$ is a lambda term.
If \$E\$ is a lambda term, the lambda abstraction \$\lambda x. E\$ is a lambda term.
If \$E_1, E_2\$ are lambda terms, the lambda application \$E_1 E_2\$ is a lambda term.
The rule of computation is called \$\b... |
Code-Golf caddy Eddie Brackets was getting tired of quine challenges, which appeared to be much too easy for the grand poobahs. He has this idea to spice up things and is sending quines to the car crusher.
Challenge:
Write a quine that prints itself "squeezed" for output purposes into an n x n square followed by that s... |
Task
Haskell's and Scala's standard libraries have an unfold function that builds a list from an initial state s and a function f. This is done with the following steps (explained in an imperative way to be simpler):
Apply f to s.
If the result
is empty, we're done building the list!
Otherwise, the result should cont... |
Background
A338268 is a sequence related to a challenge by Peter Kagey. It defines a two-parameter function \$T(n,k)\$, which counts the number of integer sequences \$b_1, \cdots, b_t\$ where \$b_1 + \cdots + b_t = n\$ and \$\sqrt{b_1 + \sqrt{b_2 + \cdots + \sqrt{b_t}}} = k\$. Since \$k\$ cannot be larger than \$\sqrt{... |
Related
Given a piece of ascii art and a factor to enlarge it by, which will always be an odd number >1, replace each character with the corresponding ascii-art, resized to fit on a grid the size of the input number:
Character
What to do
\
\ \ \A line of \ to the length of the enlarging factor, padded to fo... |
Introduction
Factorials are one of the most frequently used examples to show how a programming language works.
A factorial, denoted \$n!\$, is \$1⋅2⋅3⋅…⋅(n-2)⋅(n-1)⋅n\$.
There is also the superfactorial (there are other definitions of this, but I chose this one because it looks more like the factorial), denoted \$n$\$,... |
I have 2 inputs: 1 single number and some numbers separated by whitespace:
1
1 2 3 4 5
I want to loop over the second input, and I don't need the first input. I did this, which works:
input()
for x in input().split():somecode()
But can I go directly to the second input without doing the input() at the beginning or wi... |
Your challenge is to write a program that is a quine, meaning it prints out its own source code.
For at least one individual character, when it is removed from the program's source, a single different character is removed from the output.
By different, I mean that the character removed from the code is distinct from th... |
Background
Math SE's HNQ How to straighten a parabola? has 4,000+ views, ~60 up votes, 16 bookmarks and six answers so far and has a related companion HNQ in Mathematica SE How to straighten a curve? which includes a second part asking to move a point cloud along with the curve that we can ignore here.
From the Math SE... |
Let \$A\$ be a square matrix that is at least \$2 \times 2\$ where each element is an integer. \$A^2 = A \times A\$ will then have the same dimensions as \$A\$, and will have integer elements. For example, let
$$A = \left[ \begin{matrix}
-3 & 2 \\
0 & -1
\end{matrix} \right]$$
Therefore,
$$\begin{align}
A^2 & = \left... |
Challenge
Imagine a hexagonal grid as shown below. Let's call such a grid has size \$n\$ if it has \$n\$ dots on one side. The following is one of size 3:
- - -
- - - -
- - - - -
- - - -
- - -
Then, pick as many dots as possible on the grid so that no two dots are adjacent. For size 3, the maximum is 7 dots:
-... |
This question is about moving stacks around in the card game FreeCell, but here it will be presented more abstractly.
Given three integers \$0\le n,m<10000,0<k<10000\$.
There are \$m+2\$ columns, \$m\$ of them empty and two of them contain cards (from bottom to top) \$[0,-2,k]\$ and \$[0,-3,k-1,k-2,\cdots,1,0]\$. Besid... |
Related
A room, in the context of this challenge, is a multidimensional array where the elements on the "outside" are 1, to represent the walls, and all the other elements are 0 (empty space inside the room)
Here's a 1D room with size 5:
[1,0,0,0,1]
And here's a 2D room with size 6x4:
[[1,1,1,1],
[1,0,0,1],
[1,0,0,1... |
My PIN number is 1077, but that's too difficult to remember. I know from muscle memory that it's a digit, followed by a different digit, then followed by two of the same digit, which is different to the other two digits before it. As a pattern, we can say it is ABCC (where each letter represents a digit, and the same ... |
Background
Supplementary reading 1, Supplementary reading 2
Linear lambda calculus is a limited form of lambda calculus, where every bound variable must be used exactly once. For example, \a b c d e -> a b (d c) e is a valid term in linear lambda calculus. When embedded as a logic system, this enforces each input to be... |
This problem is inspired from shinh's problem.
Given an input of positive integer \$n\$, output a smiley triangle (see below) with \$n\$ rows.
Detailed rules
Can be either a function or a full program.
Standard I/O rules applied.
RULE CLARIFICATION: Output as exactly a string, rather than an array of strings whose it... |
I'm trying to make a pointfree function f that can act like APL's dyadic forks/Husk's §, so f g h i a b equals g (h a) (i b), where g is a binary function, h and i are unary functions, and a and b are integers (I'm only dealing with integers and not other types right now). I converted the function to pointfree in the f... |
Your task, at the moment that you choose to accept it, is to write a program that, when given a string and a PCRE-regex, calculates the minimum Levenshtein distance to another string that matches the regex (fully). All strings, as well as the regexes, should be in the Latin-1 character set.
This is code-golf, so the sh... |
Background
A maximal domino placement (MDP) on a rectangular grid is a non-overlapping placement of zero or more dominoes, so that no more dominoes can be added without overlapping some existing domino.
Alternatively, it can be thought of as a tiling using dominoes and monominoes (single square pieces) so that no two m... |
The following puzzle was invented by Eric Angelini in September 2007.
As mentioned in A131744 :
the sequence is defined by the property that if one writes the English
names for the entries, replaces each letter with its rank in the
alphabet and calculates the absolute values of the differences, one
recovers the sequen... |
05AB1E has the £ builtin which, given a list of integers b and a string s, splits s into sublists of lengths equal to the elements in b. For example, [1,2,3,4,1] "hello world"£ produces ["h", "el", "lo ", "worl", "d"]. Your task is to imitate this behaviour.
Given a list \$L\$ containing \$n\$ elements, and a list \$B\... |
><>, or Fish, is a two-dimensional esoteric programming language where the instruction pointer (IP) toroidally moves around the codebox, wrapping when it hits an edge.
><> has four basic movement instructions - <, >, ^, and v, which respectively mean to change the IP's direction to left, right, up and down. It also has... |
Background
Related: a golflang theory I posted in TNB a while ago
At-most-\$n\$-ary trees are rooted trees where each internal node has between 1 and \$n\$ children (inclusive). Two trees are considered identical only if the shapes exactly match without re-ordering each node's children. In other words, the left-to-righ... |
Task
FizzBuzz, but instead of 3 and 5, you'll take the numbers and corresponding strings as input.
You can assume all inputted numbers are coprime (and \$\ge 2\$). You'll receive one or more numbers, and a string to print with each of them. The normal FizzBuzz would be something like [[3, "Fizz"], [5, "Buzz"]], but you... |
My userid is 100664. In binary this is 11000100100111000.
An interesting property of this number is that it can be created entirely by concatenating strings which are repeated at least twice:
11 000 100100 111 000
The first few such numbers are \$3,7,10,12,15,24,28,31,36,40,42, 43, 45,48,51,53,54,56,58,60,63,80,87... |
Background
An interval graph (Wikipedia, MathWorld, GraphClasses) is an undirected graph derived from a set of intervals on a line. Each vertex represents an interval, and an edge is present between two vertices if the corresponding intervals overlap. The following is an example interval graph with corresponding interv... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.