instruction
stringlengths
34
53.1k
In this challenge, players need to tamper with a time bomb as late as possible without getting blasted in the face. Mechanics Let N be the number of bots plus one. Each round, each bot receives the following arguments: numbers played by all bots last round in ascending order. number of points it received last round. N...
Background Inspired by this video by Matt Parker A Faro shuffle is a perfect riffle shuffle where the deck is exactly interleaved with its other half. This is how to perform one: the deck of 52 cards is split into two piles of 26 cards each the two piles are interleaved. In the case of an "in" shuffle, the bottom card...
Introduction When playing Mario Kart the other day, an interesting question popped up when a Grand Prix with my 2 roommates, 9 AI drivers and myself seemed to be fairly close and therefore exciting until the very end. We asked ourselves: How close can the point difference between first and last place (#1 and #12) after...
Lucky numbers (A000959) are numbers generated by applying the following sieve: Begin with the list of natural numbers: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, ... Now, remove every second element (\$n = 2\$, the smallest element in the list aside from 1): 1, 3, ...
Introduction In this challenge, I asked you to implement swap encoding. Swap encoding is an encoding method where you iterate through the string, reversing substrings between identical characters. The basic algorithm is: For each character in the string: Check: Does the string contain the character again, after the ins...
You are given 3 non negative numbers: \$x\$, \$y\$ and \$z\$, and must minimize the number of digits (non negative) inserted at any place in the numbers \$x\$, \$y\$, or \$z\$ to make $$x + y = z$$ (a clarification: you can add any non negative digit any number of time at any place ) (you can assume that \$x\$, \$y\$, ...
Given: a blackbox function \$f : \mathbb N \to \mathbb N\$, a list of positive integers \$L\$, and a list of indices \$I\$, apply \$f(x)\$ to the elements of \$L\$ at the indices specified in \$I\$. For example, \$f(x) = x^2, L = [7, 6, 3, 9, 1, 5, 2, 8, 4]\$ and \$I = [3, 5, 8]\$ (using 1 indexing), we apply \$f(x)\...
Related: Calculate \$f^n(x)\$, Polynomialception Challenge Given a polynomial \$f(x) = a_0 + a_1 x + a_2 x^2 + \cdots + a_k x^k\$ of order \$k\$, we can compute its composition with itself \$f\left(f(x)\right) = f \circ f(x) =: f^2(x)\$, which evaluates to another polynomial of order \$k^2\$. The challenge is to revers...
Consider a grid from \$(0,0)\$ in the bottom-left corner to \$(m,n)\$ in the top-right corner. You begin at \$(0,0)\$, and can only move in one of these three ways: Directly north \$(+0, +1)\$, Directly east \$(+1, +0)\$, or Directly north-east \$(+1, +1)\$ How many different paths are there from your start at \$(0,0...
Suppose A and B are two good friends. A has borrowed \$n\$ dollar from B. Now B wants the money back from A and A is also ready to give it. But the problem is A has only \$x\$ dollar notes and B has \$y\$ dollar notes. They both want to keep the number of notes in exchange as low as possible. As an example if \$n=37\$,...
Introduction cowsay is a Unix command made by Tony Monroe, written in Perl. It outputs a picture of a cow saying given text. For example: ________________________ < Typical cowsay output! > ------------------------ \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | ...
An Abecedarian Word is a word whose letters are in alphabetical order. Your goal is to write a program that outputs all abecedarian words from a given lexicon. Rules: Standard Loopholes are forbidden. If a word contains punctuation, diacritical marks, or any characters other than ASCII alphabet characters (A-Za-z), r...
Inspired by this: http://nolandc.com/smalljs/mouse_reveal/ (source). A valid answer: Takes a number \$w\$ and (assumed non-negative) integer \$x\$. Starts with an integer list with a length of \$2^w\$, initially filled with zeroes. For each number \$n\$ from \$0\$ to \$w-1\$ (inclusive), divides the list into sub-list...
This is a code-shuffleboard answer-chaining challenge, where the answers will aim to, together, output the lyrics to this beloved 80s song. This is the full lyrics of the song, line by line. The first answer will contain a program that will output the first line of the song (We're no strangers to love). The second wil...
Given a non-empty list of integers between 1 and 9 inclusive, find the longest contiguous sublist such that the number of occurrences of each element (of the sublist) within the sublist is equal (not the number of consecutive occurrences, just the total count). You may return any non-empty subset of the solutions. Exam...
I'm not sure if this is the right place to ask, but I found this similar question so I'll go ahead. I'm very new to code golfing, so keep your smothered laughs and throw-up emoji's to yourselves please ;). Anyway, someone recently posted a challenge (that was shortly deleted) to draw a 16x16 pixel image of the Old Man ...
Base: part 1 This is part 2, Strongly suggest you go try out the first one if you haven't tried it. Story As one of the solvers, You've managed to get to the door of the base heaven. In front of the door stands the base guard @lyxal, they were angry that you all just left the encoded text on the ground, they demand tha...
A simple way to scramble a 2x2x2 Rubik's cube is to make a sequence random moves. This is not how official scrambles are done, but can get pretty close to a uniform distribution of all possible scramble states. Due to the way a 2x2 only has two layers, doing one turn on one face is equivalent (without considering the p...
Implement a function \$f\$ (as a function or complete program), such that \$ \displaystyle\lim_{n\rightarrow \infty} f(n) \$ converges to a number which is not a computable number. Answers will be scored in bytes with fewer bytes being better. IO formats Your answer may be in any of the following formats A program or ...
In this king-of-the-hill challenge, you will be making a python 3 bot to play the card game judgement! Sandbox Rules Judgement is a hand based game similar to games like rummy. In each round, 7 cards are dealt to each player, a trump suit is chosen (trump suits are chosen sequentially from the list Spades/Hearts/Diamon...
Background Information: What is a Fenwick Tree? With a normal array, it costs \$O(1)\$ to access and modify an element, but \$O(n)\$ to sum \$n\$ elements. Working with a prefix sum array (an array where the \$i\$th value represents the sum of the first \$i\$ values in the underlying data), access and summation are \$O...
Introduction You are listening to a car radio. You are pressing seek up/down, moving you to the next frequency some radio station broadcasts on, to avoid all this pointless music and listen to all the ads, or vice versa. If you try to go below the lowest frequency radio can handle, it jumps to the highest (and vice ver...
In Minecraft, pistons are blocks that can move other blocks. However, they can only move at most twelve blocks, and won't work at all if any obsidian is in the way. Also, slime blocks are sticky and stick to other blocks, except for obsidian. Your challenge Take as input a 5x5 matrix or similar, containing one piston a...
Challenge Given a positive integer \$n\$, count the number of \$n\times n\$ binary matrices (i.e. whose entries are \$0\$ or \$1\$) with exactly two \$1\$'s in each rows and two \$1\$'s in each column. Here are a few examples of valid matrices for \$n=4\$: 1100 1100 1100 1100 0011 01...
An addition-subtraction chain, is a sequence \$a_1, a_2, a_3, ... ,a_n\$, such that \$a_1=1\$ and for all \$i > 1\$, there exist \$j,k<i\$ such that \$a_i = a_j \pm a_k\$. Your task, is given a number \$x\$, find the shortest addition-subtraction chain, such that \$a_n = x\$. Rules You can assume the input is a valid ...
Background Complex floor is a domain extension of the mathematical floor function for complex numbers. This is used in some APL languages to implement floor ⌊, ceiling ⌈, residue |, GCD ∨, and LCM ∧ on complex numbers. For the rest of this challenge, an integer refers to a Gaussian integer, i.e. a complex number whose ...
Given a digit x (between 0 to 9, inclusive) and a number n, calculate the sum of the first n terms of the following sequence: \$x,10x+x,100x+10x+x,\dots\$ For example, if x is 6 and n is 2, then the result will be 6+66 meaning 72. There can be trailing whitespace in the output but not leading whitespace.
The challenge Interpret the stack-based programming language underload. The stack is a stack of strings that can be concatenated together. Each underload program is a string of some of these instructions: ~: Swap the top two elements of the stack. :: Duplicate the top element of the stack. !: Discard the top element o...
Do you know the optical effect of a tridimensional hand painted whit horizontal lines? Examples This challenge consists of making something like that effect with ascii, and transforming one 2d input into a "3d" output. The algorithm To perform this transformation, you first replace all 1 with a ¯ and all 0 with a _. In...
Given two positive reals \$a\$ and \$b\$, output some positive reals \$r_i\$, such that \$\sum r_i=a\$ and \$\prod\left(r_i+1\right)=b\$. You can assume that it's possible. You can also assume that your float type have infinite precision. Test cases: 2,3 => 2 2,4 => 1,1 or 1/2,(sqrt(57)+9)/12,(9-sqrt(57))/12 or etc. 2,...
The generalised harmonic number of order \$m\$ of \$n\$ is $$H_{n,m} = \sum_{k=1}^n \frac 1 {k^m}$$ For example, the harmonic numbers are \$H_{n,1}\$, and \$H_{\infty,2} = \frac {\pi^2} 6\$. These are related to the Riemann zeta function as $$\zeta(m) = \lim_{n \to \infty} H_{n,m}$$ Given two positive integers \$n > 0\...
You wake up and find out that your computer has been stolen! You have a few sensors and scanners, but unfortunately, the footage is incomplete, so you want to find and rank your suspects for further investigation. Your computer is a rectangle, and your camera caught a bunch of people walking around with packages; howev...
When making a Minecraft data/resource pack, you need to include a pack.mcmeta file, which specifies information about it. pack.mcmeta contains a description, but it also contains a pack_format number, which tells Minecraft which versions this pack is for. Your task is to take a version string, and output what pack_form...
If you have read in your childhood a Geronimo Stilton's book, I am sure that you remember the style of the text, sometimes the words were decorated for making the act of reading more funny for kids: example. But when you are an adult you don't have that little entertainment in your readings... why? In a nostalgic attac...
There is a boy named Peter. Peter is a picky eater and doesn't like to eat the same kind of cookie again on the same day. Peter gets a present, The present is a box of cookies! The box contains \$K\$ types of cookies. Also, it contains different amount of each type of cookie. Peter, being the picky eater he is, Wants t...
A polyglot is a program that runs in several languages. Your challenge is to: Choose at least two languages (Different versions count as different languages) Create a program or function that takes several positive integers (one for each language you chose) and returns a program that: Is a valid program in all of those...
Task Any one of these two: Determine if a given position (an ordered non-empty collection of integers in the range ‒8 to 8, or ‒7 to 7 if you want) is a valid Dimensional Chess position. List all the valid positions in any order. Make sure to describe your input (if not listing all) and output formats. The 2368 vali...
From Wikipedia, Gabriel's Horn is a particular geometric figure that has infinite surface area but finite volume. I discovered this definition in this Vsauce's video (starting at 0:22) where I took the inspiration for this problem. You begin with a cake (a cuboid) of dimension \$x \times y \times z\$. In your first sli...
Consider an array of unique integers, with an arbitrary length greater than 2. It is sometimes possible to express elements of the array as the sum of at least two other elements. For example, if our array is [2, 3, 1], we can express 3 as the sum 2+1. However, we can't express either 2 or 1 as the sum of other element...
Given guaranteed strictly positive integers \$w\$ and \$n\$, output An equilateral triangle array with side length \$w\$, filled with two distinct, consistent values. I'll call these 0 and 1 but they do not have to be equal to 0 and 1. The number of 1s inside this array must be equal to \$n\$. The output triangle must...
In response to here. Unlike the previous one, this focuses on code-golf and a new logo, no longer consisting of 6 sticks and the graying-effect as the position of the sticks go deeper. Make the Stack Overflow logo using the following criteria: The tray: Make a gray tray shaped like a bracket facing upwards using th...
Introduction Dr. Leslie Lamport, of the eponymous Lamport one-time signature scheme, is getting rather old. But he can't die until his most famous algorithm gets all the kinks ironed out! In particular, that scheme had one internal component he was never satisfied with: We hope that someone can find a more elegant met...
Input A positive integer N representing the size of the problem and four positive integers v, x, y, z. Output This is what your code should compute. Consider a set of N distinct integers and consider all ways of choosing 3 subsets (which can overlap) from the set. There are \$2^{3N}\$ different possible ways of choos...
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 to itself (which makes it an e...
The goal is simple. Write a program that outputs itself encoded as a QR code. A QR code is a way to encode data in a black and white image, similar to a 2D image. An example implementation can be found here. The QR code is displayed as text, where each pixel is either a "#" for a black pixel, or a space for a white pi...
Given an integer \$ n \ge 2 \$, you need to calculate \$ \lfloor n \log_2(n) \rfloor \$, assuming all integers in your language are unbounded. However, you may not ignore floating-point errors - for example, in python lambda n:int(n*math.log2(n)) is an invalid solution, because for example for n=10**15, int(n*math.log2...
I'm currently working with a branchless language which does not have native Less-Than, Greater-Than or Equal-To functions. I do however have min, max and abs functions and standard arithmetic (+, -, / and *) available to me. I'd like to create these three functions (as L(a, b), G(a, b) and E(a, b) respectively, which w...
Related: Multiply Quaternions Challenge Given a string made of ijk, interpret it as the product of imaginary units of quaternion and simplify it into one of the eight possible values 1, -1, i, -i, j, -j, k, -k. The evaluation rules are as follows: $$ ii = jj = kk = -1 \\ ij = k, \quad jk = i, \quad ki = j \\ ji = -k, \...
Background Gödel numbers are a way of encoding any string with a unique positive integer, using prime factorisations: First, each symbol in the alphabet is assigned a predetermined integer code. Then, to encode a string \$ x_1 x_2 x_3 \ldots x_n \$, where each \$ x_i \$ represents an symbol's integer code, the resultan...
This is a copy cat question of Simplify ijk string applied to the other nonabelian group of order 8. See also Dihedral group composition with custom labels. Challenge Given a string made of r and s interpret it as the product of elements of the dihedral group \$D_8\$ and simplify it into one of the eight possible value...
This is a two-player card game which resembles a vastly simplified game of Texas Hold'em, combined with RPS (rock-paper-scissors) and the most basic mechanic of commercial turn-based card games. The deck A single full deck consists of 30 unique cards, where each card has one symbol out of RPS and one number between 0 a...
Modern British number plates (a.k.a. registration marks or license plates) use the format AANNXXX where AA is a "DVLA memory tag" (basically a location code), NN is the age identifier, and XXX is three random letters. Your task is to, given a date, generate a random valid number plate with a date code matching the supp...
Specification Write the shortest possible code in any language that does the following: It takes two arguments, x and y, and generates x + y lines of text. The first x lines should consist of y nested pairs of square brackets separated by a space surrounding a single digit, which cycles from 1 to 9, then 0 to 9, etc. f...
In this challenge, your past self comes back to help or hurt someone else! The task is simple: write a full program, not a function, that prints the first code submission on this site submitted by the previous user, in the language of your first answer. (In the case that your first answer was purely prose, for example ...
Several Mathematica functions have system-defined short forms, e.g., /@ for Map. Many of them are listed here: https://reference.wolfram.com/language/tutorial/OperatorInputForms.html However, there also exist some system-defined short forms for function-option combinations. E.g., Log2@ninstead of Log[2, n] and Log10@...
Consider the triangular numbers and their forward differences: $$ T = 1, 3, 6, 10, 15, 21, ... \\ \Delta T = 2,3,4,5,6, ... $$ If we alter \$\Delta T\$ so that it begins with a different integer, we get a different, yet similar sequence (assuming that it begins with \$T'_1 = 1\$): $$ \Delta T' = 3,4,5,6,7,8,... \\ T' =...
Although there was a prime factors challenge posted ten years ago, it has tedious I/O and restricted time. In this challenge, your task is to write a program or function which takes an integer \$n \ge 2\$ as input, and returns its prime factors. Task: Input will consist of an integer, \$n \ge 2\$. Your program should t...
Your program must accept as input six numbers, which describe a triangle - for example, the inputs 80, 23, 45, 1, 76, -2 describe a triangle with vertices (80, 23), (45, 1), and (76, -2). The input must be given as six plain real numbers or as a list of six real numbers, in the order given in the example. Your task is ...
One day in July 2020, I made the following C program: #define A m] a[9999],*m=a;main(){for(2[A=4[A=1;;){for(;4[A;putchar(6[m-=3]+48)); for(puts(a);7[A;2[A=4[A,4[A=1)if(4[A+=3[m+=3]-1,9<(3[A=2[A+=3[A))++ 5[A,7[A=1,3[A-=10;}} with three superfluous newlines removed, it's 167 bytes and it prints the fibonacci sequence (a...
Pickleball doubles is a game where only the serving side can score. The server calls the score as a triple of numbers, the serving side's score, the receiving side's score, and \$1\$ or \$2\$ to indicate whether the server is the first or second of their side to serve. If the server's side wins a point, their score i...
Task Given a non-empty list of positive digits, group them into sublists of equal sum. You may output any subset of solutions with maximal number of sublists (equivalently, minimal sum). The input may contain repeat elements. There may not exist any solution but the singleton list containing the input itself. The outpu...
The goal of this challenge is to generalise the bitwise XOR function to other bases. Given two non-negative integers \$ x \$ and \$ y \$, and another integer \$ b \$ such that \$ b \geq 2 \$, write a program/function which computes the generalised XOR, described the following algorithm: First, find the base \$ b \$ re...
Goal Your task is to create a program taking no input that returns the link to your answer. You can find a link to your answer by clicking at the share button on your answer. Rules Standard loopholes apply except for searching for the answer online. In fact, you are expected to find the answer online. You are allowed ...
Introduction How to prove that 1 = 2: 1 = 2 2 = 4 (*2) -1 = 1 (-3) 1 = 1 (^2) You can just multiply both sides by 0, but that's cheating. This is just bending the rules a little bit. Your challenge: Write a program/function that, when given two integers, outputs a "proof" that the two are equal. Rules Your program's...
What tips do you have for code-golfing in the V lang? I have been trying to find ways to shorten codegolfs on there but can't find any resources on it. Do you guys have any? Please suggest tips that are at least somewhat specific to the V programming language (e.g. "remove comments" isn't helpful). Please post one tip ...
Though there is a prime factorization challenge and it's here, this, I feel, will be a bit more interesting than that one. To understand this, let's have an example; I will use 5,184 for this. \$5184 = 2^6 \times 3^4\$. However, for this challenge, such a factorization is insufficient - the reason is that 6 and 4 are c...
Challenge Write \$2 \le n \le 10\$ distinct, valid non-halting full programs in your language of choice. If all of them are concatenated in order, the resulting full program should be a valid halting program, but if any of them are left out, the result should still be a valid non-halting program. More formally, write \...
Given the equation of a non-parabolic conic section, output its characteristics. Spec Some info on conic sections: for more info visit Wikipedia From an equation of the form \$ax^2+bx+cy^2+dy+E=0\$, it is possible to derive the type of conic section using a combination of square completion and simple arithmetic. For t...
As the June 2021 Language of the Month is Red, what are some general tips for golfing in Red language? Please suggest tips that are at least somewhat specific to Red (e.g. "remove comments" isn't a valid tip here). Please one tip per answer!
Daylight saving time (DST), is the practice of advancing clocks (typically by one hour) during warmer months so that darkness falls at a later clock time. The typical implementation of DST is to set clocks forward by one hour in the spring ("spring forward") and set clocks back by one hour in autumn ("fall back") to re...
* and don't have a word processor with top-left align support :D Take several lines of input, with at least four unique characters of your choice including newline and space. The input can also be taken as a space-padded matrix of characters. Squash it upwards, then squash it left. Output this, with any amount of trail...
Consider a n x n multiplication table and replace each item with its remainder of division by n. For example, here is a 6x6 table and its "modulo 6" structure: (The last column and row are ignored since both are null) 1 2 3 4 5 6 | 1 2 3 4 5 2 4 6 8 10 12 | 2 4 0 2 4 3 6 9 12 15 18 | 3 0 3 0 3...
Take this array: [1, 2, 6, 4, 4, 1, 0, 0, 2, 0, 4, 1, 4, 2, 4, 8, 1, 2, 4] There are quite a few places where [1, ..., 2, ..., 4] appears, where ... is any number of items. These include [1, 2, 6, 4], [1, 0, 0, 2, 0, 4], [1, 0, 0, 2, 0, 4, 1, 4], and [1, 2, 4]. The shortest of these is simply [1, 2, 4]. Task: Given t...
Inspired by this Numberphile video. What is planing? In order to 'plane' a sequence of digits, you need to: Identify the lengths of the 'runs' (adjacently repeated digits) in the sequence. Non-repeated digits count as runs of one. Decrease the length of each run by one. Runs of length 1 become length 0. Reconstruct t...
If you convert a chemical formula to lower case, it may become ambiguous: co can be both CO or Co. Given an input consisting of a-z0-9, where 0 can only stand behind 0-9. Check whether it's ambiguous, unambiguous, or impossible. Return 3 different values for them. Shortest code wins. Examples: co - ambiguous 2h83o6...
Fluff After taking a look at deadfish, I decided it sucked, so I came up with a new (and easier) variant of it: imnotdeadfish. As with its predecessor, there are 4 commands and an accumulator which begins at 0: + # increment the accumulator - # decrement the accumulator s # square the accumulator o # output the accumul...
Why should you golf in Haskell? Find out here. In that answer, Zgarb defines a task: Let's define a function f that splits a list at the second occurrence of the first element, e.g. [0,2,2,3,0,1,0,1] -> ([0,2,2,3],[0,1,0,1]): Alright then, lets! You are to take a non-empty list consisting of digits, and output a pair...
Background Combinatory logic is a system where a term is written using a finite set of combinators and function application between terms, and reduction rules are defined for each combinator. The well-known S and K combinators have the following reduction rules: $$ \begin{aligned} S\;x\;y\;z & \overset{S}{\implies} x\;...
Challenge Your goal is to find the furthest point on a graph (from a provided start node). Your code doesn't need to handle cycles in the graph properly, but it might pose a fun challenge. For this question, you can assume the graph is actually a tree. Input data Input can be provided in any suitable format for the lan...
You have a bunch of cities on a grid which you wish to link up. Roads can be placed on any tile that doesn't contain a city, and connect to all roads or cities adjacent to them, vertically, horizontally or diagonally. Roads can link up via cities, for example C \ C-C is fully linked up. However, there are some moun...
Information Create a diagonal line given its length (let’s call the variable, say, \$n\$ where \$n > 0\$) The diagonal line starts from the top left and goes to the bottom right. You must use the ASCII character \ for the line. The input number can be given from STDIN or if your program doesn’t support that, use a har...
Program the sequence \$R_k\$: all numbers that are sum of square roots of some(maybe one) natural numbers \$\left\{\sum_{i\in A}\sqrt i\middle|A\subset \mathbb{N}\right\}\$, in ascending order without duplication. Outputting zero is optional. You should do one of: Take an index k and output \$R_k\$, either 0 or 1 inde...
Task Given a non-negative number, check if it's odd or even. In case it's even, output that number. Otherwise, throw any exception/error that your language supports, and stop the program. Example with Python Input: 1 Output: Traceback (most recent call last): File ".code.tio", line 1, in <module> IfYouWantThenThr...
Introduction Fischer random chess, also known as Chess960 for the 960 valid starting boards, is a variant of chess where each player's pieces are randomly shuffled at the start. As a reminder, each player gets 8 pawns, two rooks, two knights, two bishops, one queen, and one king. For this challenge, you don't need to k...
The Prisoner's Dilemma, but with 3 choices, and the payoffs are random! Each round, your bot recieves a 3x3 grid and chooses a row to play. The grid might be this: 4 5 7 3 1 9 9 9 0 Each number in the grid is between 0 and 10 (inclusive). Your score for the round is grid[your_play][their_play], and your oppone...
Given a positive number \$n\$ we call another (not same as n) positive number \$m\$ good if we insert same digits in both n and m and the resulting fractional value is same. $$m/n = m_{\text{transformed}}/n_{\text{transformed}}$$ $$or$$ $$m*n_{\text{transformed}} = m_{\text{transformed}}*n$$ Clarifications: No leading...
Picolisp has a feature called "super parentheses": Brackets ('[' and ']') can be used as super parentheses. A closing bracket will match [all parentheses to and including] the innermost opening bracket, or [if there are no unmatched opening brackets] all currently open parentheses. src Taking a string containing only...
From Codidact with permission. Description APL trains are a series of functions, that get applied to an argument in this way: (f g) x = f g x here f and g are prefix functions (f g h) x = (f x) g (h x) here f and h are prefix functions, while g is an infix function (a b c d e f) x = (a (b c (d e f))) x = a (b x) c (d x...
Challenge Choose any number of languages. Call this set L. Write a program so that running it in any language in L produces an interpreter for a different language in L. Each language in L must have exactly one interpreter for it. This is to prevent, for example, Nothing or Text being part of L and all interpreters be...
Given infinite different integers, order them into a sequence \$a_1, a_2, a_3, ...\$ such that \$a_i>a_{i+1}\$ iff \$i\$ is even(or odd, as long as it's constant for all possible inputs and all \$i\$). In other word, make the sequence go alternately up and down (or down first, as long as it's constant). Examples: ℤ => ...
Background Combinatory logic is a system where a term is written using a finite set of combinators and function application between terms, and reduction rules are defined for each combinator. The well-known S and K combinators have the following reduction rules: $$ \begin{aligned} S\;x\;y\;z & \overset{S}{\implies} x\;...
This is not just another challenge asking you to color random maps... In this challenge, you are asked to write a program that is actually used in the formal proof of the Four Color Theorem. First I shall describe the challenge without any background or motivation, for the impatient. A chromogram is a list made of the ...
Challenge Make a triangle of numbers like below. How to? Let say we get a numbers in the form of ab, for example 12. We then create a triangle like below: Sorry for my bad drawing! First we have 12, and we take sum of the two numbers 1 and 2, which is 3. In case the sum of two numbers are greater than 9, we just take ...
Given an integer \$ n \$ \$ (n \ge 1) \$, return/output the total number of set bits between \$ 1 \$ and \$ n \$ inclusive. To make the problem more interesting, your solution must run with a time complexity of \$ \mathcal{O}((\log n)^k) \$ or better, for some constant \$ k \$ (AKA poly-logarithmic time complexity). Th...
Inspired by this video by Ben Eater. This challenge forms a pair with Encode 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. Decoding w...
Lexicographic Ordering For this challenge we will be talking about the lexicographic ordering of strings. If you know how to put words in alphabetical order you already understand the basic idea of lexicographic ordering. Lexicographic ordering is a way of ordering strings of characters. When comparing two strings lex...
Take a line of input (function arguments or stdin, etc.). Remove comments in it, where a comment starts and ends with ". Do not remove comments in string literals, which start and end with '. String literals do not contain escapes, because smalltalk has nice, easily lexable syntax ;). Output this string. The number of...
Given an integer \$1 < n < 10 \$ generate a table like below. For \$n = 5\$, 1 2 3 4 5 2 2 3 4 5 3 3 3 4 5 4 4 4 4 5 5 5 5 5 5 For \$n = 8\$, 1 2 3 4 5 6 7 8 2 2 3 4 5 6 7 8 3 3 3 4 5 6 7 8 4 4 4 4 5 6 7 8 5 5 5 5 5 6 7 8 6 6 6 6 6 6 7 8 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 Shortest code wins! Trailing whitespace allowed ...
But Is It Art? is an esolang created by ais523, where one step is break the program into orthogonally connected "tiles": A BBBB A B B AA CC A CC Each separate letter shows a different tile. Interestingly, programs in But Is It Art? only rely on the orientations of the tiles themselves, not their placement. This means...
You're a plumber working on a house, and there's some pipes that must be connected at weird angles. You have 8°, 11.25°, 22.5°, 45°, and 90° fittings at your disposal, and you want to use as few as possible to match the angle as closely as possible. Goal Match the desired angle as closely as possible, with as few fitt...