instruction
stringlengths
34
53.1k
Overview As most of y'all who visit chat know, I am Russian by ethnicity[citation not needed]. Recently, I switched from a keyboard that maps the letters 1-to-1 (mnemonic) to Windows' default mnemonic keyboard. Here are the letter mappings: "`" -> "ъ" "q" -> "я" "w" -> "ш" "e" -> "е" "r" -> "р" "t" -> "т" "u" -> "у" "i...
Challenge Given a non-negative integer, find the sum of its digits. Rules Your program must take a non-negative integer as input. Your program should output the sum of the digits of the input integer. Your program should be able to handle inputs up to 10^100. Examples If the input is 123, the output should be 6 (1...
There are 18 primes with distinct prime digits (A124674). Namely, they are: \$2, 3, 5, 7, 23, 37, 53, 73, 257, 523, 2357, 2753, 3257, 3527, 5237, 5273, 7253, 7523\$ Your task is to output this sequence. Rules sequence rules apply. This means valid solutions may use any of the following formats: Given some index \$n\$...
Description Given an unsorted array of integers, find the smallest positive integer that does not appear in the array. Your task is to write the shortest code possible to solve this problem. Input A non-empty or empty array of integers, where the integers may be negative, zero, or positive. Output The smallest positive...
I have a follow-up question here from my previous question on Math SE. I am lazy enough to explain the content again, so I have used a paraphraser to explain it below: I was considering arbitrary series, springing up as a top priority, when I considered one potential series in my mind. It is as per the following: The ...
Introduction One question that I have come across recently is the possibility of dissecting a staircase of height 8 into 3 pieces, and then re-arranging those 3 pieces into a 6 by 6 square. Namely, is it possible to dissect the following into 3 pieces: x xx xxx xxxx xxxxx xxxxxx xxxxxxx xxxxxxxx And rearrange those 3 ...
Typically, when we want to represent a magnitude and direction in 2D space, we use a 2-axis vector. These axes are typically called X and Y: This isn't always convenient, however. The game BattleTech is played on a hexagonal grid, and it's convenient for the axes to line up with the sides of the hexagons. To represent...
It seems we've managed to go all this time without a plain vanilla Number-To-Binary challenge! Whilst this will inevitably be only one element in many languages, it should put a few esolangs through their paces. I truly looked for this challenge to no avail. If it already exists, comment as such and I'll delete this po...
Generate the shortest possible code in any programming language that can generate all Pythagorean triples with all values not exceeding a given integer limit. A Pythagorean triple is a set of three integers \$(a, b, c)\$ that satisfy the equation \$a^2 + b^2 = c^2\$. The program should output the triples in any format,...
Given a permutation, we can define its high-water marks as the indices in which its cumulative maximum increases, or, equivalently, indices with values bigger than all previous values. For example, the permutation \$ 4, 2, 3, 7, 8, 5, 6, 1 \$, with a cumulative maximum of \$ 4, 4, 4, 7, 8, 8, 8, 8 \$ has \$1, 4, 5\$ as...
Given a string of parentheses ( and ), find the length of the longest substring that forms a valid pair of parentheses. Valid pairs of parentheses are defined as the following: An empty string is a valid pair of parentheses. If s is a valid pair of parentheses, then (s) is also a valid pair of parentheses. If s and t a...
Your function must accept two strings and return new string where are UTF-16 code of all symbols is the sum of UTF-16 codes of inputs symbols If the resulting sum is greater than 65535 (maximum UTF-16 codepoint), take the sum modulo 65536 If there are more symbols in one string then sum with zero, codes of symbols wh...
Challenge: Find the number of distinct words in a sentence Your task is to write a program that takes a sentence as input and returns the number of distinct words in it. For this challenge, words are defined as consecutive sequences of letters, digits, and underscores ('_'). Input: A string containing a sentence. The ...
(Similar: Through the bases) Normally, our number system is base ten, with the digits 0123456789. However, we can increase or decrease the base count (so hexadecimal uses 0123456789abcdef and octal uses 01234567. Your goal is: given a string, interpret it in all bases 2-36 for which it's valid, compute the total, and e...
I've looked and could not find a post for this, if there is one, I'll remove it quick! Related and also related The goal is (hopefully) clear: create the shortest code (in bytes) that implements the AES256 ECB cipher mode. Either convert the result to Base64 or output a array of bytes. The input contains two parts. The...
On Pomax's Primer on Bézier Curves this "fairly funky image" appears: This is related to the fact that every cubic Bézier curve can be put in a "canonical form" by an affine transformation that maps its first three control points to (0,0), (0,1) and (1,1) respectively. Where the fourth and last control point lies afte...
It's easier to put this into coding terminology, so here we go: First find the average, median, mode, and range. Then, put those values in another array, then find the new average, median, mode, and range. Bonus -10 bytes (yeah, negative bytes, because there's already answers) for programs that can handle this many ti...
I've been a fan of My Little Pony: Friendship Is Magic for a long time, and very early on I created a pony version of myself also called Parcly Taxel (warning: may be too cute to look at). The symbol below is her "cutie mark", which you will be drawing here: Construction All key points of the cutie mark lie on a rotat...
Take the sequence of all natural numbers in binary, (1, 10, 11, ..) then write them vertically beside each-other like this (least significant bit on top; 0s have been replaced with spaces): 1 1 1 1 1 1 1 1 1 11 11 11 11 1111 1111 11111111 11 Notice there are areas of connected 1s in the...
There's a lot of questions about Conway's Game of Life, but nothing about customization (Related: 2-Player Life). Given an input, determine the result on a 100x100 grid after some iterations. The input is given as a string. For example: Using the character #, follow the following rules: If there are 2 or 3 neighboring ...
Nerdle is a Wordle variant, in which instead of words, the answers are equations. Each equation entered in the game must be a valid one. Examples: 13³-1=2196, (1/1)²*8=8, (((3)))²=9 The task is to generate and output to a .txt file, one equation per line, all possible 10 character equations that could be an answer for ...
SVG is an XML vector graphics markup language embeddable in web content. Your tips should be at least somewhat specific to SVG. Please post one tip per answer.
Write a program that takes a string as input and modifies it by reversing the string in its place by mirroring the position. The first position goes to last, second to second last and so it goes on. In simple words, the string would be mirrored. "In Place" means the program should use \$O(1)\$ additional memory regardl...
Voronoi diagram is a partition of a plane (or part of plane) into regions close to each of a given set of objects ("seeds"). Here we’ll be dealing with discrete arrays or even rather with ASCII-art: 2 2 4 4 4 4 1 1 1 1 1 1 1 3 3 3 3 2 2 4 4 4 1 1 1 1 1 1 1 3 3 3 3 3 2 2 4 4 4 1 1 1 1 1 1 3 3 3 3 3 3 2 2 2 4 1 1 1 1 1 1...
We already have challenges dealing with simulating vanilla Conway's Game of Life, Wireworld and rule 110, but so far none corresponding to a (specific) non-totalistic rule. So here is one. In June 2000 David Bell described the Just Friends rule, which uses the same square grid and two states as regular Life but has the...
Description In this challenge, you need to write a function that takes in a list of strings and returns the smallest string based on their ASCII value. You should assume that the input list contains only lowercase alphabetical strings. Test Cases ["a", "b", "c"] => "a" ["hello", "world", "code"] => "code" ["aaa", "aa",...
Write a program or function that takes in a string and outputs a count of each modern English alphabet letter in the string, case-insensitive. Input: A string consisting of printable ASCII characters (code points 32-126). Output: A list of pairs, where each pair consists of a letter and its count in the string. The lis...
Description "Imtiaz Germain primes" is not a technical name in Mathematics, but my weird creation, in the memoir of the famous mathematician Sophie Germain. These primes can be generated by the following process: 1. Take a Safe prime 2. Apply 2p + 1 on it to obtain a composite number 3. Apply 2p + 1 once more to obtain...
Your function must accept three numbers in any order: A signed real number (or ±Infinity) - The number (N) for which you have to generate a number from the range A signed integer - Minimum of the range A signed integer - Maximum of the range Input: The minimum of the range will always be less than the maximum of the...
This question is an extension of Who's that Polygon? to arbitrary numbers of sides. A fundamental polygon for a surface is an polygon with a prescribed pairing for all its \$2n\$ sides, each marked with an arrow, such that identifying the sides according to this pairing and the arrow directions produces the surface (up...
This challenge arises from a claim made in a MathOverflow answer and a paper linked in that answer which seems to back up the claim: Searching for triangular embeddings is much quicker than enumerating over all embeddings… In fact, Jungerman was able to find a triangular embedding of \$K_{18}-K_3\$ in about half an ho...
We are going to bring down an imaginary building with a series of explosions. Our building is a 5x5 matrix of integers ranging 1-9, each representing a single brick. The challenge is to set of a series of explosions to bring down our building as much as we can, why not! Each brick that is connected (horizontally, verti...
Inspired by one of many bugs I ran into while implementing selection sort in trilangle. Given a non-empty list of non-negative integers, "sort" the list using the following procedure: Find and output the smallest value in the list. If the list only has one element, stop. Recurse on a sublist: If the last element in t...
Description Write a program or function that takes in a positive integer \$n\$ as input and outputs all Sophie Germain primes that are safe primes less than or equal to \$n\$. A prime number \$p\$ is a Sophie Germain prime if \$2p+1\$ is also a prime. A prime number \$p\$ is a safe prime if \$p=2q+1\$, where \$q\$ is a...
Dedicated to Martin Gardner, taken from his book Background In the old days, the Slavs had a divination method for finding out whether a girl would get married. The girl would clutch six straws in her hand so that the ends would poke out the top and bottom of her fist. Then her friend would join together the ends of pa...
Develop a program to check if a given word is part of a language defined by the following rules: The language has a set of rules. The empty string is considered a valid word in the language. Two words from the language can be concatenated to create a new word in the language. If X is a word in the language, then "A" +...
You're driving a car in an infinite city whose blocks are pentagons arranged in the order-4 pentagonal tiling. At each step, you proceed to the next intersection and choose whether to continue left, right, or straight. A sequence of choices that returns you to your initial state (street segment and direction) is called...
This is a sequel to Ragged list pattern matching. In this challenge, the wildcard may match a sequence of items of any length instead of just a single item. Given a pattern and a ragged list of integers, your task is to decide whether the pattern matches the ragged list. The pattern is also represented by a ragged list...
Problem author: https://stats.ioinformatics.org/people/5815 You are given a system with a hidden permutation of the numbers \$1, 2, 3, \ldots, n\$. Your task is to guess this permutation by asking the system a series of questions. Each question consists of providing the system with a permutation of the numbers \$1, 2, ...
(Inspired by this challenge.) Given six real values in three pairs: \$(x_1, x_2), (y_1, y_2),\$ and \$(x_0, y_0)\$, where \$x_1 < x_0 < x_2\$ and \$y_1 < y_0 < y_2\$, create a function which maps between \$(x_1, x_2)\$ and \$(y_1, y_2)\$ which also passes through \$(x_0,y_0)\$. In other words, make some function $$f: ...
Imagine that a list of integers describes the heights of some two-dimensional terrain as seen from the side. Stamina: [ 4 4 4 4 4 4 3 3 3 3 2 2 2 - ] O /|\ / \ +---+ +---+ | | | | +---+ ...
Languages, such as C++, have introduced a new comparison operator: <=>. This operator returns -1, 0, or 1† when comparing two items together: −1 means the left-hand side is smaller,  0 when both values are equal, +1 means the right-hand side is smaller. Here is what I have been coming up with in x86-64: 556: 48 8b...
Every integer can be expressed in powers of 2. You know this as the binary system Assume you are given a set of k numbers (0 < k < 2^n). You want to decide for this set whether every integer power of 2 up to 2^(n-1) occurs at least m times One example: n = 7 (2^n = 128, ) k = 5 set = {100, 91, 88, 63, 44} m = 3 Solut...
Non-metals typically* have a fixed number of covalent bonds in every chemical they are part of. Given the number of bonds every element requires, output whether it's possible to construct a single molecule from the given chemicals, such that every atom has it's desired number of bonds. In other words, output if it's po...
Carry sort is an \$O(n)\$ "sorting" algorithm. Here's how it works. The algorithm moves left to right along a list. As it traverses a list it "carries" a single item, the largest item it has encountered so far. Once it encounters a larger item it picks up that item and drops the item it is already carrying in place. W...
Description a typeracer is an apps where user could type and evaluate their typing speed and accuracy. Criteria User could type "A quick brown fox jumps over the lazy dog." A visual indicator of each wrong character typed. A visual indicator of what characters to type. A visual indicator of what has been typed A visua...
If \$R\$ runners were to run a race, in how many orders could they finish such that exactly \$T\$ runners tie? Challenge Given a positive integer \$R\$ and a non-negative integer \$0\leq T\leq {R}\$ produce the number of possible finishing orders of a race with \$R\$ runners of which \$T\$ tied. Note, however, that run...
I'm trying to solve a CSS challenge. It contains a rotated leaf shape (looks like an eye). Score for the challenge depends on amount of characters of the code. Here's my way to make a leaf shape: div { width: 200px; height: 200px; border-radius: 99% 0; rotate: 45deg; background: #d9d9d9; } <div></div> He...
In C++, there exists a a <=> b three-way comparison operator that, for numerical types, does the following: If a < b, then return a negative number. If a = b, then return a (mathematically speaking) sign-less number. If a > b, then return a positive number. The Challenge Implement the shortest full program, function,...
Given a string s consisting of characters a-z lowercase, generate 5 arrays a1, a2, a3, a4, and a5 of size n (length of s) where the i-th element of each array represents the index of the next occurrence of the i-th character in s, with the following conditions: If no such occurrence exists, set the value to n (0-based...
I have the code: marks = tuple(tuple((input("Enter subject: "), input("Enter marks: "))) for _ in range(int(input("Enter number of tuples: ")))) print(tuple((s[:3].upper(), max(int(m) for t, m in marks if t == s)) for s in set(t for t, m in marks))) #INPUT (("Physics",131),("Chemistry",30),("Physics",100),("Computers"...
Write a program that has at least one byte that, when run, does absolutely nothing. I thought this would be done by now, but I can't find any other challenges like this. How to tell if it does nothing: No variables are declared Nothing is returned Input does nothing You could run a program after it and it would run no...
Given two inputs, a distance \$d\$ and a number \$n\$ output a list of \$n\$ random colors which each have distance \$d\$ from the previous. Background A random walk is a path which is defined by choosing a random direction and (usually) fixed distance to go at each step. We will be taking a random walk through the RGB...
Given a set of bit vectors \$A\$ and a binary matrix \$M\$, we can define the set \$MA = \{ Mx : x \in A \}\$, where \$ M x \$ is the result of the matrix multiplication of \$ M \$ by \$ x \$ over \$\mathbb{F}_2\$, the field with two elements. Given the set \$ A \$ and the set \$ M A \$, your task is to recover a possi...
Challenge: A Frog List is defined by certain rules: Each frog within a Frog List has an unique positive digit [1-9] as id (any 0 in a list is basically an empty spot, which can mostly be ignored). A Frog List will always have exactly one Lazy Frog. A Lazy Frog will remain at its position. Every other frog in a Frog Li...
Chaim Goodman-Strauss, Craig Kaplan, Joseph Myers and David Smith found the following simple (both objectively and subjectively) polygon that tiles the plane, but only aperiodically: Indeed they found a one-parameter family of such aperiodic monotiles or "einsteins". The edges of all tiles in this family meet at 90° o...
You are the sonar captain aboard an underwater submarine. The way sonar works is that every submarine sends out a ping at regular intervals. Each interval is a whole number of seconds. Each submarine has an identifying amplitude, that is no two submarines send out pings at the same amplitude. The amplitude is always a...
This challenge is from a game, Keep Talking And Nobody Explodes. This is like one of those toys you played with as a kid where you have to match the pattern that appears, except this one is a knockoff that was probably purchased at a dollar store. – From the manual Objective The Simon Says module consists of 4 colored ...
Qat is a tool that lets you search for words matching a given pattern, often used by crossword and other word puzzle writers and solvers. In this challenge, you will have to implement a specific part of Qat, namely a subset of the "equation solver". Equations The output of a Qat query depends on the dictionary you use ...
The Greatest Common Divisor, or gcd, of two positive integers \$x\$ and \$y\$ is the largest positive integer that divides both \$x\$ and \$y\$. The Least Common Multiple, or lcm, of two positive integers \$x\$ and \$y\$ is the smallest positive integer that is a multiple of \$x\$ and \$y\$. We define the Least Uncommo...
In this challenge, you're given a list of overlapping waves. Each wave is a finite list with n truthy values, then n falsy values, then n truthy and so on, where n is the wavelength (or half the wavelength I guess, but it really doesn't matter in this challenge). The values of a wave may have an offset, so a wave of wa...
Problem source: https://oj.vnoi.info/problem/backtrack_j We have these two shapes: #. ## and .# ## Let's call the first shape the L and the second shape the flipped L. On a 4x4 board, there are 16 cells. Each cell can be either free or occupied. In all the illustrations, # represents an occupied cell and . represents...
RPS 25 is a version of Rock Paper Scissors which has 25 hand symbols instead of just 3. Each symbol defeats 12 symbols, and is defeated by 12 others. Here's a link to a chart showing which symbols defeat which. The challenge here is simple: your program should take in two strings representing the symbols thrown by each...
A Bayer matrix is a threshold map used for ordered dithering that gives the illusion of having more shades of color than actually present by using a crosshatch-like pattern. Bayer matrices are square with a side length that is a power of 2. Here are some examples: \$ \displaystyle\frac{1}{4} \times \begin{bmatrix} 0 & ...
Related but noticeably different You are the leader of the guard in the dungeon of an ancient castle. There are N doors in the dungeon and N guards with keys. Guard with index i may operates with doors that have multiple indexes: i, 2 * i, 3 * i, ... The way he operates is very dumb: he just toggles state of the door:...
Consider the following spiral of positive integers: We now define grambulation as a binary operation \$\lozenge : \mathbb N \times \mathbb N \to \mathbb N\$, using this grid. Some example inputs and outputs for grambulation are: \begin{align*} 1 & \lozenge 9 = 25 \\ 1 & \lozenge 2 = 11 \\ 11 & \lozenge 10 = 25 \\ 9 & ...
For this challenge, a slice of a string is defined as an upper and lower index that can "cut" a piece of a string. All characters from the string in the range [start, end) (or [start, end] if you don't speak practlang) are part of that slice. If the upper index exceeds the string's length, the overflow is ignored. For ...
A polyomino with \$n\$ cells is a shape consisting of \$n\$ equal squares connected edge to edge. No free polyomino is the rotation, translation or reflection (or a combination of these transformations, i.e. an isometry) of another (they're equal). The sequence of free polyominoes with \$n\$ cells is as follows: 1, 1, ...
The cosine similarity of two vectors \$A\$ and \$B\$ is defined using their dot product and magnitude as: \$\frac{A\cdot B}{\|A\|\|B\|}\$ Or in other terms \$\frac{\sum_{i=1}^nA_iB_i}{\sqrt{\sum_{i=1}^nA_i^2}\sqrt{\sum_{i=1}^nB_i^2}}\$ Challenge Given two nonempty, nonzero vectors containing only integers (can be taken...
The idea is based on this interactive game. Given a set of eight decimal digits which are not necessarily distinct, your task is to find a hyperjump trip with the specified length. But what is a hyperjump? I ain't got time to click on HOW TO PLAY Ok, you have a set of eight digits where none is 0 or 9. Let's say [1, 3,...
A super prime is a prime whose index in the list of primes is also a prime: 3, 5, 11, 17, 31, 41, 59, 67, 83, 109, 127, 157, 179, 191, 211, 241, 277, 283, 331, 353, 367, 401, 431, 461, 509, 547, 563, 587, 599, 617, 709, 739, 773, 797, 859, 877, 919, 967, 991, ... For this challenge, an "order 2" super prime is defined...
The Jaccard index / similarity coefficient, also known as the Tanimoto index / coefficient, is a statistic used for gauging the similarity and diversity of finite sample sets. It was developed by Grove Karl Gilbert in 1884 for the field of weather forecasting [1] and later independently developed by Paul Jaccard [2] wh...
Heading into the final day of regular season games for the 2023 NBA season, the fifth to ninth seeds in the Western Conference were still very undecided. Four games would determine the seeding: New Orleans (N) at Minnesota (M) Utah at LA Lakers (L) Golden State (G) at Portland LA Clippers (C) at Phoenix Let the Boole...
Your task is to write a program that receives a base 10 number from 0 to 99 and outputs the German name of that number with non-ASCII characters replaced with ASCII equivalents. German number names 0 -> null 1 -> eins 2 -> zwei 3 -> drei 4 -> vier 5 -> fuenf 6 -> sechs 7 -> sieben 8 -> acht 9 -> neun 10 -> zehn 11 -> e...
Related but different. Part II Taken from the book: Marvin Minsky 1967 – Computation: Finite and Infinite Machines, chapter 14. Background As the Gödel proved, it is possible to encode with a unique positive integer not just any string but any list structure, with any level of nesting. Procedure of encoding \$G(x)\$ i...
The bots are looking for love. Can you help them? The rules The goal of this game is find the bot you have the highest compatibility with. However, robots, who are inexperienced at dating are unable to tell how well a date went. In the game, bots take turns "speed dating" some other bot. After each date, each bot choos...
You are given two strings \$a\$ and \$b\$ consisting of characters from a to z in lowercase. Let \$n\$ be the length of \$a\$. Let \$m\$ be the length of \$b\$. Let \$a'\$ be the string \$a\$ repeated \$m\$ times. Let \$b'\$ be the string \$b\$ repeated \$n\$ times. Check whether \$a'\$ is lexicographically less than \...
In this challenge, given a CSV file as a string, you'll return the data contained as a 2d array of strings. Spec: The input consists of one or more records, delimited with \r\n (CRLF), \n (line feed), or some other reasonable newline sequence of your choice A record consists of one or more fields, delimited with , (co...
In Bloons Tower Defense 6, the strength of different bloons can be measured by their Red Bloon Equivalent (RBE), or the number of single pops it takes to completely defeat the bloon. The RBE for the bloon types are as follows (sourced from the wiki) Bloon RBE red 1 blue 2 green 3 yellow 4 pink 5 black...
The alternating factorial is an alternating sum of decreasing factorials. For example, we could calculate the alternating factorial of 4 as follows: First, calculate the factorials from 4 down to 1: $$ 4!\quad3!\quad2!\quad1!\quad = \\ 4\cdot3\cdot2\cdot1\qquad3\cdot2\cdot1\qquad2\cdot1\qquad1\quad= \\ 24\quad6\quad2...
The task here is simple: given a target location on an XY grid, and a rectangle on that grid, find the length of the shortest path from the origin to the target which does not intersect the rectangle. All parameter values are integers. You can assume that neither the target point nor the origin is inside or on the bord...
Part I Previous part was considered encoding of non-empty nested lists with a positive integer. Reminding the coding procedure \$G(x)\$: If \$x\$ is a number, \$G(x) = 2^x\$ If \$x\$ is a list \$[n_0, n_1, n_2, n_3, …]\$, \$G(x) = 3^{G(n_0)} \cdot 5^{G(n_1)} \cdot 7^{G(n_2)} \cdot 11^{G(n_3)} \cdot...\$ Bases are cons...
You are given a string \$s\$ of characters from a to z. Your task is to count how many unique strings of length \$n\$ you can make by concatenating multiple prefixes of the string \$s\$ together. Since the result can be superlative you can either choose to output the whole result, the result mod \$2^{32}\$ or the resul...
Objective Given the distance between two keys in an octave, identify its name. But there's a caveat. In this challenge, there are 22 keys in an octave, not usual 12. Here, a porcupine[7] scale will be assumed. Mapping White keys are marked bold. Distance Name 0 Unison 1 Augmented Unison or Diminished Second ...
Hertzprung's Problem (OEIS A002464) is the number of solutions to a variant of the Eight Queens Puzzle, where instead of placing \$n\$ queens, you place \$n\$ rook-king fairy pieces (can attack like both a rook and a king); in other words, it's how many possible positions you can place \$n\$ rook-kings on an \$n \times...
The problem statement here is pretty simple, take two real numbers on the range [0,1) as input and output their sum, with probability 1. The catch here is that there are a lot of real numbers. There are in fact so many real numbers that it is impossible to fit all of them into any finite data type. As such, any way to ...
Not a duplicate of the valid move challenge because that asks for specific pieces. Backstory The other night I was doing a little trolling with ChatGPT and chess. I was trying to get it to call me out for making illegal moves, as a lot of the time, you can feed it whatever nonsense you want. While doing so, I wondered ...
A Hankel matrix is a square matrix in which each ascending skew-diagonal from left to right is constant, e.g.: $$\begin{bmatrix} a & b & c & d \\ b & c & d & e \\ c & d & e & f \\ d & e & f & g \end{bmatrix}.$$ Given a sequence of integers \$\{a_n\}\$, we can construct a sequence of Hankel matrices \$\{H_n\}\$, where \...
Background Being in a philosophical mood, I remembered one old idea. I think it is suitable for CG. Duplicates are not found, but it's of course just a kind of totalistic cellular automaton or erosion. Given an infinite board filled with empty (let 0) cells. We create a figure - a finite set of non-empty (let 1) cells....
Challenge You are supposed to output the series I recently designed which goes as follows which are pen stroke counts of ascending prime numbers: 2, 3, 2, 4, 3, 5, 6, 5, 7, 7, 7, 10, 4, 6, 7, 4, 4, 4, 7, 6, 8... Example This is an illustration of how this series is formed, first, it takes a prime number from in sequen...
You may have seen something called a "perpetual dice calendar": Two 6-sided dice can be rearranged and rotated. One die has the numbers 0, 1, 2, 3, 4, and 5. The second die has the numbers 0, 1, 2, 6, 7, and 8. With this, any day of the month—from 1 to 31—can be displayed on the front of the calendar. The 6 can be rot...
Related From Wikipedia: In number theory, the Calkin–Wilf tree is a tree in which the vertices correspond one-to-one to the positive rational numbers. The tree is rooted at the number \$1\$, and any rational number expressed in simplest terms as the fraction \$\frac{a}{b}\$ has as its two children the numbers \$\frac{...
This is a rewrite of the (currently closed) "Debunking Stroustrup's debunking of the myth “C++ is for large, complicated, programs only”" challenge. Challenge Write the shortest program or function that will: Download http://www.stroustrup.com/C++.html, and List all URLs contained in the HTML document. A "URL" for th...
A sequel to What dice do I need to display every integer up to X? Numbers are great, but let's take it to the next level. I'd like to have a set of dice that can be arranged and rotated to display any words I want. Think Boggle: And not just that; I want to specify the number of sides those dice have. The set should c...
Simplified version of "Signpost" puzzle from Simon Tatham's Portable Puzzle Collection. How the puzzle is created We pick up randomly positive integer N and one of permutations of 1…N with 1 at the first position: N = 12 Numbers 1 and N always stay open, and 2 is always on the right of 1. So we look at numbers 2 and 3...
The Venetian election system was... complicated. The Great Council came together and put in an urn the ballots of all the councilors who were older than 30. The youngest councilor went to St Mark's Square and chose the first boy he met who drew from the urn a ballot for each councillor and only those 30 who got the wo...
Given some raw HTML, sanitize it by formatting the spaces, as defined below. Output rules: Like many challenges, this one is inspired by XKCD. First, "untag" all tags with nothing but spaces in them. (<i>te<b> </b>xt</i> becomes <i>te xt</i>). If a tag has nothing in it (like <b></b>, simply delete it and move o...
Objective Given an unlabelled binary tree, decide whether it is contiguous in indices. Indices This challenge gives one-indexing on binary trees. The exact definition expresses all indices in binary numeral: The root is indexed 1. For every node, to get the index of its left child, replace the most significant 1 by 1...
This is my first codegolf post so let me know if I have missed anything. Thanks :) Description You are given a list of numbers with 2 < n <= 6 length i.e. [1, 10] or [75, 9, 9, 8, 2, 100]. Given the basic operators + - / * you must try and generate all possible equations. The list of numbers to pull from is: [1, 1, 2, ...
I have the code below working. But there must be a better way. file <- "http://s3.amazonaws.com/assets.datacamp.com/production/course_1127/datasets/tmp_file.csv" x <- read.csv(file = file) ts <- xts(x = x, order.by = as.Date(rownames(x), "%m/%d/%Y")) cd=coredata(ts) for (j in 1:length(names(ts))) cd[,j]<-cd[,j]/cd[1,...