instruction
stringlengths
34
53.1k
The Rockstar programming language has "poetic number literals", allowing you to assign nonnegative, finite (at least one Rockstar interpreter supports infinity) numbers to variables without typing a single digit: just type words with length equal to each digit, modulo 10. For example, This is a challenge sets the vari...
Goal: Create the smallest possible code to open a separate window, in which there are 100 circles of random sizes and colors. Rules: All circles must be visible to the unassisted, naked eye, so in other words more than 2 pixels across, the background must be black, at least 5 different colors must be recognizable, and ...
What is the most frequent word? Given a sentence, your program must make its way through it, counting the frequencies of each word, then output the most used word. Because a sentence has no fixed length, and so can get very long, your code must be as short as possible. Rules/Requirements Each submission should be eith...
The Challenge Implement amb and its sister statement require in whatever language you wish. See http://community.schemewiki.org/?amb for an example implementation in Scheme. You can rename them to a and r. amb statements select a value passed to it arbitrarily, and require statements written after amb contain condition...
Lower level languages, such as C and C++ actually have no concept of multidimensional arrays. (Other than vectors and dynamic arrays) When you create a multidimensional array with int foo[5][10]; This is actually just syntactic sugar. What C really does is create a single contiguous array of 5 * 10 elements. This foo[...
The Laver tables provide examples of programs which have not been shown to terminate in the standard axiomatic system of mathematics ZFC but which do terminate when one assumes very large cardinal axioms. Introduction The classical Laver tables An are the unique finite algebras with underlying set {1,...,2n} and an ope...
Brain-Flak (a cross between Brainf**k and Flak-Overstow) is a stack-based esoteric language. Since this challenge was posted, the language has evolved and updated, but this first revision of the language is known as "brain-flak classic". You must write a program or function that takes a string of Brain-Flak classic cod...
Inspired by this question over at Mathematics. The Problem Let n be a natural number ≥ 2. Take the biggest divisor of n – which is different from n itself – and subtract it from n. Repeat until you get 1. The Question How many steps does it take to reach 1 for a given number n ≥ 2. Detailed Example Let n = 30. The...
Given an integer N >= 2, produce an image showing a Sierpiński knot of degree N. For example, here are knots of degree 2, 3, 4 and 5: Click on the images to view full size (the higher the degree the larger the image). Specification A Sierpiński knot of degree N is drawn using the vertices of a Sierpiński triangle ...
My electric garage door works like this: There is just one push button to control the door If the door is fully closed and I hit the button, the door starts to open. It takes 10 seconds to open fully If the door is fully open and I hit the button, the door starts to close. It takes 10 seconds to close fully If the d...
A Latin square is a square that has no repeated symbols in either the X or Y columns. For example: ABCD DABC CDAB BCDA is one such square. Notice how every column and row contains a permutation of the same 4 letters. However, our Latin square has a problem: If I were to rotate the second row (DABC) 1 to the lef...
This is somewhat similar to The centers of a triangle, but with a different point. The Fermat Point is the point P in triangle ABC such that the value of AP + BP + CP is minimized. There are two cases: If there is an angle greater than 120 degrees, that vertex is the fermat point. Otherwise, draw equilateral triangles ...
Introduction Nodes in tree structures (e.g. headings in a long document, law paragraphs, etc.) are often created by assigning a specific header level (h1, h2, etc.) to each item, but outputted with additional node numbers for each level (1., 1.1., etc.), e.g.: 1. Intro (h1) 1.1. About this (h2) 1.2. Target audience (h2...
Introduction In this challenge, we will be dealing with a certain infinite undirected graph, which I call the high divisor graph. Its nodes are the integers starting from 2. There is an edge between two nodes a < b if a divides b and a2 ≥ b. The subgraph formed by the range from 2 to 18 looks like this: 16-8 12 18 \|...
What general tips are these for golfing in Lisp (any dialect)? Please post one tip per answer, and only answers that are specific to a dialect of Lisp (e.g. "remove comments" is not an answer). Please post the dialect of Lisp your tip applies to with your tip.
I want to write 7 assembly instructions (28 bytes) that runs a logical equivalent of this C snippet: c = a + b + 6; while (c > 5) { c = c - a; b = b + 1; } However, there are restrictions to the allowed instructions: add, addi, sub, subi, slt, slti, bne a, b, and c are located in registers $t0, $t1, and $s0 respe...
Background Actually (the successor to Seriously) is a stack-based imperative golfing language I created in November of 2015. Like many other golfing languages, it has one-byte commands that perform different functions based on the contents of the stack. One of its specialties is mathematics - it has a wide variety of m...
Based on a recent question in StackOverflow Write a program/function that takes in one ARRAY/list and returns the number of pair-values which sums up to a given TOTAL. Explaining TOTAL=4, ARRAY=[1,3,7,1,-3] => RESULT=2 The result was 2 because 1 + 3 and 7 + -3 are valid pairs which sums up to TOTAL=4. When one pair i...
Given the coordinates of the upper left corners of two squares and their side lengths, determine whether the squares overlap. A square includes the top and left lines, but not the bottom and right lines. That is, a point (a,b) is inside a square with side length k that starts at (x,y) if and only if x <= a < x+k and y ...
Write a program or function that finds the number of zeroes at the end of n! in base 10, where n is an input number (in any desired format). It can be assumed that n is a positive integer, meaning that n! is also an integer. There are no zeroes after a decimal point in n!. Also, it can be assumed that your programming ...
Create a bootloader that executes given Brainfuck program. This is code-golf, so the program with least bytes wins. Being a bootloader, the size of the program is counted in non-zero bytes in the compiled code. Brainfuck 30000 8-bit overflowing cells. Pointer wraps over. Some notes about operations: Input must be read...
Koronkorko is the Finnish word for compound interest. We don't want compound interest in our strings, so let's find the shortest possible regular expression to exclude it. Given a string consisting only of the uppercase alphabetic characters A-Z, determine the shortest possible regular expression that matches the strin...
Introduction Turns out, aliens love memes just as much as we do. Every alien race we've encountered so far has their own version of 2spooky4me (see the following question) and equivalent, though, with some variation. The inhabitants of planet CUTE1f can't handle a lot of spook, so their preferred spook is 1spooky2me, w...
Columnar Transposition Cipher While I have plenty of programs I have written for more advanced ciphers, I just realised I don't actually have one for one of the simplest: Columnar Transposition. The cipher, in case you don't know, works as follows: First, you take the key, and write it as numbers. The numbers are made...
Fix my Basic Orthography While I am excellent at following the English capitalisation rules when writing, when I am typing I have a habit a capitalising almost everything (as you will see from the titles of my challenges). I need a program to fix that, but because I use so many capitals, and capitals are big letters, y...
You can decompose a number greater than 0 as a unique sum of positive Fibonacci numbers. In this question we do this by repeatedly subtracting the largest possible positive Fibonacci number. E.g.: 1 = 1 2 = 2 3 = 3 4 = 3 + 1 12 = 8 + 3 + 1 13 = 13 100 = 89 + 8 + 3 Now, I call a Fibonacci product the same lists as abov...
If elected president, Donald Trump plans to implement a system of four income tax brackets (full details can be found on his website here). Your job is to take two inputs, annual income and filing status (single, married, or head of household), and output the income tax that must be paid. Income Tax Brackets (We are o...
Inspired by this site, this question could potentially be a doozie. People on StackOverflow often overuse jQuery as an answer. Therefore, we need a way to recognize programmatically if a code snippet uses jQuery. Given a string (which may or may not contain new lines,) of valid Javascript, determine if jQuery is used....
Your job is to write a program that rewrites and makes itself longer on each run of the program. Challenge The program will print Hello, World!\n (\n denotes a newline). Then, it will modify its own file so that the new program length is exactly 2x the length at runtime. This modified file when run, will print Hello, W...
Adam7 is an interlacing algorithm for raster images, such as PNG. It is called the "Adam7" algorithm because it was invented by Adam M. Costello, and it is generated by following a certain pattern 7 times. One of the cool things about the Adam7 algorithm that makes it really fun for code golf, is that the pattern can b...
There's been challenges for the shortest cat program, but as far as I know, there hasn't been any for the longest one. A cat program is a program that copies its input to its output. Here's an example: Input: Hello Output: Hello Input: cat Output: cat So, the rules are simple: The program has to copy its input to it...
This challenge is inspired by a picture that often roams on Facebook that looks like this. Except our base square will look more like this: ┌─┬───┬─┐ ├─┼─┬─┼─┤ ├─┼─┴─┼─┤ ├─┼─┬─┼─┤ └─┴─┴─┴─┘ The square is made out of n x m 1x1 square, you have to count how many sub-squares (1x1, 2x2, 3x3, 4x4, 5x5, etc.) can fit within...
I'm trying to read 4 ints in C in a golfing challenge and I'm bothered by the length of the code that I need to solve it: scanf("%d%d%d%d",&w,&x,&y,&z) that's 29 chars, which is huge considering that my total code size is 101 chars. I can rid of the first int since I don't really need it, so I get this code: scanf("%*...
Does anybody have tips for golfing in Erlang? I'm looking for specific things that can be applied to Erlang, not any language. I know we already have tips for Elixir, but that is different. As usual, please post separate tips in separate answers.
Introduction Let's observe the following square, consisting only of the digits 0 - 9: 1034 4167 8414 3542 The outer shell of this square is: 1034 4 7 8 4 3542 It contains zeros, so we need to peel off the outer shell, leaving: 16 41 The outer shell of this square is: 16 41 It does not contain any zeros and is the...
Give credit to whom credit is due. Objective Given an integer N > 0, out the smallest integers A, B, and C so that: All of A, B, and C are strictly greater than N; 2 divides A; 3 divides B; and 4 divides C. This is a code-golf, so the shortest answer in bytes wins. Test cases N => A, B, C 1 => 2, 3, 4 4 => 6, 6, 8 43...
Given two non empty lists of integers, your submission should calculate and return the discrete convolution of the two. Interestingly, if you consider the list elements as coefficients of polynomials, the convolution of the two lists represents the coefficients of the product of the two polynomials. Definition Given th...
A pangram is a sentence or excerpt which contains all twenty-six letters of the alphabet, as is demonstrated in this code golf challenge. However, a pangrammatic window is a pangram in the form of some segment of text, which may end or begin halfway through a word, found somewhere within a larger work. These naturally ...
This is a quine variation. Introduction We all write short code, because some obscure reasons, but whatever we do, the'll take up at least 144 pixels/byte (with a 12px font). But what would happen, if we would encode our code in images? This is your task today. Challenge You task is to read in your own source code (non...
I have a list, l and a function f. f is not strictly increasing or decreasing. How can I find the item in the list whose f(item) is the smallest? For example, let's say the list is: l = [1, 2, 3, 4] and list(f(x)for x in l) is: [2, 9, 0, 3] f(3) is smaller than f of any of the other ones, so it should print "3". What...
This is my friend Thomas. He is half tree, half emoticon. | | | :D | | | He is lonely. Let's make him some friends! Given a text-based emoticon as input (e.g. ಠ_ಠ, :P, >_>, not , , or ), output the corresponding treemote. A treemote's length is how many characters it is lon (basically most builtin length functi...
My local ACM chapter gives out door prizes to people who come to the meetings. You get an increased chance of winning if you solve the programming puzzle, however (but I always solve that puzzle). Thus, some people have 1 entry, while others have 2. But wait! The way the raffle program works is not by adding in another...
Given three dice rolls (integer values from 1-6) in sorted order (so as to be indistinguishable), convert them to the sum of two fair dice with an identical distribution. The answer for three to one is summing them all, modulo 6. The end-result is a perfectly flat distribution, where each of the six numbers are equall...
In this challenge, your task is to create a program which takes in a nested array and returns a single-dimensional flattened array. For Example [10,20,[30,[40]],50] should output [10,20,30,40,50]. Input The input will be a nested array (eg. [10,20,[[[10]]]]). It will contain only Integers (both negative and positive),...
You teach a class of students with interesting preferences for how their chairs are arranged. There are 3 very specific requirements they have for how the chairs are arranged: They most be arranged in a rectangle, even if it means some chairs go empty. There must be as few empty chairs as possible. They must be as "...
Introduction The arithmetic mean is defined as being equal to the sum of the numerical values of each and every observation divided by the total number of observations. Symbolically, if we have a data set containing the values a1,…,an. The arithmetic mean A is defined by the formula Objective The challenge here is, gi...
TetraVex is a tile-based edge-matching game that was originally coded by Scott Ferguson for the Microsoft Entertainment Pack 3 back in 1990. The game consists of a grid upon which square tiles are placed. The tiles have numbers or letters on each edge, and the goal is to place all tiles in the grid, with each pair of e...
Steiner Chains are a set of N circles where each circle is tangent to 2 other non-intersecting circles as well as the the previous and next circles of the chain, as seen in the below images: In this challenge, you will write a program/function that draws Steiner chains recursively, that is, circles of a given chain ...
Write some code that acts as a cat program. That is, to input a string and output it as is. But the normal reversion of your code must output the normal reversion of the input string. And the visual reversion of your code must output the visual reversion of the input string. The normal reversion is the reversed charact...
Based on my SO question, but more specifically: Find a RegEx such that, given a text where paragraphs end with an empty line (or $ at the very end), match the up to twenty last characters of a paragraph excluding the \r or $ but no more than three complete "words" including the "separators" in between and the punctuati...
A laser shoots a straight beam in one of the four orthogonal directions, indicated by <>^v. Determine whether it will hit the target O on a rectangular grid. Each of these will hit (True): ..... ...O. ..... ...^. ..... >O. ... v.... O.... ........... ........... O.........< ........... These will miss (False): ......
Let's play code golf... by playing golf. Input Your input will be a string consisting of #'s, an o, an @, and .'s. For example: ......@.. .....##.. ......... ......o.. . - playable golf course (all shots must end on one of these) # - a barrier (shots cannot go through this) o - the starting position of your golf ball ...
Challenge Joe the rapper is struggling with rhyming words in his lyrics. He needs your help. For this situation, we will use rhymes where the last syllable in a word is the same as the other word (spelled the same). When Joe inputs a word, the program will read a list of words from a file and output those that rhyme wi...
The challenge is to assign people to tasks randomly~. From stdin you get 2 lines. Line one is a comma-separated list of names. Line 2 is a comma-separated list of jobs. The output required is one line per task person combo. The line should be formatted as Name:task. If there are not enough people for jobs or vice verse...
Your task is to write a RegEx that matches everything inside strings. A string is defined as everything surrounded by (but not including) two unescaped ". A " can be escaped by \, which can also be escaped again. Testcases string: ab\c"defg\\\"hi"jkl"mn\\\\"opqrst"" matches: ^^^^^^^^^^ ^^^^^^ ^ (the em...
The challenge involve simply toggling a string within another string. Explanation If the toggle string is a substring of the main string, remove all instances of the toggle string from the main string; otherwise, append the toggle string at the end of the main string. Rules All string are composed of printable ASCII...
Find the shortest function/algorithm to translate these numbers to the ones after the dash: 0 - 0 1 - 10 2 - 20 3 - 30 4 - 40 5 - 50 6 - 60 7 - 70 8 - 80 9 - 90 10 - 100 11 - 115 12 - 130 13 - 150 14 - 175 15 - 200 16 - 230 17 - 260 18 - 300 19 - 350 20 - 400 Every integer higher than 20 is calculated by subtracting 1...
History My company sends out a weekly newsletter to everyone within the company. Included in these newsletters is a riddle, along with a shoutout to whomever in the company was the first to email/provide a solution to last week's riddle. Most of these riddles are quite trivial, and honestly pretty dull for a tech compa...
The title is pretty self-explanatory, isn't it? Your task is to output the alphabet (the string "abcdefghijklmnopqrstuvwxyz") to STDOUT, using each and every letter of the alphabet in your program once and only once. Oh, and for a bit of extra fun? The letters "g", "o", "l" and "f" must be in order (just for the code t...
In chemistry class, we were learning about titrations, and attempting one as a lab. We were using phenolphthalein as the indicator for the titration, so on top of grading the lab normally, my teacher held a little contest to see who had the lightest shade of pink, and thus the most accurate transition. Your task is to ...
Credit goes where credit is due Given two digits, x, and y, calculate the shortest number of horizontal or vertical jumps to get from x to y on a standard numpad, e.g. 789 456 123 00 You can safely assume that all inputs will be 0-9, and you do not have to handle invalid inputs. The input may be the same number twice...
Given two words and a list as input, your program must (in as few characters as possible, of course) find the shortest way to "chain" the first word to the last using the ones in the list. Two words are "chained" if their first and last letters are the same, e.g. "Food" and "Door". Your program will take input as a str...
In this challenge, your task is to write a program that takes in an image and returns the most dominant color in it. Dominant color here means the color with which most of the image is covered (see the test cases for a better understanding). Input An image's path. You'll have to load that image in your program. You ca...
This question will be a twist on finding the nth prime number. Challenge You must write a program that will take one input n, and output the nth prime number whose decimal representation contains the decimal representation of n as a subtring. Confused? Here are some examples. n=1 Primes: 2, 3, 5, 7, 11 ...
Create a program that outputs "Hi, Hello!" in k bytes. By altering n bytes, the code should output all odd numbers in the range 5 <= x <= 25. Changing another m bytes should result in a code that prints the following frame in ASCII-art: +-+ | | +-+ Change another o bytes, and print Hello, bye!. m, n and o are calculat...
In Keep Talking and Nobody Explodes, players are tasked with defusing bombs based on information from their "experts" (other people with a manual). Each bomb is made up of modules, one of which can be passwords, where the expert is given this list of possible passwords, all five letters long: about after again b...
A divisor of a number n is any number that evenly divides n, including 1 and n itself. The number of divisors d(n) is how many divisors a number has. Here's d(n) for the first couple n: n divisors d(n) 1 1 1 2 1, 2 2 3 1, 3 2 4 1, 2, 4 3 5 1, 5 2 6 1, 2, 3, 6 ...
related and inspired by -- Finding sum-free partitions A set A is defined here as being distinctly sum-free if 1) it consists of at least three elements, |A| ≥ 3, and 2) its distinct self-sum A + A = { x + y | x, y in A} (with x,y distinct, i.e., x≠y) has no elements in common with A. (Obsolete - do not use this goi...
Introduction I stumbled across this (useless) pattern the other day while I was watching TV. I named it "the 9 pattern" because the first number to use it was 9. The gist of it is, you enter a number (let's say x), and then you get back: x x + (x / 3) [let's call this y] two-thirds of y [let's call this z] z + 1 ...
As a kid, I used to play the card game "golf" a lot. Your challenge, should you choose to accept it, is to calculate the score of a golf hand. Since there are over 9000 variations on this card game1, we will go with the rules I remember playing. Rules (of the game) You end a round with 6 cards, and you want as few poi...
Inspired by the job-interview with Joel Grus, the goal of this challenge is to write a tensorflow (or other deep/machine learning) program that learns Fizzbuzz and correctly prints out the answers to the positive integers less than 1000. You can assume there are files named train.csv and test.csv and each contain a so...
The formula Take for instance the number 300 The prime factors of 300 are [2, 3, 5] (unique numbers that are factors of 300 and prime) Squaring each of those numbers will give you [4, 9, 25] Summing that list will give you 4 + 9 + 25 = 38 Finally subtract that sum (38) from your original number 300-38 = 262 (this is ...
A function is said to have a cycle of length n if there exists an x in its domain such that fn(x) = x and fm(x) ≠ x for 0 < m < n, where the superscript n denotes n-fold application of f. Note that a cycle of length 1 is a fixed point f(x) = x. Your task is to implement a bijective function from the integers to themsel...
Back in the day, all the 1337 kids used text faders in chatrooms. I don't know about you guys, but I want to feel cool like they did. The only problem is that their old scripts and applications were heavily coupled to the software they were made for, so I can't just make use of this amazing functionality wherever I wan...
In this challenge, you need to find a specific pixel within an photograph (taken with a real camera). You are passed an (R, G, B) tuple and an image, and you need to return a point (x,y) within the image that matches the RGB color given. The image may have multiple points that match the color; you only need to find 1....
Uptime is a very important metric, as we all know, so we'd like to measure the uptime since our service was first launched. The SLA specifies an uptime of a certain number of nines, such as 3 nines for at least 99.9% uptime, or 1 nine for at least 90% uptime, and you're wondering if you've actually met the SLA or not. ...
To dynamically include a JavaScript file in a web page, you'd normally insert a <script> tag pointing to your script. For example: var js_file= document.createElement("script"); js_file.src='http://example.com/js.js'; document.body.appendChild(js_file); Write JavaScript code will load an external JavaScript file in th...
Given an integer N >= 1, output the mean number of bits in an integer from 0 to N - 1 Specification The output can be calculated as the sum of the number of bits in the binary representation of each integer from 0 to N-1, divided by N. The binary representation of an integer has no leading zeroes in this context, with...
This question is probably harder than all of those "generate a sequence of numbers" tasks, because this requires TWO sequences working in unison. Really looking forward to the answers! In his book "Gödel, Escher, Bach: An Eternal Golden Braid", Douglas Hofstadter has a quite few sequences of numbers inside, all of them...
A paragraph of text has numbers and alphabetic letters mixed. Your task is to separate the numbers to the left side and the alphabetic letters to the right side in the same order of each line. Rules: Numbers are plain integers; so no decimal point, and no negative/positive signs. Numbers may or may not be contiguous,...
I am shamelessly posting a request for something I would actually find useful. The task is to take an arbitrary ascii box drawing like this | +----+----+ | state A +---+ +---------+ | | +----v----+ | state B | +---------+ ... and turn it into something more beautiful us...
Given a string containing only 0's 1's, 2's and brackets, output the grammar tree of the string. A 2 requires 2 arguments - one to the left and one to the right A 1 requires a single argument - to either the left or right A 0 doesn't require any arguments and is the base case A pair of brackets counts as one argument a...
Given a mapping from the integers from 1 to N to the integers from 1 to N, determine if the mapping is surjective, injective, bijective, or nothing. You may choose any character/digit for the four outputs. Specs Input format: n, arrays of pairs (n is the highest number in the domain and range) For example, if the first...
Write one/two program(s)/function(s): The first one should return a truthy value if given your Stack Exchange username. ~~Optional~~ An obfuscated one (as explained below) that does the same thing. Rules for number 2: May be no more than ten times the byte-count of number 1 or 100 bytes, whichever is higher. Must ...
Air balloons need a gas that is lighter than air. However, hydrogen is flammable, while helium is not sustainable, so we need a replacement! You must write code that determines whether any given gas is lighter than air. Input: a molecular chemical formula of a gas (ASCII) Output: true if the gas is lighter than air; f...
Inspired by this question which was further inspired by this one, write a program which takes two integers and adds them in a unique way, by performing an OR operation on the segments used to display them in a 7-segment display. For reference, the digits are represented in the following way: _ _ _ _ ...
Identicons are visual depictions of hash values, often made from symmetrical arrangements of geometric shapes. Your default Stack Exchange avatar is an identicon. This challenge is about creating "wordenticons", simple text-based versions of identicons that apply to strings of lowercase letters, i.e. words. Challenge W...
This is not a duplicate of this question. This is asking for the nth number that can be represented as the sum of two cubes in two different ways, while that is asking for the n-th number that can be expressed as the sum of two cubes in n ways. Introduction I was just watching The man who knew Infinity, and I thought i...
A number square containing the values 1, 2, 3, 4 looks like this: 12 34 To work out what a number square is, you first make four numbers by reading across the rows and across the columns; for the example above you would get 12, 34, 13 and 24, then you add them all up (12+34+13+24), giving you the value of the square. ...
Your challenge is to write a program (full program, not a function), that will take an integer and output all prime numbers up to (including) the given integer. Output is any readable list containing all integer primes (array, string, 1 prime per line, whatever you want) and must run to stdout or equivalent. Simple? He...
Here is the challenge as proposed by @trichoplax thanks to him for consolidating my post and standarizing it to PPCG common-rules. A galaxy is a group of numbers where each one is mapped to another via a precise function f either a symbolic one or mathematical, a structure of numbers sharing some common points with t...
Inspired by this question and refined by Luis Mendo. Challenge Given a 2D matrix of integers, each row has a maximum value. One or more elements of each row will be equal to the maximum value of their respective row. Your goal is to determine which column(s) contain the most entries which are equal to their respective ...
Find the longest run of true in a list of booleans. Return the same list, with all other trues falsified. Input, output A list; any usual format (e.g., a delimited list as a string). Details True and false can be anything your language typically uses for those values, or the integers 1 and 0. If you use single characte...
Given an input n, output the value of the Fransén-Robinson constant with n digits after the decimal place, with rounding. Rules You may assume that all inputs are integers between 1 and 60. You may not store any related values - the constant must be calculated, not recalled. Rounding must be done with the following cr...
Introduction The sign of a number is either a +, or a - for every non-zero integer. Zero itself is signless (+0 is the same as -0). In the following sequence, we are going to alternate between the positive sign, the zero and the negative sign. The sequence starts with 1, so we write 1 with a positive sign, with zero (t...
Given a non empty finite sequence of integers, return an arithmetic subsequence of maximal length. If there are multiple of the same maximal length, any of them can be returned. Definitions: An arithmetic sequence is a sequence \$a(1),a(2),a(3),a(4),...\$ such that there is a constant \$c\$ such that \$a(m+1)-a(m) = c\...
Credits to @Agawa001 for coming up with this question. Explanation My new "keybore" only has 2 buttons, namely + and -. The number in the memory starts at 0. Each consecutive press of + or - will increment/decrement the memory for exactly how many times it has been pressed consecutively. Therefore, if you press + 4 tim...
RFC 2550 is a satirical proposal (published on April 1, 1999) for a space-efficient ASCII representation of timestamps that can support any date (even those prior to the beginning of the universe and those past the predicted end of the universe). The algorithm for computing a RFC 2550-compliant timestamp is as follows ...
Background Visualizing λ-calculus terms Famous lambda-juggler (and code golfer) John Tromp devised an interesting visualization of terms in the λ-calculus. In his words: abstractions (lambdas) are represented by horizontal lines, variables by vertical lines emanating down from their binding lambda, and applications by...
Consider binary block diagonal matrices which have square blocks of 1s on the main diagonal, and are 0 everywhere else. Let's call such matrices "valid" matrices. For example, here are some valid 4x4 matrices: 1 0 0 0 1 1 0 0 1 0 0 0 1 0 0 0 1 1 0 0 1 1 1 1 0 1 0 0 1 1 0 0 0 1 1 0 0 1 1 1...