instruction
stringlengths
34
53.1k
Given a positive integer \$n\$ output the integers \$a\$ and \$b\$ (forming reduced fraction \$a/b\$) such that: $$\frac a b = \prod ^n _{k=1} \frac {p^2_k - 1} {p^2_k + 1}$$ Where \$p_k\$ is the \$k\$ th prime number (with \$p_1 = 2\$). Examples: 1 -> 3, 5 2 -> 12, 25 3 -> 144, 325 4 -> 3456, 8125 5 -> 41472...
When I was a child, I used to play this game a lot. Rules There are two players (let's call them A and B), and each player uses his hands as guns. There are three possible moves: Hands up to load ammunition to your gun. Each gun starts empty. Loading increases the ammunition by one. Hands pointing to the other player...
In music theory, an interval is the difference between two pitches. Each pitch is defined by the number of half-steps (The difference between C and C#) or whole steps (The difference between C and D). One whole step is the same as two half-steps. Here is a list of all the default intervals and the number of half-steps...
This challenge but with a better spec. Spec Your program will take a linear equation containing a single variable x and output the value of x. Input / Parsing The input will only contain numbers, operators, parenthesis (()), x, and an = sign (this means no whitespace). Parenthesis will always be balanced. There will a...
Given a matrix A, we can say that it is "sorted" if each row and column of A is sorted (ascending left-to-right for rows and top-to-bottom for columns). Thus, this matrix is sorted: [ 1 2 3 4 5 ] [ 2 2 3 4 5 ] [ 3 3 3 4 5 ] [ 4 4 4 4 5 ] [ 5 5 5 5 5 ] However, this matrix is not sorted: [ 1 2 3 4 5 ] [ 2 1 3 4 5 ] [ 3...
Introduction In the wake of the left-pad npm package fallout, let's have a code golf for implementing left-pad. The left-pad function consists of 2 default arguments and 1 additional argument, in the form string, length, (padchar). If the padchar is not given, this is standardized to a space character. Let's take an ex...
Today is Purim on which one custom is to give out triangle-shaped cookies with filling called hamantaschen (singular: hamantasch). Another custom is to drink heavily. I'm not the most perfect baker.... I have so many irregularly-sized hamantaschen to give out and so many friends to give them to! If I sent you a pictur...
Draw the following in the fewest bytes possible: ------------------------- | | ABC | DEF | | 1 | 2 | 3 | ------------------------- | GHI | JKL | MNO | | 4 | 5 | 6 | ------------------------- | PQRS | TUV | WXYZ | | 7 | 8 | 9 | ------------------------- | | ...
I was answering one challenge here and this task was part of the challenge. I've got a 73 bytes solution in javascript. But I think it is too much for a simple thing. Challenge Given as input two integers: N the length of the expected array R the interval's range starting in one: 1..R, not 0..R-1 Output in each run o...
The Challenge Given 3 numbers X, Y and Z in base B, find a Base in which the addition of X and Y yields Z. The inputs x = 20, Y = 12 and Z = 32 could yield 5 because 20 + 12 = 32 in base 5. You may assume that there will always be a base in which the addition is correct (there are cases where no base exists, thanks t...
Introduction Let's define a ternary function as a function from the three-element set S = {0,1,2} to itself: it associates to each element of S another element of S. One example of a ternary function f is f(0) = 0; f(1) = 2; f(2) = 0 There are exactly 27 different ternary functions, and we represent them with integers...
In honor of recent news of Google developing a keyboard for iPhone... Your input (for simplicity, all input is case sensitive): Location of standard dictionary file. File format is 1 valid word per line; in alphabetical order. Example file: apple banana citrus domino durian orange tuna zabc Location of personal dicti...
Challenge Given the roots of a polynomial separated by spaces as input, output the expanded form of the polynomial. For example, the input 1 2 represents this equation: (x-1)(x-2) And should output: x^2-3x+2 The exact format of output is not important, it can be: 1x^2+-3x^1+2x^0 or: 0 0 0 1x^3+0x^2+0x^1+0 or: 3 14...
At some point, I bumped into an SO question asking how to implement Perl's trivial hash-of-hashes data structure in Java. For those who don't know Perl, the hash value can be a scalar or another hash, or technically speaking hash reference. Arbitrary depth. Additional feature offered by Perl is autovivification - assi...
You have to take a base-10 number (e.g. 735) and another number for the base to convert to, and convert the base-10 number into the equivalent number in the other base. Rules: You aren't allowed to use any conversion functions built into your language This is code-golf, the shortest answer in bytes wins!
This used to be an old Computer Olympiad Question, not sure what the actual source was. Assume function f: f(1) = 1 This f(1), f(2), f(3), f(4), ... sequence of numbers are in ascending order. Number n has been repeated f(n) times Here is the sequence up to the fifteenth number: n : 1 2 3 4 5 6 7 8 9 10 11 12 13 ...
The Challenge: Just as the title says, your challenge is to use the printable ASCII characters to create a program that prints out a random polygon in the terminal based on the number of sides, n provided by the user, where n is an integer in the range 3 -> 10 including 3 and 10, in as few bytes as possible. For exampl...
Here is the 3rd ABACABA city: _ A|_| B|__| A|_|_ C|___| A|_| B|__| A|_| It is made out of the ABACABA sequence, which is basically: A (1st iteration) place B - AB repeat A - ABA (2nd iteration) Place C - ABAC Repeat ABA - ABACABA (3rd iteration) and you get the idea. The buildings have a height (corresponded by no...
Two distinct vertices in a directed graph are strongly connected if there is path in the graph from each to the other. A strongly connected component of the graph is a subset of the graph such that each pair of distinct vertices in the subset are strongly connected, and adding any more vertices to the subset would brea...
Write a full program with a source code of 256 bytes or less that looks at an image of a flag and determines what country that flag is from. A zip file containing the 196 different flags in the challenge can be downloaded from here. Source: [Flagpedia]. These 196 flag images are the only inputs your program has to hand...
Your task is to print the following ASCII Art: _ _ _______ _ | | | | (_______) _ | | | |__ | | ____ ____ ____ _ _ _____ ____ ___| |_ ____ ____| | | __)| |/ _ | _ \| _ \| | | | | ___) / _ |/___)...
In this challenge, you need to partition a list, where partitions have a max size, a min size, and a preferred size. I'll be using the notation (min,pref,max) to indicate the sizes in this challenge. For those unfamiliar with partitioning, the following list has been partitioned into parts of 3: [0..9] -> [[0,1,2],[3...
The Challenge Given an arbitrary amount of rectangles, output the total count of intersections of those when drawn in a 2D plane. An intersection here is defined as a point P which is crossed by two lines which are orthogonal to each other and are both not ending in P. Example Each rectangle here is denoted by a 2-tupl...
Everyone realizes that Tic Tac Toe is a solved game. However, the Misère version of only-Xs provides an interesting alternative. In this version of the game, both players play Xs onto the board and try to avoid making three in a row. If you'd like to see more about this, Numberphile has a nice video about this concept....
Write a program or function that listens for incoming TCP traffic on port N. It offers a simple service: it calculates sum of IP address fields of incoming connection and returns. Program or function reads integer N from arguments or stdin. It listens to incoming TCP connections on port N. When someone connects to that...
Some of you may have heard of the Wargame series of computer based real time strategy game. These games pit teams of players with primarily cold war era units to see how a hot cold war would have played out. The goal of this challenge is to simulate a tank battle in these games. Input Two "tanks" (one red and one bl...
Background Consider a round-robin tournament, in which each contestant plays one game against every other contestant. There are no draws, so every game has a winner and a loser. A contestant A is a king of the tournament, if for every other contestant B, either A beat B, or A beat another contestant C who in turn beat ...
The story "2016? Al..right," grumbled toy seller Hilbert. He opened his eyes, wiped salad dressing trickling out of his ear and ate a morning kick-start cremeschnitte. Exemplar holidays. He needs to go to work now though, and finish the year's accounting. Christmas is a very yielding period of the year, especially for...
Create program or function that takes file name as an argument or reads it from standard input, and completes the following task: Read image from a png file (name given as argument). Reverse colors in that image, so that for example dark green (0, 75, 30) would become (255, 180, 225) (because 255-0=255, 255-75=180 and...
I recently saw this question on stackoverflow. It's a great question, but there's one fatal problem with the question. They are asking for the best way to do it. E.g, easiest to read, most idiomatic, neatest etc. Don't they know that isn't what matters? You're supposed to ask about how to do it with the fewest bytes of...
Alice and Bob are playing a little game. First, they draw a tree from a root node (indicated by a thick dot), with no internal nodes, with numbers at the leaves. Any node may have any number of children. We start at the root, and first to play is Alice (A). She must select one of the current node's children. Then it's...
Background You awake to find yourself lost in a one dimensional labyrinth! A mystical genie (or something) appears and explains that the exit lies in front of you, but that between you and the exit is a series of challenges. As you wander forward you realize that all of the so-called challenges are merely locked doors....
This is a little codegolf challenge from codingame.com. I was wondering how much Python3 code is necessary (but of course answers are not limited to Python3). Input The first line contains one positive integer n. The second line contains n positive integers. Each consecutive integers on the second line are separated by...
Your challenge is to passwordify the string! What is passwordifying, you ask? Take a string as input. This string will only contain uppercase letters, lowercase letters, digits, and spaces. You must replace all spaces with underscores and move all numbers to the end of the string in the order that they appear from lef...
If you don't know already, a quaternion is basically a 4-part number. For the purposes of this challenge, it has a real component and three imaginary components. The imaginary components are represented by the suffix i, j, k. For example, 1-2i+3j-4k is a quaternion with 1 being the real component and -2, 3, and -4 bein...
Explanation Befunge is a two-dimensional program that uses stacks. That means, to do 5 + 6, you write 56+, meaning: 56+ 5 push 5 into stack 6 push 6 into stack + pop the first two items in the stack and add them up, and push the result into stack (to those of you who do not know stacks, "push" just means add ...
You are in a one-floor dungeon. There is a treasure which is protected by locked doors. Doors can be opened by finding the corresponding keys. Your goal is to find the shortest path to the treasure. Input Input will be a two-dimensional grid representing the initial layout of the dungeon. ########### #$ # g# # #...
Your job is to open a browser window of the default browser to http://codegolf.stackexchange.com. Your code must open the browser itself, and cannot rely on an open one. This is code-golf, so the shortest answer in bytes wins. Moderator note: A large number of answers to this challenge use the URLs http://ppcg.lol or...
You are an explorer, mapping an unknown world. Your ship is carried on the wind. Where it goes, who knows? Each day, in your spyglass, you see features to the north, south, east and west. You always see four such features, corresponding to the cardinal directions. Your spyglass reports ASCII symbols like this: ~~.*, ~...
As per Luke's request and Peter Taylor's addition to this challenge. Introduction Everyone knows the game tic-tac-toe, but in this challenge, we are going to introduce a little twist. We are only going to use crosses. The first person who places three crosses in a row loses. An interesting fact is that the maximum amou...
The Challenge Everybody loves genetics, right? In this challenge, you will be given the genotypes of two parents. You must find each possible genotype of a child produced by the parents. You must account for dominant and recessive alleles as well as incomplete dominance and codominance. An example input for the parents...
Since I am INSANELY hyped for the Final Fantasy XV Uncovered event, I want you to write me a program to tell me when it is!!! The input Your take input in the form of HH:MM XDT, where HH is a number in the range 1-12, MM is a number between 0-60, and XDT is a time zone, with X being one of E (eastern, UTC-4), C (centra...
An arborally satisfied point set is a 2D set of points such that, for any axis-aligned rectangle that can be formed using two points in the set as opposite corners, that rectangle contains or touches at least one other point. Here is an equivalent definition from Wikipedia: A point set is said to be arborally satisfi...
Your Task: Print "Hello, World!" using a palindrome. Simple, right? Nope. You have one restriction: you may not use comments. "Comments" include Normal // or # comments Adding extraneous characters to a string literal Triple-quoted string comments Creating a string literal to hide characters You may not use a pre-de...
The challenge is simple: Determine the type of an input, and output an identifier telling what type it is. "UI", Unsigned integer: 0, 1,34, 111111111111111111111111111111111111111111 "SI", Signed integer: +0, +1, +42, -1, -3, -111111111111111111111111111111111111111111 "UD", Unsigned decimal: 0.0, 1.23, 1234.1234 "SD...
This post would make more sense if it were Friday the 13th today... But oh well. Write a full program that, given any year as the input from at least -10,000 to 10,000, prints all dates of that year that are Friday and also on the 13th of the month. Output can be expressed as MM/dd, dd/MM, dd.MM, or any other readable ...
Write a program that accepts input (through stdin) as a string of unary numbers delimited by spaces, and prints the equivalent string of numbers in binary, decimal, and hexadecimal. These unary symbols are allowed: stroke, '/' or '\' Decimal 1 ASCII 'I' ASCII '-' Your program does not have to support all symbols, but...
"Hey Bob, I need a new acronym. Something better than 'Automated Support System'. I need you to fabricate me an acronym!" "Sure thing Joe! I'd love to fabricate an elaborate way to renovate, and not replicate something that you can tolerate." "Alright Bob, make sure it can separate itself from the old acronym we need t...
I'm new to this stackexchange, but I must say I am very impressed by the knowledge of some here, and the original codegolf answers for some questions. I'm not even sure if the following is possible, since my programming language knowledge is very limited, but it sounds like a pretty interesting challenge: Goal: Output ...
In this code-challenge you will write a hash function in 140 bytes1 or less of source code. The hash function must take an ASCII string as input, and return a 24-bit unsigned integer ([0, 224-1]) as output. Your hash function will be evaluated for every word in this large British English dictionary2. Your score is the ...
(Just open 50 tabs in Google Chrome :D (just kidding, no you can't)) Shortest code for infinite disk I/O any language, C# example: using System.IO; namespace FileApp { static class Program { public static void Main() { do { File.WriteAllText("a", "a"); File.Delet...
Inspired by this Numberphile entry Background The cube distance numbers of an integer n are defined here as the set of integers that are x³ distance away for a given x. For a simple example, with n=100 and x=2, the cube distance numbers are {92,108}. This can be extended into a larger set simply by varying x. With x ∈ ...
Write a program or function that takes an input greater than or equal to 2. It should output a truthy or falsy value corresponding to whether the input is a Lucas number or not. You may take input from STDIN, or whichever source is most suitable to you. This question is different to this one because this question is sp...
I have a new programming language called Brussels-Sprout. Brussels-Sprout functions in an array of 256 boolean values, all initialized to zero, has one instruction pointer, and one "bit index". After each (non-branching) instruction is executed, the instruction pointer is incremented by one. If the instruction pointer...
Introduction A code page maps integer values to a specific character. We can visualize a code page like this: +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+...
Given a string of letters and a set of words, output an ordering of the words so that they can be found in the string by dropping letters that are not needed. Words may occur more than once in the word set. The input string and all words will consist of 1 to 1000 lower case letters each. The letters to be dropped may o...
I have a counter. It's a small device that looks like this: The display goes from 0000 to 9999. It has a little push-button at the top that increases the count by 1, and a little knob at the right whose purpose is to reset the counter back to 0. Now, the thing about the little knob is that if you turn it backwards, y...
The code on this site is rapidly being depleted. We need to invest in renewable strings. So you must write a program that takes a string and converts it into a windmill. The Challenge Let's take a simple wind-mill string as an example. Take the string abc. The pivot is the center character, in this case b. Since the st...
Your job is to write a program that finds the optimal number of moves it takes to get from the lower-left corner of a rectangle to the upper-right corner directly opposite. Your program will accept input as an ordered pair (width, height). These will be the dimensions of the rectangle you will work with. Your program w...
The above image is called a hexa-glyph. Hexa-glyphs are some cool patterns I made up while doodling during my DiffEq class. Here's how you make one: Consider the following set of points, shaped like a regular hexagram. The inner hexagon is what will contain the final glyph, while the outer 6 points form a star and...
Wikipedia has several restrictions on an article's title. I summarize them here: It may not be empty. It may not begin with a lowercase letter. A character is considered lowercase if it has an Ll after its name in UnicodeData.txt. It may not contain any of the characters: # < > [ ] | { } _ It may not be . or .. It may...
The derivative of a function is a cornerstone of mathematics, engineering, physics, biology, chemistry, and a large number of other sciences as well. Today we're going to be calculating something only tangentially related: the arithmetic derivative. Definition The arithmetic derivative a(n) or n' is defined here (A0034...
Let's write the shortest code to perform a simplified variant of the DoD 5220.22-M Wipe Method with only two writing passes. Any programming language accepted, but the use of disk-wiping-oriented libraries is prohibited. Here's how we are to implement it in pseudocode: Set x to 0 [Start] 'Write Pass For each sector in...
This is essentially the same thing as this question, except harder. You are again to write a program that gets from the lower-left corner of a rectangle to the upper-right corner. However, this time diagonal moves are allowed. The program will accept an ordered pair (width, height), and use these as the dimensions for ...
Okay, I propose a shortest-key-logger challenge. As explained by the gentleman at "Are key-logger questions allowed?", strict rules have to be imposed in order to make this challenge valid for PPCG. The key-logger has to run on Windows, Linux or Mac OSX (any programming language is welcome). Upon execution, it has to ...
Inspired by this question about packing into this format. Occasionally I see a completed crossword and being as I am, I can't be bothered to find out what the solutions to the clues actually were. Input: A 2D string (any format, newline separated, 2d list etc.) Blank squares will be represented with a (space characte...
Introduction Let a field be a rectangle filled with only the characters - and [0-9]. An example of a field is: 11-011123 111-010-- 0010---01 111-01234 You see that this field has been separated into three smaller areas: To calculate the score of a smaller area, we just add all numbers up. For example: 11 111 0010 111...
This challenge is in honor of the Rookie of the Year category winners of Best of PPCG 2015: muddyfish (for I'm not the language you're looking for!) and quartata (for Implement a Truth-Machine). Congratulations! Background In the deepest trenches of the ocean, there lives a rare and elusive square-shaped fish called th...
The plus-minus sequence The plus-minus sequence is one that starts with two seeds, a(0) and b(0). Each iteration of this sequence is the addition and subtraction of the previous two members of the sequence. That is, a(N) = a(N-1) + b(N-1) and b(N) = a(N-1) - b(N-1). Objective Produce the plus-minus sequence, in infinit...
Write a program that will output its own source code when run, and nothing else. Seems easy, right? The catch is that when the source code is reversed, your program must output "Hello, World!" exactly, without the quotes. This is code-golf, so lowest byte count wins. Edit: Your quine must be a proper quine.
Moderator note: https://strawpoll.me has officially shut down, and the linked API no longer appears to work or provide data. Therefore, new answers cannot actually do the task and so the challenge has been closed to prevent any new answers. Strawpolls are great, and we use them in chat all the time for getting opinio...
I have a pile of clean socks that I want to sort into pairs. Unfortunately, I can only take socks from either end of the pile, not the middle. Further, I can only remove socks from the pile a matching pair at a time. My strategy is to first split the pile into one or more smaller piles. I think some examples will make ...
The input is a word of lowercase letters not separated by whitespace. A newline at the end is optional. The same word must be output in a modified version: For each character, double it the second time it appears in the original word, triple it the third time etc. Example input: bonobo Example output: bonoobbooo Stan...
This challenge is to write fast code that can perform a computationally difficult infinite sum. Input An n by n matrix P with integer entries that are smaller than 100 in absolute value. When testing I am happy to provide input to your code in any sensible format your code wants. The default will be one line per row of...
Introduction For the ones who don't know, a palindrome is when a string is equal to the string backwards (with exception to interpunction, spaces, etc.). An example of a palindrome is: abcdcba If you reverse this, you will end up with: abcdcba Which is the same. Therefore, we call this a palindrome. To palindromize t...
A nearly massless cat is dropped in space (don't worry, with a space suit and everything) at the point (x, y, z) with velocity (vx, vy, vz). There is an fixed, infinitely dense planet (with volume of 0) at the point (0, 0, 0) and it attracts objects at distance r with acceleration 1/r^2. According to Newtonian gravity,...
What general tips do you have for creating a bot to participate in a King of the Hill challenge? What strategies do you use to go from considering the challenge to creating your bot? What data structures do you find most useful? Please post one tip per answer.
A narcissist program is simple. It is related to a quine. If the input is equal to it's source code, it prints a truthy value, if not it prints a falsy one. That is it. Rules: It can't read it's own file. This is code-golf, so the shortest answer wins. Hash functions are not allowed. This trivializes it into just s...
What general tips do you have for golfing in Racket / Scheme? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Racket / Scheme (e.g. "remove comments" is not an answer). I'm aware Scheme and Racket (formerly PLT Scheme) are technically different language...
Write a program or function that takes in a multiline string of 0's and 1's. No other characters will be in the string and the string will always be rectangular (all lines will have same number of characters), with dimensions as small as 1×1, but otherwise the 0's and 1's may be arranged arbitrarily. You may assume the...
You must write a program or function that takes a string of brackets and outputs whether or not that string is fully matched. Your program should print a truthy or falsy value, and IO can be in any reasonable format. Rules and definitions: For the purpose of this challenge, a "bracket" is any of these characters: ()[]...
Intro Cookie Clicker is a popular browser game in which the player has to click a cookie to gain... Cookies! The player can buy upgrades which will automatically farm cookies for you. Sometimes a golden cookie will enter the screen, which will provide a bonus upon clicking it. Challenge This challenge will not be about...
A snakified string looks like this: T AnE eOf ifi ing h s x l A k e r isI amp Sna dSt Your Task Take a string s and a size n, then output the snakified string. The inputs ThisIsAnExampleOfaSnakifiedString and 3 would produce the example above. Specifications s will only contain ASCII characters between code points 33...
Your program must take an input (n for the purpose of description) and output all permutations of a number that is n digits long with no repeating digits, where each of the digits preceding and including its index are divisible by the place in the number that it falls. You can read about magic numbers here. Rules: 1 <...
Given a matrix, output a representation of the matrix where the top left element is on top, the anti-diagonal is the central row and the bottom right element is at the bottom. For example, consider the following matrix: 1 2 3 4 5 6 7 8 9 The diamond version of this matrix is: 1 4 2 7 5 3 8 6 9 Inputs and output...
Let's do an exercise together, shall we? Simply follow the movements of the stickman. What stickman you ask? The one we are about to create! Make a program that allows for a string-input only containing integers, and outputs the following nine stick-figures with an interval in between: @ \@/ |@_ _@| @/ \@ |@| \@\ /...
In this game two players compete to eat the most points worth of tokens, but there's a twist! Eating multiple tokens in a row of the same color gives an ever-growing bonus, but watch out, or your opponent will thwart your plans by eating the tokens you want before you can! Rules: 1 versus 1 n by n board (random size b...
Introduction A pointer array is an array L of nonzero integers where 0 ≤ L[i]+i < len(L) holds for all indices i (assuming 0-based indexing). We say that the index i points to the index L[i]+i. A pointer array is a loop if the indices form a single cycle of length len(L). Here are some examples: [1,2,-1,3] is not a po...
In this challenge you are supposed to fill a grid 10x10 with numbers from 1 to 100 (each number once) following this rules: Number 1 must be on the bottom row Number 100 must be on the upper row Two consecutive numbers must be one next to the other (diagonals doesn't count) The grid must be random It's not necessary ...
What you need to do is create a Boolean parser. Boolean expressions, in case you haven't heard of them yet, have two inputs and one output. There are four 'gates' in boolean arithmetic, namely OR (represented by |), AND (represented by &), NOT (which are used a bit like brackets : / and \ note, I could have used !, bu...
Given a string, find the first word starting with each letter (case insensitive). Sample Using Ferulas flourish in gorgeous gardens. as input: "Ferulas flourish in gorgeous gardens." ^^^^^^^ ^^ ^^^^^^^^ | | | | | --> is the first word starting with `g` | --> i...
Your task is to compute the greatest common divisor (GCD) of two given integers in as few bytes of code as possible. You may write a program or function, taking input and returning output via any of our accepted standard methods (including STDIN/STDOUT, function parameters/return values, command-line arguments, etc.). ...
In ValiDate ISO 8601 by RX, the challenge was to use only standard regular expressions to validate standard date formats and values (the former is a common job for RX, the latter was unusual). The winning answer used 778 bytes. This challenge is to beat that using any language of your choosing, but without special date...
A regular string looks like this: Hello,IAmAStringSnake! And a string snake looks something like this: Hel l rin o,IAmASt g S !ekan Your Task String snakes are dangerous, so you must make a program that takes a string snake as input and outputs it as a regular string. Specification...
Is the path correct ? Given a string, your program must determine whether or not Alice can reach Bob, following the signs on the map. You must return a truthy or falsy value. The input string will contain the following characters : (space) and \n. Only used for padding. >, <, ^, v, are the "signs". They show the dire...
Welcome to your first day at PPCG Inc. As our newest junior assistant document sorter, you are responsible for making sure all documents we sent down to you are archived in alphabetical order. It's so easy a monkey can do it. Well, metaphorically speaking, as we did hire a monkey to do it. Guess what? Turns out monkeys...
The Challenge In this challenge you have to do two different (but related) tasks depending of the order of the input. Your program will recieve a string s and an integer n as input and will split s into pieces of length n if s comes first. The last element will be shorter if necessary. split s into n pieces of equal l...
One of my favorite algorithms was posted on Stack Overflow as an answer to What is the fastest way to generate prime number recursively?. In pseudocode: Nathan's algorithm bool isPrime(int n): if (n < 2) return false for p in 2..n-1: if (isPrime(p) && n%p == 0) return false return true This program...
Here is an image: %%%%%%%%%%%%% % Hello, % % world! % %%%%%%%%%%%%% But it is too confusing for our undersized brains to compute. So we average it like this: Split it into 2 x 2 sections. If the picture ends before a section is complete, imagine that there are spaces there. Average the values of the ASCII chara...
You must write a program or function that creates a "stair-ified" string. Here is how you "stair-ify" a string: For each character in the string: If the character is an upper or lowercase vowel, not including 'y', output it then move the rest of the string up a column. If the character is a space or a tab, output it ...