instruction
stringlengths
34
53.1k
Uilta is a minority tungusic language spoken in the far east of Russia. A neat thing about Uilta is that it has pitch accent which can be predicted by a computer program. In this challenge we are going to take Uilta a word and determine where the accent peak is. Let me explain how this can be done. Phonemes The first ...
Whyte Notation is a classification method mainly for steam locomotive, that classifies by wheel arrangement. On a steam locomotive ( we're only focusing on non articulated locomotives here ), the wheels are generally disposed like this : you have a specific number of leading wheels, then a specific number of driver whe...
Given a positive integer n, randomly output n non negative integers that sum to one hundred. n will be at most 200. The output should be present as a list of integers (not sorted). Your random sample should be uniformly sampled from all lists of n non negative integers that sum to one hundred. Your code should run in a...
Intro Imagine a list of elements and their outcomes when some non-commutative function is applied to them. For example, we will use the elements Rock, Paper, and Scissors, the outcomes Win, Lose, and Tie, and an operator * such that X*Y = what would happen if you played X against Y As a list, you might write it this wa...
Inspired/mostly copied but I don't think it's a dupe. Also Inspired. In this challenge, you will create polyglots that include all languages from previous answers, and another language which you won't share and others must guess. The first language prints 1, the second prints 2, etcetera. For example, if the first answ...
The Narrative You are a bad musician. You never bothered to learn how to count rhythms. To remedy this shortcoming, you decide to write a program that will tell you how to count in any given time signature. You are still a bad musician, but you can at least pretend that you can count rhythms. The Objective Given a time...
This challenge requires integration with C, so you can stop reading if you're not interested. Matrix multiplication is a simple operation, but the performance depends a lot on how efficiently the code is written. Let's compute m = x * y. The following code is the implementation of the textbook algorithm. for (int i = 0...
The "standard" polyhedral game dice have 4, 6, 8, 10, 12 and 20 sides. (Yes, I know that there are two 10-sided dice which together make a d100, but we're ignoring that right now.) If I want to generate a random number between 1 and \$n\$ where \$n\$ is not one of those sides, I have a couple of options. One option is ...
Your challenge, should you choose to accept it, is to take as input: A program in DirectionLang (as an ASCII string consisting of DirectionLang instructions) A list of pairs of integers, henceforth known as the pretty places. This list may be taken in any reasonable format. You should then output a truthy value if th...
Given a word, decide if it is an ambigram. When rotated: b > q d > p l > l n > u o > o p > d q > b s > s u > n x > x z > z Assume only lowercase letters as input. Test input: this, another, lll, lol, dad, dab, dap, wow, ooi, lollpopdodllol, Ones That Should Return Truthy Values: lll, lol, lollpopdodllol, Note tha...
Problem Assume you have a single 7-segment display without a decimal point, so 7 "lines" that can be labelled A through G as seen here. This display will only show the numbers from 0 to 9 as usual, like so: Any time this display changes from one number to another, some of its lights will have to change their state fr...
Take as input an integer in any reasonable format. Then, output all the proper sub-strings of the base-10 digits of that integer that are powers of two, in any reasonable format. Test cases 10230 -> [1, 2] 13248 -> [32, 1, 2, 4, 8] 333 -> [] 331 -> [1] 32 -> [2] # As 32 is not a proper sub-string, since it is the whole...
J-uby is the Language of the Month for June 2022, so I'm looking for tips for golfing in it. As usual, please post one tip per answer, and avoid general tips such as "remove whitespace" or "avoid comments".
An alternating permutation is a permutation of the first \$ n \$ integers \$ \{ 1 ... n \} \$, such that adjacent pairs of values in the permutation alternate between increasing and decreasing (or vice versa). Equivalently, it is a permutation where there are no "runs" of continuously increasing or decreasing values wi...
Introduction Time is a really simple concept. Seconds pass, one after the other, all the same. But humans love making it hard. This Stackoverflow question has gathered many answers and even though they are surprisingly long and complex, most of them will still fail for certain inputs. Can you format a number of seconds...
Challenge In this challenge, you have to fill an \$M\$ x \$N\$ rectangle grid with the most \$A\$ x \$B\$ rectangle pieces possible. Requirements: The sizes of the \$M\$ x \$N\$ rectangle grid is always bigger than the sizes of the \$A\$ x \$B\$ rectangle pieces. In other words, \$min(M, N) ≥ max(A, B)\$ You can freel...
Robber's challenge This cops-and-robbers challenge challenges the Cop to write a non-empty program that, when run, produces some non-empty output in language A, and, when reversed, produces some non-empty output in language B. The program may produce any output to STDERR when run in either language, but may not take in...
Cops' challenge This cops-and-robbers challenge challenges the Cop to write a non-empty program that, when run, produces some non-empty output in language A, and, when reversed, produces some non-empty output in language B. The program may produce any output to STDERR when run in either language, but may not take input...
For this challenge a "binary tree" is a rooted tree where each node has 0 children (leaf) or 2. The children of a node are unordered, meaning that while you might draw the tree with left and right children there isn't a distinction between them and mirroring the tree or a sub-tree does not produce a new tree. In this...
aka. implement an easier version of 05ab1e's canvas element. Description The canvas element is used to draw ASCII lines on the screen. The (easier version of the) canvas element takes a list of integers and returns a multi-line string (or a list of strings). The integers map to the following directions: 7 0 1 ↖ ↑...
Lists can contain lists and we have nested lists. But we don't like nested lists and want to flatten them. By flattening I mean create a list which does not contain any list, but elements of lists it contained before. I'll explain it more. Input An arbitrary size list which has the below properties: it can contain int...
Given an integer \$N\$ consider a permutation \$p=p_1,p_2,p_3,\ldots\$ of \$1,\ldots,N-1\$. Let \$P = p_1 , p_1+p_2 \bmod N, p_1+p_2+p_3 \bmod N, \ldots\$ be its prefix sums modulo \$N\$. Sometimes \$P\$ will be a permutation of \$1,\ldots,N-1\$ itself. For example, \$N=4: p=3,2,1 \rightarrow P=3,1,2\$ Negative example...
The Mongolian language has "vowel harmony". In short the vowel harmony means that certain vowels are not allowed to be placed next to each other in a word. This means that suffixes of words have to care about the vowels present in the words they attach to and need to resolve to a vowel that matches the harmony of the...
Related, but not dupe. Challenge A list of integers \$a_1, a_2, a_3, \dots, a_n\$ (\$ n ≥ 1 \$) is Fibonacci-like if \$a_i = a_{i-1} + a_{i-2}\$ for every \$i > 2\$. Note that every list that contains only 1 or 2 integers is Fibonacci-like. For example, \$[1]\$, \$[6, 9]\$, \$[6, -4, 2, -2, 0, -2, -2, -4, -6, -10]\$, ...
Given a list of positive integers such as [69, 420], your challenge is to generate the sequence of numbers that can be formed by concatenating numbers from the above set, in ascending numerical order. For example, with [69, 420] the sequence begins: 69 420 6969 42069 69420 420420 Note that elements of the sequence sho...
I have a set of colored plastic cups. They come in four colors: green, yellow, pink, and blue. When I put them on my shelf, I like to stack them in a certain pattern. Your job is, given a list of any number of four distinct values (to represent the four cup colors), output a visual representation of how I would stack t...
Write a program or function which takes a string of text as input and outputs the number of non-alphabetical characters in it (standard I/O rules apply). A non-alphabetical character is any character not appearing in this string: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ In terms of ASCII character codes, t...
Today, you're going to be writing Polish. No, not Polish notation—Polish, the actual language spoken in Poland. Given a number and a noun, output a Polish sentence telling me that there are that many of that thing, using the appropriate template below. The input consists of an integer in the range from 0 to 200, and a ...
Parenthetical names Your challenge is to build a program that puts parentheses around the 'title' part of names. For example, Sonic the Hedgehog is converted to Sonic (the Hedgehog). Rules: Around every the that passes the following rules, an opening parentheses will be added before the the and a corresponding closing...
Given a non-negative integer n, print the result of P(P(...P({}))), where the number of P's is n (P is the power set function). 0 => {} 1 => P({}) 2 => P(P({})) 3 => P(P(P({}))) n => P(f(n-1)) input result 0 {} 1 {{}} 2 {{},{{}}} 3 {{},{{}},{{{}}},{{},{{}}}} ... The result should only contai...
This is a cross-post of a problem I posted to anarchy golf: http://golf.shinh.org/p.rb?tails Given two integers \$ n \$ and \$ k \$ \$ (0 \le k \le n) \$, count the number of combinations of \$ n \$ coin tosses with at least \$ k \$ tails in a row. For example, if \$ n = 3 \$ and \$ k = 2 \$, the answer is \$ 3 \$: HHH...
In this king-of-the-hill challenge, you will program a bot, consisting of a python function of the form def BOTNAME(info, me, round): pass # ... main body Specifically, the function must run in python3.9. Each bot will be entered into the contest 10 times. The arguments it take in are info, me, round. The three ar...
Let \$Z\$ be either the integers, the positive integers, or the non-zero integers; pick whatever's convenient. Give two functions \$f\$ and \$g\$, each \$Z \to Z\$, such that: \$f(g(a)) = g(f(a))\$, for infinitely many integers \$a\$, and \$f(g(b)) \ne g(f(b))\$, for infinitely many integers \$b\$. Rules Many of the ...
Given a multi-dimensional rectangular array of non-negative integers, pad it with the minimal number of zeroes so that only zeroes are "touching the edges" of the array, in every dimension. The output must remain rectangular, have the same number of dimensions as the input, and be no smaller than the input. Example For...
In this challenge you will be simulating a frog jumping from lily-pad to lily-pad in a pond. A frog's jump distance is uniquely determined by the size of the lily pad it jumps from. So for example there are lily-pads that let a frog jump 1 unit, lily-pads that let a frog jump 2 units etc. A frog can never jump more ...
Introduction A circle-tangent polynomial is a polynomial of degree \$N\ge3\$ or above that is tangent to the unit circle from inside at all of its N-1 intersection points. The two tails that exits the circle are considered tangent at their intersection points from inside as well. You may consider such polynomials are w...
Say I have a ragged list, like: [ [1, 2], [3, [4, 5] ] ] And I want to iterate over each item and delete it one-by-one. However, I don't know the structure of the list. So, I have to iterate over the list, with the following algorithm: Look at the first item of the list. If it's a list, concatenate it to t...
Plot contrivance You wake up to find that something has gone horribly wrong! Your time machine has malfunctioned and you are lost sometime between June 2022 and October 1991. You check the computer that you keep on the desk to see what time it is, but alas the positron interference from your quantum undetangler has fr...
This is my 12th question, so I thought of this idea. Goal: Output 12, with any preceding or trailing whitespace permitted In as many languages as possible (where different versions or flags count as the same language) Without using any numbers The criteria for a valid programming language are the same as those of The ...
Let us consider the following representation of the periodic table. __________________________________________________________________________ | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |--------------------------------------------------------------------------| |1| 1...
Given a string like [[[],[[]]],[]], made of only commas and square brackets, your challenge is to determine whether it represents a list. A list is either: [], the empty list At least one list, joined with commas and wrapped in square brackets. You may use any three characters instead of [,]. You may output as: Any ...
In set theory, a set is an unordered group of unique elements. A pure set is either the empty set \$\{\}\$ or a set containing only pure sets, like \$\{\{\},\{\{\}\}\}\$. Your challenge is to write a program that enumerates all pure sets, in some order of your choice. Standard sequence rules apply - you may: Output al...
Unsurprisingly, fibonacci primes are primes that are also Fibonacci numbers. There are currently 34 known Fibonacci primes and an additional 15 probable Fibonacci primes. For the purpose of this challenge, the Fibonacci numbers are the sequence \$F_n\$ defined as \$F_1 = 1\$, \$F_2 = 1\$, and \$F_n = F_{n-1} + F_{n-2}\...
A binary max heap is a rooted tree with integer labeled nodes such that: No node has more than 2 children. The label of every node is greater than all of its children. We say a sequence of integers is heapable if there exists a binary max heap, whose labels are the sequence's elements, such that if \$p\$ is the paren...
Inspired by wezl. Your challenge is to take words (sequences of [a-zA-Z]) and truncate them to length 3. For example, never gonna give you up would become nev gon giv you up. Words will not necessarly be delimited by spaces - for example, youtube.com/watch?v=dQw4w9WgXcQ will become you.com/wat?v=dQw4w9WgX. Input will b...
Given a multidimensional, rectangular array and a list of dimensions, such as: [ [1, 2], [3, 4] ] [3, 4] Your challenge is to extend the matrix to the dimensions given in the list. To extend an array to a length in a single direction, simply repeat its elements; for example, if we want to extend [1, 2, 3] to length...
To increase data safety at our company, we are planning to start using Gray code numbers (where successive values differ by only one bit) instead of classical binary ones. Please help us to make a program that converts numbers to Gray code (single number to single number), but the program needs to be safe as well. This...
Background In the online graphing calculator Desmos, there is a certain shape that appears in the lower left portion of the graph in many high detail graphs, which the Desmos community has dubbed "Bernard". You can see an example of it in this graph and an isolated version of it in this graph. This shape is a consequen...
There are a bunch of different casing conventions, like camelCase, PascalCase, snake_case etc. It's annoying juggling all of these, so instead of choosing one like a sensible person, why not cursedly mix all of them together? Your challenge is to, given a list of words (only containing lowercase letters), convert them ...
I have recently been on a quest to create really really slow sorting algorithms that make Bogosort seem like it is the best. The task is simple: Sort an array of integers in as long average time as possible, with the average Bachmann–Landau notation begin as high as possible, while keeping the best case performance fas...
Given \$a\$ and \$b\$, both odd \$n+1\$-bit integers, compute \$a/b\$ to a precision of \$n+1\$ bits in the 2-adic integers. That is, compute \$c\$ such that \$a = bc\, (\mathop{\rm mod} 2^{n+1})\$. \$n\$ should be your language's native integer size, or if native integers are bigints, take it as a parameter. If your l...
This is a simpler variant of my previous challenge Don't touch the walls!, as suggested by Jonah. Given a multi-dimensional rectangular array of integers between 0 and 9, output all the elements which are "touching the edges". Output is very flexible: it can be in any order, and may be flattened or partially nested, bu...
Given a decimal integer n as input, output the smallest (in terms of absolute value) decimal integer m such that the absolute value of n-m is a binary integer (composed only of 1s and 0s). n and m can be any integer, positive or negative. Example Let n = 702. The closest binary integer is 1000 = |702 - (-298)|, so m = ...
In this challenge you will receive a list of non-negative integers. Each one represents a mushroom with a cap of that radius centered at that location. So a 0 means that it occupies no space at all, a 1 means that its cap only occupies space above it, a 2 means it occupies space above it and one unit to the left and ...
For this challenge, we will define the "complement" of a list of integers A as being any list B such that the union of A and B is a list of consecutive integers with no repeats. In other words, B is the complement of A if B has all of the integers between the minimum and maximum of A which are missing from A, and B ha...
Related. Given a list of 3 or more positive integers, remove every number X for which there is another number Y in the list and the average of X and Y is also in the list. In other words, if X, Y, and the average of X and Y are all in the input, neither X nor Y should appear in the output. Note: Pairs of numbers are no...
So I have the situation where I have one boolean value a and, if that one is true and b<c I want it to end up as true, if a is false and b>c I want it to resolve as true as well. If b=c I want it to be always false, no matter the value b and c are both numbers. My best approach so far is a?b<c:b>c or maybe b^c^a^b<c. I...
In this challenge you will receive a list of pairs of non-negative integers representing a mushroom forest. Each pair represents a mushroom whose center is at that horizontal coordinate. The only part of the mushroom we care about is the cap (the flat bit at the top). The first integer in each pair represents which ro...
Say I have a grid with some obstacles: ---- | X | | | |XX | | | ---- I can fill this with numbers, as distance from the top left corner. But, because there are obstacles in the way some cells will take further to reach than a straight line: ---- |01X5| |1234| |XX45| |7656| ---- This can be done through f...
In the hovertext of this xkcd: There's an "encoding" based on replacing runs of roman numerals with their sums. To do this: Find all runs of at least 1 roman numeral (IVXLCDM) Replace them with their sums, as numbers The Roman Numerals are IVXLCDM, corresponding respectively to 1, 5, 10, 50, 100, 500, 1000. You shou...
The Fibonacci polynomials are a polynomial sequence defined as: \$F_0(x) = 0\$ \$F_1(x) = 1\$ \$F_n(x) = x F_{n-1}(x) + F_{n-2}(x)\$ The first few Fibonacci polynomials are: \$F_0(x) = 0\$ \$F_1(x) = 1\$ \$F_2(x) = x\$ \$F_3(x) = x^2 + 1\$ \$F_4(x) = x^3 + 2x\$ \$F_5(x) = x^4 + 3x^2 + 1\$ When you evaluate the Fibo...
For this challenge, a word is defined as a string of letters, separated by spaces. Given a string of words, and an integer i representing an index into that string, output the whole word which contains the character at index i. For example (using 0-based indexing), with the string code golf, and the index 6, the 7th ch...
In this challenge we considered a frog hopping around a lily pond. To recap the lily pond was represented as a finite list of positive integers. The frog can only jump forward or backwards by a distance equal to the number at its current location. So for example: [2, 3, 1, 4, 1] Here the frog is on a 1 so i...
Related Sometimes when I use my microwave, I do a little trolling and enter times such as 2:90 instead of 3:30 because they end up being the same time anyway. The microwave happily accepts this and starts counting down from 2:90, displaying times like 2:86 and 2:69 until it gets back to a stage where it can count down...
Write the shortest program or function that mimics the addition in this XKCD strip: Input Two positive decimal integers containing only the digits 150. Output The positive decimal integer result of adding the two inputs together in the manner shown above. This output should also only have the digits 150. Specification...
In this challenge, you'll print out the SBCS of Jelly, a popular golfing language. Its code page looks like this: _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F 0_ ¡ ¢ £ ¤ ¥ ¦ © ¬ ® µ ½ ¿ € Æ Ç Ð 1_ Ñ × Ø Œ Þ ß æ ç ð ı ȷ ñ ÷ ø œ þ 2_   ! " # $ % & ' ( ) * + , - . / 3_ 0 1 2 3 4 5 6 7 8 9 : ; < = > ? 4...
FizzBuzz is where a range of positive integers is taken, and numbers divisible by 3 are replaced with "Fizz", divisible by 5 with "Buzz" and divisible by 15 with "FizzBuzz". I've got some FizzBuzz output here. Unfortunately, it's been shuffled: 4 Fizz Fizz Buzz 2 A bit of logic shows us that this is 2, Fizz, 4, Buzz, ...
Lambda calculus is a system of computation based on single-argument functions; everything in it is such a function. Due to this functional nature, juxtaposition is commonly used to denote function application, grouped from left to right. For example, \$(f g) h=f g h\$ denotes what would conventionally be written \$(f(g...
There's a payment machine for laundry in my building which does a few frustrating things. The ones relevant to this challenge are: It doesn't make change. So if you pay over the amount then you are not getting that over-payment back. It doesn't accept coins smaller than 20c. Meaning the only coins it accepts are 20c...
Given a string containing a sequence of ascending consecutive positive integers, but with no separators (such as 7891011), output a list of the separated integers. For that example, the output should be [7, 8, 9, 10, 11]. To disambiguate the possible outputs, we add the restriction that the output must always have at l...
A twin of this. FizzBuzz is where a range of positive integers is taken, and numbers divisible by 3 are replaced with "Fizz", divisible by 5 with "Buzz" and divisible by 15 with "FizzBuzz". For example, FizzBuzz from 1 to 10 is 1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz. Your challenge is to, given a list of Fizzes, B...
Goal You have to print the ASCII printable characters' code page (0x20-0x7E). The output should look like this: !"#$%&'()*+,-./ 0123456789:;<=>? @ABCDEFGHIJKLMNO PQRSTUVWXYZ[\]^_ `abcdefghijklmno pqrstuvwxyz{|}~ Rules The output should be exactly like shown above, but trailing whitespace is OK. No builtins that triv...
A pristine program is a program that does not have any errors itself but will error if you modify it by removing any contiguous substring other than the entire program. A crystalline program is sort of the opposite. It is a program which doesn't have any errors itself but will error if you modify it by adding any 1 cha...
This challenge will be based on an R language trivia: every release is named and it's a reference to Peanuts comic strips (see here and here). Task Given a release name, output its number. For reference, use the below list: Great Pumpkin 2.14.0 December Snowflakes 2.14.1 Gift-Getting Season 2.14....
In these previous challenges[1][2] I've been dealing with "mushroom forests". To help with these I draw little diagrams of the forests to help. In this challenge we are going to reverse engineer the data from these diagrams. To recap ha! mushroom forests are a list of pairs of non-negative integers. Each pair repres...
Given n, k, and p, find the probability that a weighted coin with probability p of heads will flip heads at least k times in a row in n flips, correct to 3 decimal digits after decimal point (changed from 8 because I don't know how to estimate the accuracy of double computation for this (was using arbitrary precision f...
Background The monkeys need help organizing their defense and have asked you, Benjamin the code monkey, to create a program that will list all tower upgrade options. Each tower has three unique upgrade "paths", each having a tier represented by a number between 0 and 5 inclusive, 0 meaning no upgrade. Up to two paths m...
Challenge Create the image of a progress pride flag. Output Dimensions Rules Your program must create the image and not just load it from a website The colours can be just your language's default if it is very difficult / impossible to load RGB values, else they should be: red: (255,0,0), orange: (255,140,0), yello...
Given a list \$X\$ of 2 or more integers, output whether, for all \$n\$ such that \$0 \leq n < length(X)-2\$, there exists a pair of equal integers in \$X\$ separated by exactly \$n\$ elements. In other words: output whether, for all overlapping slices/windows of the input, there exists at least one slice/window of eac...
This is a repost of this challenge Challenge There is an old, popular riddle: Find an English word with 8 letters that, taken away one letter, creates a new valid word. Repeat that until there are no letters left. Example solution: starting staring string sting sing sin in I Your task is to write a program, which t...
We all know that any positive integer can be represented as the sum of powers of two. This is how binary representations work. However there's not just one way to do this. The canonical method, used in binary representations represents it as the sum of unique powers of two. For example \$5=2^0+2^2\$. However since \...
I came across this picture the other day: (Credit to Josep M Batlle I Ferrer) Your job is to generate this picture. This graph is generated by repeatedly applying newton's method to the graph of: $$f(x)=\cosh(x)-1$$ In other words, repeatedly apply the following function to every point till the rectangular distance is...
You want to write your English essay. However, all characters on your keyboard broke other than the arrow keys and the enter key. You want to find out how to place the characters so you can write your essay with the least movement. Formally, you have to assign to each character of !"$%&'()+,-./0123456789:;<=?[]`abcdef...
Background In programming, there is a recursive algorithm called binary exponentiation, which allows for large integer powers to be calculated in a faster way. Given a non-zero base \$x\$ and a non-negative exponent \$n\$, the algorithm goes something like this (based on the example code from Wikipedia): Function exp_b...
Background (feel free to skip) Ordinals are the abstract representation of well-orders. A well-order of a set is a total order, which basically means that every element in the set can be compared against any other element in the set, and one of them is either smaller or larger. Also there are no cycles. The crucial dif...
Given a matrix of non-negative numbers (of arbitrary dimension) and a number, get all multi-dimensional indices of the number in that list. For example, let's say we have the list [[0,1,0],[1,0,0]] and the number 1. In the first list, we see one 1 at the second index. If we were using one-based indices, this would be i...
Find a bijective function which maps integers to arbitrarily large tuples of integers. Given the input \$n\$, output the tuple it matches to. Edit: The empty tuple is included in the mapping.
I noticed that it seems nobody has posted a non-ASCII (related) USA flag challenge yet, so what better time than the 4th of July? The Challenge Draw the current (as of 2022) flag of the United States of America. Here is the flag: Specifications Hoist (height) of the flag: A = 1.0 Fly (width) of the flag: B = 1.9 Hoi...
Inspired by this accidental misspelling If you could read the title, then you already know what the challenge is about. If not, then I'll tell you. Easy: simply take each word (single space delimited), and swap the positions of the first two letters. You may assume that the input will contain only lowercase ASCII let...
Background When searches return many pages of results, GitHub avoids cluttering their UI by eliding page links. Instead, their UI lets you select: Pages at the beginning of the results. Pages near the current page. Pages at the end of the results. In this way, no more than 11 page links are ever displayed at one tim...
Task In this challenge, your task is to write a program or function which takes an array of paths with an additional boolean indicating it is a file or directory and outputs a file/directory tree in any reasonable format. Remarks Some directories can end with a forward slash ("/") but this is not always the case A par...
In this challenge you will be given a list of positive integers which represents some range of integers which has been truncated for display. Your job is to find the missing bits and insert ellipses to show that that part has been truncated. The input will always be strictly ascending and if two consecutive values dif...
Implement a function or program which raises x to the power of y. Inputs are 16-bit signed integers. That is, both are in the range [-32768, 32767]. The output should be in the same range. I chose this range because it should make it possible to do exhaustive testing to ensure all edge-cases are covered. If the output ...
Greeklish, a portmanteau of the words Greek and English, is a way of writing modern Greek using only ASCII characters. This informal way of writing was extensively used in older applications / web forums that did not support Unicode, and were not programmed to show Greek characters. Nowadays, its use is minimized due t...
If you place the positive integers together and read each set of two adjacent digits at the same time, you get: (A136414) 12, 23, 34, 45, 56, 67, 78, 89, 91, 10, 1, 11, ... However, if you squash that sequence again: 12, 22, 23, 33, 34, 44, 45, 55, 56, 66, 67, 77, 78, 88, 89, 99, 91, 11, 10, 1, 11, 11 and so on. Your...
Given a list of positive integers as input you are to determine if there is a way to pair up the elements such that: All but one element is in a pair No element is in more than one pair Every pair is of equal elements No two pairs have elements separated by the same distance in the original list For example if the in...
Background I was working on a system where for convenience (not security) people could use four digit codes to identify themselves. I figured this is something that may actually be useful in many real cases, yet is well enough defined that it could make a nice challenge! Explanation of pin codes and typo resistant sets...
Background On a Rubik's cube there are 54 moves that you can execute, for example, turn the right face anti-clockwise, or rotate the top face and the horizontal slice twice. To notate any move, each face (or slice) has a letter assigned to it. To move that face clockwise once, you just write the letter on its own, so f...
Background A backronym is an acronym that was formed from an existing word. For example, spam is actually named after the canned meat product as used in the Monty Python sketch, but can be interpreted as "stupid pointless annoying mail". Challenge Given a string a, and a word t, capitalise the correct letters of the w...
Warning: Contains minor Deltarune Chapter 1 Spoilers Within the Forest section of the first chapter of Deltarune, there are a few puzzles that consist of entering playing-card suits in a certain order to move to the next section. Below is an example of such a puzzle: The way to solve the puzzle is to do any of the ...