instruction
stringlengths
34
53.1k
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...
Your task is to make a quine, that is a non-empty computer program that prints it's own source without reading it. In addition if you remove any one byte from your original program the new program should print the source of your original program. This is code-golf so answers are scored in bytes with fewer bytes being ...
The task is simple: Create an if-statement from scratch in x86 assembly that runs in as few clock-cycles as possible. Must be x86 assembly. Can't use any of the conditional jump/branch instructions (e.g. je, jne, jz, jg, jge, jl, jle). Can use jmp to jump to existing blocks of code. Can use cmp if necessary. Can't cal...
Your Programs: You'll write two programs (both in the same language). The storage program takes a string from STDIN and stores it somewhere persistent (see below) and then exits without error. The retrieval program takes no input, retrieves the string that was stored, and prints it to STDOUT. Objective test of Persiste...
Take a string as an input, and perform addition/subtraction of all the digits in the string and output the sum of those operations as the result. Rules The digits in the string are read from left to right If a digit (n) is odd, perform addition with the next digit (n + n1) If a digit (n) is even, perform subtraction ...
Terminology An increasing number is one where each digit is greater than or equal to all the digits to the left of it (ex. 12239) A decreasing number is one where each digit is less than or equal to all the digits to the left of it (ex. 95531) A bouncy number is any number that is not increasing or decreasing. Since th...
This time, we want render the count of bytes in a human readable way to user. Let's write a program (a full one or a function or other acceptable formats) to do this. Input An non-negative integer, in range \$0\leq n<2^{31}\$, which means n bytes. Output A string, the human friendly representation of n bytes. Conventio...
Introduction In the not so distant future with the AI revolution, we will need a way to solve their captchas to prove we're not humans. This challenge was inspired by CommitStrip. Challenge One such captcha is the challenge of calculating the sum of all odd digits of Pi from digit 1 to digit n, including the first digi...
Players of the traditional board game Go measure their skill in a system of ranks: Players new to the game are ranked 30th kyū (written 30k) and progress counting down to 1st kyū (written 1k). These are considered the student ranks. A player may promote from 1st kyū to 1st dan rank (written 1d), and then progress coun...
Your task is, given x, output 2*x. Easy right!? But there's a catch: x will be given as a (possibly infinite) continued fraction, and the output must be a continued fraction. The input is guaranteed to be a real algebraic number whose degree is at most 2. Input: The continued fraction of x. This is split into 3 parts: ...
Yes, I know there are already three pokemon type questions, but almost all submissions hardcode the whole chart in one way or other. I think it'd be nice to change the requirement a bit to encourage more shortcut-taking typically seen in decision problems. Objective Write a program/function/whatever that accepts the at...
Challenge Sandbox post Given a positive integer (K) Output a uniformly-random integer (Y) between [0, K). If Y > 0 Assume K = Y and repeat the process until Y = 0. Rules Input must be printed at first Output format as you wish Your program must finish. 0 must be the final output, Optionally an empty line instead 0
I work at a bakery that serves Wheat, Rye, Barley, Grain, and French bread, but the baker's a little weird - he stacks the loaves in random order, and sometimes just leaves some shelves at the end empty. Each day, the same customer comes in and asks for one of each loaf of bread, but the tricky thing is, he's a germoph...
For a given list of number \$[x_1, x_2, x_3, ..., x_n]\$ find the last digit of \$x_1 ^{x_2 ^ {x_3 ^ {\dots ^ {x_n}}}}\$ Example: [3, 4, 2] == 1 [4, 3, 2] == 4 [4, 3, 1] == 4 [5, 3, 2] == 5 Because \$3 ^ {(4 ^ 2)} = 3 ^ {16} = 43046721\$. Because \$4 ^ {(3 ^ 2)} = 4 ^ {9} = 262144\$. Because \$4 ^ {(3 ^ 1)} = 4 ^ {...
Write a program or function that can distinguish the following 12 trigonometric functions: sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh. Your program is given one of the above functions as black box and should output the function's name either as given above or the way it is named in your lan...
A set of n positive numbers has 2^n subsets. We'll call a set "nice" if none of those subsets have the same sum. {2, 4, 5, 8} is one such nice set. Since none of the subsets has the same sum, we can sort the subsets by sum: [{}, {2}, {4}, {5}, {2, 4}, {2, 5}, {8}, {4, 5}, {2, 8}, {2, 4, 5}, {4, 8}, {5, 8}, {2, 4, 8}, {...
Build a function in python that can win a Sevens game provided that there are only 2 players Here are the instructions from Wikipedia: All cards are dealt to the players, even if as a result some players have one card more than others. The owner of the seven of hearts begins by playing it. Similarly, the other ...
Given a string containing only letters, output the length of the longest run of consecutive alphabetical letters the word contains, where order does not matter. An example algorithm may sort the word, remove duplicates, and then output the length of the longest run. Test Cases watch -> 1 stars -> 3 antidisestablishment...
Does anyone have any suggestions as to how I could shorten this program? _=map(ord,raw_input());_=[10if y==88else 0if y==45else 58-_[x-1]if y==47else y-48for x,y in enumerate(_)];t=0;exec('t+=sum(_[:2+(_[0]+_[1]>=10)]);_=_[2-(_[0]==10):];'*10);print t Run it online I'd like to write a bowling calculator. I'm fairly pr...
Challenge: Create a program that prints out the size of its own source code file. For example, a 35 bytes size of program must print out 35. Pre-calculation is not valid. What I mean by pre-calculation is: // test.js -> its size is 15 byte console.log(15) It must dynamically calculate the size of own source code fi...
Introduction Briscola is one of Italy's most popular card games. It is a trick-taking card game, like Bridge. Briscola is well known for its bizarre point system. In this challenge, given two cards, you will output whether the first one scores more, less, or the same number of points as the second in Briscola's point s...
Given a number from 1 to 24, output the kissing number to the best of current knowledge (some numbers will have more than one acceptable output). Knowledge of geometry is not essential as the outputs are all listed below. From the Wikipedia page on the Kissing Number Problem: a kissing number is defined as the number ...
A perfect square is an integer that is the square of an integer; in other words, it is the product of some integer with itself. Calculate the number of perfect squares below a number \$n\$ where \$n\$ will be taken as an input Examples: There are 9 perfect squares below 100: 1, 4, 9, 16, 25, 36, 49, 64, 81 Constrain...
Math has a lot of symbols. Some might say too many symbols. So lets do some math with pictures. Lets have a paper, which we will draw on. To start the paper is empty, we will say that is equivalent to \$\top\$ or \$\textit{true}\$. If we write other things on the paper they will also be true. For example Indicates ...
Not to be confused with this question. You need to draw a times table (also known as Cremona's method for cardioid generation) as shown in this video. The number \$n\$ and \$k\$ will be the inputs. In the video n and k are 2 and 10 respectively. How to draw? Draw a circle, divide its perimeter into equal spaced parts...
Given positive integers \$w\$ and \$h\$ output \$w\$ columns and \$h\$ rows of text as described below. The first row begins with 11 0s, the second row with 10 1s, third with nine 2s and so on down the the tenth row with two 9s. On each of these first ten rows, following the initial run of consecutive digits, the next ...
Challenge: Given a list of nonempty lists of integers, return a list of tuples of the following form: First list tuples starting with each element of the first list followed by the first element of every subsequent list, so the ith tuple should be [ith element of first list, first element of second list, ... , first el...
Introduction Your challenge today (inspired by this challenge) is to write a number of snippets, functions or full programs each that output various ascii emoticons, without reusing characters. Challenge The list of valid ascii emoticons for this challenge is both here and in the code block at the bottom of this post....
Traveling with electronics is always fun, especially when you need an adapter to charge them. Your challenge is to make planning a trip a little easier by checking if a given plug will be compatible with a given socket. Challenge Given a plug type and a socket type, return a value that indicates whether they will work ...
Background: the Ramsey number \$R(r,s)\$ gives the minimum number of vertices \$v\$ in the complete graph \$K_v\$ such that a red/blue edge coloring of \$K_v\$ has at least one red \$K_r\$ or one blue \$K_s\$. Bounds for larger \$r, s\$ are very difficult to establish. Your task is to output the number \$R(r,s)\$ for ...
I use "suffix" loosely here to mean "any sub-string that follows the prefix". "Prefix" here means the START of a word, where a word's start is defined as either after a space or from the first character of the input text (for the first word). A "prefix" in the middle of a word is ignored. E.g. if your input prefix is "...
Given two line segments, determine if the line segments intersect and if so, where. In the case that the two given line segments are co-linear and overlap, determine the midpoint of the overlapping segment. Lines will be specified in pairs of (x, y) coordinates. Examples [(-1, -1), (1, 1)], [(-1, 1), (1, -1)] => (0, 0...
Description OEIS sequence A096004 gives the Number of convex triangular polyominoes [polyiamonds] containing n cells. It begins: 1, 1, 1, 2, 1, 2, 2, 3, 2, 2, 2, 3, 2, 3, 3, 5 For example, a(8)=3 with the following three convex polyiamonds: Input: 8 Output: *---*---*---*---* / \ / \ / \ / \ / *---*---*---*---* ...
Defintion A centrosymmetric matrix is a square matrix that is symmetric about its center. More rigorously, a matrix \$A\$ of size \$n \times n\$ is centrosymmetric if, for any \$i,\: j \in ([1, n] \cap \mathbb{Z})\$ the following relation is satisfied: $$A_{i,\:j}=A_{n+1-i,\:n+1-j}$$ Examples of such matrices Here is a...
Challenge Given a positive integer N, output the sum of the first N reciprocals as an exact fraction, which is represented as a pair of integers in a consistent order representing numerator and denominator. Rules Output must be exact. Output should be as a pair of integers in a consistent order representing numerator ...
Given 2 brainfuck code snippets A and B, output some brainfuck code C which has the same behavior as running B with the input of As result. Note that C must work for any input that match the following assumptions, as if it were given to A. You can assume: Finite input. both A and B halt. EOF is consistently 0 or consi...
Rearrange a given list such that all the odd numbers appear before all the even numbers. Besides for this requirement, the output list may be in any order. The input will only contain integers, but they may be negative and there may be duplicates, and they may appear in any order. Shortest solution wins. Test cases [1,...
Imagine the following 24-hour clock that can be controlled by arrow keys: ╔══╗ ┌──┐ ║00║:│00│ ╚══╝ └──┘ HH mm Pressing the up arrow twice (↑↑) will increase the currently focused hour input: ╔══╗ ┌──┐ ║02║:│00│ ╚══╝ └──┘ HH mm Pressing the right arrow (→) will focus the other input. ┌──┐ ╔══╗ │02│:║00║ └──┘ ╚══...
...or Toroidal Moore Neighbourhoods Given positive integers h, w and a non-negative integer i, return all of the indices surrounding i. You are to assume a matrix consisting of h rows of w elements, numbered from lowest, in the top left-hand corner, to highest, in the bottom right-hand corner, and return, in any reaso...
Challenge Given nine numbers, a, b, c, d, e, f, g, h, i, as input which correspond to the square matrix: $$\mathbf{M} = \begin{pmatrix}a& b& c\\ d& e& f\\ g& h& i\end{pmatrix}$$ Find the inverse of the matrix, \$\mathbf{M}^{-1}\$ and output its components. Inverse Matrix The inverse of a matrix 3 by 3 obeys the followi...
Related: Let's design a digit mosaic, Print/Output the L-phabet. Sandbox post here Given 2 inputs C = columns and rows, S = starting point output a matrix as follow: Input 4, 3 1 2 3 0 2 2 3 0 3 3 3 0 0 0 0 0 Explanation Given C = 4, S = 3 1) Create a C x C matrix filled with 0 4 colu...
In the spirit of Solve the Halting Problem for Befinge, let's define another 2D language called Modilar SNISP. Modilar SNISP has the following six instructions: \ directs the instruction pointer as follows: if approached from the top, go right; if approached from the right, go up; if approached from the bottom, go l...
In Russia we have something like a tradition: we like to look for lucky tickets. Here's what a regular ticket looks like: As you can see, the ticket has a six-digit number. A six-digit number is considered lucky if the sum of the first three digits is equal to the sum of the last three. The number on the photo is not...
Kids-related intro Whenever I take my kids to an amusement park, the kids get more nervous the closer we are to the park, with the nerve peak when we are in the parking lot and find no place to park. So I've decided I need a method to find the closest free parking space to minimise the time spent parking. Technical int...
Challenge Given an image of the Moon as input, output the phase of the Moon. Phases of the Moon Your program will be supplied one of these images in png format and you must output the phase exactly as given: new moon hexdump waxing crescent hexdump first quarter hexdump waxing gibbous hexdump full moon hexdump...
If we take the natural numbers and roll them up counter clock-wise into a spiral we end up with the following infinite spiral: ....--57--56 | 36--35--34--33--32--31--30 55 | | | 37 16--15--14--13--12 29 54 | | | | | 38 17 ...
Consider the following list: expected = [ 'A', 'B', 'AB', 'C', 'D', 'CD', 'ABCD', 'E', 'F', 'EF', 'G', 'H', 'GH', 'EFGH', 'ABCDEFGH', 'I', 'J', 'IJ', 'K', 'L', 'KL', 'IJKL', 'M', 'N', 'MN', 'O', 'P', 'OP', 'MNOP', 'IJKLMNOP', 'ABCDEFGHIJKLMNOP', ... ] Here's one way to look at it - you're learning how to write Chinese...
Given three non-negative integers y, m, and d (of which at least one must be positive) and a valid date with a positive year (in any reasonable format that includes the year, month, and day, and no additional information), output the date that is y years, m months, and d days after the original date. The Gregorian cale...
Background An ex-increasing set sequence of order \$N\$ is defined as a sequence of integer sets \$S_1,S_2,\cdots,S_n\$ which satisfies the following: Each \$S_i\$ is a non-empty subset of \$\{1,2,\cdots,N\}\$. For \$1\le i<n\$, \$S_i \cap S_{i+1} = \varnothing\$, i.e. any two consecutive sets have no elements in comm...
Introduction We all know the cool S (also known as Superman S, Stüssy S, Super S, Skater S, Pointy S, Graffiti S etc. etc.): billions of schoolchildren around the world drew this S and immediately felt proud of themselves. In case you've forgotten or had a completely uncool childhood, here is an image of said cool S: ...
Your program has to have an year like 1957 to be the input and then output the century of that year. For example: In: 1946 Out: 20 In: 1705 Out: 18 In: 1900 Out: 19 In: 100 Out: 1 In: 2001 Out 21 because 1946 is in the 20th century. Keep in mind that 2000 should be 20th century or 1900 should be in 19th century. There...
Introduction Today's challenge is all about teeth. Specifically, how long it takes to brush from one tooth to another. Your challenge is, given the locations of two teeth, output the shortest amount of time possible to brush from the first to the second. Challenge For this challenge we will be using a layout of an aver...