instruction
stringlengths
34
53.1k
Do While False At work today one of my colleagues was describing the use-case for do while(false). The person he was talking to thought that this was silly and that simple if statements would be much better. We then proceeded to waste half of our day discussing the best manner to write something equivalent to: do { ...
Given two arbitrarily precise decimal numbers 0 ≤ x < y ≤ 1, compute the shortest (in digits) binary number b such that x ≤ b < y. Output the binary digits of b after the binary point as an array or a string of zeroes and ones. Note that the empty array means 0.0, by virtue of deleting trailing zeroes. This also makes ...
I define the method of combining a sequence to mean that every number in the sequence is concatenated as a string, then that result is made an integer. [1, 2, 3] -> 123 For every finite sequence of at least 3 consecutive integers, missing exactly one element in the sequence, and this missing element may not be the fir...
Challenge Implement binary search on a list of length 256 with no branches. Specification Input an integer X and a strictly increasing list of integers Output is the greatest element of the list that is less than or equal to X The output will always exist List will always have exactly 256 elements and be strictly incr...
Your objective is to write a program that takes an input, and, when chained together N times, performs "sequential multiplication". What is sequential multiplication, you may ask? It's a sequence with a seed a defined as thus: f(0) = a f(n+1) = f(n)*(f(n)-1) So, let a = 5. Thus, f(0) = 5, f(1) = f(0)*(f(0)-1) = 5*4 = ...
ROT-128 is a variant of ROT-13, where instead of cycling through the 26 letters, you cycle through the 256 possible bytes. Your task is to create a program that outputs the ROT-128 of its own source. The outputted program must also be a valid program and output the original program. Scoring This is code golf, so leas...
Introduction Let's observe the following string: ABCDEFGHIJKLMNOP If we swap the ends of the string, which are these: ABCDEFGHIJKLMNOP ^^ ^^ We get the following result: BACDEFGHIJKLMNPO After that, we delete the ends of the string, which in this case are B and O. The result is: ACDEFGHIJKLMNP If we repe...
You are provided a set of arbitary, unique, 2d, integer Cartesian coordinates: e.g. [(0,0), (0,1), (1,0)] Find the longest path possible from this set of coordinates, with the restriction that a coordinate can be "visited" only once. (And you don't "come back" to the coordinate you started at). Important: You cannot "p...
The first programming language I was exposed to was Sinclair BASIC. Like many BASIC dialects, it requires all source code lines to be numbered. As a result, use of the GO TO command was idiomatic and jumps execution to the given line number (no labels). Also there is a related GO SUB command which can be used as a rud...
Inspired by Project Euler #17, this is your challenge. Write a full program or function that takes a number as input, then print or return how many letters it would take to count up to and including that number in English (starting at one). You do not include spaces, commas, or hyphens, but you should include the word ...
Given a non-flat list of integers, output a list of lists containing the integers in each nesting level, starting with the least-nested level, with the values in their original order in the input list when read left-to-right. If two or more lists are at the same nesting level in the input list, they should be combined ...
Given an input of a list of positive integers with some replaced with 0, output the list with the missing numbers that were changed to 0 replaced. Characteristics of the input list: The list will always have a length of at least 2. Let us define the input list as a and the "original list" (that is, the list before num...
Write a program or function that takes in a non-negative integer N from stdin or as a function argument. It must print or return a string of a hollow ASCII-art square whose sides are each made with N copies of the number N. Specifically: If N is 0, no copies of N are used, so there should be no output (or only a single...
It's simple: Make a proper quine where if you remove any character, it's still a quine. The difference between this and a radiation hardened quine is that if your program is AB, in a radiation hardened quine A would output AB, but here, A would output A. Code golf, all standard rules, standard loopholes apply, no cheat...
Have you ever wondered, when doing shopping, how to pack your products into 2 bags you're carrying so that a total weight would be distributed among them as evenly as possible? Your task is to write a function, that takes a list of positive numbers (lets say integers for simplicity) as an input. It should return two li...
I like patterns in time. My favorite is when the time lines up. For example, all of these line up: 3:45 12:34 23:45 3:21 6:54 This is because each digit in the hour/minute is increasing/decreasing by one each time. Your task is to take the current time and check if it "lines up" in this pattern in a program. (You will...
A histogram is an array of integers that counts the number of times a symbol occurs. For example, for the string "aaabbbabbdebabbbebebdbaaabbabaaaaeebeaabaaba" a histogram is a: 18, b: 18, c: 0, d: 2, e: 6, or [18, 18, 0, 2, 6] in short. If we were to pick a random character out of this string, what would the chance be...
The Inspiration The Challenge I'm tired of seeing the same old-same old clock in my top-right-hand corner of my screen. It's time for a new clock. While the clock clock sated my lack of interesting clock for a little while, it simply will do no longer. Your job: make a better, more interesting clock. The Rules Make a c...
Introduction The middle-square method is used for the generation of pseudorandom numbers. However, this is not a good method in practice, since its period is usually very short and has some severe weaknesses. How does this work? Let's take an example: For the seed, we pick 123456: Seed 123456 The seed squared (see...
We've all heard of the Knight's Tour puzzle: find a route for a knight that passes through all the squares on a chess board. But let's be honest, it's a little bit boring. So, let's give the knight a bit of a challenge. Task Write a program that takes the knight through all the squares on an arbitrary-sized, arbitrary-...
I noticed that my car's odometer was at 101101 when I got to work today. Which is a cool number because it's binary (and a palindrome, but that's not important). Now, I want to know when the next time I'll have a binary odometer reading. I can't read the odometer while I'm driving, because that would be dangerous, so i...
This challenge is simple, given a decimal number, convert to binary, and calculate the sum of the sub-strings of the binary number, whose length is shorter than the original number. Here is an example: Input: 11 Binary: 11 -> 1011 Substrings: 101 = 5 011 = 3 10 = 2 01 = 1 11 = 3 1 = 1 0 = 0 1...
Given an input of a list of slices of a string, output the original string. Each slice will be given as a list of length 2, containing the start position of the slice (an integer ≥0) and the slice itself. If your language does not support arrays of arbitrary types, you may also take this as a struct or similar, or simp...
If you've ever learned about primes in math class, you've probably have had to, at one point, determine if a number is prime. You've probably messed up while you were still learning them, for example, mistaking 39 for a prime. Well, not to worry, as 39 is a semiprime, i.e., that it is the product of two primes. Similar...
Input description A string (for best results, all characters should be printable and be the same width). Output description A character star following the pattern: 0 0 0 1 1 1 222 0123210 222 1 1 1 0 0 0 where 0, 1 ... are subsequent characters of the string. The output does not necessarily have to be ...
Introduction You are probably familiar with the "puts on sunglasses" emoticon-meme: (•_•) ( •_•)>⌐■-■ (⌐■_■) In this challenge, your task is to take the first line as input, and output the last one, effectively putting sunglasses on that little button-eyed person. To make the task a bit more difficult, the characters ...
Taxicab Numbers or OEIS A011541 are the least numbers that are able to be represented as \$n\$ different sums of two positive cubed integers, for successive \$n\$. You'll need to print out the \$n\$th taxicab number. This should work for any \$n\$ in theory. However, as only 6 taxicab numbers have been discovered so fa...
A lipogram is a block of words that omits a particular symbol. Right now, I am avoiding our fifth symbol of 26 that commonly show up. You should know by now what I am omitting. If not, look up "lipogram" and you will know. Your Task With a char, a blank, and a following string (blanks may show up in this; with only ASC...
Inspired by Draw a timeline. Given a timeline of events, output the date for each event. A timeline will be given in the form 2000 --AF-C-------E--D---B-- Where the first line shows a known point in time. The known year is always the character below the first digit of the known year You may assume: On the timelin...
Given a number > 0, output the sum with all digits (1 .. n) concatenated and reversed and add them up. For example, with n = 6: The numbers 1 to 6 concatenated: 123456 Reversed: 654321 Adding them up together will result in: 777777. Another example is n = 11: 1 2 3 4 5 6 7 8 9 10 11 > 1234567891011 and 11 10 9 8 7 6...
Challenge You will be given a positive integer n as input. Output should be a pyramid-like sandpile built on the rules specified below: Each integer "falls" downward from the same initial starting point, like sand falling into a conal-shape. Numbers greater than the number directly below it when it hits the sandpile ...
Related: Program my microwave oven and Generate lazy values. My colleague is so lazy that he doesn't even bother to move his finger when programming the microwave oven. (This is actually true!) Help him find the microwave input that gives the time closest to what he wants, but where all digits are the same. If two inpu...
Related: Program my microwave oven. Inspired by Generate lazy microwave input. The lazy value of the non-negative integer N is the smallest of the integers that are closest to N while all their digits are identical. Return (by any means) the lazy value of a given (by any means) N. N ≤ the largest integer that your lang...
While bored in high-school (when I was half my current age...), I found that \$f(x) = x^{x^{-1}}\$ had some interesting properties, including e.g. that the maximum \$f\$ for \$0 ≤ x\$ is \$f(e)\$, and that the binding energy per nucleon of an isotope can be approximated as \$6 × f(x ÷ 21)\$... Anyway, write the shortes...
Write a function or program which, given a number of lines and columns, generates a corresponding tabular environment for LaTeX with no data in it. Table format and tabular Environment Here is an example of a table with 2 rows and 4 columns: As you can see, we do not count the first row nor do we count the first colum...
Sliding doors have varying prices based on the width of the doors. The different prices are as follows: 60 - 80 cm: ¤150 81 - 100 cm: ¤200 101 - 120 cm: ¤220 When buying a closet you would obviously want to minimize the cost, so your task is to find the width of the doors that minimizes the total cost based on the...
Inspired by Copied from this question at Stack Overflow. Given a matrix A, create a matrix B such that the columns of A are arranged in a block-diagonal fashion. For example, given 1 2 3 4 5 6 the output would be 1 0 0 4 0 0 0 2 0 0 5 0 0 0 3 0 0 6 Rules Input and output may be in the form of 2D arrays, nested arrays...
I hope this picture looks familiar to you. It's one of Pacman's ghosts in his "vulnerable" state, after Pacman has eaten a power pill. The challenge Picture our ghost in a little frame, using ASCII art. At normal scale (more about this later), each square in the above image should correspond to one character, and the ...
A friend of yours has given you directions to the best restaurant in town. It's a series of left and right turns. Unfortunately, they forgot to mention for how long you need to go straight ahead between those turns. Luckily you have a street map with all the restaurants on it. Maybe you can figure out which restaurant ...
The SAS programming language is a clunky, archaic language dating back to 1966 that's still in use today. The original compiler was written in PL/I, and indeed much of the syntax derives from PL/I. SAS also has a preprocessor macro language which derives from that of PL/I as well. In this challenge, you'll be interpret...
Context Straw Poll is a website that is meant for the creation of simple/informal polls. Provided with a list of options, the user can select their choice(s), and the votes are tallied up. There's two very important features of a Straw Poll: It is possible to view the current results before voting It is often possib...
As we learned from The Holy Numbers, there are 5 holy digits (0, 4, 6, 8, 9), and positive integers consisting solely of those digits are holy. Additionally, the holiness of a number is the sum of the holes in the number (+2 for every 0 or 8, and +1 otherwise). Now, there is an additional property to take into consider...
In almost every row nowadays, the people tends to order themselves as militaries would do. Challenge Suppose 4 people where: person 1 has priority against person 2, 3 and 4, person 2 has priority against person 3 and 4, person 3 has priority against person 4, person 4 has the lowest priority. Then, when ordering thos...
The task This is a simple challenge. Your input is a single non-empty string, containing only digits 0123456789 and hashes #. It will contain exactly one run of digits, which encodes a nonnegative integer and may wrap around the end of the string, and at least one #. The integer may have leading zeroes. For example, ##...
While Rust is very, very rarely competitive in code golfing competitions (Java is often shorter), it can still be fun to golf in. What are some tricks for making Rust code shorter? Please post only one tip in each answer.
Note: This challenge has been changed to eliminate the strict whitespace manipulation requirements that made this challenge low-quality. Some rules regarding whitespace have been changed. I'm rather good at mental math, particularly adding positive integers in my head. Here is my method for adding the numbers together...
Totally not inspired by Visualize long division with ASCII art ;) Your job is to show long hand addition with ASCII art. You solve longhand addition by adding up the columns right to left, placing the value of the ones place in the result, and carrying the tens place over to the top of the next column. Input Input can ...
A struggling manufacturer named Tennessee Instrumental is desperate to get into the calculator business. Problem is, they don't have any software engineers on payroll, and the deadline is coming up fast. It's your job to help TI configure a basic calculus-ready calculator that can simplify expressions input as strings...
It's become somewhat of a tradition in PPCG that some users temporarily change their names by an anagram (a new name formed by reordering the letters of the old). Sometimes it gets difficult to find out who is who. I could use a program or function to tell if two phrases are anagrams of each other. The challenge The pr...
Welcome to BBC Casting. We need a program that we can use to select a new actor to play The Doctor on Doctor Who. In the spirit of the show, your program will perform a regeneration from one actor's name to the next. We will test your program by running through the 13 names of actors who have already played The Doctor ...
Background I wanted to make a pretty word cloud, like this: these are words floating I computed the (x,y)-coordinates of the first letter of each word, plugged them into my word cloud generator, and let it do its job. However, I accidentally used (y,x)-coordinates, so the result looks like this: these ...
No one is quite certain what the emoticon >:U is intended to represent, but many scholars believe it looks like an angry duck. Let's assume that's the case. Task Given an integer n between 0 and 3 inclusive, print or return quack if n = 0, >:U if n = 1, U U > : U U > U U > : U U UUU if n = 2,...
This challenge is similar to this old one, but with some unclear parts of the spec hammered out and less strict I/O requirements. Given an input of a string consisting of only printable ASCII and newlines, output its various metrics (byte, word, line count). The metrics that you must output are as follows: Byte count...
The Challenge: Find if a number contains a digit. The number and the digit are to be taken as input. Output must be a boolean value. But you are not allowed to use the string representation of the number at any time. Now don't count upon a char* either. You must devise a mathematical way to do it. Rules: • You can't us...
π(n) is the number of primes less than or equal to n. Input: a natural number, n. Output: π(n). Scoring: This is a fastest-code challenge. Score will be the sum of times for the score cases. I will time each entry on my computer. Rules and Details Your code should work for n up to 2 billion ( 2,000,000,000 ). Bui...
Given a set of letters, output all strings made of those letters. (This is Kleene star of the set.) For example, for {'a','b'}, the strings are: '', 'a', 'b', 'aa', 'ab', 'ba', 'bb', 'aaa', 'aab', ... Input: A non-empty collection of distinct letters a..z. These may be characters or single-character strings. Output: A...
Introduction As an example, let's take the number 7. We then duplicate this and place 7 spaces in between. We get this: 7_______7 After that, we are going to decrease the number, until there are no spaces left. We get the following for the number 7: 7_______7 6543210 Then, we just merge the two of them, so: 7___...
Ever wonder what countries surround another? I do too, sometimes, and, well, here's the challenge for it. I have provided a list of countries and the countries that they touch that you must recognize at the bottom of this post in a code block. You need to create a full program that outputs (in the most convenient way p...
Task: Given an input consisting of exactly one of the characters <>^v, output a second input consisting of the printable ASCII characters (from space to tilde), oriented with the arrow. Let's assume the second input to the program is ABC. This is what it should do: Input >: print ABC. Input <: print CBA. Input ^: prin...
The challenge Given a list of words ["Programming", "Puzzles", "Code", "Golf"] output the words crossword-style: P r o g r a m m i n g u z z G l C o d e l s f The Algorithm You have to process the list in the given order. The words are printed in alternating orientations, starting h...
What general tips do you have for golfing in D? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to D (e.g. "remove comments" is not an answer). Please post one tip per answer.
A standard domino set has 28 unique pieces: Given a list of 28 or fewer unique dominoes, output the list required to make a complete set. Input and output dominoes are specified by two digits - the number of pips on each side of the domino, e.g. 00, 34, 40, 66. The digits may be given in any order, so 34 is the same d...
Challenge Given the following C# method: private static bool Test(bool a, bool b) { if (a && b) return false; if (a) if (b) return true; return false; } Supply the values a and b so that true is returned. Winning condition The first entry who can supply the correct arguments to make the given method evalua...
Challenge description For every positive integer n there exists a number having the form of 111...10...000 that is divisible by n i.e. a decimal number that starts with all 1's and ends with all 0's. This is very easy to prove: if we take a set of n+1 different numbers in the form of 111...111 (all 1's), then at least ...
Given an input of a program written in oOo CODE, output the BF code that it represents. Here is a short description of how oOo CODE works: First, all non-alphabetic characters are removed (everything not in the range A-Za-z). For example, take the program PROgRam reVERsES giVeN iNPut sEqUENcE (an example given on the ...
In a twist on finding a needle in a haystack, you need to find the largest contiguous haystack containing exactly one needle. Note that you cannot connect cells on diagonals, only left/right/up/down. Input An array (or a number of user input lines, your pick) of 'N' (needles) and '#' (hay) characters. Input only contai...
I think about if I was turned into an ant, I'd want my loved ones to know, so I thought of a plan- I'd gather twigs and leaves and write my name on the ground, Then I'd wait for my family and friends to crowd round But now I'm thinkin'- that when they saw it They'd think the human me wrote it and an ant was cr...
Pike is a dynamically typed interpreted scripting language, heavily influenced by C, which typically compiles to C99 with a few #defines. (It even has a preprocessor!) What general tips do you have for golfing in Pike? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat...
Create a Pascal's Triangle that is a nested list and contains zeros in the unused spots. In the output array, the numbers of Pascal's Triangle are separated by zeroes and padded by zeroes on each side so that they are centered. For example, the bottom row (last sub-array) must have no zeroes on the left and the right; ...
In the ASCII art world, there is water, hash walls and letter mechanisms. You are in a room made up of hash walls (# signs): ####### # # # # # # # ### # # # ####### You install an S water source (S sign) and an E water tank (E sign) which can receive water from any direction, but you only have one S so...
Your task is to write a program, that given a list of chat messages, count how many times each person gets pinged, so I can know how popular everyone is. But, since I have to do it surreptitiously, I need it to be as small as possible so I can hide the code. Specs The input comes in a list of 2-tuples, with each item...
For mostly historical reasons, bash is quite a hodge-podge of syntax and programming paradigms - this can make it awkward and sometimes frustrating to golf in. However it does have a few tricks up its sleeve that can often make it competitive with other mainstream script languages. One of these is brace expansion. Th...
A highly composite number is a positive integer that has more divisors than any smaller positive integer has. This is OEIS sequence A002182. Its first 20 terms are 1, 2, 4, 6, 12, 24, 36, 48, 60, 120, 180, 240, 360, 720, 840, 1260, 1680, 2520, 5040, 7560 For example, 4 is in the sequence because it has 3 divisors (nam...
Task description Sometimes, you really need to fit something you’re writing in a small space. It may be tempting to drop the vowels and wrt lk ths – and failing that, who really needs spaces? Thssprfctlrdbl!† Write a function or program that removes lowercase vowels aeiou, and then spaces, and then any characters from ...
Given an image, output the [width in pixels of a full vertical section]1 (if one exists). If no vertical section exists, output 0. Input may be provided as a local file or a nested array. If you choose to take input as a nested array, white pixels should be represented by a truthy value while non-white pixels should be...
You have a deck of cards, consisting of cards with non-negative numbers on them, and you haven't shuffled it yet, and no player trusts the other players to be fair at shuffling. You devise a way to shuffle the deck that is completely deterministic, but chaotic enough that the other players are okay with using it. Here'...
Jason has a big JSON but it's unreadable, so he needs to prettify it. Formatting Spec The JSON has 4 different types: Numbers; Just 0-9 Strings; Double quoted " strings escaped with \ Arrays; Delimited by [], with items separated by ,, items can be any of these types Objects; Delimited by {}, format is key: value wher...
Introduction There are often times that we have challenges which require communication of some sort (such as in team KOTH), where density of information may be more important than density of code. There are a number of compression techniques that can allow us to convey more information in less space, but for simple dat...
Given an input of an ASCII art picture, output the ASCII art italicized. To italicize the ASCII art: Insert zero spaces before the last line, one space before the second-last line, two spaces before the third-last line, etc. Remove any extra leading whitespace that may have been created. That is, if each line has at l...
Write a program or function that prints an input string around the discrete circle that has the minimum possible radius. For example, for input This is an example, your program should output: a si n s i e h x T a m p le Circle generation You shall use the M...
Background I have a ladder leaning on a wall, and a remote-controlled robot that can climb it. I can send three different commands to the robot: UP: the robot takes one step upwards. If it was on the highest step, it trips over, falls down and explodes. DOWN: the robot takes one step downwards. If it was on the lowest...
Similar to the Catalogue of hello world. I want to produce a catalogue of short ways to produce CSV. CSV Definition In this case CSV meaning the more literal interpretation of; A string representation of a list or array separated by commas. The input types should not be mixed i.e [1, "hello"] is NOT valid input The out...
Suppose we define a simple program that takes an array L of natural numbers with some length N and does the following: i=0 #start at the first element in the source array P=[] #make an empty array while L[i]!=0: #and while the value at the current position is not 0 P.append(L[i])...
You may have seen puzzles like this: Find the 0: OOOOOOOOOOOOOOOOOOOO0OOOOOOOOOOOOOOOOOO The challenge is to write a program that finds the index of the different letter given an image. Input Input will be an Image. The image will consist of one line of black text in the Helvetica 24 pt. font on a white background. T...
In this challenge, your task is to make write a program with less than 300 characters that takes a short paragraph or a few sentences that a candidate has said and output who said it. Input: Can be taken as a parameter to a function, input to a program etc. It will be a short paragraph, properly punctuated. Output: The...
Symbolic Differentiation 2: Back on the Chain Gang Task Write a program that takes in a certain sort of function from stdin and differentiates it with respect to x, using the chain rule.* The input function will be a string of the following form: "trig_1 trig_2 trig_3 ... x" where trig_n is a trigonometric function si...
This challenged is highly inspired by what @Mego created with his Holy and Holier numbers, lots of thanks to him and his puns. Holy numbers are numbers composed of only the digits with holes, which are: 04689 Numbers with at least one unholy digit are considered unholy. Unholy digits are evil by definition, but being ...
List all of the combinations with replacement (or combinations with repetition) of size k from a set of n elements. A combination with replacement is an unordered multiset that every element in it are also in the set of n elements. Note that: It is unordered. So a previously printed set with a different order shouldn'...
This is a window: --- | | --- Let's add some walls |. Put two spaces on either side of it so that the window has plenty of room. | --- | | | | | | --- | Now let's add a roof and a ceiling. To keep the window in the middle of the room, let's add one more row above it and below it. --------- | | | --- | |...
The Challenge I was reading Google's Java Style Guide the other day and stumbled over their algorithm to convert any arbitrary string into camelCase notation. In this challenge you have to implement this algorithm since you don't want to do all this stuff in your head when you are writing your super competitive Java su...
Given the name of a Stack Exchange site which doesn't have their own design yet, decide how many ASCII characters (non-ASCII ones are counted separately) are there on their icons. Your code should distinguish these 4 cases: 1 character: Astronomy Beer Freelancing Health History Law Music: Practice & Theory Parenting Th...
Introduction File names can be wildly varying things, ranging from a simple blah.txt to 303549020150514101638190-MSP0.txt. The former is usually human generated, while the latter is often machine generated. Wouldn't it be nice to have a simple function to make educated guesses on whether or not a file might be consider...
Introduction Say you have a population of people. This population is made up of 100 Alices and 25 Bobs. So, 80% of the population are Alices and 20% are Bobs. We want to change the proportional makeup of the population to be 62% Alices and 38% Bobs. Rules You can only add to the population. You cannot take any away...
Shifty-eyes ASCII guys like to shift ASCII Ii's: >_> <_< >_< <_> Given a string of shifty-guys, spaced apart or separate lines, shift the Ii's side to side, left the wall and right the skies: Ii The shortest shifter wins the prize. Say What? Write a program or function that takes in a string of an arbitrary list of t...
Given an input of a list of words and their abbreviations, output the pattern by which the abbreviations can be formed. Let us take the example input of potato ptao puzzle pzze as an example (that is, the abbreviation for potato is ptao, and the abbreviation for puzzle is pzze). Consider all possible ways to obtain pt...
It's Friday... so let's go golfing! Write code that determines the player's scoring on a hole in a game of golf. The code can be either a function or entire program. As the genre suggests, shortest code wins. Input (parameters or stdin, your choice): An integer representing the hole's par, guaranteed to be between 3...
Cellular Automata are truly fascinating. The ones that are usually talked about are the binary ones, i.e., the ones representable by a number. However, those, in my opinion, have been done to death. Ternary CAs are more interesting, but we have all of ASCII to consider! What fun could that be! Instead of deciding a rul...
Consider some binary sequence, using 1 and 2, e.g.: 1, 2, 1, 1, 2, 2, 1, 2, 1, 2, 2, 1 ... Let's write down the run lengths of that: 1, 2, 1, 1, 2, 2, 1, 2, 1, 2, 2, 1 ... _ _ ____ ____ _ _ _ ____ 1, 1, 2, 2, 1, 1, 1, 2, ... In this case we happen to get another binary sequence. Of course, that's not g...
Given a vector of \$n\$ values \$(x_1,x_2,x_3,\ldots,x_n)\$ return the determinant of the corresponding Vandermonde matrix \$V(x_1, x_2, \ldots, x_n) = \begin{bmatrix}1 & x_1 & x_1^2 & x_1^3 & \ldots &x_1^{n-1} \\1 & x_2 & x_2^2 & x_2^3 & \ldots &x_2^{n-1} \\ \vdots & & & \vdots & & \vdots \\ 1 & x_n & x_n^2 & x_n^3 & ...
Introduction Let's say that S1 = a...b and S2 = ..c... If we place them on top of each other, we get: a...b ..c.. We merge both strings, with the . as the liquid character (which can overlapped). We get this: a.c.b If one of the string is longer than the other, we just apply the same algorithm: a.....b ..c.. becom...