instruction
stringlengths
34
53.1k
This challenge is inspired by a talk about Schläfli symbols, etc that I gave in a Geometry seminar. While I was putting together this challenge, I saw that Donald Knuth himself was interested in (some subset of) this problem. In October 2016, he commented on a related OEIS sequence: If [the OEIS author] is wrong about...
Challenge: I want to know about the real roots of polynomials. As a pure mathematician, I care about the existence of such roots, rather than their numeric values. The challenge is to write the shortest program that takes a polynomial, of degree at most 4, and simply returns how many distinct real roots said polynomial...
Description of the problem Imagine a quarter of an infinite chessboard, as in a square grid, extending up and right, so that you can see the lower left corner. Place a 0 in there. Now for every other cell in position (x,y), you place the smallest non-negative integer that hasn't showed up in the column x or the row y. ...
Simple challenge: The code must be both valid Lisp and valid Fortran, and must print out "hello world" in both. Note: I've sunk about 5 hours into this at this point, I'm not even sure it's possible at this point... Details: Must be in a single source file. Any version of Fortran and any Lisp are allowed (specify whic...
Task Write a program/function that when given a positive integer \$n\$ and a digit \$d\$ which is not 0 outputs a way to represent \$n\$ using only addition, subtraction, multiplication, exponentiation, division, concatenation, parenthesis and the digit \$d\$. Examples n = 6, d = 1 => (1 + 1) * (1 + 1 + 1) n = 6, d...
This will turn into a series involving other aspects of calculus, including using the "derivative" of a string to find "stationary points" etc, as well as "integration" of sentences Introduction If y'all have ever studied calculus, you'll most likely know that differentiation is limited to differentiable functions. No...
Definitions: A palindrome is a string which reads the same backward or forward (not counting spaces or special characters), such as "madam" or "Sorel Eros". A date is said to be a palindrome when its dd-mm-yyyy format is a palindrome (or any other local representation). Two strings are said to be anagrams when the co...
The point of this challenge is to find the smallest positive integer that uses up at least all of the digits supplied in the input after it is squared and cubed. So, when provided an input such as 0123456789 (i.e. a number that finds the result): 69² = 4761 69³ = 328509 It means that 69 is the result of such an input....
The Monkey has swung home to find his tree all in pieces. He likes order and scoops up all his 'tree-parts' and sets them out in 3 groups. The Monkey's 3 nested lists: STEP = [['S', '1', 'B', '3'], ['S', '3', 'B', '11'], ['S', '5', 'B', '12'], ['S', '4', 'B', '13'], ['S', '2', 'B', '14']] TRANSITION = [['T', '2', 'B',...
Task Given a string composed of ASCII printable characters, return how many strings could fit the given pattern with character literals and regex-like ranges. Pattern string The pattern string follows this grammar (the | means an option and the * means 0 or more occurrences of whatever was immediately to the left): pat...
Setup: For two sets \$A,B\$, we say \$A \subseteq B\$ if every element in \$A\$ is also in \$B\$. Another way of saying this, is that we can order the elements of \$A,B\$ into two lists \$L_A,L_B\$, such that \$L_A[i] = L_B[i]\$ where \$i\$ ranges over the indices of \$L_A\$. We proceed to extend this idea, to define ...
Write a script that outputs A to stdout infinitely. There should be no newlines or separators between the characters. Standard loopholes apply. This is code-golf. The shortest solution in each language wins.
[ CODE GOLF] BAM! - Fire and Smoke Your Oscilloscope has exploded from one too many waves. Re-create these waves assuming the following: All waves are Sine Waves An amplitude of 1 spans 3 lines (Therefore and amplitude of 2 would span 5 lines) [Vertically] We want to see 100 characters worth of sine (Can be any ch...
Task As input you have: a positive integer N And you should output: The number of integers in \$[1,N]\$ (an inclusive range) which end with the digit \$2\$ in base ten. Test cases 1 -> 0 2 -> 1 5 -> 1 10 -> 1 12 -> 2 20 -> 2 30 -> 3 54 -> 6 97 -> 10 100 -> 10 Rules It is a code-golf so the lowest score in bytes wi...
How many petals around the rose How many petals around the rose is a dice game you can play with your friends. Similar to "can I join the music box", there is a person that knows how the game works and the others have to discover the rule. In this game, someone rolls some dice (usually two or more) and then people have...
Context (Feel free to skip, doesn't really matter for the algorithmic explanation of the task) European Portuguese is a fairly complicated language to learn, mostly because of its grammar. One particular annoying thing is conjugating the verbs correctly: We have this mechanism that, when we have a verb followed by a no...
"All roads lead to Rome" is a saying that essentially means there are plenty of different ways of achieving an objective. Task Your task is to write a program that finds a set of link connections from one Wikipedia page to the Wikipedia page about Rome. Notice that it is not enough to find the word Rome with a hyperlin...
Introduction The \$n\$-ellipse is a generalization of the ellipse with possibly more than two foci. Specifically, given \$n\$ points on the plane, called foci, the \$n\$-ellipse is the set of points of the plane whose sum of distances to the \$n\$ foci is equal to a constant \$t\$. This challenge is about plotting the ...
Given a strictly positive integer n (therefore 0 isn't a valid test case), produce an approximate triangle of height n. A non-programmatic process of drawing the picture Initially we start with the base of the triangle. | So, we want to draw a triangle of a height of 5. First we know that all the |'s align on a straig...
Task Your task is to take a character in: AÁÀÃÂBCÇDEÉÊFGHIÍJKLMNOÕÓÔPQRSTUÚVWXYZaáàãâbcçdeéêfghiíjklmnoõóôpqrstuúvwxyz and turn it into a characters in: AAAAABCCDEEEFGHIIJKLMNOOOOPQRSTUUVWXYZaaaaabccdeeefghiijklmnoooopqrstuuvwxyz by the obvious operation: dropping the accents in the letters. Input A character in any se...
Miller-Rabin test Given a base \$b\$ and an odd number \$n\$: Write \$n\$ as \$2^{s}\times d + 1\$ where \$d\$ is odd \$n\$ is a strong probable prime if either: \$b^d\equiv 1 \pmod n\$ \$b^{d\cdot2^r}\equiv -1 \pmod n\$ for any non-negative \$r\$ strictly less than \$s\$. A strong probable prime which is composite ...
Sometimes I make bad jokes... And a bad joke I like to make involves interpreting exclamation marks in sentences as the factorial sign. Task Your task is to write a program that receives a sentence and applies the factorial joke to the sentence. The "factorial joke" consists of looking for exclamation marks "!" and doi...
Task Given an integer matrix M and a modulus m, find an inverse of M modulo m. If the matrix M is not invertible modulo m, the behaviour is left unspecified. Matrix inverse If M is a square matrix, its inverse exists if and only if its determinant is not 0. Similarly, when we are talking about matrices modulo m, the in...
I'm recieving 2-dimensional positions of two objects as a string with this format: x1,y1,x2,y2. The string is recieved from a readline call (replaced in the snippet with a prompt). In order to get the horizontal and vertical position differentials, I'm writing the following code: [x1,y1,x2,y2]=prompt("Please enter th...
My robot for generating Mad Libs-style sequence challenges has gone rogue! To defeat it, I need you to write code that can solve all the challenges it can crank out. Your input is three selections for the blanks A, B, C, each from (1,2,3), specifying the sequence challenge to solve, and the number \$n\$ that's the inpu...
Write the shortest program that prints, in order, a complete list of iPhone iterations, according to this site: iPhone iPhone 3G iPhone 3GS iPhone 4 iPhone 4S iPhone 5 iPhone 5c iPhone 5s iPhone 6 iPhone 6 Plus iPhone 6s iPhone 6s Plus iPhone SE iPhone 7 iPhone 7 Plus iPhone 8 iPhone 8 Plus iPhone X iPhone XR iPhone XS...
Challenge You will be given a string as an argument. You need to convert that string to upper case. But you can't use any built in method or function nor any external programs. Rule No use of built in methods or functions or external programs. Only arithmetic, bitwise, logical operators, regex, replace, split, join, A...
She said s(he) be(lie)ve(d), he said sbeve. Input A non-empty string, s. It's guaranteed that s will have only printable ASCII characters and at least one word (defined as [A-Za-z0-9]+) in parentheses, and all parentheses will be closed respectively. Output A string containing all non-whitespace characters (whitespa...
Correct a single-letter typo in a fixed text. Input: The paragraph below but with exactly one typo, where a single letter a-zA-Z is replaced by a different letter a-zA-Z. To be clear, the letter isn't replaced everywhere it appears, but just in that one place. For example, the first word "In" might become "IZ". Non-let...
Background In JIS X 0208 a 94 by 94 map (kuten (区点)) is defined to encode Chinese characters (kanji), phonetic moras (kana) and other symbols. Along with this standard there are 3 different encodings that maintain 1-1 correspondences with the map, namely JIS, Shift_JIS and EUC. These encodings take 2 bytes for each cha...
Write a program or function that fulfills the following Scores less than 101 bytes under normal code-golf rules Takes no input1 and always outputs a single integer. Every integer is a possible output. Your score will be the probability of the most frequent integer occurring, with a lower scoring being the goal. That...
There are 5 different "special characters": % & # $ ! These special characters are in a string with numbers. Like so: "5 ! 60%2$5.3" (valid). You must determine the validity of the string and there are certain rules in order to determine validity of the string. Rules: These special characters can exist in a string...
In this challenge you will take a an ascii art image of a highway like so | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | And you need to put rain across its lanes like so |\\\|\\\| |\\|\\| |\\\\\\\| |\\\\\| |\\\|\\\| |\\...
This is a simple game of getting rid of those damn numbers. You start with the numbers from 1 to 19, written in a grid of 9 by 3: 1 2 3 4 5 6 7 8 9 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 You may notice that the number 10 is missing, this because the number zero would be hard to get rid of later on. The two rules are: I...
Task Given a set of n unique elements and a multiset l of positive numbers that add up to n, find all the ways of partitioning those unique elements into disjoint sets with sizes given by the elements of l. (A multiset is a set that allows repeated elements) The point here is that we are taking everything in the output...
There are 10 types of people in the world, those who understand binary and those who do not. Where are you? Let's see! Challenge Your task is to convert a decimal integer to binary, only using a set of arithmetic operators (+, -, *, / and %). You can use conditional statements, loops and variables. (No bitwise operator...
This challenge initially appeared in this challenge as a an extra brain teaser. I am posting it with permission from the original author so that we can have a formal competition. Your task here will be to implement a function1 that forms a permutation on the positive integers. This means that each positive integer ...
[Question inspired by Can you calculate the average Levenshtein distance exactly? . Thank you Anush. ] The longest common substring between two strings is the longest substring which is common to both. Please note this is not the same as the longest common subsequence whose fastest algorithm takes quadratic time. The ...
You have a square board with a bunch of items laid out on it in one of a \$3 \times 3\$ grid of cells and you want to lift it up using balloons, but you can only attach balloons to the corners of the board. Your task is to determine the minimum number of balloons in each corner to make sure the board won't tip over in ...
Given an positive integer n (including 0 if you decide to support it), output all numbers in the generated sequence up to the index n. For the current test cases of the current challenge numbers are one-indexed. Feel free to submit 0-indexed answers though. Base sequence We start from this sequence (NOT, but quite simi...
Task Given a input string s which contains only printable ascii characters output all strings which contain only printable ascii characters and are strictly smaller than s in any order String a is strictly smaller than a string b if either of the following is true: len(a) < len(b) len(a) == len(b) and string a is lexi...
Inspiring myself on a recent challenge, we ought to compute a sequence that is very close to A160242. Task Your task is to generate the sequence \$ \{s_i\}_{i=0}^\infty \$: 1, 2, 1, 1, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, ... Which is more easily understandable in this format: 1 2 1 1 2...
Your task is to write a program or function that takes as input a list of positive integers and determines if there are any two integers in the list, that both appear the same number of times. For example the list [1, 2, 3, 2] Has one 1 and one 3 so it satisfies the condition. But the list [3, 2, 2, 1, 2, 3] does not...
I am quite proficient in C++ and Java and want to learn competitive programming to participate in contests like Google codejam and other online contests held on sites like CodeChef and Codeforces. I would like to get information about any free resources including websites and courses to learn the "sport". Book suggesti...
This challenge like some of my previous challenges will have you counting free polyforms, which are generalizations of Tetris pieces. This code-golf challenge will have you count polyomino-like polyforms on hypercubes. In particular, this challenge is to write a program that takes in three parameters: n, which represe...
We know that not all fractions have a terminating binary representation. However every fraction can be written as a leading portion followed by a repeating portion. For example \$1/3\$ starts with \$0.\$ and then just repeats \$01\$ endlessly. This corresponds to the bar notation taught in primary school. For examp...
Note: Bot Factory KoTH (2.0) is now posted; you're probably looking for that one instead! In this challenge, bots (consisting of JS functions) move around an infinite factory (playing field), collecting characters (UTF-16). These characters can be used to build worker bots, or droppedfor other bots to pick up. Results ...
The system Assume the Earth is flat and that it extends infinitely in all directions. Now assume we have one infinitely long train railway and n trains in that railway. All trains have different speeds and all trains are going in the same direction. When a faster train reaches a slower train, the two trains connect (be...
Background Binary Sudoku, also known as Takuzu, Binario, and Tic-Tac-Logic, is a puzzle where the objective is to fill a rectangular grid with two symbols (0s and 1s for this challenge) under the following constraints: Each row/column cannot have a substring of 000 or 111, i.e. one symbol cannot appear three times in ...
Challenge Your task is to generate a string using this sequence: 1,1,2,1,1,2,3,2,1,1,3,2,4,2,3,1,.... Which is more understandable in this format: 1 1 2 1 1 2 3 2 1 1 3 2 4 2 3 1 1 4 3 2 5 2 3 4 1 The pattern increases the number of Digits in the string by two for each increment in the Value of N For each integer val...
Challenge Your goal is to write a function that puts quotes around a sequence of capital letters in a string. So some examples (everything on the left (before function) and right (after function) are STRINGS): Hello the name's John Cena -> "H"ello the name's "J"ohn "C"ena I got BIG OLD truck -> "I" got "BIG" "OLD" truc...
Challenge Print the numbers: 1 22 333 4444 55555 666666 7777777 88888888 999999999 In that order. I/O Takes no input. The numbers can have any delimiters desired (or none). That includes lists, cell arrays, .jpeg, etc.... Example outputs: 122333444455555666666777777788888888999999999 [1,22,333,4444,55555,666666,77777...
This challenge is inspired by @LuisMendo's MATL answer to my "binary multiples" challenge. Task Pick a code-golf challenge that is open and that has been posted before this one; let me call it the "linked challenge". The linked challenge must be a challenge whose task involves producing output. Write the shortest code ...
This code-golf challenge will have you computing OEIS sequence A300154. Consider a spiral on an infinite hexagonal grid. a(n) is the number of cells in the part of the spiral from 1st to n-th cell that are on the same [row*] or diagonal (in any of three directions) as the n-th cell along the spiral, including that cel...
Here are the first 100 numbers of a sequence: 1,2,33,4,55,66,777,8,99,11,111,12,133,141,1515,1,11,18,191,22,222,222,2232,24,252,266,2772,282,2922,3030,31313,3,33,33,335,36,377,383,3939,44,441,444,4443,444,4455,4464,44747,48,499,505,5151,522,5333,5445,55555,565,5757,5855,59559,6060,61611,62626,636363,6,66,66,676,66,666,...
Identify each letter of the English alphabet with the number denoting its position in the alphabet, that is, a = 1, b = 2, c = 3, ..., z = 26 (no distinction between lower and upper case letters is made). Every other character is identified with 0. The "sum" of a word is the sum of its characters, for example: the su...
Introduction The current coronavirus disease is officially named COVID-19, from the 3 words corona virus disease, and the year 2019. (Technically it's coronavirus, making 2 words, but whatever...) Given this example, we can apply this naming convention to name other potential diseases. Challenge You will be given 3 wor...
In this challenge, bots must survive as long as possible. In each turn, the bot with the most HP is eliminated. This challenge is inspired by the Smallest unique number KoTH. Results After 100,000 rounds: Jack: 63390 The Follower: 4942 The Algorithm: 2452 The Randomiser: 140 Toe Tipping: 0 EZ: 0 The Average: 0 LowProfi...
Goal Write a program or function that returns the day of the week for a date, eg. 01/06/2020 -> Mon However, it's unknown if the date is in the format mm/dd/yyyy or dd/mm/yyyy. If you can be certain of the day of the week, return it. If there is uncertainty, return an error. 02/07/2020 -> Err (Thu? Fri?) Input...
Pure data is a graphical programming language designed for audio processing. This makes it unsuitable for most general programming but especially unsuitable for code-golf. It would then be nice to have a tips question so that people can get a first foot up in this language. What tips are there for golfing in Pure Data...
Symja is a "computer algebra language & Java symbolic math library for Android NCalc calculator". It's a fun little language, so I'm wondering if y'all have any tips for golfing in Symja. As per usual, "remove comments", etc, isn't really an answer. It turns out that there is no comment system in Symja, so "remove com...
Context When I was a little kid, I watched a Disney movie where Goofy told his son "Boy, even a broken clock is right two or three times a day." (see this youtube clip, courtesy of @Arnauld). Rationale Given the previous statement, we wish to look at a clock that is stopped and answer the following question: is this cl...
Let's consider the sequence of the binary representation of positive integers (without any leading zero): 1 2 3 4 5 6 7 8 9 10 11 12 ... 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 ... If we join them together, we get: 1101110010111011110001001101010111100 ... If we now look for the pattern...
A directed graph G is given with Vertices V and Edges E, representing train stations and unidirectional train routes respectively. Trains of different train numbers move in between pairs of Vertices in a single direction. Vertices of G are connected with one another through trains with allotted train numbers. A hop is ...
Natural numbers ≡ \$\mathbb{N}≡\{0,1,2,...\}\$ The submission can be either a program or a function, both cases will henceforth be referred to as "function". The task is to golf the shortest function \$\mathbb{N}^n→\mathbb{N}\$, i.e. a function that maps \$n\$ natural numbers (with \$n>0\$ being a number of your choosi...
In the shortest amount of code in any programming language, filter out the duplicate items in an array of which the order is irrelevant. Here are some test cases: [1, 2, 2, 3, 1, 2, 4] => [1, 2, 3, 4] ['a', 'a', 'b', 'a', 'c', 'a', 'd'] => ['a', 'b', 'c', 'd'] I also should note that there currently aren't any open q...
Context The water buckets riddle or the water jugs riddle is a simple riddle that can be enunciated in a rather general form as: Given \$n > 0\$ positive integers \$a_1, a_2, \cdots, a_n\$ representing the capacities (in units of volume) of \$n\$ buckets and a positive integer \$t \leq \max(a_1, a_2, \cdots, a_n)\$, fi...
Sequel of Counting valid Binary Sudoku rows. Background Binary Sudoku, also known as Takuzu, Binario, and Tic-Tac-Logic, is a puzzle where the objective is to fill a rectangular grid with two symbols (0s and 1s for this challenge) under the following constraints: Each row/column cannot have a substring of 000 or 111, ...
Challenge You will be given a string that can contain lowercase letters, uppercase letters, or spaces. You have to turn the vowels (a, e, i, o, u) in the string to upper case and consonants to lower case. This applies whether or not the letter was originally upper case or lower case. Spaces remain as is. Note that "y" ...
Given N integers, output the sum of those integers. Input You may take the integers in any reasonable format, including: stdin arguments an array or list Rules Your code must not include the characters + or -. Standard loopholes apply. Take note of Abusing native number types to trivialize a problem. This is code-...
Objective Simulate an edge-triggered D Flip-Flop. What is D Flip-Flop? A D flip-flop is an electronic digital device that outputs an inputted data (abbr. D) with synchronization to a clock (abbr. CLK). Usually CLK is a uniform pulse, but in this challenge, CLK may be not uniform. Input A bitstring with length \$n\$ wil...
Given a string as an input (which can be any acceptable/convenient format in your language), implement pendulum encoding. The test cases are split into individual items (which aren't quoted) for a visually appealing explanation. How do I do that? The current iteration index starts at 0. If the iteration index is even,...
Submit a well-formed program or function with usual I/O rules which satisfy the input, output, and algorithm conditions below. Shortest submission (in bytes) wins. As always, standard loopholes are forbidden. In short: Two distinct 8-bit integer inputs must produce two 8-bit integer outputs so that all four numbers are...
Task Your task is to make the smallest function/program that can, when gives an number N, return/print: the number of possible choices a, b such that \$1 \leq a < b < N\$ and a and b have exactly one common digit in base 10 (there exists a digit, and only one digit, which appears both in a and b, for example 12 and 23,...
Setup Take the following 4x4x4 cube along with a 2D view of 3 of its faces, with a common 1x1x1 cube highlighted: The arrows represent the points of view that generated the V1, V2 and V3 faces drawn underneath the big cube. Given an arrangement of some 1x1x1 cubes inside the main cube we can try and identify it with o...
Construct a full program which outputs Hello, World!. The score of your submission will be equal to the sum of all of the ASCII values of the distinct characters. The lowest score wins! Rules It must be a full program which takes no input It must only print to STDOUT, nothing else It must be strictly less than 1000 by...
Given required values for an expression with 2 variables, output a short expression which fulfill these values Input You may take the input in any reasonable format, e.g. f(x,y)=z, {(x, y): z}, [[[x,y],z]], but please write what format is your input is taken in Output Your output needs the be a valid infix expression f...
Chef Avillez is about to cook us some really nice meal. He is just waiting for us to give him some ingredients and to request a meal. Task Given a list of ingredients (strings matching /[a-z]+/) and a requested meal (string matching /[a-z][a-z ]*/) output the integer amount of meals Chef Avillez can make. Algorithm Eac...
Task Your task is to draw these beautiful oak trees: 1 -> @@@ @@@@@ @|.|@ _|_|_ 2 -> @@ @@@@@@ @@@@@@@@ @@| .|@@ | | __|__|__ 3 -> @@@@@ @@@@@@@@@ @@@@@@@@@@@ @@@| |@@@ @| .|@ | | ___|___|___ 4 -> @@ @@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@@@ @@@@| |@@@@ @@| .|@@ | | | ...
Task Write a function/full program that will be able to produce two different sequences of integers in [0, ..., 9]. You will take an input seed to decide whether to output your specific sequence or the common one. For that matter, you must choose one non-negative integer, let us call it k. When the input seed is equal ...
In this challenge, all bots are wizards. At the beginning of each round, they create a wand which has a certain chance of successfully stunning another wizard. They then fight, by choosing one bot to attack in each turn. The last bot remaining wins. Results 500 games, 1000 rounds each Revenge!: 132101.68886125216 JustE...
This challenge is inspired by Fortran's idiosyncratic implicit typing rules. Your task will be to determine the data type of the object GOD according to the implicit typing rules explained below. Background Fortran 77 has six data types: CHARACTER, COMPLEX, DOUBLE PRECISION, INTEGER, LOGICAL, and REAL. Any object not e...
Objective Given a dimension of an SI unit, convert the Lorentz-Heaviside version of a Planck unit \$1\$ into SI metric. What is a Planck unit? Planck units are a set of units of measurement. It defines five fundamental constants of the universe as dimensionless \$1\$. What is a dimension? There are five types of fundam...
(yes, "generating generating" in the title is correct :) ) Context In middle (?) school we are taught about sequences and, in particular, we are taught about linear sequences where the nth term is generated with an expression of the form an + b, where a and b are some coefficients. In this challenge, we will deal with ...
Given a compressed string \$s\$ made of printable ASCII characters (32 to 126), your task is to print or return the original text by applying this simple decompression algorithm: Start with \$k=0\$ Look for the first occurrence of the digit \$k\$ in \$s\$ and the sub-string \$s'\$ consisting of the \$2\$ characters pr...
Task A date can be compactly represented in a 6-character string in the format ddmmyy where the first two characters (dd) represent a day, the 3rd and 4th characters (mm) represent a month and the last two characters (yy) represent a 20XX year. Given a string with 6 characters in [0-9] determine if it represents a vali...
In this challenge, submissions will be programs or function which, when given an emoticon such as :-), :(, or :D, will rate their happiness from 0 to 3. An emoticon will be one of the following: :(: 0 :|: 1 :): 2 :D: 3 Emoticons may also have noses (a - after the :). Test cases: :( -> 0 :-| -> 1 :D -> 3 :-) -> 2 :|...
Inspired by I reverse the source code, ... Your task, if you wish to accept it, is to reverse text and mirror select characters. Yes, yes, I know. Very surprising. Input A string, stdin, an array of characters, or any other source of text. All characters of the input are guaranteed to be in the printable ASCII range (3...
Objective Given a nonempty multiset of Rock, Paper, and Scissors, output the winning figure according to the special rule. Background For a multiplayer RPS, if all three figures come out, usually it's considered a draw. But by that rule, the probability to draw would dramatically increase when there are many and many p...
These are the classical puzzles: You need to boil eggs for exactly 9 minutes, or else the visiting Duchess will complain, and you will lose your job as head chef. But you have only 2 Hourglasses, one measures 7 minutes, and the other measures 4 minutes. How can you correctly measure 9 minutes? (taken from here) Let's...
Task A Rotate-Left-Double number in base \$n\$ is a number \$m\$, when its base-\$n\$ digits are rotated left once, equals \$2m\$. The base-\$n\$ representation of \$m\$ cannot have leading zeros. One example in base 7 is the number 480, or \$1254_7\$. When rotated left once, the value becomes \$2541_7 = 960\$. Given t...
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 exactly 2 from each other. The twist is that your code must run in l...
As input you will receive An integer \$a\$ A list of integers that is infinite and strictly-monotonic1. Your program should check in finite time if \$a\$ appears the list. You should output one of two distinct values. One if \$a\$ appears in the list and the other if \$a\$ does not. This is code-golf so answers wi...
Objective Given an Arabic string consisting of ISO/IEC 8859-6 Arabic letters (U+0621–063A, 0640–064A), decode it to Arabic Presentation Forms-B (U+FE70–FEFF). Behavior of Arabic letters ISO/IEC 8859-6 Arabic letters change their displayed form to letters in Arabic Presentation Forms-B, which are categorized to isolated...
Write a program that takes in two non-negative integers S and N in that order. S represents the side length of a square grid of . characters. N represents the number of those .'s that need to be changed to x's. You may assume N is no greater than S squared. Your program needs to output this S×S square of .'s and N x's ...
The challenge Make 2 programs which convert decimal to and from base 94, or a bidirectional program. Base 94? Base 94 is like any other base, but instead of 0 to 9 and letters, it uses ASCII characters 33 to 126. Not 127 because chr(127) is DEL. Not 32 because that's a space. Examples 0 - ! or empty string 1 - " 93 - ~...
For this challenge, submissions should be a program or function shaped like a right triangle, which produces a right triangle of the same size. What is a right triangle? For this challenge, a right triangle consists of 1 or more lines, each containing a number of characters (assume all non-newline characters are the sa...
The challenge: Given four coordinates, each in x y form, your job is to find out whether or not the given coordinates form a rectangle, and output a truthy/falsey. Rules: For the sake of simplicity, squares, lines (two identical pairs of coordinates) or dots (all four of the coordinates are the same) are all counted a...
Introduction: Although it seems challenges scored by least unique characters have been attempted, there are few which were well-received. I think it's a potentially interesting scoring criterion, as long as different languages aren't competing with each other (as with code golf). Challenge: Create a basic FizzBuzz prog...
Task For a given base \$n \ge 3\$, find the smallest positive integer \$m\$, when written in base \$n\$ and rotated right once, equals \$2m\$. The base-\$n\$ representation of \$m\$ cannot have leading zeroes. The corresponding OEIS sequence is A087502, and its base-\$n\$ representation is A158877 (this one stops at \$...