instruction
stringlengths
34
53.1k
Given an positive even integer \$ n \$, output the set of "ways to pair up" the set \$ [1, n] \$. For example, with \$ n = 4 \$, we can pair up the set \$ \{1, 2, 3, 4\} \$ in these ways: \$ \{\{1, 2\}, \{3, 4\}\} \$ \$ \{\{1, 3\}, \{2, 4\}\} \$ \$ \{\{1, 4\}, \{2, 3\}\} \$ This can more formally be described as the ...
Introduction Many old chess books use descriptive notation to notate squares on a chessboard, naming the file (column) of the square based on the starting piece positions of White or Black, depending on whose move it is. The ranks (rows) are numbered 1 through 8, with 1 being closest to the player. For example, from Wh...
In some languages, strings are started and ended with a quote mark ('). And quote itself is escaped by writing it twice sequentially. For example, empty string is written as '', and I'm is written as 'I''m'. This question is about find out all non-overlapping strings from left to right in such format from the given inp...
Your task is to output all possible ways to end a game with a tie (all rows, columns, and diagonals are completely filled and do not have 3 X's or 3 O's, and there are exactly 5 X's and 4 O's in total) in Tic-Tac-Toe (assuming X goes first): OXO XXO XOX OXX XOX OOX XOX XOO XOX XXO OXO OXX XOX XOX OXX XXO O...
Related We start with the string a, and forever append to the string a comma followed by the string quote-escaped, where quote-escaping means doubling all quotes in a string, and then surrounding it with an additional pair of quotes. In the first few steps we will get: a a,'a' a,'a','a,''a''' a,'a','a,''a''','a,''a'',...
Story: The π was recently computed with accuracy to 100 trillions digits, but it is useless to us. We can't do accurate enough math, because rational numbers are too boring and so we don't know that much digits of them! Challenge: Your task will be to write program or function which takes string of digits including dec...
Given a multi-line string as input containing characters "|", "_" and " " (space), count the number of cells it contains. A cell is the following structure of 3 characters by 2 lines: _ |_| That is, an underscore on one line (the characters to its right and left don’t matter), and "|_|" right below it. Two cells can ...
In this challenge you will receive as input a list of binary lists. The list represents a game board with each element representing a location on the board. The list at each location represents the tiles on the board, with a 0 being a white tile (□) and a 1 being a black tile (■). Each place can have any number of t...
Special String We call a binary string \$S\$ of length \$N\$ special if : substring \$S[0:i+1]\$ is lexicographically strictly smaller than substring \$S[i+1:N]\$ for \$ 0\leq i\leq N-2\$, Note: \$ S[a:b] \$ is substring \$S[a]S[a+1]...S[b-1]\$ Given a binary string \$T\$ of length \$N\$ we are interested in the fi...
Every now and again, I'll encounter a large string of alphabetical text encoded as numbers from 1-26. Before I knew that I could just google a translator online, I had to personally, painstakingly copy and paste the entirety of the encoded text into a text document and translate it myself. Thankfully, I did know about ...
Introduction Super Mario 64 has a heavily overcomplicated RNG, ably explained here by Pannenkoek. I thought it might be interesting to implement it. Challenge Implement the RNG function, except for the two special cases. (Not part of the below description; everything below is what you should implement.) Input and outp...
Given a string \$ x \$, we say another string \$ y \$ is half of it, if both of the following properties are true: \$ y \$ is a (not necessarily continuous) subsequence of \$ x \$ - there exists a strictly increasing sequence \$ a_i \$ such that \$ y_i = x_{a_i} \$ Each character appears in \$ x \$ exactly twice as ma...
Given a ragged list, we can define an element's depth as the number of arrays above it, or the amount that it is nested. For example, with the list [[1, 2], [3, [4, 5]]] the depth of the 2 is 2, as it is nested within two lists: The base list, and the list [1, 2]. The depth of the 4 is 3 as it is nested within three li...
The exponential generating function (e.g.f.) of a sequence \$a_n\$ is defined as the formal power series \$f(x) = \sum_{n=0}^{\infty} \frac{a_n}{n!} x^n\$. When \$a_0 = 0\$, we can apply the exponential function \$\exp\$ on this formal power series: \$\begin{align} \exp(f(x)) &= \sum_{n=0}^{\infty} \frac{1}{n!} f(x)^n ...
Given a string, shuffle it so that it becomes a palindrome. For example, adadbcc can be arranged into dacbcad, or dcabacd, acdbdca and more. Any of these (or all) is acceptable, and duplicates are allowed if outputting all. Something like abc cannot be shuffled into a palindrome, and you can assume it won't be inputted...
Let’s take a positive integer such as 123. We define the shifted auto-sum of this integer as follows: 123 has 3 digits. We thus consider 3 copies of 123. We stack each copy on top of each other, shifted by 1 digit each time: 123 123 123 We pad each copy with 0s (excluding the last one) to get a standard column a...
Suppose you have an array with some known set of values (e.g. a string of \$0\$ and \$1\$) and you want to get all the locations of \$1\$s. Instead of storing a list of all the indices, if the \$1\$s come in "clumps" you can sometimes save space by storing starting and ending indices of "runs" of values -- i.e. substri...
I haven't. :P So I decided to define one: A tralindrome is a string which contains three equal-length sections X, Y, Z such that all characters in the string are included in at least one of the three sections, X starts at the first character, Y starts at or right after the last character of X, and Z starts at or right...
Inspired by this question. Challenge Let L be a list of n distinct elements. Let P be the set of all (unordered) pairs of positions in P. Let R be a result of applying a pair-swap operation on L by every pair in P in any order. Example: L = [1, 7, 8] P = {(1, 2), (0, 1), (0, 2)} L = [1, 7, 8] -> [1, 8, 7] -> [8, 1, 7] ...
Take as input two strings \$A\$ and \$B\$. Output a string \$C\$ that is \$A\$ but with two characters swapped such that the Levenshtein distance \$d(C,B)\$ is as small as possible. You must swap two characters and you cannot swap a character with itself, although you may swap two identical characters in different po...
Output the area \$A\$ of a triangle given its side lengths \$a, b, c\$ as inputs. This can be computed using Heron's formula: $$ A=\sqrt{s(s-a)(s-b)(s-c)}\textrm{, where } s=\frac{a+b+c}{2}.$$ This can be written in various ways, such as $$ A= \frac{1}{4}\sqrt{(a+b+c)(-a+b+c)(a-b+c)(a+b-c)}$$ $$ A= \frac{1}{4}\sqrt{(a^...
Generate \$T=\{T_1,...,T_x\}\$, the minimum number of \$k\$-length subsets of \$\{1,...,n\}\$ such that every \$v\$-length subset of \$\{1,...,n\}\$ is a subset of some set in \$T\$ Here, \$n > k > v\$ and \$v \ge 2\$ Any number can appear only once in 1 set Order of numbers is not important Answer with code & explan...
This was related to a program I am writing. Although the title is simple, the challenge is a lot more complicated. Your challenge You must write a program that takes an input, and your answer must match the sample outputs in this question. What the program should be is that you must output "HelloWorld" with the length ...
This is not the same as m-ss-ng-lette-s Challenge: Given a string with masked characters, generate all possible words, inclusive of non-meaningfull words. Rules: The sequence of the characters in the string does not change. The masked character (*) will be one of an English alphabets [a-z]. There are no line breaks, s...
Recently, I've found a rant from 2004 about Internet Explorer's color parsing. Turns out, MS made sure that just about anything will be parsed as a color somehow and I think it makes for a neat challenge. Well, how does IE parse colors? Let's give it an input with a length of... ...less than 4 chars: Replace chars no...
It is known that any natural number can be decomposed into the sum of three triangular numbers (assuming 0 is triangular), according to Fermat's Polygonal Number Theorem. Your task is to come up with an algorithm of decomposing number into 3 triangular numbers that has the best asymptotic complexity. As an input you ar...
Write a program or function that takes a character as input and outputs a character. Also, choose a list of 13 distinct ASCII printable characters (32-126). When a character from this list is passed into the program or function, it should output the character at the corresponding position in Hello, world!. This way, ru...
Background Here on CGCC, a commonly seen subgenre is radiation-hardening – writing a program that works even if one character is deleted. A similar problem is studied in the field of coding theory: finding an encoding that can be decoded even if one symbol is deleted from the encoded string. In this challenge, we're lo...
Given a string containing some parentheses and some other ASCII printable characters, like this: (abc((123))(k)) your task is to remove any sets of parentheses that are redundant. A set of parentheses is redundant if: It encloses another set of matching parentheses, like ab((123)), or It encloses the entire string, li...
We can model a rail network as a directed graph, where each node is a train station and each edge is a train connecting two train stations. We'll assume that each train travels between its corresponding stations at a regular schedule and takes a fixed amount of time Your code should take a list of trains, where each tr...
Your task is to write a program that performs case conversion from plain text, and other case formats, into one of the specified formats below. Inputs will be either plain lowercase text, or one of the detailed cases below. You must remove non-alphabetic characters except (space), _ (underscore) and - (hyphen), then ...
Inspired by this Your task today: given two strings, find the string with the lowest maximum Levenshtein distance to the input strings. For example, using Steffan and Seggan, the average string will be Steggan. It is distance 2 from Steffan (replace the gg with ff), and 1 from Seggan (add a t). That gives it a maximu...
Given two non-negative integers e.g. 27, 96 their multiplication expression would be 27 x 96 = 2592. If now each digits is replaced with a symbol, such that two digits are replaced with the same symbol if and only if they are equal we could get something like AB x CD = AECA or 0Q x 17 = 0Z10 or !> x @^ = !x@!. (follo...
Knight is the Language of the Month for August 2022, and I noticed that it didn't have a tips page, so here it is! I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Knight (e.g. "remove comments" is not an answer). Please post only one tip per answer.
During work on some project I needed to draw pixels on screen. I found some put-pixel function in JS, but code was quite big and clumsy - so I wonder, how small put-pixel function can be... Challenge Create the smallest put-pixel function. We count size of whole program: initialization code (if needed), function and co...
I could not think of a better title. This is a tips question. I'm asking for tips on golfing my code. I recently took part in a code golf competition in C. The competition ended and I lost. The problem is: Input a line with a number n. Then input n lines, each line contains only a set of cards in descending order, e. ...
Given two strings: a string s and an alphabet a, implement string projection in the shortest code possible. String projection returns a string o that contains the characters in s that are in a. The order of the characters in o must match the order of characters in s. So if s = "abcd" and a = "12da34", o = "ad", since o...
So the golf question was like this: You are given a number T and then a total of T number of 17-character strings. For each of the strings, output yes if it contains four consecutive identical characters or contains the substring DX, else output no. The following constraints are promised for each of the 17-character ...
If the agent is at the origin it always moves right when you choose it. The goal is to get one agent to 10. The cost is the sum of the square of the total number of moves (left or right) taken by each individual agent until the first agent gets to 10. You want to minimise the expected cost Once you have fixed a strateg...
Let us assume that we have number X. Let us assume that we have positive integer "components" (C) of this X number. We can add these components together like C1+C2+...+Cn = X. We have N as limit of number of components. We have B as limit of biggest component Distribution: if we have [8;8;5] then avg of components is ...
In most programming languages, arithmetic is written with infix notation -- i.e. the operator is put in between the operands -- e.g. 1+2. In contrast, with Polish notation (a.k.a prefix notation), the operator comes before the operands -- e.g. +1 2. As long as the number of operands for each operator is fixed, this mea...
Given a positive integer n, output all of its anti-divisors in any order. From OEIS A006272: Anti-divisors are the numbers that do not divide a number by the largest possible margin. E.g. 20 has anti-divisors 3, 8 and 13. An alternative name for anti-divisor is unbiased non-divisors. In other words, 1 < m < n is an a...
We don't have a challenge for conversion between Cartesian and polar coordinates, so ... The challenge Write two programs (or functions) in the same language: one that converts from polar to Cartesian coordinates, and the other from Cartesian to polar coodrinates. The score is the sum of the two program lengths in by...
Challenge Given a positive-length string \$S\$, a divisor of \$S\$ is another (not necessarily distinct) string for which there exists a number \$a\$ such that when we repeat the divisor \$a\$ times, we get the string \$S\$. For example, the string abcd is a divisor of the string abcdabcd with \$a=2\$. Your challenge i...
In chess, the queen piece can move arbitrarily far in each cardinal and intercardinal direction. What does this mean? Well, I'll show you with an ASCII drawing: \..|../ .\.|./. ..\|/.. ---Q--- ../|\.. ./.|.\. /..|..\ It means the queen (notated as Q) can move along these lines (notated as \, |, /, and -), and cannot r...
We once made a Hexagony template without actually knowing it. But after a bit of experience with Hexagony, it becomes apparent that it is not enough; sometimes the source code is too short for the given hexagon, and you get totally unexpected results. So I came up with an idea: a template that gives a hint when the cod...
I noticed that in Microsoft Word, single quotations are either ‘ or ’, but not in Notepad. Your task today is: given a string q, convert all the ' characters (only) to ‘ or ’, according to these rules, and then output it: If the character before the quote is a space, and after it comes a character, it becomes ‘ If the...
Something I found while looking through some old files. It seemed like a neat idea for a code golf challenge. The intro One of the most popular events at the annual Cyclist's Grand Competition for Charity (CGCC) is the rocket bike parcours. The rules are simple: Inspect the parcours and place a bet on wheather is it po...
In this game, you can look inside one box at a time chosen by you. When you do that, you can see how many coins there are in that box. The wizard has one last twist for you. At any point, you can choose to give up on this set of boxes and get him to start the whole process again (with a new random \$x\$). Of course, i...
Given a universe of \$v\$ elements, a Kirkman triple system is a set of \$(v-1)/2\$ classes each having \$v/3\$ blocks each having three elements, so that every pair of elements appears in exactly one block all classes are partitions of the universe. Kirkman's schoolgirl problem corresponds to the \$v=15\$ case. Fif...
If you place a knight on any square of a chessboard, what is the smallest amount of steps to reach every position? Rules It is an 8 by 8 board. The knight starts at an arbitrary position, taken as input. The knight moves 2 squares in one direction and 1 square in the other, for example, a knight on the square marked N...
Searching for rotatable numbers, like: 68089 If you consider numbers upside-down, 6 looks like 9, 8 looks like 8, 9 looks like 6 and 0 looks like 0. The others digits (1, 2, 3, 4, 5 and 7 ) look like nothing... I wonder how many number could be rotatable between 0 and 1000! The answer is definitively 11: 0, 8, 69, 8...
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.