instruction
stringlengths
34
53.1k
It's the election! The area which we are in implements the system of voting called instant runoff (sometimes called alternative vote or preferential voting). Each voter orders each candidate from most preferred to least preferred, marking a "1" for their most preferred candidate, a "2" for their second candidate, and s...
Inspired by Silicon Valley's "three-comma club" scenes, like this one, in this challenge you'll be telling ten people the "comma club" to which they each belong. If you're unfamiliar with the term "comma club," let me explain: you're in the one-comma club if the money you have is in the inclusive range $1,000.00 to $99...
Your task: given an input string, determine whether the binary representation of that string does not have 4 1s or 0s in a row, anywhere. Furthermore, your code itself should not contain any such runs of four in a row. Test Cases String Binary Result U3 01010101 00110011 Truthy 48 ...
Note: Minor spoilers for The Martian are in this challenge. Read ahead with caution The Martian is a Science Fiction novel about astronaut and botanist extraordinaire, Mark Watney, who has been accidentally stranded on Mars. At one point in the book, Mark tries communicating with NASA, but the only means of communicat...
You know those stackable shelves that are basically just wooden boxes that can be stacked together? We're going to simulate building some bookshelves out of those with some ASCII art. Our books are all conveniently uniform in size, and all look like the following: |X| |X| |X| The bookshelves are individual boxes, alwa...
You've probably heard of the Fibonacci numbers; they're pretty famous. Each number in the Fibonacci sequence is the sum of the last two in the sequence with the first and second numbers being 1. The sequence looks like this: 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75...
Draw the parabolic trajectory of a thrown ball. The input is the ball's initial upward velocity, a positive integer v. Every second, the ball moves 1 space right and v spaces vertically, and then v decreases by 1 to due to gravity. So, the upward velocity eventually steps down from v to 0 and down to -v, finally falli...
Thanks to @KritixiLithos for helping me out with this challenge! V is a programming language that I wrote so that I could use and extend vim for code-golf challenges. The very first commit was on March 3rd, 2016, meaning that today V turns one year old! Woo-hoo Over V's first year of existence, there have been 176 com...
Let's say I have the following (2D) matrix: [[1, 2, 3, 4 ], [5, 6, 7, 8 ], [9, 10, 11, 12], [13, 14, 15, 16]] Rotate the matrix counterclockwise R times (not in 90 degree increments, just by 1 number each time), 1 2 3 4 2 3 4 8 3 4 8 12 5 6 7 8 --> 1 7 11 12 --> ...
Given an non-negative integer \$n \ge 0\$, output forever the sequence of integers \$x_i \ge 3\$ that are palindromes in exactly \$n\$ different bases \$b\$, where the base can be \$2 \le b le x_i-2\$. This is basically the inverse of OEIS A126071, where you output which indices in that sequence have the value \$n\$. I...
In this exercise, you have to analyze records of temperature to find the closest to zero. Write a program that prints the temperature closest to 0 among input data. Input N, the number of temperatures to analyse (optional). This will be nonzero. The N temperatures expressed as integers ranging from -273 to 5526. Outp...
The dice game Mia introduces a very non-trivial order of sets of size two: {3,1} < {3,2} < {4,1} < {4,2} < {4,3} < {5,1} < {5,4} < {6,1} < {6,5} < {1,1} < {2,2} < {6,6} < {1,2} In general, the order within a tuple does not matter {x,y}={y,x}, {1,2} is greater than anything else, Pairs are greater than non-pairs and th...
You should have heard about the Fibonacci Numbers, often called the Fibonacci Sequence. In this sequence the first two terms are 0 and 1, and every number after the first two is the sum of the two preceding ones. In other words, F(n) = F(n-1) + F(n-2). Here are the first 20 Fibonacci numbers: 0 1 1 2 3 5 8 13 21 34 55 ...
Sometimes it happens that while typing a sentence, I am distracted and I end up typing the same couple of words twice couple of words twice in succession. To make sure make sure other people are not bothered by this, your task is to write a program that resolves this problem! Task Given an input string (if it matters f...
For context, this problem is based on a old chat-bot project I did. Problem: Given a string of words containing any of the characters: " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" Find the frequency of each triplet of words. All non-alphanumeric characters should ...
There are two forms of nouns, singular and plural. The conversion between these two is quite easy. Normally, you end it with s. ex. car => cars. If it ends with s,x,z,ch or sh, end it with es. ex. bus=>buses. If it ends with y with a consonant just before it, change the y to ies. ex. penny => pennies. If it ends wi...
Definition of Additive Primes: Numbers which have exactly 2 divisors are called Prime numbers. Numbers which are prime and their sum of digits is also a prime number are called Additive Primes Task: Given an integer x, compute all the additive primes amongst the first x prime numbers, with 2 being considered both t...
Imagine I have an infinite number of homework problems (!) each given an integer number. Math Problem Notation is a notation for describing subsets of the problem using problem specifiers. An MPN expression can consist of several things: A single value. This represents a set containing the number: 99 -> {99}. A simple...
The λ-calculus, or lambda calculus, is a logical system based on anonymous functions. For example, this a λ-expression: λf.(λx.xx)(λx.f(xx)) However, for the purposes of this challenge, we'll simplify the notation: Change λ to \ (to make it easier to type): \f.(\x.xx)(\x.f(xx)) The . in lambda headers is unnecessary,...
This construction is a way of representing the Natural Numbers. In this representation, 0 is defined as the empty set and for all other numbers, n is the union of {0} and {n-1}. For example to construct 3 we can follow the algorithm: 3 = {ø, 2} = {ø, {ø, 1}} = {ø, {ø, {ø}}} Task As you may have guessed your task is t...
The boardgame Terra Mystica has some very interesting mechanics for one of the primary resources, power. Instead of gaining and spending units of power from a bank, each player starts the game with exactly 12 units of power which are distributed over three "bowls", which are labelled I, II and III. Gaining and spending...
In this challenge, I have a field of avocados which I'd like to juice as quickly and completely as possible. Can you write a program or function to help me work out how to juice all the avocados perfectly? As input, you'll get the avocados as an mxm square grid, where m is an integer between 3 and 6. Each square contai...
You've been given a bag of Skittles. Everybody knows that in order to appreciate the different flavors the most, you need to rotate between the flavors. Basics: You can only eat 1 skittle at a time The order that you eat your skittles must be periodic. Each period cannot contain a particular flavor more than once. ...
A big part of radio communication is the NATO Phonetic Alphabet, which encodes letters as words to make them easier to understand over comms. Your job, if you wish to accept it, is to print them one by one. You must print this exact string to stdout: A: Alfa B: Bravo C: Charlie D: Delta E: Echo F: Foxtrot G: Golf H: Ho...
Background This challenge is in honor of apsillers, who won the Not as simple as it looks category in Best of PPCG 2016 with their challenge Can my 4-note music box play that song? Congratulations! On their "About Me" page, this user has a really neat simulator for the Game of Life cellular automaton. (Seriously, go ch...
There's a confusing factor in the 'Curious' badge. The "Positive question record". (total questions - negative questions - closed - deleted)/total questions is the formula of the question record. (negative, closed and deleted 'stack' with each other. that means if a question is negative and closed, it counts as two min...
This is the cop's thread. The robber's thread is here. Write a code that takes an input n and creates a n-by-n "snake matrix". A snake matrix is a matrix that follows this pattern: 3-by-3: 1 2 3 6 5 4 7 8 9 and 4-by-4: 1 2 3 4 8 7 6 5 9 10 11 12 16 15 14 13 The exact output format is optiona...
This is the robber's thread. The cop's thread is here. A snake matrix is a square matrix that follows this pattern: 3-by-3: 1 2 3 6 5 4 7 8 9 and 4-by-4: 1 2 3 4 8 7 6 5 9 10 11 12 16 15 14 13 Your task is to write a code that takes an input n and creates such a matrix, in the same language as a cop pos...
For some part of history people in France used a decimal clock. with the clock having 10 hour day, 100 minutes an hour and 100 seconds per minute. Though this clock simplified calculations a bit the idea wasn't appreciated by most of the world which used our current 24 hour, 60 minute hour, and 60 second minute. And he...
If you don't know what a queen is in chess, it doesn't matter much; it's just a name :) Your input will be a square of arbitrary width and height containing some amount of queens. The input board will look like this (this board has a width and height of 8): ...Q.... ......Q. ..Q..... .......Q .Q...... ....Q... Q..........
Given two integers, A and B, output A if A-B (A minus B) is in A-B (A to B), otherwise output B. "A minus B" is standard subtraction. "A to B" is the range of integers starting at A and ending at B, including both A and B. For example: 1 to 4: 1, 2, 3, 4 -2 to 5: -2, -1, 0, 1, 2, 3, 4, 5 3 to -1: 3, 2, 1, 0, -1 7 to 7:...
My boss* does not understand why her programmers react negatively to users changing program requirements. Help her understand! On every answer, create a new requirement. Then, write a program/function that solves that requirement and all prior requirements, while in a new programming language. Examples User 1 posts the...
For a story I'm writing, I needed to convert 101⅐ (101 + 1/7 if that doesn’t show up for you) into base 47. Expressing an integer in some base brings back memories of first learning how to program back in the days of 8-bit systems; it’s a fairly easy exercise. Doing so using a floating-point format is a bit harder, tho...
Oh, <PROGRAM NAME HERE>, tell me how many character '<CHARACTER HERE>'/s are there in your body. I do not think it a dupe to this. That question asks for printing a list directly but this one requires some input that will cause problem. Your work is to write a quine-like program/function that takes an input of one cha...
Input: Two integers: one negative, one positive. Output: On the first line output lowest to highest. On the second line we've removed the highest and lowest numbers and sign-changed all individual numbers. On the third line we've removed the highest and lowest numbers again and sign-changed all individual numbers again...
Given a string of the characters +=- where there is at least one =, insert positive integers between all the symbols and at the start and the end such that the math equations are satisfied. For example, given the input +-=-= you need to insert positive integers A through F like this A+B-C=D-E=F such that the equation...
This answer-chaining challenge is officially over, resulting in the win of Wheat Wizard, with a total of 7 answers. Any other answer is welcome, but it won't influence the accepted answer for this challenge, nor the winner. Task: Print all the positive divisors of a number x taken as input. Input: A single number x w...
The Challenge Given the number of items, n, in a non-empty, sorted list output the index, i(n), at which its "Back-To-Front Permutation" would reside in a list of all permutations if said permutations were sorted lexicographically. Results may be 0 or 1-based, just say which (that is i, not n). The Back-To-Front Permut...
Writing out numbers is among the Hello worlds of programming, often the numbers 1-10. I want to write out many numbers! Many, Many numbers. But how many numbers do I have to write? Task Given an integer input, give a number as output that would give me the number of digits that would be in a string containing all integ...
Your task is to take a sequence of characters (the music) as input (in a function or program), and print (or return) the music as it would look like in a music box. You will only receive the characters ABCDEFG.() as input, and the input will never be empty. You may also receive the letters in lowercase, if you wish for...
(Meaning: Convert English to Bleet) We have praised goats as god for years now. But if we can't translate English to 'Bleet', the Goat God's language, we cannot communicate with them. So, to communicate with them, we have researched the activities of goats, and retrieved this pattern, which is the core of the language....
Create a program that calculates my reading speed! The challenge Write a program which takes some text as input and waits for a start signal from the user to display the input. When to user gives a second end signal, the program should output the reading speed of the user, which is defined as the number of words in the...
The challenge here is to extend an implementation of palindrome given the following as inputs: n > 1 and a list l. Your program must palindrome the list both vertically and horizontally, that is to say it must first palindrome the list itself, then each element in the list after; or the other way around. Before pali...
Consider the following string: Tin Snips This string contains several atomic symbols on the periodic table. We could rewrite this string to identify several of them: [Ti][N] [Sn][I][P][S] Of course, we could also write it this way: T[In] [S][Ni][P][S] The rules for rewriting the input are as follows: The case of th...
SPECIFICATION Given m variables, create every combination up to order n. For example, The output of mapping two variables (a and b) to order 1 would be: a b a b The output of mapping two variables (a and b) to order 2 would be: a a2 b b2 a b a2 b a b2 a2 b2 The output of mapping two variables (a and b) to order 3 ...
Problem Given a file with: 56 (65%), 33(75%), , 44, "“hello”,(5) world", goodbye 89 (25%), 33(75%), , 44, "hello world", goodbye 92 (97%), 33(75%), , 44, "hello world", goodbye Goal Write back to that file with: 56, 33, , 44, "“hello”,(5) world", goodbye 89, 33, , 44, "hello world", goodbye 92, 33, , 44, "hello world"...
Randomly choose one out of k-length, ordered subset of characters in a string, while only storing a limited number of characters. The subset must be chosen with equal probability and may contain repeated characters. Do this without generating all possible permutations and assume k is at most the length of the string. F...
Bubble-wraps are maximum-level entertainment. Everyone can agree to that. Now, you will make even computers enjoy bubble-wraps. Specs You will be given two integers, w, and h.(each are responsively width and height) Your program should output all w*h phases waiting 1 second between each one and terminate. Every bubble-...
Write a program or function that takes in the following input in a reasonable format of your choice: Two positive integers W and H that define the width and height of the image you'll be generating. Two RGB colors C1 and C2 that will be used to color the image. A list of 3-tuples of the form (r, x, y) that define circ...
Write a program that will determine if a given matrix represents a quandle. A quandle is a set equipped with a single (non-commutative, non-associative) operation \$◃\$ which obeys the following axioms: The operation is closed, meaning that \$a◃b = c\$ is always an element of the set if \$a\$ and \$b\$ are elements o...
Background Brag is a card game similar in concept to, but simpler than, poker. A hand in brag consists of three cards and is ranked as follows from highest to lowest: Three of a kind - all three cards the same rank. Named as "three Kings" etc. Running flush aka straight flush. All three cards of same suit and of conse...
...and real golf for my code friends. This is a challenge based on a one year old XKCD comic which consists mostly of toasts (parodies of the first in the comic) following a distinct pattern, but with some slight variation. Your task is to write a program (or function) that takes the first half of any toast from the ...
The Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different. Let P be a binary string of length n and T be a binary string of length 2n-1. We can compute the n Hamming distances between P and every n-length substring of T in order from left to ri...
Given two inputs, you should print or return whether the characters in the first string are - in order - inside the second string. For example, we want to check whether the string hello, taken as the first input, and the sample text (the second input) is abhcedddldddloallllll. This should output a truthy value, as the ...
In the card game Magic: the Gathering there are five different colours, which represent loose affiliations of cards, White (W), Blue (U), Black (B), Red (R) and Green (G). These are often arranged in a pentagon as follows: W G U R B Both in the lore of MtG as well as in many card mechanics, adjacent colours in th...
Here is a diagram of a prison using ASCII characters: +------------------------------+ | | | X X | | | | D D | | | | | | ...
Consider depicting a simple, open, two-dimensional curve on a W wide by H high grid of text where X represents part of the curve and . represents empty space and no other characters are used. Every grid space has 8 neighboring grid spaces, its Moore neighborhood. Grid spaces beyond the borders are considered empty. A g...
Code-Bowling You've been hired by Brunswick Bowling to create a simple program to output the text Code Bowling on their monitors. This company is worth a pretty penny and you feel you can swindle them for quite the bit of cash. The job description clearly states that they pay on a scoring basis and you're pretty confi...
In this challenge, you receive a string as input containing a string of X's, Y's and Z's eg. "XYZZ". X, Y and Z represent a particular character. This pattern is then compared with a second string input. If the pattern exists as a substring in the second input, return True, otherwise, return False. Once a pattern is fo...
Binary trees A binary tree is a tree with nodes of three types: terminal nodes, which have no children unary nodes, which have one child each binary nodes, which have two children each We can represent them with the following grammar, given in BNF (Backus–Naur form): <e> ::= <terminal> | <unary> |...
This challenge is adapted from the British Informatics Olympiad. Dice game Two players are playing a dice game where they each roll a pair of dice, and the highest sum wins. The pairs of dice have the same number of sides, but do not have to have the same values on each side. Therefore, the game is fair if for both pa...
While doing some research for a different challenge I'm formulating, I came across a Cayley graph, specifically this one. Since I'm one of the top ascii-art challenge writers, of course I had to make an ASCII art challenge for this. Your challenge is to produce this ASCII art depiction of a Cayley graph of the free gro...
In honor of national pi day, create a program that, when given an integer, n, as input, will create a circular "pie" constructed of these smaller pies: Your program should output the image in a closed polygonal shape, and the number of outputted images should be equal to the value of the nth digit of pi. Below are som...
This challenge is inspired by this very nice answer by TidB. In TidB's answer, every eight character is in the correct order: gnilwoB edoC (Code Bowling backwards). The other strings however are were in a strange, random order. Your challenge is to fix this. Take a (non-empty) string and a positive integer n as input....
Problem: Your task is to decide if in a sequence of numbers, every number contains at least one of the digits of the number that preceded it. For example, the following should return truthy: [1, 12, 203, 0, 30] ^ ^ Contains a 0 ^ Contains a 2 ^ Contains a 1 The following should return ...
Sometimes, when I'm really bored I like to take the sum of an array of non-negative integers. I only take the sum of arrays of lengths that are powers of two. Unfortunately I often make mistakes. Fortunately I keep track of my work as I go along in the following way: I add pairs of adjacent numbers until there's only o...
Not an interpreter. Arguably a compiler. But I'm talking about a transpiler. It can be in any language, but it must return js-valid arrow notation code. The λ-calculus string would be passed as an argument to a function, or the whole program, and in some way the program would return/log/print the string with the js-not...
A list of numbers is called monotonically increasing (or nondecreasing) is every element is greater than or equal to the element before it. For example, 1, 1, 2, 4, 5, 5, 5, 8, 10, 11, 14, 14 is monotonically increasing. Given a monotonically increasing list of positive integers that has an arbitrary number of empty sp...
I need to stop thinking of punny names Your task is to create as many snippets (programs that have input and output built-in), functions or full programs as possible that sorts whatever your language's version of integer arrays is in ascending order, but for each program, you're only allowed to use the characters in AS...
Most everyone here is familiar with Pascal's Triangle. It's formed by successive rows, where each element is the sum of its two upper-left and upper-right neighbors. Here are the first 5 rows (borrowed from Generate Pascal's triangle): 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 We're going to take Pascal's Triangle and p...
Given three numbers m,n and p, your task is to print a list/array of length p starting with m and n and each element after p represents the difference of the 2 numbers before it, m-n (Counter-Fibonacci Sequence) For this challenge you can either use a function to return or print the result or a full program. Input Thr...
You find yourself on a chessboard, as one does. You can see the exit but it is awfully far away and you would rather not walk all the way. Luckily some locals have offered you a ride. A Knight, a Rook, a Bishop and a King are all willing to take you to your destination, but seeing how this is a chessboard they must e...
Code-Bowling Quine Challenge You must bowl a quine following the rules of code bowling and quines but the source code must be in the shape of a rectangle (details specified below) Quine Quines returned must be returned via the ways defined in the standard I/O rules. Rules Code-Bowling Rules Character : Byte Ratio I...
The J language has a very silly syntax for specifying constants. I want to focus on one cool feature in particular: the ability to write in arbitrary bases. If you write XbY for X any number and Y any string of alphanumerics, then J will interpret Y as a base X number, where 0 through 9 have their usual meaning and a t...
Question Given the atomic number of an element in the range [1-118] output the group and period, of that element as given by the following Periodic Table Of Elements. For elements in the Lanthanide and Actinide series, (ranges [57-71] and [89-103]), you should instead return L for the Lanthanides and A for the Actinide...
Some decimal numbers cannot be precisely represented as binary floats due to the internal representation of the binary floats. For example: rounding 14.225 to two decimal digits does not result in 14.23 as one might expect but in 14.22. Python: In: round(14.225, 2) Out: 14.22 Assume, however, that we have a string rep...
Introduction You have to simulate playing golf over an input string that represents the green. The 2-character substring () represents the hole, and is guaranteed to appear only once in the string. This is a sample green: ABCDEFGHIJKLM()NOPQRSTUVWXYZ The simulation consists of outputting the characters that the ball f...
Challenge is to write a function/program which outputs a truthy or falsey value alternately each time you call it. No input. It can start with either true or false.
In this challenge, you'll calculate how great your land is. Write a program or function that calculates the size of your land, given a wall you have built. You're given a non-empty input string containing a set of 4 distinct characters of your choice that represent the four directions "up", "down", "left" and "right" ...
Code-Bowling Challenge Write a program or function that produces the same output, no matter how you re-arrange the source code. (Output can't be an error) Pangram Scoring Your score is the amount of unique characters in your source code. A program with source code AJB would have a score of 3 A program with source ...
Goal: Given an array of strings, create abbreviated​ versions of each string. Specification: For this challenge, an abbreviation is the first N characters of a string. For the string abc: a, ab, and abc are all valid abbreviations, while bc, and ac are not. Given an array of strings, we want to find the shortest set of...
Background Inspired by Octave's (and, by extension, MATL's) very convenient interpretation of truthy/falsy matrices, Jelly got the Ȧ (Octave-style all) atom. Ȧ takes an array as input and returns 1 if the array is non-empty and does not contain the number 0 (integer, float, or complex) anywhere in the tree structure; o...
This challenge sounds too simple to not already exist, so let me know if it is a duplicate. The task Print Hello, world! The rules Your code has to be in "byte order". This means that every character / byte has a higher or equal byte value than the preceding character / byte. Exceptions to this rule are the whitespace ...
Rock-and-roll founding father Chuck Berry sadly passed away today. Consider the chorus of his famous song "Johnny B. Goode": Go, go Go Johnny go, go Go Johnny go, go Go Johnny go, go Go Johnny go, go Johnny B. Goode (There are other ways it has been punctuated but the above will serve for the purposes of the challenge...
Challenge Given a string with any characters a-z or A-Z, return an 'encrypted' string, where all characters are replaced by the character next to it (assuming a QWERTY keyboard). Case (uppercase, lowercase) does not matter. The input will only have characters a-z and A-Z. Shortest code in bytes wins. Example Input a...
A simple FizzBuzz using strings. Given 1 word or phrase (string) 2 unique characters Output The word or phrase with each occurrence of the first character replaced with fizz and each of the second character replaced with buzz Rules The first letter in both Fizz and Buzz must remain capitalized For the rest of the wo...
This is a Code Golf challenge. Flood is a game in which the player is presented with a game board such as this: On each turn, you choose a colour (on the link above, by clicking a square containing that colour), and the cell in the top-left corner is filled with that colour - this colour will absorb all adjacent cells...
Given N, output the Nth term of this infinite sequence: -1 2 -2 1 -3 4 -4 3 -5 6 -6 5 -7 8 -8 7 -9 10 -10 9 -11 12 -12 11 ... etc. N may be 0-indexed or 1-indexed as you desire. For example, if 0-indexed then inputs 0, 1, 2, 3, 4 should produce respective outputs -1, 2, -2, 1, -3. If 1-indexed then inputs 1, 2, 3, 4, ...
Today, we'll be computing the most efficient binary function. More specifically, we'll be computing the function which, when an expression is created from applying the function to the constant input 0 or its own output, can represent all positive integers with the shortest possible expressions, placing higher priority ...
The task is to create a program (or a function), which outputs array elements in the order, determined by two numbers F and B. F is number of elements to print, B is the rollback distance (from last printed element). Each element must be printed on separate line and blank line must be inserted after each rollback. Run...
This is a Google interview question, see here for a youtube link. The task: Find 2 integers from an unordered list that sum to a given integer. Given an unordered list of integers, find 2 integers that sum to a given value, print these 2 integers, and indicate success (exit 0). They don't need to be any particular num...
We've had challenges for SIGSEGV and SIGILL so why not... Write the shortest code that results in a Bus Error (SIGBUS) in any programming language. Your program can't call raise() or kill(getpid(),sig) or pthread_kill(pthread_self(),sig), or any other equivalent.
You will be given a nested array. Your program has to visualize the array. But.. How? For example, let's assume we have a nested array, like [["1","2"],[["1","2"],"3"],"4",[[[["5"]]]],"6"]. This nested array can be visualised as: ->1 ->2 -->1 -->2 ->3 >4 ---->5 >6 Examples Input 1: ["Atom",["Proton",["Up Quark", "Up...
Note: There is not been a vanilla parity test challenge yet (There is a C/C++ one but that disallows the ability to use languages other than C/C++, and other non-vanilla ones are mostly closed too), So I am posting one. Given a positive integer, output its parity (i.e. if the number is odd or even) in truthy/falsy va...
In this challenge, you are given a limited amount of information about a particular game of chess, and you need to predict who won the game. You are given two sets of data: Piece counts (What pieces are still alive) Board colors (The color of pieces on the board) More importantly, you don't know where the pieces are ...
Given a string s composed of lowercase letters, such as aabaaababbbbaaba and a positive integer n, such as 4, output a length-n string t such that when t is repeated to the length of s, they have as many chars in common as possible. For the given example, the optimal output would be aaba, because it has thirteen chars...
This is the first in a series of Island Golf challenges. Next challenge Given an island in ASCII-art, output an optimal path to circumnavigate it. Input Your input will be a rectangular grid consisting of two characters, representing land and water. In the examples below, land is # and water is ., but you may substitut...
Here in the absolutely made up country Rnccia we have a lot of good stuff, but the roads aren't good. There are lots of holes and only half of them get fixed. Even then, only half of the fixes are well done. Your task is to embrace the bad roads of this country and draw them for me. Input You receive two positive integ...
Consider a stream/file with one integer per line. For example: 123 5 99 Your code should output the sum of these numbers, that is 227. The input format is strictly one integer per line. You cannot, for example, assume the input is on one line as an array of integers. You can take input either from STDIN, in form of a ...
Challenge Given input in the form <n1>, <n2> where number can be -1, 0, or 1, return the corresponding cardinal direction. Positive numbers move East in the x-axis and South in the y-axis, Negative numbers move West in the x-axis and North in the y-axis. Output must be in the form South East, North East, North. It is c...