instruction
stringlengths
34
53.1k
Print or return the following string: R******* *R****** **R***** ***R**** ****R*** *****R** ******R* *******R *....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......* *....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......* *....... .*...... ..*..... ...*.... ....*... .....*.. ......*. ......
Solve the Greek Computer Puzzle Toy There is a small toy of a series of stacked dials -- loosely inspired by the Antikythera Device. The puzzle, made by Project Genius, has a series of dials that must be arranged in a particular configuration to win. In this challenge, you will write a function/program to find that sol...
Given a positive input \$n\$, output all permutations of either \$\{0,1,\ldots,n-1\}\$ or \$\{1,2,\ldots,n\}\$. Examples Outputting permutations of \$\{1,2,\ldots,n\}\$. Input Output 1 [(1)] 2 [(1, 2), (2, 1)] 4 [(1, 2, 3, 4), (1, 2, 4, 3), (1, 3, 2, 4), (1, 3, 4, 2), (1, 4, 2, 3), (1, 4, 3, 2), (2, 1, 3, 4...
The goal of radiation hardening is to make a program still work after you remove a byte. However, what if a skilled competitor is purposefully trying to mess with you? In this game, each bot will take turns removing one character from the next bot down the line. If the bot fails to produce valid output next turn you ga...
Given an undirected graph, find out if it is a tree. A tree is an undirected graph in which there is exactly one path between any two vertices. In other word, the graph is both acyclic and connected. Input You can take input in any reasonable format. Here are some example formats: an adjacency matrix, e.g., [[0,1,1,0]...
A perfect number is a positive integer whose sum of divisors (except itself) is equal to itself. E.g. 6 (1 + 2 + 3 = 6) and 28 (1 + 2 + 4 + 7 + 14 = 28) are perfect. A sublime number (OEIS A081357) is a positive integer whose count and sum of divisors (including itself) are both perfect. E.g. 12 is a sublime number bec...
Given a list of positive integers \$\mathcal I=I_1,I_2,I_3,...,I_n\$ and a base \$b>1\$ return their "carry-less sum", i.e. represent \$\mathcal I\$ in base \$b\$ and sum digit-by-digit discarding carry. Worked example: I = 13, 2, 9; b = 3 In base 3: 111 + 2 + 100 ----- = 210 and back to base 10: desired out...
Write an interactive program or function which allows the user to play The Coinflip Game! The object of the game is to repeatedly flip a coin until you get the same result \$n\$ times in a row. Specific behavior of the program/function is as follows: At the start of the game, the user inputs a positive integer \$n>1\$...
easy mode of my previous challenge A perfect number is a positive integer whose sum of divisors (except itself) is equal to itself. E.g. 6 (1 + 2 + 3 = 6) and 28 (1 + 2 + 4 + 7 + 14 = 28) are perfect. A sublime number (OEIS A081357) is a positive integer whose count and sum of divisors (including itself) are both perfe...
Level-index is a system of representing numbers which has been proposed as an alternative to floating-point formats. It claims to virtually eliminate overflow (and underflow, in its symmetric form) from the vast majority of computations. The usual floating-point format internally represents a number \$x\$ in terms of a...
Produce Graham's Number in Magic the Gathering using the fewest number of cards and without using any infinite combos. Rules: Producing Graham's number means do anything that requires Graham's number to represent the game state. For example, you could produce Graham's number 2/2 zombie tokens, have Graham's number li...
A ragged list is a (finite depth) list where each element is either a positive integer or a ragged list. A ragged list is properly tiered if it contains either all positive integers or all properly tiered ragged lists. For example [1,2,3,6] is properly tiered because it is a list of only positive integers. [[1,2],[[1]...
Introduction: I'm old-fashioned and still read a physical newspaper in the morning while eating my breakfast. Although I don't like Sudoku that much, I do solve the Light-complexity ones, which are extremely easy. With these, I always try to solve all the numbers using only the Hidden Single technique†, in increasing o...
This is the cops' thread of a cops-and-robbers challenge. The robbers' thread can be found here In this challenge as a cop you will choose two programming languages A and B, as well as a non-empty string S. You are then going to write 4 programs: A program which outputs exactly S when run in both A and B. A program w...
This is the robbers' thread. For the main rules to this challenge see the cops' thread In this challenge, robbers will choose a cop's vulnerable or safe post and try to figure out a pair of languages such that they print the correct results for the 4 programs. When you find a solution post an answer of it here and lea...
I have previously posted a challenge, smallest number of steps for a knight in chess. Now I would like to go a step further by adding the possibility to choose your piece. If you place a piece on any square of a chessboard, what is the smallest number of steps to reach every possible position? Rules It is an 8 by 8 bo...
If you consider the following PHP+C polyglot snippet, there is a problem regarding class property access in the printf call: #include <stdio.h> #include <stdlib.h> #define class struct #define function class Point { #define public int public $x; public $y; }; int function main() { struct Point* $p = ...
There already is a Brainfuck interpreter question, but it is from 2011 and not up to date with current site standards and vague in places. I have proposed reposting this in chat, and it was well-received. Here goes. Objective Given the Brainfuck code and the program's input as input, run the Brainfuck code. As there ar...
Conways' Game of Life is a well known cellular automaton "played" on an infinite grid, filled with cells that are either alive or dead. Once given an initial state, the board evolves according to rules indefinitely. Those rules are: Any live cell with 2 or 3 living neighbours (the 8 cells immediately around it) lives ...
In a given 2d grid of positive integers (representing different types of "bubbles"), there are one of two actions that you can do each "step". You can either: Pop an island (a connected group of bubbles - two bubbles that are diagonally adjacent are not considered connected) of the same type of bubbles, given that th...
The wizard has a cunning cousin who is a witch. She looks down on the wizard, regarding him and his puzzles as mathematically naive. On reading his latest puzzle, she scorned him for always asking discrete problems with what she (unfairly) characterises as simple solutions, where the real, proper question should be co...
An ant starts on an edge of a dodecahedron, facing parallel to it. At each step, it walks forward to the next vertex and turns either left or right to continue onto one of the other two edges that meet there. A sequence of left/right choices that returns the ant to its initial state (edge and direction) is called a rou...
Print or return the following text: Hello world! The quick brown fox jumps over a lazy dog. However, your submission will not be scored in bytes. Instead, primarily it will be scored by the width in pixels of the program when written in Arial in a 12pt font. In particular, the score is: $$ (\text{visual width in px}) ...
A number is a Mersenne Prime if it is both prime and can be written in the form 2m-1, where m is a positive integer. For example: 7 is a Mersenne Prime because it is 23-1 11 is not a Mersenne Prime because it cannot be written as 2m-1 15 is not a Mersenne Prime because it is not prime The first few Mersenne primes:...
The partition function: In number theory, the partition function p(n) represents the number of possible partitions of a positive integer n into positive integers For instance, p(4) = 5 because the integer 4 has five possible partitions: 1 + 1 + 1 + 1 1 + 1 + 2 1 + 3 2 + 2 4 Your task: Accept an input (let's call i...
Given a relation, and a domain, output whether the relation is an equivalence relation. Context For this challenge, a relation is defined as being a set of ordered pairs that is a subset of the cartesian product of a domain with itself. That is, \$R \subset X \times X\$. For a relation \$R\$ to be an equivalence relati...
The persistence of a number \$x = d_1d_2d_3...d_n\$, with \$d_1 \ne 0\$, under some function \$f : \mathbb N_0 \times \mathbb N_0 \to \mathbb N_0\$ is defined as the number of applications of \$f\$ to the digits of \$x\$ before it reaches a single digit integer. That is, if we have the map $$I_f: (x = d_1d_2d_3...d_n) ...
This is not a duplicate of Sum of combinations with repetition. This question considers 1+2 to be the same as 2+1. The other question doesn't. OEIS link - A000008 Background If you have 4 types of coins (1, 2, 5 and 10 cents), in how many ways can you make an amount? There are 4 ways of making 5 cents: 1 + 1 + 1 + 1...
Background "Fly straight, dammit" (OEIS A133058) is a sequence of integers, which has these rules: \$a_0 = a_1 = 1\$ \$a_n = a_{n-1}+n+1\$ if \$gcd(a_{n-1}, n) = 1\$ Otherwise, \$a_n = \frac{a_{n-1}}{gcd(a_{n-1}, n)}\$ In pseudocode: a[0] = a[1] = 1 if gcd(a[n-1], n) == 1 then a[n] = a[n-1] + n + 1 else a[...
A complete deterministic finite automaton is a machine, with some states. Each state in the automaton has, for each character in the alphabet, a pointer to a state (not necessarily a different one). The automaton starts at some state, and then reads a string, character by character. For each character, the automaton mo...
One of my favorite memes is the bouncing DVD logo. Yet silly but extremely satisfying, a DVD logo keeps bouncing on a screen and if you ever happened to watch this screensaver, you were most likely anxiously waiting for the logo to exactly hit the corner. I know part of the fun is the waiting, but let's try to predict...
The Fibonacci word is a sequence of binary strings defined as: \$F_0 = \$ 0 \$F_1 = \$ 01 \$F_n = F_{n-1} F_{n-2}\$ The first few Fibonacci words are: 0 01 010 01001 01001010 0100101001001 010010100100101001010 ... Each of these strings is a prefix of the next, so they are all prefixes of the single infinite word \$...
Turing Machine Preliminaries A Turing machine is specified by the following data A finite set of symbols S = \$\{s_1,s_2,...\}\$ A finite set of states M = \$\{m_1,m_2,...\}\$ A partially defined function $$T : M \times S \to S \times \{\mathrm{left},\mathrm{right}\} \times M $$ Any encoding of such a Turing machin...
The string tut-tutut-tut-tuttut-tut can be constructed with overlapping or concatenated instances of the word tut-tut: tut-tutut-tut-tuttut-tut tut-tut tut-tut tut-tut tut-tut The string tut-tututut-tutut-tut cannot: tut-tututut-tutut-tut tut-tut^ |tut-tut | tut-tut ...
Note: most of the questions that are already in existence about this topic only deal with two numbers as inputs. This question deals with any number (>1) of inputs. GCD The GCD (greatest common divisor) of a list of integers is the largest integer which divides all of the numbers in the list. For example: \$gcd(9, 12,...
A jigsaw puzzle consists of (usually rectangular-ish) pieces. On each side of a piece, there is either an edge or a connector (a term I made up). A connector is either a tab sticking out (outie) or a slot facing inwards (innie). Two pieces can be joined if the outie tab can fit into the innie slot. The goal is to assem...
Imagine a very simple language. It has just 2 syntax features: () indicates a block scope, and any word consisting only of 1 or more lower case ASCII letters, which indicates a identifier. There are no keywords. In this language, the value of identifiers is not important except when they appear multiple times. Thus for...
Write a program, which outputs I'm Blue, and then Da, Ba, Dee, Da, Ba, Die, forever, the words must be space-seperated in one line, and it must pause 0.4 to 0.6 seconds after printing each word. Also, the text should be outputted in the color blue 0x0000FF or in ANSI escape code blues. So the output must be something...
In 1988, the International Mathematical Olympiad (IMO) featured this as its final question, Question Six: Let \$a\$ and \$b\$ be positive integers such that \$ab + 1\$ divides \$a^2 + b^2\$. Show that \$\frac{a^2 + b^2}{ab + 1}\$ is the square of an integer. (IMO problems) This can be proven using a technique called ...
Given a set of letter grades, output the GPA (grade point average) of those grades, rounded to one decimal place. Valid grades and their corresponding value are the following: A = 4 grade points A- = 3.7 grade points B+ = 3.3 grade points B = 3 grade points B- = 2.7 grade points C+ = 2.3 grade points C = 2 grade points...
Your task: given a nonzero positive number i, calculate pi using the Nilakantha series unto i terms. The Nilakantha series is as follows: $$\text 3 + \frac{4}{2 \times 3 \times 4} - \frac{4}{4 \times 5\times 6}+\frac{4}{6 \times 7 \times 8} - ...$$ 3 is the first term, 4/2*3*4 is the second, -4/4*5*6 is the third, and...
This is the follow up question to standard Sudoku solver. You are given a Sudoku grid where . represents an empty cell and the other cells are filled with numbers 0-8 (inclusive). Rules: All the numbers in Sudoku must appear exactly once in all left-top to right-bottom diagonals. All the numbers in Sudoku must appear ...
I have made a short script that will pull dns txt records down from a server and combine them into a single string. DNS txt records are: 1.website.com 2.website.com 3.website.com Each of these are iterated through using the single digit number. The double quotes at the beginning and the end of the strings are trimmed T...
Your task is to write a program that calculates the amount of different ways to display any given whole positive number using the following rules: Meet the 'advanced binary system': Any whole positive number can be displayed in binary form, but each bit can have every number from 0 to 9. This means, a valid number migh...
Input A calendar year from 927 to 2022. Output You can use any three distinguishable outputs. As an example, “K” (short for King) or “Q” (short for Queen) depending on which of the two England had in that year. If there was both a King and Queen in that year you can output either. If there was no King or Queen for th...
The Fabius function is an example of a function that is infinitely differentiable everywhere, yet nowhere analytic. One way to define the function is in terms of an infinite number of random variables. Specifically, given a sequence of independent random variables \$\{U_n\}\$, where each \$U_n\$ is uniform on the inter...
based off my previous challenge, this wikipedia article, and a Scratch project Your task: given i, calculate \$\pi\$ till i terms of the Gregory-Leibniz series. The series: $$\pi=\frac{4}{1}-\frac{4}{3}+\frac{4}{5}-\frac{4}{7}+\frac{4}{9}-...$$ Here, 4/1 is the first term, -4/3 is the second, 4/5 is the second and so...
Following this question: Tut-tut-tut-tut-tut Write a program that writes "tut-tut-tut" without using the characters "t", "u" or "-" in the code itself. This is code golf, shortest code in bytes wins.
inspired by thejonymyster's idea Rules This challenge is about finding languages that are very suitable for one task but quite the opposite in the other. The two tasks share a theme, but Task 1 is designed to be number-oriented while 2 is string-oriented. You can participate in three categories: Numbers: Choose a lang...
Given the diagonals of a matrix, reconstruct the original matrix. The diagonals parallel to the major diagonal (the main diagonals) will be given. Diagonals: [[5], [4, 10], [3, 9, 15], [2, 8, 14, 20], [1, 7, 13, 19, 25], [6, 12, 18, 24], [11, 17, 23], [16, 22], [21]] Rules The matrix will be non-empty and will consis...
Input A string of text. Output The string of text, however, every consonant is the next consonant in the alphabet, and every vowel is the next vowel in the alphabet (z becomes b, u becomes a). The case of the new letter should be the same as the letter it is replacing (a becomes e, A becomes E). If there are two conson...
The wizard is determined to pose the most challenging challenge yet for which he believes the previous solution techniques will not work. He decides to go multidimensional. If there is a number line with \$x = 10\$ then your task is to prove this. If you do so you win. In this situation, for your code to be correct, ...
A composition of an integer \$n\$ is a representation of \$n\$ as a sum of positive integers. For example the eight compositions of 4 are as follows: 4, 3 + 1, 1 + 3, 2 + 2, 2 + 1 + 1, 1 + 2 + 1, 1 + 1 + 2, 1 + 1 + 1 + 1. The challenge is to output the number of compositions of \$n\$ in which the greatest part is odd....
In chess, the Fool's Mate is the fastest possible way to reach checkmate. It is reached with Black's second move. In chess notation, one possible sequence of moves that achieves Fool's Mate is 1.f3 e6 2.g4 Qh4#. This is not the only possible way to achieve this checkmate (in the same number of moves). There are three ...
Carryless multiplication is an operation similar to binary long multiplication, but with XOR instead of addition: 1011 11 × 101 5 ----- 1011 0 1011 ------ 100111 39 In this challenge, you'll be given a positive integer >= 2, and must return a list of all positive integers which are carryless factor...
I recently stumbled across this image on wikimedia commons. It's a little bit of an information overload at first, but after examining it a bit it shows an interesting number system for writing nibbles. Image created by user Watchduck. First off a "nibble" is a 4 bit number which is really a number ranging from 0 to ...
Write a program/function that finds the amount of fuel needed to escape Earth's gravity well given the exhaust velocity of the fuel and the amount of mass to transport using the Tsiolkovsky rocket equation: $$\Delta v = v_\text{exhaust}\ln\dfrac{m_\text{start}}{m_\text{end}}$$ where \$\Delta v\$ is the change in veloc...
Description All cubic equations can be solved, and every cubic has at least one solution. The goal of this challenge is to find the real solutions to a given cubic using inputs, and (obviously) the smallest program size. Rules The solution must find the real solutions of a cubic correctly, using any method. The cubic m...
In this challenge you will take as input a non-empty list of binary values (these can be booleans or integers on the range 0-1), you should output all the ways to partition the list into non-empty sections such that no two adjacent equal values in the initial list are separated into different sections. For example if t...
Futoshiki is a logic puzzle where an \$n×n\$ Latin square must be completed based on given numbers and inequalities between adjacent cells. Each row and column must contain exactly one of each number from \$1\$ to \$n\$ while satisfying the inequalities. In a solved Futoshiki puzzle any row (or column) forms a linear ...
Take a list of 2-digit hexadecimal numbers as input, and output the binary value, replacing each 1 with an 'X', and each 0 with a space. For example Input = FF, 81, 47, 99. FF = 11111111 in binary, so print XXXXXXXX 81 = 10000001 in binary, so print X X 47 = 01000111 in binary, so print X XXX 99 = 10011001 in ...
User inputs an integer. Print out proper fractions using all positive integers up to the user's input, in ascending order. Rule 1: Eliminate equal fractions. Rule 2: Fractions should be in their simplest form. Rule 3: Use "/" as a fraction symbol and next line (\n or \r as convenient) as a separator between fractions. ...
A Tiefling is a character race, from Dungeons and Dragons, that has this list of possible traits: small horns fangs or sharp teeth a forked tongue catlike eyes six fingers on each hand goat-like legs cloven hoofs a forked tail leathery or scaly skin red or dark blue skin cast no shadow or reflection exude a smell of b...
Given two arrays of non-negative integers \$A = [A_1,A_2,\ldots,A_n]\$ and \$R = [R_1,R_2,\ldots,R_n]\$ which are equal in length, return an array which has the element \$A_1\$ repeated \$R_1\$ times, then element \$A_2\$ repeated \$R_2\$ times, all the way up to \$A_n\$. Standard loopholes are forbidden. As this is co...
Given a binary message, and the number of parity bits, generate the associated parity bits. A parity bit is a simple form of error detection. It's generated by counting the number of 1's in the message, if it's even attach a 0 to the end, if it's odd attach 1. That way, if there's a 1-bit error, 3-bit error, 5-bit erro...
Does anyone have tips on how to golf in this language? Please one tip per answer and avoid posting simple and general tips such as "remove whitespace". Here is the github link and here is the esolang page.
Given an integer n >= 1 as input, output a sample from the discrete triangular distribution over the integers k, for 1 <= k <= n (1 <= k < n is also acceptable), defined by p(k) ∝ k. E.g. if n = 3, then p(1) = 1/6, p(2) = 2/6, and p(3) = 3/6. Your code should take constant expected time, but you are allowed to ignore o...
Print or return the following string: zottffssentettffssenttttttttttttttttttttffffffffffffffffffffsssssssssssssssssssseeeeeeeeeennnnnnnnnno This is the first letter of each of the numbers zero, one, two, all the way up to one hundred. Standard I/O rules apply, but the output must be exactly as shown above, optionally ...
You've gotten out of Earth's gravity well - good for you! However, you're feeling a bit uncomfortable in zero-gravity, and you want to replicate 1 \$g\$ of force in a centrifuge. Use the equation for force in a centrifuge: $$\text{RCF} = \frac{r_\text{m} \, \left(\frac{2 \pi N_\text{RPM}}{60}\right)^2}{g}$$ Where \$\t...
This challenge, I hope, is simple to understand. Given a date-string (given in any format you prefer, so long as it has 4 digits of year and 2 digits of day and month), calculate the weekday for the particular date-string. You must output 7 different values, corresponding to the weekday you have calculated. It's okay i...
A partition of a list \$A\$ is a way of splitting \$A\$ up into smaller parts, concretely it is list of lists that when concatenated gives back \$A\$. For example [[1],[2,3],[5,6]] is a partition of [1,2,3,5,6]. The trivial partition is a partition that "splits" the list into only one piece, so [[1,2,3,5,6]] is also a ...
Given an alphabet represented as a nonempty set of positive integers, and a word made up of symbols from that alphabet, find that word's position in the lexicographically ordered set of all words, assuming words can't contain duplicate symbols. Example Consider the alphabet {1, 2, 3} and the word [2, 3, 1]. The set of ...
Gematria is an ancient Jewish method to determine a numeric value of a letter sequence, using a fixed value for each letter. Gematria is originally applied to Hebrew letters, but for the context of this challenge, we'll use Latin script instead. There are many ways to implement Gematria in Latin script, but let's defin...
inspired by Longest Increasing Substring Task Given a list of non-negative integers, output the length of its longest alternating subsequence. An alternating sequence is a sequence of numbers which alternates between strictly increasing and strictly decreasing. [], [999], [9, 1], and [0, 5, 0, 3, 2, 4] are examples of ...
In this challenge, you are going to take a number and turn it into a string, but not in the common way. You will use the aaaaa way! The aaaaa way is simply replacing each digit of the input number with the letter at that position in the alphabet. For example, 11111 would become aaaaa and 21223 would become babbc. If th...
In R print(x, digits=n) does something a little complicated. It always shows all the digits to the left of the decimal point and then, if there are any digits to the right it rounds the whole number so that at most n digits are shown. However, leading 0s are not counted. Here are examples to show how the function work...
I want to read two strings on separate lines, each string the same length and containing only 0's and 1's, and determine if the first is the one's complement of the second. How succinctly can this be done in Python3? (Sorry to specify the language, but this is for my son who's studying Python) A list comprehension see...
Discussion in courtrooms often occurs at a high speed and needs to be accurately transcribed in case the text of the decision is needed in future cases. For this purpose, the stenographers who transcribe court discussions use specially designed keyboards with a small set of buttons, which are pressed in groups to spell...
The task is simple: given a 32 bit integer, convert it to its floating point value as defined by the IEEE 754 (32-bit) standard. To put it another way, interpret the integer as the bit-pattern of an IEEE binary32 single-precision float and output the numeric value it represents. IEEE 754 single precision Here is a conv...
Background In 1960, the 11th General Conference on Weights and Measures defined the Système International d'Unités (SI) Units which scientists still use today. The metre and the kilogram became standard units in that conference. These were based on powers of 10 (10, 100, 1000, etc.). For example: there are 100 centime...
Given an input of a string, output the partial fraction in string form. The partial fraction decomposition of a rational fraction of the form \$\frac{f(x)}{g(x)}\$, where \$f\$ and \$g\$ are polynomials, is its expression as: $$\frac{f(x)}{g(x)}=p(x)+\sum_j\frac{f_j(x)}{g_j(x)}$$ In this case \$p\$ is 0, because we ass...
Given an array of \$n\$ positive integers we will say its self-sum order is the number of ways to add elements from it to make \$n\$. We will count ways as distinct up to associativity. So \$1+(2+3)\$ and \$(1+2)+3\$ are not counted as separate ways to make 6, but \$2+4\$ and \$4+2\$ are counted as separate. Two sums...
An alphadrome is a word in which each letter in the first half of the word "reflects" its alphabetical "opposite" in the second half of the word. Write a program or function that returns truthy if the given word is an alphadrome and falsey otherwise. For example, BEEB is a palindrome. Its first letter B "reflects" its ...
Determine whether a given sequence could be a winning sequence for the game shut the box. Background There are a few variants to this game, so I'll clarify the rules here. Play begins with 12 tiles (1 through 12) face up. Each turn the player rolls two six sided dice, and must then flip over one or more tile(s) which s...
Ruby has a strange operator, .., called flip-flop (not to be confused with the range operator, which looks the same). Used in a loop, flip-flop takes two conditions as operands and will return false until the first operand is truthy, then return true until the second operand is truthy, whereupon it returns true one mor...
Given a message, append checksum digits using prime numbers as weights. A checksum digit is used as an error-detection method. Take, for instance, the error-detection method of the EAN-13 code: The checksum digit is generated by: Multiplying each digit in the message alternating by 1 and 3 (the weights) Summing it up...
Let \$p(x)\$ be a polynomial. We say \$a\$ is a root of multiplicity \$k\$ of \$p(x)\$, if there is another polynomial \$s(x)\$ such that \$p(x)=s(x)(x-a)^k\$ and \$s(a)\ne0\$. For example, the polynomial \$p(x)=x^3+2x^2-7x+4=(x+4)(x-1)^2\$ has \$1\$ and \$-4\$ as roots. \$1\$ is a root of multiplicity \$2\$. \$-4\$ is...
MD5 checksums are relatively easy to crack. For this challenge you will create two separate programs, the first one writing Hello, World! and the second one writing Goodbye Cruel World! but with the source code having identical MD5 hashes. The source code of both programs must not be identical. The programs can use th...
From the infinite triangular array of positive integers, suppose we select every 2nd numbers on every 2nd row as shown below: $$ \underline{1} \\ \;2\; \quad \;3\; \\ \;\underline{4}\; \quad \;5\; \quad \;\underline{6}\; \\ \;7\; \quad \;8\; \quad \;9\; \quad 10 \\ \underline{11} \quad 12 \quad \underline{13} \quad 14 ...
Given an integer \$ n \ge 1 \$, your task is to output an array \$ a \$ consisting of \$ n^2 + 1 \$ integers, such that all possible pairs of integers \$ (x, y) \$ satisfying \$ 1 \le x, y \le n \$ exist as a contiguous subarray in \$ a \$, exactly once. For example, if \$ n = 2 \$, a valid output would be \$ (1, 1, 2,...
This challenge requires a small amount of knowledge about chess. A description of the details required can be found at the bottom if you are not familiar with chess or want a refresher. For a certain board configuration consisting only of queens we can say that each queens threat number is the number of other queens i...
From the infinite triangular array of positive integers, suppose we repeatedly select all numbers at Euclidean distance of \$\sqrt{3}\$, starting from 1: $$ \underline{1} \\ \;2\; \quad \;3\; \\ \;4\; \quad \;\underline{5}\; \quad \;6\; \\ \;\underline{7}\; \quad \;8\; \quad \;9\; \quad \underline{10} \\ 11 \quad 12 \q...
Write 2 programs in the same language which count the number of shared subsequences of consecutive elements from 2 given sequences. For example, given "test" and "enter", there are 5 shared subsequences of consecutive elements: t t e e te One possible algorithm consists in counting, for each subsequence of consecutive...
Given a matrix like this: 1 1 3 -2 3 -4 1 -1 1 1 1 0 0 -1 0 0 By taking a 2×2 "sliding sum", where the sum of every 2×2 region of the matrix is one element of the resulting matrix, we get: 1 1 1 1 -1 1 1 1 1 We can do this for sliding windows of any size. For example, a 1×3 sliding sum of the same input ...
Introduction: Some times using a 24-hour clock are formatted in a nice pattern. For these patterns, we'll have four different categories: All the same (pattern A:AA or AA:AA): 0:00 1:11 2:22 3:33 4:44 5:55 11:11 22:22 Increasing (pattern B:CD or AB:CD, where D==C+1==B+2==A+3): 0:12 1:23 2:34 3:45 4:56 12:34...
In this challenge we are going to consider lists of integers such that for every member \$x\$ at index \$i\$ then the indexes \$i+x\$ and \$i-x\$ have the value \$x+1\$ or are out of bounds for the list. We will call these trampoline lists. If we play around with these for a while we can notice that if we start a list...
Box blur is a simple operation for blurring images. To apply box blur, simply replace each pixel with the average of its and the surrounding 8 pixels' values. Consider, for example, the following example, in which each "pixel" has a one-digit value: \begin{array} {|r|r|}\hline 1 & 1 & 1 \\ \hline 1 & 7 & 1 \\ \hline 1 ...
Let \$n\$ be some positive integer. We say that \$n\$ is of even kind if the prime factorisation of \$n\$ (counting duplicates) has an even number of integers. For example, \$6 = 2 \times 3\$ is of even kind. Likewise, we say \$n\$ is of odd kind of the prime factorisation of \$n\$ has an odd number of integers, such ...
I recently solved a coding challenge in one of the challenge papers that my IT teacher gave to us. It was a seemingly simple, but fun challenge, so I thought it will make fun golfing. The task Given an input of a 2x2 matrix that contains 4 strictly positive integers (i.e. non-negative and non-zero), like this: $$\begin...
Some chess variants use interesting non-standard pieces. In order to concisely describe new pieces or to describe pieces without requiring everyone to memorize a bunch of non-standard names some new notation can be invented. In this challenge we are going to look at Parlett's movement notation and convert it to nice at...