instruction
stringlengths
34
53.1k
Input: A list of integers (which will never contain a zero) Output: A list of the same size with counts based on the following: If the current item is negative: Look at all items before this item, and count how many times the digits occurred in those other numbers If the current item is positive instead: Look at all i...
Challenge Predict the distance between the Sun and the nth planet when using any formula that gives the same result as the Titius–Bode law: d=(3*2^n+4)/10. BUT WAIT... there is one restriction: Your source code can not include any of the Titius–Bode law's digits So, your program can not contain the characters 0, 1, 2,...
Given an input sentence consisting of one or more words [a-z]+ and zero or more spaces , output an ASCII-art histogram (bar graph) of the letter distribution of the input sentence. The histogram must be laid out horizontally, i.e. with the letter key along the bottom in alphabetical order from left to right, with a Y-a...
So what might be the shortest language for this simple task? Task: You are given an input of type String - the string is a valid hexadecimal number ([0-9A-F]). Convert it to a decimal number and print it to the console. Tests: HEX -> DEC 1 -> 1 98 -> 152 539 -> 1337 1337 -> 4919 A5F9 > 42489 F -> 15 Win Condition: Th...
Write a program that, when run in different languages, outputs a different byte permutation of the code in each language. The exact source code is counted as one permutation. Here "different language" can be different version(Py 2 and Py 3) or different standard flags. It's different output that forces different versio...
So, there's a famous children's rhyme... This is the house that Jack built. This is the malt That lay in the house that Jack built. This is the rat That ate the malt That lay in the house that Jack built. This is the cat That killed the rat That ate the malt That lay in the house that Jack built. This is the do...
Description : You are given a string of numbers (positive and negative but not decimals) along with the number of entries like so. Like so 8 '1 2 5 0 7 -9 12 -8' Task : Your job is to return the number closest to zero be it +ve or -ve. Your input will be separated by spaces only. You are free to return the answer in a...
Given an arbitrary sequence consisting of 1 and A split this sequence up so that A is at the beginning of each sub sequence. Sequences without a leading A and Sequences without 1 before the next A will be self contained. Example Input 111A11A1111111A1A1AA should result in 111 A11 A1111111 A1 A1 A A Above already cont...
Description : Given an array of strings representing a grid of cells With the key : 0 = 'dead cell' 1 = 'live cell' write a function that returns the next iteration following the rules of Conway's Game of Life . Rules Any live cell with fewer than two live neighbours dies, as if caused by underpopulation. Any live ...
Assignment is simple to explain: write the shortest code you need to determine whether an executable binary program supplied as parameter is 32 or 64 bits. If there is a different kind of bitness, you can also do for it, but is not mandatory. What I really don't want is telling me you support other bitnesses and after ...
A lot of PPCG users helped with the creation of this challenge, both in chat and the Sandbox, specifically Martin Ender, AdmBorkBork, Emigna and user202729 Our community has found it necessary to create a set of languages designed specifically for golfing, "golfing languages" as we call them. Such languages have evolve...
Input: Integer n which is >=0 or >=1 (f(0) is optional) Output: The n'th number in the sequence below, OR the sequence up to and including the n'th number. Sequence: (0),1,-1,-3,0,5,-1,-7,0,9,-1,-11,0,13,-1,-15,0,17,-1,-19,0,21,-1,-23,0,25,-1,-27,0,29,-1,-31,0,33,-1,-35,0,37,-1,-39,0,41,-1,-43,0,45,-1,-47,0,49,-1,-51,0...
Description : Given a string of space separated binary digits or space separated booleans or an array of binary digits or array of booleans . Your job is to find the xor of each until you end up with one answer either 0 or 1. The inputs will always be valid and will only be either 0 or 1. Example : 1 0 0 1 0 --> 0 1 0 ...
(Inspired by last week's Riddler on FiveThirtyEight.com. Sandbox post.) Given a year between 2001 and 2099, calculate and return the number of days during that calendar year where mm * dd = yy (where yy is the 2-digit year). 2018, for example, has 5: January 18th (1 * 18 = 18) February 9th (2 * 9 = 18) March 6th (3 *...
Given a set of items, each with a weight and a value, determine the number of each item to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as possible. Wikipedia for more information For example you can be given a max weight of 15 and objects with ...
Due to technical limitations of Stack Exchange, the title is rendered incorrectly. The correct title for this challenge is Make a Word Icicle! Word Icicle Word cicle ord cicle ord icle ord i le or i le or i l or l or r Today's challenge is to make icicles out of t...
Description : Given an input (a string , array , integer) , Your job is to append one of the following to it. st , nd , rd , th . Examples : 1 ---> 1st 2 ---> 2nd 3 ---> 3rd 4 ---> 4th 11 ---> 11th 12 ---> 12th 13 ---> 13th 14 ---> 14th and so on and so forth This is code golf so shortest code will win in each langua...
Having a function f that takes arguments x1, x2, …, xn                                                – ie.  f : X1 × X2 × … × Xn → Y – currying redefines f as a function taking a single argument a1 which maps to yet another function. This technique is useful for partial application, for example with a curried pow func...
This is a code golf puzzle: shortest byte count wins. The program should do the following (standard loopholes obviously forbidden): Input a hexadecimal number Convert to octal Then interpret the digits as if in decimal (765 octal -> 765 decimal) Divide the number by two Convert to hexadecimal Example: Input: 4a3d Out...
Description : Given a string as input, check if it is a valid ordinal number in English or not. If it is valid return truthy value otherwise return falsy value. (Suggested by @Arnauld. Thanks . Also by @JoKing) For users who want to know about ordinal numbers go here : https://www.mathsisfun.com/numbers/cardinal-ordina...
In this task you are given an odd number of white balls and the same number of black balls. The task is to count all the ways of putting the balls into bins so that in each bin there is an odd number of each color. For example, say we have 3 white balls. The different ways are: (wwwbbb) (wb)(wb)(wb) for the two differ...
A Walsh matrix is a special kind of square matrix with applications in quantum computing (and probably elsewhere, but I only care about quantum computing). Properties of Walsh matrices The dimensions are the same power of 2. Therefore, we can refer to these matrices by two's exponent here, calling themW(0), W(1), W(2)....
This is a cops-and-robbers challenge based around defining languages and proving they are Turing complete. This is the cops' thread. The robbers' thread is here. Cops As a cop, you will prepare two things: A formal specification of a programming language, or other computational system. (Computational systems are defin...
This is a cops-and-robbers challenge based around defining languages and proving they are Turing complete. This is the robbers' thread. The cops' thread is here. Robbers The cops will post definitions of Turing-complete languages. Your task is to crack them by proving that they are indeed Turing complete. See the cops'...
This challenge is inspired by the meme Men of Culture. The meme involves blanking out parts of the original caption, Ah, I see you're a man of culture as well. to make it appear as if the character is saying something else. Your challenge is to write a program that, given an input, show how the original sentence can ...
Input is in this format: image fontwidth fontheight rowwidth xoffset yoffset xgap ygap non-existent charstart thetextitself thetextitself: The text that should be rendered from the image. image: The image filename. Implementation may vary; it could be either the filename from your computer, an image URL, or something ...
Introduction A sequence of numbers is passed in as the input. The program has to generate the lowest degree polynomial possible. This was my first programming project in college and it would be interesting to see how much smaller the solution could have been. Challenge The input is a list of integers separated by a com...
Description : Given x and y positions of two circles along with their radii, output the area of intersection of the two circle. Input : You will be given following input : array 1 = x and y positions of circle a array 2 = x and y positions of circle b radius = radii of the two congruent circles Input method : ([12 ,...
You're given the map of a cinema theatre as a boolean matrix: 0 represents a free seat, 1 - occupied. Each Finn who walks in chooses the seat farthest away (Euclidean distance) from the nearest occupied one, or if several such exist - the first among them in row-major order. Output a matrix showing the order seats will...
Your challenge is simple: write as long of a pristine program as possible in the language of your choice using only unique bytes. (The full definition of a pristine program, copied from that link, is at the bottom of this question.) That's right, no strings attached. Your code doesn't have to do anything at all, just r...
For a computer language, a reserved word is a word that cannot be used as an identifier, such as the name of a variable, function, or label. For other computer languages, keywords can be considered as the set of the language instructions. Challenge Using your language of choice, write a code in the chosen language that...
Recursively define a "valid arithmetic expression": Any natural number is a valid arithmetic expression. If s is a valid arithmetic expression, then so is (-s). If p and q are valid arithmetic expressions, then so is (p+q). In the above, a "natural number" is recursively defined as follows: 0 1 2 3 4 5 6 7 8 9 are n...
look! It's an ASCII maze! Soo coolzors, amazeballs and stuff. +-+-----+---+ | | | | | | ++ | | | | ++ +-+ | | | | +-------+ | | | | | +---------+-+ But, but, but... it's a pain to work out which direction all the parts of the maze are going. I just want to draw the layout and the maze make it...
This sentence employs two a’s, two c’s, two d’s, twenty-eight e’s, five f’s, three g’s, eight h’s, eleven i’s, three l’s, two m’s, thirteen n’s, nine o’s, two p’s, five r’s, twenty-five s’s, twenty-three t’s, six v’s, ten w’s, two x’s, five y’s, and one z. Such sentences are called autograms. Your task is to write a p...
Given an input integer n >= 10, output the average of all deduplicated rotations of the integer. For example, for input 123, the rotations are 123 (no rotation), 231 (one rotation) and 312 (two rotations). The average of those is (123 + 231 + 312) / 3 or 222. As another example, take 4928. The rotations are 4928, 9284,...
This is a CC-BY-SA challenge from the CCSC Mid-South Programming Contest 2018. Author(s): Brent Yorgey Source: Consortium for Computing Sciences in Colleges Mid-South Programming contest 2018 https://ccsc18.kattis.com/problems/ccsc18.mountainrange Good news: you have been hired to do all the special effects for a fil...
Your mission is to build an algorithm (program or function) that can optimize packing fruit from a conveyor belt into bags to be sent off to retailers, optimizing for a largest number of bags. Each bag has to weight at least a certain amount, but any excess is lost profit since that weight could be used to fill another...
Back in the day, telephone autodialers used punched cards with one column for each digit of the number to be dialed. Columns had seven rows. The first three rows represented the numbers (1,2,3), (4,5,6), and (7,8,9) respectively. The last three rows rotated this arrangement by 90°: (1,4,7), (2,5,8), and (3,6,9). The mi...
Challenge : Your job is to find the given number N. Input : You will be given a string in the following form: dN ± Y = X Where: d, N, X, Y are all numbers with d , X , Y being integers (not decimals). Output : Solve the equation and output the value of N rounded. Round up if decimal is greater than or equal to 0.5...
Given string S representing a dollar amount, make change for that amount of money use the least number of coins to make the change and record the amount of each coin in a list. Here are the coins available to use and their value. Coin : Value Dollar Coins : $1.00 Quarters: $0.25 Dimes: $0.10 Nickels: $0.05 Pennies: $0....
Interleaved sequences represent an arbitrary merging of some number of sequences. An interleaved sequence can be made by appending elements to a list one by one from some number of lists, choosing the next element from some list each time. Therefore, an interleaved sequence will contain exactly the same elements of all...
Given a polynomial in one variable with rational coefficients, output an equivalent expression containing only 1, variables, and definite integrals. For example, -x2 can be expressed as ∫x∫111dtxdu. E := 1 | var | ∫EEEdvar Any reasonable input/output method is allowed. Examples: Your score will be the your code length...
This is a KOTH challenge for the dollar bill auction game in game theory. In it, a dollar is being sold to the highest bidder. Bids go up in increments of 5¢, and the loser also pays their bid. The idea is that both players escalate the bidding war far beyond the value of a dollar in order to cut their losses. Let's ho...
Description You are given the results of a range function where every element has been rounded down to the nearest whole number. Your goal is to recover the original list. For example, the following function (in Python3) will produce an input for your program: from numpy import arange, floor def floored_range(A, B, C):...
Take the numbers 0, 1, 2, 3, 4, ... and arrange them in a clockwise spiral, starting downward, writing each digit in its own separate square. Then, given one of four distinct and consistent ASCII characters (your choice) representing an axis, and an input integer n, output the first n terms of the sequence described by...
Challenge : Given a word, check whether or not it is an isogram. What : An isogram is a word consisting only of letters with no duplicates (case insensitive). The empty string is an isogram. Examples : "Dermatoglyphics" ---> true "ab" ---> true "aba" ---> false "moOse" ...
Challenge: Take a string of upper or lower case letters as input (optional), and calculate the score that string would get in a game of Scrabble in English. Rules: The score of each letter is as follows (use this even if there are other versions of the game): 1 point: E, A, I, O, N, R, T, L, S, U 2 points: D, G 3 point...
The Seidel Triangle is a mathematical construction similar to Pascal's Triangle, and is known for it's connection to the Bernoulli numbers. The first few rows are: 1 1 1 2 2 1 2 4 5 5 16 16 14 10 5 16 32 46 56 61 61 Each row is generated as follows: If the row number is even (1-indexed): Bring...
Challenge A simple challenge: given two or more strings, output all of the substrings that are in each string. Rules Input is always a comma separated list of strings Strings should be outputted from longest to shortest length without duplicates Strings should preserve whitespace Examples Input: aaa,aa Output: aa a ...
99 Varieties of Dosa is a popular chain of roadside dosa stalls across South India. This is inspired by a combination of this chain and the classic CodeGolf challenge "99 Bottles of Beer". Recreate the variant of the menu of the popular '99 Varieties of Dosa' listed below. (Note: Despite the name, the list contains 10...
Given integers N , P > 1 , find the largest integer M such that P ^ M ≤ N. I/O: Input is given as 2 integers N and P. The output will be the integer M. Examples: 4, 5 -> 0 33, 5 -> 2 40, 20 -> 1 242, 3 -> 4 243, 3 -> 5 400, 2 -> 8 1000, 10 -> 3 Notes: The input will always be valid, i.e. it will always be integers g...
Introduction A childhood game designed to help children learn to count in french in Canadian schools is played as follows: Students go around the room counting up to 11 A number greater than 11 cannot be said A student can say either 1, 2, or 3 numbers If a student says the number 11 then they are removed from the nex...
Write the shortest program or function which generates these 1000 numbers or a sequence (0- or 1-indexed) which begins with them. [0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1,...
I'm looking to find the fastest racer around. Show me your fastest lap around this 18x14 track shown below. ______ / \ / \ / ____ \ / / \ \ / / \ \ | | | | | | | | | | | | | | | | \ \ / / \ \____/ / \ ...
Challenge : Given an integer n as input. Create a diamond that is 2x the given number n. Input : Input is integer n and 2 < n ≤ 3000. Output : Output will be a string and it will be in form of a diamond consisting of + with an addition line at the start showing n using + Examples : D(3) : +++ + +++ +++++ +++++ ++...
I've been recently playing through 'The Weaver' and I think it presents an interesting challenge for code-golf. Premise: The Weaver is a game wherein you are given a number of ribbons coming from 2 directions 90 degrees apart and your goal is to swap them at certain intersections to achieve a desired output.    Like th...
Do you love watching cool timelapses of constructions or other massive work done in minutes? Lets make one here. We will be looking at an excavator digging quarry, making pictures each day to see whole progress. And your task is to show us this process! Quarry is defined by the width of its first layer. Excavator is de...
Challenge : Given a string rotate every char by its index. e.g --> 'Hello' should be 'Hfnos'. Input : Input is given as string s length of string is 2 < s ≤ 100. Input will either be alphabet , number or one of the following whitespace , ! , @ , # , $ , % , ^ , & , * , ( , ) Output : Output will be a string with all...
Specifically, Conway's PRIMEGAME. This is an algorithm devised by John H. Conway to generate primes using a sequence of 14 rational numbers: A B C D E F G H I J K L M N 17 78 19 23 29 77 95 77 1 11 13 15 15 55 -- -- -- -- -- -- -- -- -- -- -- -- -- -- 91 85 51 38...
Let's start by defining a reflection of a character in a string: Given a string with distinct lowercase alphabetical letters with no spaces such as abcdefg, define a reflection of a letter in the string c as moving it (without changing the order of any other letter) to a new place in the string such that the num...
Task Given 2 positive integers n and k, where n > k, output the number of surjections from a set of n distinguishable elements to a set of k distinguishable elements. Definition A function f: S → T is called a surjection if for every t∈T there is s∈S such that f(s) = t. Example When n=3 and k=2, the output is 6, since ...
Today was AP exam registration day at my school, and while I was meticulously bubbling in the pages and pages of information required, the idea for this challenge hit me. So, given a string of letters and numbers, output an appropriately filled out bubble chart. Rules: For each character in the input string, replace t...
I got to wondering yesterday if I could write a program to comb through a given word search and output the answers. It was actually surprisingly easy. Now I wonder just how small we can get. Rules Your first input is a string or collection of n lines, each of which is n characters long Your second input is a list of ...
In light of today's date... A factorial of a number n, is the product of all the numbers from 1 to n inclusive. The Challenge Given an integer n where 0 <= n <= 420, find the sum of the digits of n!. It's that simple :P Notes: I feel like this challenge isn't too simple, as some languages have a very hard time storing ...
This challenge is completely ripped offheavily inspired by All Light, developed by Soulgit Games. Challenge You are an electrician, and it's your job to wire up all the lights to the battery. The lights and battery are laid out in a grid. You can connect a light or battery to the nearest light or battery to its north,...
AKA: Generate Clickbait From an Array. Given an array of integers, generate some cringe-worthy clickbait based on its arrangement and length: If it's 20 elements or less, you can make a Top X List. Parameters: length of the array. Prime numbers are celebrities, so anytime two of them are next to each other it'll pass ...
This is my first challenge on ppcg! Input A string consisting of two different ascii characters. For example ABAABBAAAAAABBAAABAABBAABA Challenge The task is to decode this string following these rules: Skip the first two characters Split the rest of the string into groups of 8 characters In each group, replace each ...
Let's start by re-defining a reflection of a character in a 2-d array of characters: Given a square 2-d array of characters with distinct lowercase alphabetical letters, define a reflection of a letter in the matrix as swapping it with the character directly across from it through the center of the square. Thus, a re...
Swapping two elements in a vector/matrix is very simple in Octave: x='abcde'; x([4,1])=x([1,4]) x = dbcae Unfortunately, I have yet to find a way to do this inside an anonymous function. While the function below is syntactically correct, it only gives back the two elements that are swapped, not the entire x vector...
Here's an interesting sequence discovered by Paul Loomis, a mathematician at Bloomsburg University. From his page on this sequence: Define f(n) = f(n-1) + (the product of the nonzero digits of f(n-1)) f(0) = x, with x as any positive integer, written in base 10. So, starting with f(0)=1, you get the following sequence ...
I just love this simple cypher, it's so fun reading not-quite human-readable words and filling the gaps... Ot wes thi bist uf tomis, ot wes thi wurst uf tomis, ot wes thi egi uf wosdum, ot wes thi egi uf fuuloshniss, ot wes thi ipuch uf biloif, ot wes thi ipuch uf oncridaloty, ot wes thi siesun uf loght, ot wes thi ...
Background The Royal Netherlands Meteorological Institute defines a heat wave* as a series of at least 5 consecutive days of ≥25°C weather (“summery weather”), such that at least 3 of those days are ≥30°C (“tropical weather”). The tropical weather doesn't have to be measured consecutively: for example: 30, 25, 30, 26, ...
Your task is to automatically complete URLs like the address bar in most browsers is doing. We will use the following (simplified) rules: If the input string starts with http://, ftp:// or https://, return the string unchanged. Otherwise, if the input string contains a dot ., e.g. in.put then the HTTP is assumed and ...
This challenge was posted as part of the April 2018 LotM challenge Brain-Flak is a turing-tarpit language which has gained quite a lot of fame here on PPCG. The memory of the language is composed by two stacks, but a "hidden" third stack was discovered by Wheat Wizard, leading to some interesting new ways of thinking ...
Given two positive numbers N >= 2 and N <= 100 create a matrix which follows the following rules: First Number starts at position [0,0] Second Number starts at position [0,1] Third number goes below First Number (position [1,0]) Following numbers goes in "slash" direction Range of numbers used is [1, N1 * N2]. So, num...
TL;DR Record (left-right)/length for each pair of consecutive elements. If they're 0 or negative, don't record it. Once this is done, take these actions. Don't update quotients: Increment right and decrement left for (0, .3) Remove from the array at >=.3 Print both elements for >.5 Print the remaining array. Have s...
The input consists of i rows with neighbors information. Each ith row contains 4 values, representing the neighbor of i to the North, East, South and West directions, respectively. So each value represents a neighbor at the given direction of the ith row, starting from row 1, and can go up to 65,535 rows. The 0 value i...
Where am I now? Given a string d, containing only the letters NSWE, determine the coordinates I've traveled (from left to right, consuming greedily) and the final coordinate where I reside. The rules for reading coordinates from left-to-right: If the next character is N or S: If the character after the N or S is anot...
Challenge You will create a function which takes a matrix filled with letters from the alphabet and determine if a 2x2 square composed of vowels exists. If a 2x2 square of vowels is found, your function should return the top-left position (row-column) of the square. If no 2x2 square of vowels exists, then return the ...
This question is similar to Biggest Square in a grid. Challenge Given a matrix of 1 and 0 in a string format "xxxx,xxxxx,xxxx,xx.." or array format ["xxxx","xxxx","xxxx",...], You will create a function that determines the area of the largest square submatrix that contains all 1. A square submatrix is one of equal widt...
Make a quine but with a twist. Statement The quine prints its code but puts its first character at the end. (You can do it in reverse but include that note in your answer) The output must then be a program which is also an solution. Example: Assume your code was foobar, running it will return oobarf which will be anoth...
Find the area of a region of unit cells given its perimeter loop as a sequence of 90-degree turns. For example, take the three-cell region XX X whose perimeter loop we draw L<S<L v ^ S R>L v ^ L>L Each turn is marked as left (L), straight (S), or right (R). Starting from the R, the turns are RLLSLSLL. So, given in...
The goal of this challenge is to determine if a move is a legal English Checkers move. This challenge will use an 8x8 board. A moved piece should be treated as a man (not a king) that can only move diagonally forward. The board will have 0 or more black pieces and 1 or more white piece. One white piece will be current...
How the encoding works Given a list of bits: Hold a prime (starting with 2) Have a list For each bit in the input If it's the same as the previous bit, add the prime you're holding to the list If it's different, hold the next prime and add that to the list Return the product of all the numbers in your list For the ...
Challenge Create a function that takes an string as a parameter. (Easy as far) This string will contain Single digit numbers Letters from the alphabet Question marks (Of course) Your function will check if there are exactly 3 question marks between every pair of two numbers that add up to 10 or more. If so, then your...
Cross posted from my anagolf post (note: may contain spoilers, post mortem). Output the following text exactly. You may have additional trailing whitespace on each line, and trailing newlines as well. Shortest code, in bytes, wins. ...
Make an upside down triangle of positive integers. Every number in the triangle must be distinct. Each number is the summation of its two parents (similar to how Pascal's triangle is constructed, but upside-down). Construct it in such a way that the bottom number is minimized. For example, for input n = 4, here is a po...
Challenge: You'll be given an ASCII image of a pile of weights as input, and must output the combined weight of the pile. Format: There are 5 different weights, weighing 1, 2, 5, 10, 20 Passerees (or some other arbitrary unit). The weights looks like this, in ascending order: 1: __ |__| 2: ______ |______|...
Output either the text below, or a list of lists of integers (more details below). 0 10 1 20 11 2 30 21 12 3 40 31 22 13 4 50 41 32 23 14 5 60 51 42 33 24 15 6 70 61 52 43 34 25 16 7 80 71 62 53 44 35 26 17 8 90 81 72 63 54 45 36 27 18 9 91 82 73 64 55 46 37 28 19 92 83 74 65 56 47 38 29 93 84 75 66 57 48 39 ...
Related, both rope, nail and falling, but reversed and some other differences Consider a loop of rope hanging on n nails on a row. Given a table showing whether the rope would fall down when each possible set of nails were removed, please provide a possible roping way. You may assume such a solution exist. Here, "fall ...
Challenge: Your job is to create a simple interpreter for a simple golfing language. Input: Input will be in the form of string separated by spaces. You can replace space separation with what you want Output: Output the result (a number or a string) obtained after performing all operations. If there are more than on...
In Chess, a Knight on grid \$(x, y)\$ may move to \$(x-2, y-1)\$, \$(x-2, y+1)\$, \$(x-1, y-2)\$, \$(x-1, y+2)\$, \$(x+1, y-2)\$, \$(x+1, y+2)\$, \$(x+2, y-1)\$ or \$(x+2, y+1)\$ in one step. Imagine an infinite chessboard with only a Knight on \$(0, 0)\$: How many steps is required for moving a Knight from \$(0, 0)\$...
Challenge In this challenge you will construct trees, in the form of ASCII Art using recursion. Basically you will generate the ASCII version of the Fractal Tree Input Number of iterations 0 < N <= 5 Output The Nth iteration of the Fractal Tree. It must be a matrix of 63 rows and 100 columns. (i.e. 6300 printable ch...
A Pillai prime is a prime number \$p\$ for which there exists some positive \$m\$ such that \$(m! + 1) \equiv 0 \:(\text{mod } p)\$ and \$p \not\equiv 1\:(\text{mod }m)\$. In other words, an integer \$p\$ is a Pillai prime if it is a prime number, if there exists another positive integer \$m\$ such that the factorial...
We've had a lot of quine challenges, but a lot of the quine formats are similar, lets create some variance in our quines. Your task is to create a selection of programs in the same language (at least 2), all of which output their own source code, however, none of these programs can share any characters. For example, if...
Inspired by the challenge A pile of weights. Challenge Given an integer as a weight in pounds, output an ASCII barbell that can represent the weight. Weights will come in the form of the barbell (which will weigh 45lbs) and plates with the following weights: 45lbs, 35lbs, 25lbs, 10lbs, and 5lbs. Weights will be repre...
Challenge : Given two non-negative integers (X and Y > 1) calculate the sum of digits of their powers . i.e : sum of digits of X ^ Y . Input : Two non-negative integers X and Y Output : The sum of digits of X raised to power Y X ^ Y. Examples : 5 , 2 ---> 7 9 , 4 ---> 18 3 , 17...
Schlosberg Numbers In issue 5 of Mathematical Reflections, Dorin Andrica proposed the problem of characterising the positive integers n such that is an even integer. Eight people submitted correct solutions showing that these are the integers n for which is even. The published solution was by Joel Schlosberg, so I c...
Given a list of case-insensitive ASCII letter strings ("words"), output whether the entire list can be found on some four-by-four configuration ("board") of letter squares, in which no square can be used more than once in a word, and in which words are formed by moving from any square to any adjacent square including d...
Adapted from the UIL - Computer Science Programming free response question "Carla" for 2018 District. Introduction In UNIX-like operating systems, each file, directory, or link is "owned" by a "user", who is a member of a "group", and has certain "permissions" represented by a ten-character string such as "drwxrwxrwx"....