instruction
stringlengths
34
53.1k
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...
In this challenge you must write a computer program that creates a stack of a thousand identical \$1 \times 1\$ frictionless homogeneous blocks such that each block is supported and the stack is stable under gravity when placed on the edge of a table which spans from \$x = -\infty\$ to \$0\$ horizontally, with the surf...
Much harder than Can this pattern be made with dominoes? Challenge A grid of width \$w\$ and height \$h\$ is given, filled with 1s and 0s. You can place a domino somewhere on the grid only if both cells are 1. You cannot overlap dominoes. What is the maximum number of dominoes you can fit in the given grid? The worst-c...
The Lisp language has a family of functions car, cdr, cadr, etc for accessing arrays. For each one, an a defines taking the first item of an array, and a d defines taking the rest. For example, running cadr on [[1,3,4],5,7] will return [3,4] as the a gets the first item ([1,3,4]) and the d removes the first item. We've...
Given a list of integers find the "trajectory" that results from indefinitely moving the instructed steps to the right (left if negative), wrapping if necessary, starting at the first element. A "trajectory", here, is defined as a list containing the elements that are visited only one time, in the order they are visite...
The goal of this challenge is to fill a niche that is mostly lacking on this site. In my observations there most parsing verification challenges fall into two categories: Super easy parsing. This parsing can usually be done with a regex, and regex based answers usually do well. Super complex parsing. These are cha...
Background SKI combinator calculus, or simply SKI calculus, is a system similar to lambda calculus, except that SKI calculus uses a small set of combinators, namely S, K, and I instead of lambda abstraction. Unlike lambda calculus, beta reduction is possible only when a combinator is given enough arguments to reduce. T...
This is a rock: * Rocks can be stacked. Apart from the bottom-most layer, each rock must rest on two other rocks, like this: * * * You have a pile of rocks, and your boss wants you to pile them symmetrically, taking up the least horizontal space possible. Your challenge is to take a number of rocks as input, and out...
This includes tips for all related derivatives, as coding in these langs often primarily consists of writing the function in the lambda calculus and then compiling it down at the end. Among others, this includes tips for: Standard combinator calculi SKI system BCKW system Esolang combinator calculi Iota/Jot/Zot La...
Related: Boustrophedonise, Output the Euler Numbers (Maybe a new golfing opportunity?) Background Boustrophedon transform (OEIS Wiki) is a kind of transformation on integer sequences. Given a sequence \$a_n\$, a triangular grid of numbers \$T_{n,k}\$ is formed through the following procedure, generating each row of num...
Consider a binary tree built the following way: The root node is \$1\$ For a given node \$n\$: If \$n\$ is odd, its only child is \$2n\$ If \$n\$ is even, one of its children is \$2n\$. If \$\frac {n-1} 3\$ is an integer and not already part of the tree, its right child is \$\frac {n-1} 3\$ Recursively and infinite...
Forth is one of the few non-esoteric stack-based languages. For this challenge, we will use a small subset of Forth, which simply executes a sequence of words in a linear fashion — without any definitions or loops. In good Forth code, each word definition includes a stack effect comment, which explains the layout of th...
Wheat Wizard has once tried to come up with a parsing problem unsuitable for regex, but it failed due to Anders Kaseorg's Perl regex answer. This is the second attempt. Now that we know that Perl regex is far more powerful than we've imagined, this challenge aims to be un-golfy for it instead. Introduction A lambda ter...
I want you to make a gui window like this: * if you're thinking, the [quit] button closes the window in any language using minimum "different" characters.. AND remember that the gui window must use native widgets instead of custom icons and buttons like I have Windows 8, so my GUI window looks like this: If you didn'...
Inspired by this video by Matt Parker The distances between the letter keys of a QWERTY keyboard are somewhat standardised. The keys are square and both the horizontal and vertical spacing are 19.05mm (so if there were no gaps between the keys, their side lengths would be 19.05mm), and the three rows of keys are offset...
Write a program that outputs the exact string: jan ale o, toki! ("Hello, world" but in toki pona to prevent builtins.) with an optional trailing newline. Additionally when all copies of any one byte present in your program are removed the program must fail to produce a correct output no matter what byte is selected. T...
Story My local pizza delivery introduced new discount. You get 50% discount from every second item on your order. But being greedy capitalists, they forgot to mention that they will rearrange items the way they need to give you as little as possible. Example Imagine you ordered - Pizza $20 - Pizza $20 - Coke $2 - Coke ...
Background -rot transform (read as "minus-rot transform") is a sequence transformation I just invented. This transform is done by viewing the sequence as a stack in Forth or Factor (first term on the top) and repeatedly applying -rot +. -rot is a command that moves the top of the stack to two places down, and + adds tw...
The game shapez.io has a huge variety of shapes you can produce, such as: Each shape has a unique short code, for example the above is CrWbScRu. This means, going clockwise from top right, red circle (Cr), blue wedge (Wb), cyan star (Sc), uncolored rectangle (Ru). There are four different shapes: Rectangle - R Wedge ...
Your task is to create a program that outputs the string: Hello, Toroidal Earth! with an optional trailing newline. Additionally if I remove the first line1 of your program and add it as a line after the end of your program the new program should be a valid solution to this challenge in the same programming language. ...
Given a number \$n ≥ 2\$, a blackbox function \$f\$ that takes no arguments and returns a random integer in the range 0...n-1 inclusive, and a number \$m ≥ n\$, your challenge is to generate a random integer in the range 0...m-1 inclusive. You may not use any nondeterministic builtins or behaviour, your only source of ...
The edit distance between two strings is the minimum number of single character insertions, deletions and substitutions needed to transform one string into the other. This task is simply to write code that determines if two strings have edit distance at most 3 from each other. The twist is that your code must run in l...
The game shapez.io has a lot of shapes. In my previous challenge, the object was to generate a random code for a shape. Now, your challenge is to render a shape. Specs Shapes Each shape has a unique shortcode, for example: is CrWgRuSp - clockwise from top right, red circle, green wedge, uncolored rectangle, purple sta...
Write a function that takes in a string and for each character, returns the distance to the nearest vowel in the string. If the character is a vowel itself, return 0. Vowels are : aeiouAEIOU For the purposes of this challenge, y is not a vowel. The input will be a string consisting of uppercase and lowercase letters. E...
Let's define a function \$f\$ which, given a positive integer \$x\$, returns the sum of: \$x\$ the smallest digit in the decimal representation of \$x\$ the highest digit in the decimal representation of \$x\$ (which may be the same as the smallest one) For instance: \$f(1)=1+1+1=3\$ \$f(135)=135+1+5=141\$ \$f(209)=...
Consider the integer set \$S = \{3, 5, 6, 7\}\$. If we list all \$2^n\$ subsets of \$S\$ (its powerset) and calculate their sums, we get $$ \mathcal{P}(S) = \{\emptyset, \{3\}, \{5\}, \{6\}, \{7\}, \{3, 5\}, \{3, 6\}, \{3, 7\}, \{5, 6\}, \{5, 7\}, \{6, 7\}, \{3, 5, 6\}, \{3, 5, 7\}, \{3, 6, 7\}, \{5, 6, 7\}, \{3, 5, 6,...