instruction
stringlengths
34
53.1k
I've been enslaved in a quine factory. The other workers and I can't communicate with the outside world, we can only slave away making quines all day. The masters will reject any work that isn't a proper quine. I'll have to put messages into the quines I make to let people know we're trapped here. The Challenge Help us...
Given an array of numbers with length >=3 and length % 3 == 0 [1, 2, 3, 4, ...] You will split it in sub-arrays of length 3 [[1, 2, 3], [4, 5, ...], [... And return an array with [0] => The amount of cases in the sub-array where all numbers are equal [1] => In case all numbers in sub-array are not equal, the amount ...
Given two strings of letters, transfer the capitalization pattern of each string onto the other one. Fewest bytes wins. Input: CodeGolf xxPPCGxx Output: coDEGOlf XxppCgxx Both strings will be equal-length and nonempty, with only letters a..z and A..Z. You may output the two resulting strings in either order rel...
Given a list of strings, replace each string by one of its non-empty substrings which is not a substring of any of the other strings in the list and as short as possible. Example Given the list ["hello","hallo","hola"], "hello" should be replaced by just "e" as this substring is not contained in "hallo" and "hola" and ...
Minesweeper is a puzzle game where mines are hidden around a board of nondescript tiles with the goal of identifying the location of all mines. Clicking on a mine loses the game, but clicking on any other tile will reveal a number from 0-8 which signifies how many mines directly surround it. Given a number, you must di...
Create a function which takes a polynomial equation, a value for x and returns the result of the operation. Example: given 4x^2+2x-5 and x=3 output 37. This is the result of 4(3)^2+2(3)-5 Assume all polynomials are valid Polynomial format will always be coefficient(variable)^exponent => 4x^2 except : When exponent ...
You may have seen Jacob's Ladder in children's science museums. If you're not familiar with what they look like, there are several images and video examples on the Wikimedia Commons. The challenge today is to create an animated ASCII version of the electrical gadget. In the end, it should look something like this: La...
Define f(a,b) := a if b=1; a^f(a,b-1) if b>1 (Tetration, where ^ means power) for positive integers a and b, given four positive integers a,b,c,d, compare f(a,b) and f(c,d). Your program should output three constant values to mean "greater", "less" and "equal". Samples: a b c d f(a,b) output f(c,d) 3 2 2 3 27 > ...
The challenge Create a function which takes an array of numbers and subtract from each element the lowest element in the array that has not yet been subtracted from another. After using the lowest value, It can not be used again. Numbers in the array are decimal numbers, and not necessarily integers. Example: Input: ...
Challenge Given a sequence of numbers, create a function which returns the sequence steps. Assume a sequence will be N >= 3 Sequence will repeat it steps at least once Sequence will only contain natural numbers Your function or program should return the shortest possible sequence of steps Example: Input: [1, 2, 3, 5,...
Challenge : Count the number of ones 1 in the binary representation of all number between a range. Input : Two non-decimal positive integers Output : The sum of all the 1s in the range between the two numbers. Example : 4 , 7 ---> 8 4 = 100 (adds one) = 1 5 = 101 (adds two) = 3 6 = 110 (adds two) = 5...
We define the function g as g(n) = n XOR (n * 2) for any integer n > 0. Given x > 0, find the smallest integer y > 0 such that gk(y) = x for some k > 0. Example x = 549 549 = 483 XOR (483 * 2) (as binary: 1000100101 = 111100011 XOR 1111000110) 483 = 161 XOR (161 * 2) (as binary: 111100011 = 10100001 XOR 101...
So, I have an array ['a', 42, 'b', 42, 'a'] I want to alert users to the fact that 42 and 'a' appear in it twice. some_function(['a', 42, 'b', 42, 'a']) should return ['a', 42] Write some code to extract the duplicates from an array. It should accept an array as input. The array can have multiple types of object. ...
Input Take a list of values xi each paired with a key yi. [(x1, y1), (x2, y2), ...] Output Return a list L containing only values from the set {xi}. The length of L must be equal to the number of unique keys k in the set {yi}. For each unique key k there must be a value from {xi} that has key k. Details Standard l...
Task Given a number between 0 and 1 and another integer, print the approximated value of the first number rounded off to the specified number of digits given by the second integer. For example, if the input is 0.3212312312 , 2 then the output is: 0.32 Rules The number of digits after the dot should always equal the s...
This is a Cops and Robbers challenge. For the Robbers' thread, go here. The Cops have three tasks. 1) Pick a sequence from the OEIS. 2) Pick a language (this is suggested to be a golflang, but doesn't have to be) that, when given input n, outputs A(n) (where A(n) is the sequence chosen) using all usual code-golf rule...
This is a Cops and Robbers challenge. For the Cops' thread, go here. The Cops have three tasks. 1) Pick a sequence from the OEIS. 2) Pick a language (this is suggested to be a golflang, but doesn't have to be) that, when given input n, outputs A(n) (where A(n) is the sequence chosen) using all usual code-golf rules. ...
Inspiration. Consider a list l, consisting of numbers. Define a block operation at index i on the list l to be the act of moving 3 consecutive elements starting from i in l to the end. Example: l, i (1-indexing) -> l (after applying block operation at index i) [1,2,3,4,5], 1 -> [4,5,1,2,3] [1,2,3,4,5,6,7], 3 -> [1,2,6,...
Input A string of printable ASCII characters, for example: This is an example string. Output For every consonant (BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz) that is not followed by a vowel (AEIOUaeiou) add the last vowel before it, in lowercase. Consonants before the first vowel are left as-is: Thisi isi ana examapal...
Background Three years ago, this guy Tom Murphy got it into his head to extend the idea of a portmanteau to all words in a language and called this a portmantout (portmanteau plus tout [French for all]). Defining English as a list of 108,709 words, he managed to find a sequence of 611,820 letters with the following two...
I like to think of a 10-adic number as a number that goes infinitely to the left, or an integer modulo a very very large power of 10. Things carry infinitely to the left and vanish. To see what I mean, note that ...6667 * 3 = 1 in the 10-adic land, since the "2" that carries to the left goes to infinity. Addition and m...
Challenge : Inspired by Alphabet Position Finder Given an string and one of two possible mathematical operator (+ or -) as input, your task is to return the operation of each alphabet position from the string. Example : Input: "Hello World", "+" => "Hello World" = [8, 5, 12, 12, 15, 23, 15, 18, 12, 4] (converted to the...
You will be given a string s. It is guaranteed that the string has equal and at least one [s and ]s. It is also guaranteed that the brackets are balanced. The string can also have other characters. The objective is to output/return a list of tuples or a list of lists containing indices of each [ and ] pair. note: The s...
Challenge : Check : if there are exactly n exclamation marks ! between every pair and whether the sum of each pair equals to 10. Input : A string of arbitary length. The number of exclamation marks to check for Output : if there are exactly n exclamation marks between each pair, return truthy value, otherwise fal...
I forgot towel day Sandbox link PHP script for both examples (error, formatting the string) Corrected php script, the input is self explanatory PHP script with more input comment/uncomment $argv to see different results As you may know, May 25 is well known as Towel Day, because of the many uses a towel can have. A si...
One day, I saw the challenge to multiply two strings and I thought I might be able to do one better. That challenge was fake. It was elementwise maximum. It was not real multiplication. So I set out to make something real. Real division between two strings. I quickly realized that this would make an amazing challenge,...
You have come across an old Indian manuscript, one that describes mounds of buried treasure. The manuscript also tells you the location of the treasure, except that some crucial numbers have been encoded indirectly into the text. You figure out that the text uses a 'Kaadi' system, a restricted subset of the more common...
Imagine a text file where each csv record may have different numbers of fields. The task is to write code to output how many fields there are in each record of the file. You can assume there is no header line in the file and can read in from a file or standard input, as you choose. You can assume a version of rfc418...
Your task is to decipher a non-empty string consisting of printable ASCII characters in the range [32..126]. Reading the string character per character: each time you encounter a letter in lowercase, associate it with the next letter in uppercase, starting with 'A' each time you encounter a letter in uppercase, replac...
A little known fact is that if you turn on enough language extensions (ghc) Haskell becomes a dynamically typed interpreted language! For example the following program implements addition. {-# Language MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, UndecidableInstances #-} data Zero data Succ a cl...
Let's define a simple language that operates on a single 8-bit value. It defines three bitwise operations (code explanation assumes 8-bit value variable): ! Negate the least significant bit (value ^= 1) < Wrapping left-shift (value = value << 1 | value >> 7) > wrapping right-shift (value = value >> 1 | value << 7) In...
Background Nonogram, also known as Picross or Griddlers, is a puzzle where the objective is to determine if each cell on the 2D grid should be colored or left blank, using the numbers of consecutive colored cells on each line. The following is an example Nonogram puzzle with solution. The problem is, some commercial N...
Introduction I've seen throughout the code-golf challenges several simple tasks involving JSON, such as interpreting JSON strings with RegExs, and almost every other manipulation I could think of. In a binding for AppleScript that I was using for a Node project, I noticed that objects would be returned in a strange wa...
Here's an array representing a standard deck of cards, including two Jokers. [ "AS", "2S", "3S", "4S", "5S", "6S", "7S", "8S", "9S", "10S", "JS", "QS", "KS", "AD", "2D", "3D", "4D", "5D", "6D", "7D", "8D", "9D", "10D", "JD", "QD", "KD", "AH", "2H", "3H", "4H", "5H", "6H", "7H", "8H", "9H", "10H", "JH", "QH", "K...
Introduction: The best options for the glass of your house will: 1. Let through as little heat as possible in both directions (insulation-value Ug). (2. Let through as much sunbeams as possible from the outside to the inside.) (3. Let through as much light as possible from the outside to the inside.) We only care about...
Taken from StackOverflow Question Challenge Given an encoded string in format n[s] where n is the amount of times s will be repeated, your task is to output the corresponding decoded string. n will always be a positive number s can not contain empty spaces strings only contains letters from the alphabet s length can b...
This challenge is really simple (and a precursor to a more difficult one!). Given an array of resource accesses (simply denoted by nonnegative integers) and a parameter n, return the number of cache misses it would have assuming our cache has capacity n and uses a first-in-first-out (FIFO) ejection scheme when it is fu...
This is inspired by an 05AB1E answer by Magic Octupus Urn. Given two arguments, a positive integer and a string/list of characters: Translate the number to base-n, where n is the length of the string. For each character, replace every appearance of the index of that character in the base-n number with that character. ...
Introduction In a private chat, a friend of mine apparently recently stumbled across a security system which has the following two restrictions on its valid pins: Each digit must be unique (that is "1" may only appear once) The order of the digits doesn't matter ("1234"="4321") So to illustrate how bad this padlock s...
Here's a programming puzzle for you: Given a list of pairs of strings and corresponding numbers, for example, [[A,37],[B,27],[C,21],[D,11],[E,10],[F,9],[G,3],[H,2]], output another list which will have just the strings in the following manner: The total count of any string should be exactly equal to its corresponding ...
Problem Description Given: a function \$f(a, b, c, d, e) = \frac{a \times b}c + \frac de\$ an array \$x = [x_1, x_2, x_3, x_4, ..., x_n]\$ of non-distinct integers a target value \$k\$ What is the most efficient way, in terms of worst-case \$n\$, to find 5 distinct indices \$x_a, x_b, x_c, x_d, x_e\$ from \$x\$ such ...
Inspired by a real-life scenario, which I have asked for an answer to here: https://superuser.com/questions/1312212/writing-a-formula-to-count-how-many-times-each-date-appears-in-a-set-of-date-ran Given an array of timespans (or startdate-enddate pairs), output a count of how many timespans cover each day, for all days...
You are given two arbitrary integer lists, e.g. [-10, 99, -6, 43], [100, 32, 44]. You are to pick one integer from each list and sum them up, then sort the best pairs ordered by the absolute distance to 100 in ascending order. Paired up integers from each list shall not be repeated in the output. For instance, we have ...
This is a bit similar to this dust covered entry but I'm hoping my spin on it makes it unique enough. Not been able to find anything dissuading me from posting this but there is quite the sea out there. Anyway! The challenge: Your code receives a string of characters; It converts this into an ASCII-art style version of...
First, let's talk about Beatty sequences. Given a positive irrational number r, we can construct an infinite sequence by multiplying the positive integers to r in order and taking the floor of each resulting calculation. For example, If r > 1, we have a special condition. We can form another irrational number s as s =...
A frog sits on a lily pad wishing it were on the other side of the river. There are some lily pads of varying sizes between the frog and the other side of the river. Larger lily pads allow the frog to jump further than smaller ones and the frog wishes to reach the other side of the river in as few jumps as possible. ...
I have a simple challenge for you this time. Given an array of positive integers A (or the equivalent in your language), replace each entry Ai with the sum of the next Ai elements of A, cycling back from the beginning if there are not enough items. As usual, you can compete in any programming language and can take inpu...
The digital root (also repeated digital sum) of a positive integer is the (single digit) value obtained by an iterative process of summing digits, on each iteration using the result from the previous iteration to compute a digit sum. The process continues until a single-digit number is reached. For example, the digital...
The positive rational numbers can be shown to be numerable with the following process: Zero has the ordinal 0 Arrange the other numbers in a grid so that row a, column b contains a/b Plot a diagonal zig-zag top right to bottom left Keep a running tally of the unique numbers encountered along the zig-zag Here's a pict...
For the purposes of this question, a deck of cards is formatted in this way: [ "AS", "2S", "3S", "4S", "5S", "6S", "7S", "8S", "9S", "10S", "JS", "QS", "KS", "AD", "2D", "3D", "4D", "5D", "6D", "7D", "8D", "9D", "10D", "JD", "QD", "KD", "AH", "2H", "3H", "4H", "5H", "6H", "7H", "8H", "9H", "10H", "JH", "QH", "K...
Introduction I recently came across an oral exam where the candidates were asked to find a logical circuit than can negate 3 inputs A,B,C using only two NOT gates. The question also specified that such a circuit is unique up to removal of useless gates and reordering inputs/outputs. The candidates were asked to prove t...
Introduction Jonny wants to play Frogger. However, he's not very good. In fact, he will only try to move forward, and only after the platforms have moved. Find out if Jonny's frog manages to reach the end of the path or if it dies on its way. Challenge The program will be receiving as input a Frogger grid composed by 0...
Background In the game of Nim, players alternate removing "stones" from "piles": on each turn, a player must remove between one and all stones from a single pile. The object of Nim is to take the last stone or, in the misere variant, to force your opponent to do so -- however, it turns out the strategies are nearly id...
Introduction: Although I originally had a Dutch song in my head, where the lyrics are: "Doe 'n stapje naar voren, en 'n stapje terug" (which translated to "Take a little step forward, and a little step back"), when I searched for the full lyrics, I realized they only got back and forth, and never sideways. So, instead ...
Camel Up Cup 2k18 In this challenge, we will be playing the semi-popular board game Camel Up. Camel Up! is a board game that has players betting on camels to win rounds, win the game or lose the game, set traps to influence movement or move a camel. Each of these decisions rewards you with the chance of getting some mo...
Definition: a prime power is a natural number that can be expressed in the form pn where p is a prime and n is a natural number. Task: Given a prime power pn > 1, return the prime p. Testcases: input output 9 3 16 2 343 7 2687 2687 59049 3 Scoring: This is code-golf. Shortest answer in bytes wins.
Don't tell anyone, but I've nicked my uncle's time travel machine! My uncle is obsessed with prime numbers, though, and that shows in the machine — he has programmed it so that it can only go to dates that sum up to a prime number. So it can't go to 1947-08-15 because 1947+8+15 = 1970, which is not a prime number. It ...
The Challenge Given a grid of numbers (10 <= N <= 99) Return number with the highest sum of the four numbers adjacent to it; that is the numbers above, below, right, and left of the number, but not itself. The number itself does not count, only its four neighbors. A number on the edge should be treated as though the m...
Given a string, your task is to collapse it into a zigzag-like structure as described below. Folding into a Zigzag We'll take the string "Mississippi" as an example: First, output the longest prefix consisting of unique characters only: Mis When you reach the first duplicate character C, ignore it, and output the lo...
Write code that when given a positive number \$x\$ as input, outputs the largest positive divisor of \$x\$ less than or equal to the square root of \$x\$. In other words find the largest \$n > 0\$ such that \$\exists m\geq n:m\cdot n=x\$ (Exists \$m\$ greater than or equal to \$n\$ such that \$m\$ times \$n\$ is \$x\$)...
It seems that many people would like to have this, so it's now a sequel to this challenge! Definition: a prime power is a natural number that can be expressed in the form pn where p is a prime and n is a natural number. Task: Given a prime power pn > 1, return the power n. Testcases: input output 9 2 16 4 343 ...
Given a string, character list, byte stream, sequence… which is both valid UTF-8 and valid Windows-1252 (most languages will probably want to take a normal UTF-8 string), convert it from (that is, pretend it is) Windows-1252 to UTF-8. Walked-through example The UTF-8 string I       ♥        U  T  F  -  8 is represente...
According to this question a Superb Shuffle™️ is defined as a full deck of cards (including jokers) which follows this set of rules: No two cards (except Jokers) of the same suit are adjacent. No card (except Jokers) is adjacent to one of the same value. No card (except Jokers) is adjacent to one of an adjacent value ...
Consider the following sequence: 0 1 3 2 5 4 8 6 7 12 9 10 11 17 13 14 15 16 23 ... Looks pretty pattern-less, right? Here's how it works. Starting with 0, jump up n integers, with n starting at 1. That's the next number in the sequence. Then, append any numbers "skipped" and that haven't been seen yet in ascending or...
Challenge Given a positive integer \$N\$, repeat each of its digits \$d_1, d_2, d_3, \cdots, d_n\$ a number of times corresponding to its position in \$N\$. In other words, each digit \$d_k\$ should be repeated \$k\$ times (for each \$1\le k\le n\$, 1-indexed), thus creating the new number: $$\overline{d_1d_2d_2d_3d_3d...
This is the followup challenge from this one, if you're confused please check that one out first. First, let \$m(s, k)\$ be the number of cache misses a sequence \$s\$ of resource accesses would have assuming our cache has capacity \$k\$ and uses a first-in-first-out (FIFO) ejection scheme when it is full. Then given ...
Output this exact text: 1 i 12 hi 123 ghi 1234 fghi 12345 efghi 123456 defghi 1234567 cdefghi 12345678 bcdefghi 123456789abcdefghi 12345678 bcdefghi 1234567 cdefghi 123456 defghi 12345 efghi 1234 fghi 123 ghi 12 ...
Let's have a function \$f\$ that takes a string and removes all pairs of adjacent identical characters. For example \$f(a\color{red}{bb}ba\color{red}{cc}) = aba\$ Note that when two pairs overlap we only remove one of them. We will call a string perfectly paired if repeated application eventually yields the empty stri...
Introduction Write a program or function that, given the coordinates of where a dart lands on a dartboard, return the score of that dart. Dart coordinates are given as two integers, x,y measured from the center of the dartboard, with millimeter precision. How to score a dart Darts is a game played by throwing a dart at...
If you throw an ASCII egg in a given direction, you end up with an ASCII splat of size n. It "starts" with one o (the yolk), and continues in a given direction with "lines" consisting of 2 up to n *'s. The *'s are separated by one "space", and the o and all the "lines" of *'s are separated by "lines" of "space". The di...
Consider this spiral ########### # # ####### # # # # # ### # # # # # # # # # # # # # # # # ##### # # # ######### Starting in the centre: The first line (upwards) has 3 characters. The second line has the same number of characters (3) Next, we add two chars (5) for the next two sides. This pattern continue...
On Math Stack Exchange, I asked a question about the smallest region that can contain all free n-ominos. I'd like to add this sequence to the On-Line Encyclopedia of Integer Sequences once I have more terms. Example A nine-cell region is the smallest subset of the plane that can contain all twelve free 5-ominoes, as i...
Challenge Given an integer greater or equal to 4, n, print a rounded rectangle of as close as possible (with a gap of 1) sides and a perimeter of n characters. Rules n is always 4 or greater, because otherwise the output wouldn't be a square The characters for the perimeter can be any non-whitespace character The rect...
For the purpose of this question a meandering curve is one that follows the general direction from left to right, but makes repeatedly n+1 turns at 90 degrees to the left and then n+1 turns to the right (for n>0). In fact the meander itself will have n segments. The turns are denoted with +. The width of the meanders (...
Recamán's Sequence is defined as follows: \$a_n=\begin{cases}0\quad\quad\quad\quad\text{if n = 0}\\a_{n-1}-n\quad\text{if }a_{n-1}-n>0\text{ and is not already in the sequence,}\\a_{n-1}+n\quad\text{otherwise}\end{cases}\$ or in pseudo-code: a(0) = 0, if (a(n - 1) - n) > 0 and it is not already included in the sequ...
This challenge is based on, and contains test cases from, a programming course I took at Aalto University. The material is used with permission. Two and a half years ago there was a challenge about spoonerisms in English. However, in Finnish spoonerisms are much more complicated. Spoonerisms in Finnish In Finnish, the ...
Challenge You are given three integers as input - min_value, max_value, sample_size, that you can pass to your answer as either array or several parameters. Your task is to output a diagram in any convenient format, that shows the frequency of numbers in the (min_value, max_value) range showing up when a random number ...
So, I wrote a simple Javascript game (as yet unnamed) and naturally I wanted to write an API so I could write a bot to play it for me, and naturally I wanted to let the PPCG community have a go for themselves. It's a 'snake' game with the simple goal of collecting as many blue squares as possible while avoiding red squ...
Given a pattern (string or array format) of Bits : [0,1,1,1,0,1,1,0,0,0,1,1,1,1,1,1] The tasks is to replace any number of consecutive 1-Bits with an ascending number sequence starting at 1. Input Pattern (can be received as an string or array) Example: String: 1001011010110101001 Array: [1, 0, 0, 1, 0, 1, 1, 0, 1,...
This is a cops-and-robbers challenge. The robbers' thread is here. An interesting question to think about is the following: If I have a sequence of numbers how many of them do I have to provide before it is clear what sequence I am talking about? For example if I want to talk about the positive integers in order star...
This is a cops-and-robbers challenge. The Cops' thread to this challenge is here An interesting question to think about is the following: If I have a sequence of numbers how many of them do I have to provide before it is clear what sequence I am talking about? For example if I want to talk about the positive integers...
A spoonerism is what you get when swap the beginnings of two adjacent words in a sentence. In this challenge, we'll try to find a plausible spoonerism based on one incorrect word. So, given a list of words** and an input word that is NOT in the dictionary, return a string (not necessarily a dictionary word) for which t...
This is an answer-chaining question, which means that all answers are affected by those before them. The task The n-th answer to this question must run in all languages that are present in answers before it. They need not run in order, but must print the name of the language currently running, reversed. Additional rule...
I am a big fan of the game Creeper World, and especially the sequel. You don't need to know how this game works to answer the question, I just wanted to mention where my question originated from. In the game, your objective is to destroy the Emitters that are spawning Creeper, using a weapon known as a nullifier. Nulli...
The one dimensional twitter waterflow problem is this: You are given an array that represents a hill in the sense that the ith entry is the height of the ith location of the hill. When it rains, water logs in the hills, and you need to figure out how much water would log. For example, after raining, the array 2 5 3 4 3...
One of many unique features of the Malbolge programming language is its highly unintuitive OP operator, referred to only as "op" in the documentation and source code but popularly known as the "crazy" operator. As described by Ben Olmstead, the creator of the language, in its documentation: "don't look for pattern, it'...
For this task your code should take two sorted arrays of integers X and Y as input. It should compute the sum of the absolute distances between each integer in X and its closest number in Y. Examples: X = (1 5,9) Y = (3,4,7) The distance is 2 + 1 + 2. X = (1,2,3) Y = (0,8) The distance is 1 + 2 + 3. Your code can t...
You are fish in a pond that needs to survive by eating other fish. You can only eat fish that are the same size or smaller than yourself. You must create a program that takes a shoal of fish as sorted input. From this you must work out how many fish you can eat and ultimately the size you will grow to. Size chart +----...
Consider two sorted arrays of integers \$X\$ and \$Y\$ of size \$m\$ and \$n\$ respectively with \$m < n\$. For example \$ X = (1,4)\$, \$Y = (2,10,11)\$. We say that a matching is some way of pairing each element of \$X\$ with an element of \$Y\$ in such a way that no two elements of \$X\$ are paired with the same el...
A portmanteau word is a combination of two words that takes part of each word and makes them into a single new word. For example, lion + tiger => liger. Let's write a program to generate portmanteaus from a pair of input words. Computers aren't the best at English, so we'll need to establish some rules to ensure that t...
A matrix can be thought of as the altitudes of a surface in 3D space. Consider the 8 neighbours (orthogonal and diagonal) of a cell as a cyclic sequence in clockwise (or anticlockwise) order. Some neighbours may be higher than the original cell, some lower, and some levelled at the same height as the original cell. We ...
In this question I will talk about programs as strings, this is strings of bytes, not characters. How your resultant program is rendered or displayed is not important to this challenge, only how it appears in memory matters. A pristine program is a program \$S\$ that when run does not error, however it will error when...
Challenge Given a sequence of non-negative integers, create a function that output a descendant pyramid where the children are the sum of both parent numbers. The result is outputted as an string using tab \t. Note: trailing tabs on each line are not required 1\t\t2\t\t3\n\t3\t\t5\t\n\t\t8\t\t results in 1 2 ...
Introduction OEIS sequence A127421 is the sequence of numbers whose decimal expansion is a concatenation of 2 consecutive increasing non-negative numbers. Put simply, every number in the sequence is formed by putting together n with n+1 for some non-negative, integer value of n. The first several terms are: 1, 12, 23,...
Based on a list of numbers and their equivalent letters, take a string input, replace the characters of that string with the equivalent number/letter and output the result. List 1 = a 2 = b 3 = c 4 = d 5 = e 6 = f 7 = g 8 = h 9 = i 0 = j Input thisisastring1124 Output t89s9s1str9n7aabd Rules Numbers are equiva...
Challenge The task is simple. Given an array and a first and last value: Return the first of the last after the first, and the last of the first before the last. Or simply: Given an array, var1, var2. Example Array: [ var2, , var1, , var2, , var2, var1, var2, ] Return: The index of the first var2 on the right side of...
Given dimensions of a 2D array, except 1xn, that results in an odd number of elements, find the midpoint index. Example: Input is 3x5, representing the 2D array [0,0] [0,1] [0,2] [0,3] [0,4] [1,0] [1,1] [1,2] [1,3] [1,4] [2,0] [2,1] [2,2] [2,3] [2,4] The midpoint index is [1,2] Input 3 5 Output 1 , 2 Rules Stand...
Your task is to write a computer program or function that takes a list of nonnegative integers of at least length 2 and determines if they are a "zigzag". A sequence is a zigzag if and only if the numbers alternate in being larger and smaller than the number that comes before them. For example \$[1,2,0,3,2]\$ and \$[...
Write a program or function that, given an integer n, construct an array with n dimensions of n length, where each element is an identifier of its own coordinates. That is, starting with one array, populate it with n arrays, where each of those contain n more arrays, up to a depth of n-1. The elements of the deepest ar...
In the 1990s, COBOL computer engineers worked out a way to extend six-digit date fields by converting them to YYYDDD where YYY is the year - 1900 and DDD is the day of the year [001 to 366]. This scheme could extend the maximum date to 2899-12-31. In the year 2898, the engineers started panicking because their 900 yea...