instruction
stringlengths
34
53.1k
For a 2 dimensional array we will define the elements in either the first row or the last column to be the largest "J-Bracket" of the array. For example in the following array elements in the J-bracket are highlighted: \$ \begin{bmatrix} \color{red}{\underline 1} & \color{red}{\underline 2} & \color{red}{\underline 4}...
It's laundry day, and you have lots of clothes that need to be washed. Wanting to have as much time left over for code golf as possible, you hope to optimize how quickly you wash and dry them all. You have three types of appliances: Washing machines: Take dirty clothes and turn them into wet clothes Dryers: Take wet c...
It's 2050, and people have decided to write numbers in a new way. They want less to memorize, and number to be able to be written quicker. For every place value(ones, tens, hundreds, etc.) the number is written with the number in that place, a hyphen, and the place value name. "zero" and it's place value does not need ...
Seeing that the current language for Learn You a Lang for Great Good is Piet, and that we don't seem to have a tips page for Piet yet, I decided to make one. Piet is a stack-based esoteric programming language in which the programs are meant to resemble abstract drawings. What are some general tips for golfing in Piet?...
Given a list of the integers from \$1\$ to some \$n\$, give the minimum number of adjacent swaps required to put the list in ascending order. You will receive a list as input and should output a non-negative integer. You may if you wish choose to expect a list of the integers from \$0\$ to \$n\$ instead. This is code-...
Description The Caesar cipher is a cipher, where every letter in the alphabet will be rotated by a secret number. If the rotation is \$7\$, then a -> h, g -> n, v -> c and z -> g. Today, we're playing Caesar's Cipher with ASCII chars, (0-127 inclusive). So, with rotation \$7\$, b -> i, Z -> a, x -> DEL (127), But, even...
We are probably all used to the English alphabetical order: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z When we compare words in English for the sake of alphabetization we first compare the first letter, whichever word has the later first letter comes later. If they are the same we check the second letter and...
Imagine throwing a rock into a pond. You get to see perfect circles of ripples spreading out over the pond, bouncing off of each other. Of course, nothing can be as serene as that in coding, but, we can try! Given a point on a 2D array (x, y) and the dimensions of a 2D array/pond (w, h), and a "frame" count, f, return ...
Given some input array a = [a1, a2, ..., an] and a positive integer k, shuffle the input array a such that no entry is farther than k from its initial position. Example Given the array [1, 2, 3, 4, 5, 6] and k = 1, this means the entry 3 can be at following positions: [*, 3, *, *, * ,*] [*, *, 3, *, *, *] (original ...
The brilliant engineers at <enter company you love to hate> have struck again. This time they've "revolutionised" the generation of random permutations. "Every great invention is simple" they say and their magical new algorithm is as follows: Start with a list 1,2,3,...,n of numbers to permute. For each element x in t...
Curry is the Language of the Month this month and some users are starting to get into it, so let's get some tips together. Haskell and Curry are similar in a lot of ways and a lot of tips for Haskell work well in Curry and vice versa. So I'd like in this question to gather tips for code-golf in Curry, that would be use...
Sieve of Eratosthenes is a method for finding prime numbers: take the sequence of all positive integer numbers starting from 2 then for each remaining number drop all its multiples. 2 3 x 5 x 7 x 9 x 11 x 13 x 15 x 17 x ... 2 3 _ 5 _ 7 _ x _ 11 _ 13 _ x _ 17 x ... Task Given a number \$n \ge 2\$, find the minimum amo...
Problem John bought 5 apples. You are given the weights of every group of four apples, and must then find the weights of the apples themselves. For example, if all apples without the first one weigh 798 g, without the second - 794 g, without the third - 813 g, without the fourth - 806 g, and without the fifth - 789 g, ...
Recently a friend of mine posed the following: What subset of the integers satisfies the condition if distinct a and b are in the subset, their average is not in the subset? I know the set of non-0 squares satisfies the condition, but I wonder if there exists a more... dense set that satisfies the condition. (It turn...
Given a string, like potatocarrot, break it into the smallest number of substrings possible. These substrings can consist either be a single character, or one of a list of words passed as input. For example, if [carrot, potato] was the input, the optimal way to break the string up would be [potato][carrot]. If the list...
Given a base type T, this can be augmented with * or [], each meaning pointer and array. For example, []*T means "array of pointer to T" and *[]T means "pointer to array of T". Let's call * and [] type modifiers. C has a way of ordering these modifiers tied to the evaluation order. []*T in C-style becomes T *[], and *[...
Two or more positive integers are said to be "friendly" if they have the same "abundancy". The abundancy of an positive integer \$n\$ is defined as $$\frac {\sigma(n)} n,$$ where \$\sigma(n)\$ is the sum of \$n\$'s divsors. For example, the abundancy of \$30\$ is \$\frac {12} 5\$ as $$\frac {\sigma(30)} {30} = \frac {1...
Introduction: Apparently I keep coming up with word search related challenges lately. :) When I do the word search in the Dutch news paper, some words are very easy to find because they contain letters that aren't too common in Dutch words, like x or q. So although I usually look for the first letter or prefix of a wor...
Background Piet is an esoteric stack-based programming language in which programs are images meant to resemble abstract paintings. To keep the challenge from being unnecessarily complex, you will not have to consider most of the colors present in Piet, which determine what instructions are executed; instead, each type ...
Please help me automate my discrete mathematics homework. Given a valid propositional formula, check if it is an instance of one of Łukasiewicz's axioms. Here's how it works. A term can be defined inductively as follows: Single lower-case letters of the Latin alphabet (a, b, c, etcetera) are terms. Given a term ϕ, ¬ϕ ...
A polyiamond of size \$n\$ is a contiguous shape formed by joining \$n\$ equilateral triangles side by side. Your output should consist of two distinct characters, plus whitespace as necessary (▲ and ▼ work great!). Trailing whitespace is acceptable. You may use any other characters - but you may count ▲▼ as 1 byte e...
Given a string consisting of ()[]{}, print the paired brackets in the same order as they appear in the string. Any opening bracket ([{ can be paired with any closing bracket )]}. For example: ({()[}]] returns: (], {], (), [} Rules A string consisting of ()[]{} should be received as the input The bracket-pairs should ...
Given a pattern and a ragged list of positive integers, your task is to decide whether the pattern matches the ragged list. The pattern is also represented by a ragged list. But in addition to positive integers, it may contain a wildcard value. Here is the rule for matching: A positive integer matches the same positiv...
Let's say we have a 2-D list, like the following one: \$ \begin{bmatrix} \color{red}{1} & \color{red}{2} & \color{red}{3} & \color{red}{4} \\ \color{blue}{5} & \color{blue}{6} & \color{blue}{7} & \color{red}{8} \\ \color{green}{9} & \color{green}{10} & \color{blue}{11} & \color{red}{12} \end{bmatrix} \$ Notice how the ...
Your task is to make a program or function that takes a nonnegative integer (or a different convenient format to represent it) that represents an angle measure in degrees from 0 to 180 (inclusive) as input and outputs every possible time (in hours and minutes; no seconds) on an analog clock where the measure of the sma...
The Matoran Alphabet is the alphabet used by many of the characters in the Bionicle universe. Your challenge is to create a program or function that takes a string as input and creates an image of the input written in the Matoran alphabet. The input will only consist of uppercase letters (A-Z), numbers (0-9), and spac...
Or Fix American Kennel Club's database As covered by the recent video by Matt Parker, the American Kennel Club permits thirty-seven (37) dogs of each breed to be assigned the same name (source), because of a database restriction for Roman numeral length. Given an integer, your task is to output the length of its Roman ...
This is a quine challenge related to Write the shortest self-identifying program (a quine variant) Write a function or a full program that compares lexicographically its source code and input, that is, output three distinct values of your choice telling if input / source code is Bigger, Equal or Less than source code /...
For our purposes, a trend is a contiguous subsequence of an array that falls into one of three categories: increasing, e.g. [1,2,3,10,239] decreasing, e.g. [8,5,0,-3,-50] stable, e.g. [7,7,7,7] Note that [1,1,2,3] is not a valid trend. It can be broken up into a stable trend [1,1] and an increasing trend [1,2,3]. In ...
makina is a cell-based esolang composed of automata which move around a grid. These automata follow paths of instructions that direct their movement. Your task is to, given a makina program using only the below instructions (so a subset of normal makina) as input, output two distinct values depending on whether or not ...
\$ 1089 \$ is a very special number. To prove why, select any 3-digit number whose first and last digits differ by at least 2. Then, reverse the digits, and take the difference of these two numbers. Reverse the digits once more, and add these two numbers together. You will get \$ 1089 \$. The magic is left as an exerci...
CLOSED to competing entries New bots are welcome but are not part of the main competition and probably won't be officially tested. You stand on a dusty stretch of code, watching the other programs stare at you. Will they shoot? How much ammunition do they have left? All you know is that you want to be the last one stan...
A binary eye is an odd set of digits, with all of its digits except the center one set to 1 or 0, and the center one set to the opposite of the others. Thus, there are two binary eyes for a given odd number of digits: x eyes 1 1,0 3 101,010 5 11011,00100 7 1110111,0001000 9 111101111,000010000 Make ...
Given an integral polynomial \$p\$, determine if \$p\$ is a square of another integral polynomial. An integral polynomial is a polynomial with only integers as coefficients. For example, \$x^2+2x+1\$ should gives truthy, because \$x^2+2x+1 = (x+1)^2\$. On the other hand, \$2x^2+4x+2\$ should gives falsy: \$2x^2+4x+2 = ...
Objective Given a positive integer, spell it out in the conlang I made. Specification Let \$n\$ be the inputted integer. \$n\$ shall be spelled out in the following specification. The entire spelling is case sensitive. With the decimal expansion of \$n\$, let d be the least significant nonzero digit of \$n\$. First, d ...
Given an input string and a wrapping string, find the location of the first input string char in the wrapping string and replace it with the wrapping string char 1 step to the right of that, find the second char in the wrapping string and replace it with the char 2 steps to the right, find the third and replace it with...
This challenge has been divided into parts. Your goal is to convert a sentence into a form of 'short-hand' For Part 1 these are the rules Take in 1 word Remove all vowels(a,e,i,o,u), except the ones at the beginning and the end If a letter is repeated more than once consecutively, reduce it to only one (e.g. Hello -> ...
Given an expression like 4 / 2 + 3, determine whether the expression has the same value in Python 2 and Python 3. Recall that in Python 2 division rounds down (so that 5 / 2 -> 2), whereas in Python 3 division returns a float (so that 5 / 2 -> 2.5). For simplicity's sake, we will only consider expressions of the form: ...
Part 1 of the challenge revolved around converting the letters into specific unicode characters. Lore In this part we receive the output from the function made in Part 1, which now has to be arranged in an artistic manner. Aim Take 1 word as input which has already undergone transformation in the function made in Part ...
Starting with 1, output the sequence of integers which cannot be represented as the sum of powers of earlier terms. Each previous term can be used at most once, and the exponents must be non-negative integers. This sequence starts: 1, 2, 6, 12, 25, 85, 194, 590, 1695, 4879, 19077, 83994, 167988 For example, after 1 an...
Input variables: (Names are just examples, they don't need to be named like this) GrandTotal - integer to divide SplitCount - number of output integers required UpperLimit - highest valid value for any one output integer LowerLimit - lowest valid value for any one output integer Valid Output: Outout must be a random ...
New Posts and New Sandbox Posts are chatbots that occupy CGSE's main chatroom, The Nineteenth Byte. They've been doing their jobs for almost one full year now, so I thought I'd make a challenge to honor their contributions! The challenge is simple: Draw the profile picture of either New Posts (NP) or New Sandbox Posts ...
The Collatz Conjecture The famous Collatz Conjecture (which we will assume to be true for the challenge) defines a sequence for each natural number, and hypothesizes that every such sequence will ultimately reach 1. For a given starting number N, the following rules are repeatedly applied until the result is 1: While N...
I have a cake shop that specialises in birthday cakes. The cakes that I sell must have candles placed in a circle. You would probably think I can just divide 360° by the number of candles, but the machine for placing candles is quite unique; it uses a list of numbers representing positions of candles, placing them one-...
I've been developing some programs involving me fetching a vector from a url using Alpha-2 country codes (such as GET /jp.svg for Japan). Except, oh no! All the country data on my computer uses Alpha-3! That just won't do...The task is simple: Take an Alpha-3 country code (e.g. UKR) and return its Alpha-2 equivalent (...
Task The input consists of a JSON object, where every value is an object (eventually empty), representing a directory structure. The output must be a list of the corresponding root-to-leaf paths. Inspired by this comment on StackOverflow. Input specifications You can assume that that the input always contains a JSON ...
Slope fields or direction fields, are a graphical representation of the solutions to a first-order differential equation of a scalar function. A slope field shows the slope of a differential equation at certain vertical and horizontal intervals on the cartesian plane, and can be used to determine the approximate tangen...
Inpired by recent Stand-up Maths' video. Task Wrapping a list x can be seen as inserting "line-breaks" into x every n-th element, or forming a matrix from x with n columns (feeding rows first). To be perfectly rigorous in the definition of x wrapped into a matrix, we can pad the last row with 0s. Given a list x of posi...
Given two sets of strings, \$ D \$ and \$ R \$, find the shortest string which contains every string in \$ D \$, but contains none of the strings in \$ R \$. There are almost always multiple possible outputs; you should output at least one of them, but you can output more. You can assume this is possible with the input...
Your task, should you choose to accept it, is to take two input values \$a\$ and \$b\$, where \$a\$ and \$b\$ are in the set \$\{T, U, F\}\$, and compute and output their logical conjunction in a three-valued logic system. A three valued logical conjunction is this transformation: a b output U U U U F F F ...
You have a line with two endpoints a and b (0 ≤ a < b) on a 1D space. When a or b has a fractional value, you want to round it to an integer. One way to do this is to round a and b each to its nearest integer, but this has a problem that the length of the rounded range (L) can vary while b - a stays the same. For examp...
Given a string and the characters used to encode it, you need to compress the string by only using as many bits as each character needs. You will return the character codes for each character needed to create a compressed string. For example, given the string "the fox" and the encoder characters " abcdefghijklmnopqrstu...
In calculus, the derivative of a mathematical function defines the rate at which it changes. The derivative of a function f(x) can be marked as f'(x), and these can sometimes be abbreviated to f and f'. The derivative of the product of two functions fg is f'g + g'f. The derivative of three fgh is f'gh + fg'h + fgh'. In...
This part is somewhat detached from the actual array manipulation side of the challenge, scroll down for an explanation that is much more array-based You've been learning how to shuffle poker chips recently, but, as you're still learning, you don't always get the perfect alternating shuffle that you're aiming for. Inst...
A few days ago I made a puzzle about moving people on an airplane. Now I am interested in the general version of this puzzle and the shortest code golf for it. I will briefly summarise the puzzle here. A small airplane went through some heavy turbulence and all its N passengers ended up sitting in reverse order, ie., p...
If you wanted to compute a very large long problem, that on a machine that you could buy today for an inflation adjusted price, will take some amount of years/decades. The issue is, if you only have that budget, and so can only purchase one machine. So if you purchase the machine now, it may actually take longer to com...
Consider the equation $$\frac x {y+z} + \frac y {x+z} + \frac z {x+y} = n$$ for positive integers \$x, y, z\$ and \$n \ge 4\$. Your code will receive \$n\$ as an input, and output three integers \$x, y\$ and \$z\$ such that the equation holds. You may assume that a solution always exists. Background This equation is a ...
Challenge: Given two integers \$a\$ and \$b\$, with lengths \$A=length(a), B=length(b)\$, output an ASCII-art of the \$a^{th}\$ root of \$b\$, including the answer rounded to \$A\$ amount of decimal places. The size of the ASCII-art root also depends on \$A\$ and \$B\$. Example: \$a=123\$, \$b=1234\$ ____ 123 /123...
A binary matrix represents a shape in the plane. 1 means a unit square at that position. 0 means nothing. The background is 0. For example, the matrix [[0,1,0],[0,0,1],[1,1,1]] represents the following shape: o----o |////| |////| o----o----o |////| |////| o----o----o----o |////|/...
A binary matrix represents a shape in the plane. 1 means a unit square at that position. 0 means nothing. The background is 0. For example, the array [[0,1,0],[0,0,1],[1,1,1]] represents the following shape: o----o |////| |////| o----o----o |////| |////| o----o----o----o |////|//...
Connecting Dots We define a type of question on the test, connecting the dots Question parameters There are two parameters. Suppose they are 5 and 4. The second one must be less than or equal to the first one. Thus, the question will look like this: * * * * * * * * * Possible answer...
Related challenge A band matrix is a matrix whose non-zero entries fall within a diagonal band, consisting of the main diagonal and zero or more diagonals on either side of it. (The main diagonal of a matrix \$A\$ consists of all entries \$A_{i,j}\$ for which \$i=j\$.) For this challenge, we will only be considering sq...
Haplology Haplology is a linguistic term: the omission of one occurrence of a sound or syllable that is repeated within a word, for example probly for probably. For this challenge, it means specifically, replacing any sequences of two or more letters that are repeated two or more times with just one copy. For example...
Powers We define an important power as a number that can be represented as \$ x^y \$ where \$ x ≥ 2 \$ and \$ y ≥ 2 \$. Palindrome We define an important palindrome as a number that is the same written forwards and backward, and is greater than 10. Thus, the last digit must not be 0. Palindromic Power We define a Palin...
Is it a good chord? Definition of a chord: We define a chord as three notes together. Definition of a note: We define a note as a number between 1 and 7, inclusive. As in music, we define 1 as do, 2 as re, 3 as fa, etc. However, the note names are not important. They will not be included in the question and likely not ...
This is different from Floating Point XOR, and more in the spirit of a comment by R.. GitHub STOP HELPING ICE on that challenge, but I thought of this idea independently. Generalized XOR The bitwise exclusive or (XOR) operation is usually considered in terms of integers, but it can be naturally generalized (extended, i...
Challenge: Given an integer \$n\$, guaranteed to be \$\geq2\$ and a power of 2, we are going to draw multiply boards either side-by-side or below one another, where the first has dimensions of \$n\$ by \$n\$; the second \$\frac{n}{2}\$ by \$\frac{n}{2}\$; the third \$\frac{n}{4}\$ by \$\frac{n}{4}\$; etc.; until the fi...
The words "center a" probably give flashbacks to any decent HTML developer. Luckily, we are not working with divs, we are working with matrices. Given a matrix where w=h, and given a "length" to extend it by, make a new matrix and center the old one in it, populating blank squares with the length. For example: m = [ [1...
Overview I was playing with Desmos and discovered a really cool spiral: Doing some research, I discovered that this spiral was the Archimedian spiral. Every point on the spiral is exactly \$\theta\$ away from the origin, where \$\theta\$ is the angle from the origin. That is, any point on the spiral has the polar coo...
Implement a function or program that can run simplified BitCycle code. The functions you must implement are: <^>v: Change the direction of a bit to the direction this is pointing. +: Turn all 0s left and all 1s right. \ and /: Reflect one bit 90 degrees, then become inactive. In regular BitCycle, this is displayed as -...
King of the Hill: Greed Control What is Greed Control Greed control is a multiplayer round-based game in which in every round, a player bet a number inside a specific range, say 1~100. Say 2 people betted 100, then they'd both get 100/2 which is 50 points in the game. Basically, the players that choose the same numb...
The Task The task is easy: given an Alpha-2 country code, output the Alpha-3 equivalent. The input may be in any case you choose, and the output in any consistent case of your choosing. Here are the codes: [["AF", "AFG"], ["AX", "ALA"], ["AL", "ALB"], ["DZ", "DZA"], ["AS", "ASM"], ["AD", "AND"], ["AO", "AGO"], ["AI", "...
The Narrative You are a frog who is at the edge of a pond with waterlilies. You would like to cross the pond without getting wet, so you plan to jump from lily to lily. There is, however, one problem: you are a rare species of frog which can only jump one specific distance, and so you might not be able to cross the pon...
Background BitCycle is a two-dimensional Turing-complete programming language involves moving bits around a playfield. Because I am too lazy to write BitCycle programs myself, you will be writing a program which outputs BitCycle programs for me! Unfortunately, the storage space on my computer is only about a bit, so yo...
Given a set of positive integers \$ S \$, output the set of all positive integers \$ n \$ such that \$ n \$ can be made by summing a subset of \$ S \$ in more than one different way, i.e., that are the sums of more than one subset of \$ S \$. To be clear, a subset of \$ S \$ means that you can't use numbers from \$ S \...
In this challenge, you will create the shortest graphical program that displays exactly "Hello, world!" You will need no input. You might be asking yourself, "what does he mean by graphical?" Well, by graphical, I mean not writing to stdout. For example, look at my ES6 answer, which makes an alert box pop up rather tha...
Related: Deck Names Friends or Foes Paying for Spells The Magic: the Gathering card game has five colours of magical mana: white (W), blue (U), black (B), red (R), and green (G). Cards can be any of the \$2^5=32\$ subsets of these colours. Hereafter 'colours' refer just to the initials W, U, B, R, G. The order that the...
Given a multidimensional array, find the recursive alternating sum. An alternating sum is simply the sum of an array, where every other item (starting with the second) is negated. For example, the alternating sum of [7, 1, 6, -4, -2] is the sum of [7, -1, 6, 4, -2], or 14. In this challenge, you'll take the alternating...
Here's an advanced version of the Count the Liberties challenge. The definitions of the terms liberty and group are the same as the previous challenge, so have a look at the previous one for details, but briefly put, A group is a group of stones that are connected horizontally or vertically. Liberty is the number of e...
King of the Cards Code available here! In this King of the Hill challenge, you must write a bot that can play Crazy Eights. This is a card game often played by children, in which the objective is to empty your hand. How to Play The game of Crazy Eights is deceptively simple. At the beginning of the game, each player ge...
Design a function or program that, when run normally, outputs the triangular numbers. However, when any single character is deleted, the program/function should not function in the original programming language, but instead produce the triangular numbers in one other programming language. Scoring Your score will be the...
Draw an "apartment" building according to the specifications below. Basic Rules Take, as input, the number of floors of the building. Return a building with that many floors meeting the following specifications: The building will be eight characters wide, with eight underscore characters (_) on top and eight dashes (-)...
Definition of long text Long text usually shows emphasis, for instance, loooooool or yaaaaaaaaaay. Usually the vowel is replicated many times. In this challenge we require: At least 3 times, which means yaaay and yaaaay are allowed, but yay and yaay are not. Consistent, which means that shoes can turn out be shoooeee...
In Fewest (distinct) characters for Turing Completeness, the goal is to find the minimum number of characters which make a language Turing Complete...in other words, allow it to do any computation possible with any other language. In this challenge, we'll be doing somewhat of the opposite, and finding the minimum numbe...
This is the robbers' challenge. The cops' one is here. In Fewest (distinct) characters for Turing Completeness, the goal is to find the minimum number of characters which make a language Turing Complete...in other words, allow it to do any computation possible with any other language. In this challenge, we'll be doing ...
The Zany Car Game is a tile matching game. You are given a number of tiles, with coloured cars split into a top and bottom half. To win the game, you need to find a square arrangement of the tiles so that only whole, correctly coloured cars are formed at each tile join , like the image below. Challenge Given a square ...
For any ragged list its dimensions will be a list of non-negative integers defined as follows: Elements that are not a list will have dimensions \$\textbf{[}\,\,\textbf{]}\$. An empty list has dimensions \$[0]\$. An \$n\$ dimensional list \$L\$ of length \$x\$ has dimensions \$x : k\$ where \$k\$ is the element wise m...
Introduction If \$\newcommand{\fib}{\operatorname{fib}}\fib(x)\$ calculates the \$x\$th Fibonacci number, write a program that calculates \$\fib(\fib(m))\$ for any integer value of \$m \ge 0\$. (Of course, there will be practical limits based on the language, so lesser limits are acceptable. Also, it's okay to stop at ...
Given two positive integer fractions \$x\$ and \$y\$ such that \$x < y\$, give the fraction \$z\$ with the smallest positive integer denominator such that it is between \$x\$ and \$y\$. For example \$x=2/5\$, \$y=4/5\$, the answer is \$1/2\$. Other fractions such as \$3/5\$ are also in between the two, but \$1/2\$ has...
This is the reverse of this challenge. Given an encoded list of codepoints and the characters used to encode it, you need to decompress it to its original string. For example, given the encoded list [170, 76, 19, 195, 32] and the encoder characters " abcdefghijklmnopqrstuvwxyz", the output should be "the fox". How, tho...
Introduction In chess, Knights can move two squares in one direction, and then one square in an orthogonal direction. On an x/y plane, these can be thought of as being a relative change of coordinates, such as (+1, -2). Challenge Your task is to output all 8 possible moves as pairs of relative x/y coordinates, in any o...
A run ascending list is a list such that runs of consecutive equal elements are strictly increasing in length. For example [1,1,2,2,1,1,1] can be split into three runs [[1,1],[2,2],[1,1,1]] with lengths [2,2,3], since two runs are the same length this is not a run ascending list. Similarly [2,2,1,3,3,3] is not run as...
Inspired by the recent 3Blue1Brown video Consider, for some positive integer \$n\$, the set \$\{1, 2, ..., n\}\$ and its subsets. For example, for \$n = 3\$, we have $$\emptyset, \{1\}, \{2\}, \{3\}, \{1,2\}, \{1,3\}, \{2,3\}, \{1,2,3\}$$ If we take the sum of these subsets, we can then ask ourselves the following ques...
This challenge is about implementing Shm-reduplication, originating in Yiddish, where one takes a word, duplicates it, and replaces the first syllable in the second word with "Shm" in order to indicate that one does not care. Some examples include: "Isn't the baby cute?", "Eh, baby shmaby" "Come buy from my store, we ...
Characters in strings are sometimes represented as their ASCII hexadecimal codes. Printable characters have two hex digits in their representation. Swapping those digits leads to another character, which will be our output. The table of relevant character codes can be found on Wikipedia. Details Take a string as input...
The sequence of Fibonacci numbers is defined as follows: \$ F_0 = 0 \\ F_1 = 1 \\ F_n = F_{n-1} + F_{n-2} \$ Given a Fibonacci number, return the previous Fibonacci number in the sequence. You do not need to handle the inputs \$ 0 \$ or \$ 1 \$, nor any non-Fibonacci numbers. Errors as a result of floating point inaccu...
We can arrange the positive integers like this: 1_| 2 | 5 | 10 4___3_| 6 | 11 9___8___7_| 12 16 15 14 13 That is, in L-shaped brackets expanding down and right infinitely. Then, we can read it off with the antidiagonals: 1 2 5 10 / / / 4 3 6 11 / / / 9 8 7 12 / / / 16 15 14 13 For the above, we rea...
In this question I asked you to determine if a run ascending list could be made. It was code-golf so naturally most the answers are very slow. But what if we want it to be fast. In this challenge I ask you to solve the same task except your goal will be to minimize asymptotic time complexity. Here's the challenge re...
You are given 100 arrays/sets of 5-8 numbers between 1-20. If you combine all the arrays you will always get at least one of each number (1-20), so don't worry about an "unsolvable" case. The goal is to find the combination of arrays that minimizes duplicate numbers while still getting one of each number from 1-20. Her...
PROBLEM For a list of numbers, list: Find the lowest possible integer, x, which is optimally close to the whole number even-harmonics of the values in list. list has a length of n, and all of the values in list are <= 2000 x has a precision of 1.0 (integers only), and must be a value in the range [20, 100] An even-har...