instruction
stringlengths
34
53.1k
There are several questions regarding this game, even a king-of-the-hill contest here. But I think all those challenges and contests need a way to automatically determine the winner of a game. So: Challenge Given two inputs in the range ["rock", "paper", "scissors", "lizard", "spock"] representing the selections for pl...
It's all in the title... Take as input a positive integer n>=12 and... do what the title says. Yes, this is on OEIS A187924. Some test cases 12 -> 912 13 -> 11713 14 -> 6314 15 -> 915 16 -> 3616 17 -> 15317 18 -> 918 19 -> 17119 20 -> 9920 40 -> 1999840 100-> 99999999999100 This is code-golf. Short...
Forget BIDMAS! Write a program that takes an equation and an operator precedence order, and prints the result. Example input format: 1.2+3.4*5.6/7.8-9.0 */+- Rules & guidelines: The only operators that are defined are addition (+), subtraction (-), multiplication (*), and division (/). No parentheses, no exponentiati...
The famous constructed language Esperanto uses the Latin alphabet (mostly, see the linked wikipedia page for details). However, there are some characters with accents: ĉ, ĝ, ĥ, ĵ, ŝ, and ŭ. (C-circumflex, g-circumflex, h-circumflex, j-circumflex, s-circumflex, and u-breve.) Naturally, these characters are very hard to ...
Objective Write a program or function (or equivalent) that sorts out and returns the odd letter in the matrix of random size. Details You will be passed a matrix (as a string) as input of random dimensions such as this. bbbbbbbbbb bbbbbdbbbb bbbbbbbbbb bbbbbbbbbb bbbbbbbbbb Your job is to find the letter that doesn't...
Let's define fn(k) as the sum of the first k terms of the natural numbers [1, ∞) where each number is repeated n times. k | 0 1 2 3 4 5 6 7 8 9 --------+------------------------------------------------- f_1(k) | 0 1 3 6 10 15 21 28 36 45 deltas | +1 +2 +3 ...
Another sequence, another challenge.* Definition A prime p is in this sequence, let's call it A, iff for every digit d in p's decimal expansion, you replace d with d copies of d and the resulting integer is still prime; zeros are not permitted. For example, 11 is trivially in this sequence (it's the first number, incid...
Introduction As you all know, German has umlauts. They're these things: ¨ However, most keyboards don't have an umlaut key. That's fine, though, because you can write ö, ä, and ü as oe, ae, and ue. Challenge Your job is to to replace ö, ä, and ü with oe, ae, and ue (and likewise for their capital versions). You have t...
This is a QWERTY keyboard. Q W E R T Y U I O P A S D F G H J K L Z X C V B N M We can "spiral out" on this keyboard, starting from G. The spiral will start at G, go to H, then to Y, then to T, then F, then V, then B, then N, then J, then U, then R, then D, then C,... etc. Your challenge is to, given a number 1 ≤ N ...
The Challenge Given a string indicating the symbolic notation of UNIX permission of a file and its ownership (user ID and group ID), decide whether a given user A has permission to read / write / execute it. Related. Permissions in UNIX system In UNIX, every file has three classes of permissions (user, group and others...
Description While support is getting better and better for people to write in various scripts around the world using unicode, and now you can even write in emojis as well, unfortunately most fonts[citation needed] are still missing Latin characters based on the double acute accent, which is required to write properly i...
The Task Your task is to create a program or a function that, given an input, outputs the input text with random letters capitalized, while keeping already capitalized letters capitalized. Every combination of capitalizations of the lowercase letters should be possible. For example, if the input was abc, there should b...
Background The United States has a unique love of gerrymandering––the deliberate manipulation of an electoral district to predict certain voting results. Just recently there was a gerrymandering case brought before the Supreme Court. Gerrymandering, especially when related to race, is ruled illegal and results in the r...
Introduction Mathematicians often work with number sets. These are groups of numbers that share common properties. These are number sets are, in order from most specific to most broad: Natural numbers (symbol N): These are the counting numbers: 1, 2, 3, ... Integers (symbol Z): These are all the numbers with...
It's that time of year when many of us get our advent calendars! If you are unfamiliar with an advent calendar, these are special calendars used to count down advent in anticipation of Christmas. In my experience the doors are placed randomly, and part of the fun as a child was working out where tomorrow's door was! O...
The solar year is 365 days, 5 hours, 48 minutes, 45 seconds, and 138 milliseconds, according to this video. With the current Gregorian calendar, the rules for leap years are as follows: if year is divisible by 400, LEAP YEAR else if year is divisible by 100, COMMON YEAR else if year is divisible by 4, LEAP YEAR ...
You left your computer for too long, and it went to sleep. Wake it up again by printing the following coffee maker. ________._________ | | \ - / | || | \ - / | || |___\___/ | || | X | | ___ | | / - \ |______| / - \ | ____ | /_______\ ||7:30||__________ ||____| | |______...
Look at the following string. Notice a pattern? ABEFNOPEFGH DC G Q I M H R J LKJI S K D T L C U M BAZYXWV N E O D P C Q BAZYXWVUTSR As some might have noticed, it's basically a spiral of the alphabet, where the distances between rows / columns are gradually increasing b...
The challenge Given two integers as input (x and y), output x as a string with as many leading zeroes necessary for it to be y characters long without the sign. Rules If x has more than y digits, output x as string without modification. Output as integer is not accepted, even if there are no leading zeroes. When x is ...
Next >> Descriptive Keywords (for searching): Make Two Matrices Equivalent, Overlap, Array, Find Challenge Santa has had a history of elves stealing presents from his vault in the past, so this year he designed a lock that is very hard to crack, and it seems to have kept the elves out this year. Unfortunately, he has l...
4-state barcodes Many postal services (Royal Mail UK, Canada Post, US Mail, etc) use a 4-state barcode to encode information about their mail. Rendered in ASCII, it may look something like this: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A 4-state barcode is a row ...
You probably know the rhetorical question of whether a glass is half full or half empty. I'm getting a little tired of the phrase, so I decided that it's time to eliminate this confusion about glass fullness or emptiness programmatically. Your task is to write a program that takes an ASCII art representation of an ugly...
Given you have an infinite sequence of numbers defined as follows: 1: 1 = 1 2: 1 + 2 = 3 3: 1 + 3 = 4 4: 1 + 2 + 4 = 7 5: 1 + 5 = 6 6: 1 + 2 + 3 + 6 = 12 7: 1 + 7 = 8 ... The sequence is the sum of the divisors of n, including 1 and n. Given a positive integer x as input, calculate the lowest number n which will produ...
Inspired by this comment. Input The number of seconds on the timer. Output Here's our basic microwave: _____________________________________________________________ | | ___________ | | | | [display] | | | ____________________...
I'm (still) trying to make another submission to the Largest Number Printable question, and I've got the following bit of code: f=->a{b,c,d=a;b ?a==b ?~-a:a==a-[c-c]?[[b,c,f[d]],~-c,b]:b:$n} h=[],$n=?~.ord,[] h=f[h]until h==p($n+=$n)-$n Ungolfed: f=->{b,c,d=a if b if a==b # a is not an array return a-1 elsif a...
<< Prev Next >> Challenge Now that Santa has finally figured out how to get into his present vault, he realises that somehow the elves got in there before him and stole some of his presents! They haven't figured out how to leave the vault yet though, so Santa has to try and catch them all. Santa and the elves both have...
Given a natural number n write a program or function to get a list of all the possible two factors multiplications that can be used to achieve n. To understand better what is pretended you can go to http://factornumber.com/?page=16777216 to see when n is 16777216 we get the following list: 2 × 8388608 4 × 41943...
Introduction Suppose I have a list of integers, say L = [-1,2,2,1,2,7,1,4]. I like having balance in my life, so I'm happy to see it has as many odd elements as even elements. What's more, it also has an equal number of elements in all modulo classes of 3 that it has elements in: [-1,2,2,1,2,7,1,4] 0 mod 3: 1 ...
Oh no! I have a theory test soon and I don't remember the scales yet! Help me remember my major scales by printing the following: 7♯ - C♯ D♯ E♯ F♯ G♯ A♯ B♯ C♯ 6♯ - F♯ G♯ A♯ B C♯ D♯ E♯ F♯ 5♯ - B C♯ D♯ E F♯ G♯ A♯ B 4♯ - E F♯ G♯ A B C♯ D♯ E 3♯ - A B C♯ D E F♯ G♯ A 2♯ - D E F♯ G A B C♯ D 1♯ - G A B C D ...
<< Prev Next >> Unfortunately, Santa was not able to catch the elves in time! He has to go back to manufacturing presents now. Since the elves are definitely not Santa's slaves, he has to figure out the expenses for how much to pay them. Challenge Given some information for the presents, determine the cost of manufactu...
Introduction As is known, in 2017, Finland celebrates its 100 years of independence. To mark the occasion, it is your job to produce a Finnish flag for everyone's enjoyment. Challenge Create a program or a function that produces the flag of Finland (the grey border is there for presentation purposes only): Flag specif...
<< Prev Next >> Santa was able to remanufacture all of the presents that the elves stole overnight! Now he has to send them to the assembly line for packaging. He usually has a camera to supervise the assembly line both to make sure the elves are doing a good job and because assembly line pictures look nice on advertis...
Related: Iterated phi(n) function. Your challenge is to compute the iterated phi function: f(n) = number of iterations of φ for n to reach 1. Where φ is Euler's totient function. Related OEIS. Here's the graph of it: Rules: Your goal is to output f(n) from n=2 to n=100. This is code-golf, so shortest code wins. Here...
A traditional Western die is a cube, on which the integers 1 to 6 are marked on the faces. Pairs that add to 7 are placed on opposite faces. As it is cube, we can only see between 1 and 3 faces (inclusive)1 at any given time. Opposite faces can never be seen at the same time. Your task is to write a program or function...
Today's Google doodle is about Celebrating 50 years of Kids Coding: The goal is program the path of a little bunny so that it can eat all the carrots. There are 4 types of blocks (see pictures below): From left to right: O("...", k) = orange piece: these are for loops which executes k times the program "...". G = g...
Suppose you have a set of sets of integers. It's possible that some of the sets will overlap (i.e. sharing elements). You could get rid of the overlaps by deleting elements from the sets, but then some of them might end up empty; that would be a shame. Can we make all the sets disjoint without emptying any of them? Not...
Programs often list outcome statistics, such as this: 54% of participants received an award 69% of participants got a promotion 85% of participants increased their salary These percentages are the result of dividing a/x, where both a and x are whole numbers, and the result is rounded to the nearest hundredth. Your ta...
<< Prev Next >> Thanks to the PPCG community, Santa has managed to remanufacture all of his presents and after the assembly line, the presents are now ready to be moved into the transport docks! Each of Santa's transport docks only holds a range of present sizes because the transport sleighs are specialized for a speci...
Background: I originally posted this question last night, and received backlash on its vagueness. I have since consulted many personnel concerning not only the wording of the problem, but also its complexity (which is not O(1)). This programming problem is an evil spin on an Amazon interview question. Question: Given a...
Problem Consider a square 3 by 3 grid of non-negative integers. For each row i the sum of the integers is set to be r_i. Similarly for each column j the sum of integers in that column is set to be c_j. The task is to write code to enumerate all possible different assignments of integers to the grid given the row a...
The Challenge I am thirsty and need a drink, but I don't know what to order. Your task is to provide me with either a drink or options for one. I/O Input will be either a base or a drink name. If given a base, your program should output one random drink from a list of drinks with that base. If given a drink name, your ...
<< Prev Next >> Thanks to the PPCG community, Santa managed to sort his presents into the correct order for moving into the transportation dock. Unfortunately, the transportation dock signs are broken so he doesn't know where to put all the presents! The presents are all grouped together and not by their ranges, which ...
If you're sad, that's wrong. We need to scrub out ALL sadness. This is a sad face, for reference: ...... .S..S. ........ ...SS... ..SS..SS.. .S......S. ........ Where S is a consistent pixel, . is any pixel other than S, and is any pixel. Note that the sad face is not a perfect square, only the . shoul...
A half-exponential function is one which when composed with itself gives an exponential function. For instance, if f(f(x)) = 2^x, then f would be a half-exponential function. In this challenge, you will compute a specific half-exponential function. Specifically, you will compute the function from the non-negative integ...
Today's date is quite an interesting one. Let's take a look at why. The date 07/12/2017 (in DD/MM/YYYY date format) can be split into the year (2017) and the rest (07/12). You may notice that the digits in the year can be rearranged to match the digits in the rest of the date, which is the basis of this challenge. The ...
Problem Draw a hexagon chain x long, each with side of y length Input x - the length of the chain <= 50 y - the length of each side <= 50 Examples x=1,y=1 _ / \ \_/ x=4,y=1 _ _ / \_/ \_ \_/ \_/ \ \_/ \_/ x=3,y=2 __ __ / \ / \ / \__/ \ \ / \ / \__/ \__/ \ / \__/ Rules ...
Related but very different. A boustrophedon is a text where every other line of writing is flipped or reversed, with reversed letters. In this challenge, we will just reverse every other line, but leave the actual characters used intact. You may chose which lines to reverse, as long as it is every other one. You may ta...
I once saw on the xkcd fora a format for expressing numbers in an odd way. In this "factor tree" format: The empty string is 1. Concatenation represents multiplication. A number n enclosed in parentheses (or any paired characters) represents the nth prime number, with 2 being the first prime number. Note that this ...
<< Prev Next >> After some careful analysis, Santa was able to determine the dock size ranges and get the presents into the correct transportation dock. Now, he needs you to help him balance out the transportation carts and place the presents in them in the most balanced fashion. Challenge You will be given the size of...
Background I am currently in an AP Comp Sci A: Java class, and I want to start some of my friends on code golfing. I have a challenge from the course, and I would like to see how many bytes the community can do this challenge in. Challenge details: Given two input strings, the main string and the pivot string, do the ...
Given an integer \$x_1\$ and some black box function \$f: ℤ → ℤ\$ find a fixed point of \$f\$ in the sequence defined by \$x_{k+1} := f(x_k)\$. Details A value \$x\$ is said to be a fixed point of \$f\$ if \$x = f(x)\$. For instance if \$f(x) = \text{round}(\frac{x}{\pi})\$ and we have a starting point \$x_1 = 10\$ t...
Let's define a self-contained number as a positive integer, whose digits appear in runs of length equal to themselves only. In other words, any decimal digit d (excluding 0) occurs only in runs of length exactly d. Task You can choose any of the three methods listed below: Given an integer n, output the nth (either 0 ...
The main purpose of the RGB (Red Green Blue) color model is for the sensing, representation and display of images in electronic systems, such as televisions and computers HSL (Hue Saturation Lightness) is an alternative color model, designed in the 1970s by computer graphics researchers to more closely align with the ...
There has not been a challenge regarding slope fields, as a far as I can tell. So, I might as well make one. The challenge Given: A black box function f which takes two arguments, x and y (both real numbers) , and returns the value of the slope at point (x,y) (also a real number) A list of real numbers, X, representi...
Adapted from this FiveThirtyEight riddle. Background Examine the following infinite sequence: 3 3 3 2 3 3 3 2 3 3 3 2 3 3 2 3 3 3 2 ... Let's say the sequence is 1-indexed. The ith number in the sequence determines how many 3s there are before the ith 2 and following any previous 2s. So since the sequence starts with ...
Write an indefinitely-running program that reports how many instances of itself are currently running. Each instance of the program should also report the order in which it was opened out of all other currently-running instances. Example The user launches the program for the first time - we'll call this Instance 1. Ins...
A follow-up to this challenge Given a set of mixed dice, output the frequency distribution of rolling all of them and summing the rolled numbers on each die. For example, consider 1d12 + 1d8 (rolling 1 12-sided die and 1 8-sided die). The maximum and minimum rolls are 20 and 2, respectively, which is similar to rolling...
Background I was working on a StackOverflow helper program (that sends me notifications) when I noticed something rather interesting in StackOverflow's Network tab: StackOverflow uses WebSockets (not too surprising, but good to know)! For this challenge, we will be conquering StackOverflow's web socket server. This p...
Background: This question is a remix of the one that I made previously on this forum. The only difference with this one is: the range is significantly larger, AND dynamic. Details below! Also, I'm typing this question incredibly quickly, so if there are any grammatical errors, I do apologize and ask if anyone would edi...
Task Given two positive integers (dividend and divisor), calculate the quotient and the remainder. Normally it would be calculated as e = o*q+r where q*o<=e and 0<=r<o. For this challenge it still e = o*q+r but q*o>=e and -o<r<=0. For example e=20 and o=3, normally it would be 20/3 -> 20=3*6+2, since 18<=20 and 0<=2<3....
<< Prev Thanks to the PPCG community, Santa now has balanced his storage carts. Now, he needs to move them into the transport docks so that they can be sent to the loading bays. Unfortunately, the tracks to move the carts around are a mess, and he needs to figure out how to get them all around without them crashing tog...
GPA Calculator (GPA = Grade Point Average) You are a stressed out college student during finals week. Instead of studying for your exams coming up, you decide it is best to determine what GPA you will have at the end of the semester. This way you have data to back up your decision of staying up all night to get that A ...
In APL, you can write tacit functions, called trains. How they work is irrelevant for this challenge. Here are the different ways they can be grouped, using ⍴ as the function: ⍴ -> ⍴ ⍴⍴ -> ⍴⍴ ⍴⍴⍴ -> ⍴⍴⍴ ⍴⍴⍴⍴ -> ⍴(⍴⍴⍴) ⍴⍴⍴⍴⍴ -> ⍴⍴(⍴⍴⍴) ⍴⍴⍴⍴⍴⍴ -> ⍴(⍴⍴(⍴⍴⍴)) ... The order remains the same. The procedure is...
Near the middle of the semester in chemistry, we get problems like: Convert 1.283850057 to Scientific Notation and Convert 3.583✕106 to Standard Notation This is just stupid busy work for people who already know how to do this. So… The Challenge Given an input in any reasonable, convenient format, in either standar...
In atomic physics and quantum chemistry, the electron configuration is the distribution of electrons of an atom in atomic orbitals. For example, the electron configuration of the neon atom is 1s2 2s2 2p6 (From Wikipedia) Challenge Your challenge is to take a number representing the atomic number of an element and out...
For any String that is composed of lower cased alphabetical characters, make a function that returns a list of all of it's variations, empty strings returns empty list Test Cases "" -> [] "a" -> ["a", "A"] "ab" -> ["ab", "Ab", "aB", "AB"] "abc" -> ["abc", "Abc", "aBc", "ABc", "abC", "AbC", "aBC", "ABC"] This is Code-g...
Given an Integer array: Start from the first number Jump forward n positions where n is the value of the current position Delete the current position, making what was the next position the current position. Goto step 2 until there is one number remaining Print that number Rules The array wraps-around (the next number...
Yahtzee is a game played with five six-sided dice and a score sheet with thirteen different boxes to fill a score in. Each box has its own scoring rules: 1s, 2s, 3s, 4s, 5s, 6s all score points equal to the sum of the respective dice (that is, a roll of [3, 2, 3, 1, 5] scored as 3s would be awarded 6 points: 3 for eac...
In case you missed Encode Factor Trees, here is the definition of a Factor Tree: The empty string is 1. Concatenation represents multiplication. A number n enclosed in parentheses (or any paired characters) represents the nth prime number, with 2 being the first prime number. Note that this is done recursively:...
Given 2 random circle sections, return how many times they intersect. Rules/clarifications are as below. You are provided 10 total values, The center (x,y) of the circle section Angles of the circle (i.e. (0,90) would be a quarter circle "facing" the top-right corner. The radius of the circle section The circle s...
For another challenge I am writing, I need to verify that test cases are solveable with bounded integers. Specifically, I need to verify the following, for a non-empty array of integers A and an integer bit width n: All integers a in A satisfy -2**(n-1) <= a < 2**(n-1) (representable with n-bit two's complement intege...
You work at a virtual, old-fashioned printing press. To help you arrange your monospace letters faster, you decide to make the shortest program possible to help you. Given a string of text and a page size, generate and output each page of the text. Examples For example, with a page width of 14, height 7, and some text,...
Challenge For a given positive integers range, find the first and last prime number entirely composed of prime number digits, exceptionally including 0 (for the digits, a range of 0-2 should output 2-2). The range is inclusive. If no number is found, the expected output is 0. If there is only one such number, the expec...
Write a regular expression which matches a given string consisting of three non-negative, space-separated integers if and only if the last integer is the sum of the previous two. Answers may be for integers of any numeral system with radix between 2 and 10. Test cases These should fail: 0 1 2 10 20 1000 These should m...
Standard ML (or golfier: SML) is a general-purpose, modular, functional programming language with compile-time type checking and type inference. (from Wikipedia) Though you almost certainly will never win a code golf challenge with SML, (ab-) using it for golfing can nevertheless be quite fun (<- keyword for function d...
I call this sequence "the Jesus sequence", because it is the sum of mod.</pun> For this sequence, you take all the positive integers m less than the input n, and take the sum of n modulo each m. In other words: $$a_n = \sum_{m=1}^{n-1}{n\bmod m}$$ For example, take the term 14: 14 % 1 = 0 14 % 2 = 0 14 % 3 = 2 14 % 4 =...
This challenge posed an algorithm for encoding an integer n as another integer r. What follows is a succinct explanation of that algorithm, using n=60 as an example. The original algorithm First, we encode the number as a string of brackets. If n = 1, return an empty string. Otherwise, we take n's prime decomposition...
This is based on how my company deals with the monitoring of the working times for every employee. Each one of us has a card that can be passed in front of a sensor, so that a clock registers the times at which the employees check in or out the office. Every time register is linked to a code: Code 0: the employee arri...
The characteristic polynomial of a square matrix \$A\$ is defined as the polynomial \$p_A(x) = \det(Ix-A)\$ where \$I\$ is the identity matrix and \$\det\$ the determinant. Note that this definition always gives us a monic polynomial such that the solution is unique. Your task for this challenge is to compute the coeff...
Given 4 points on the 2D planes A, B, C, D, calculate the area of the intersection region of the triangles OAB and OCD, where O is the center of the plane, having coordinate (0, 0). Algorithms that runs in constant time complexity (in terms of arithmetic operations) are encouraged, but not forced. Rules Each point is ...
Dice Cricket is a game I was introduced to as a child and have used as a way to pass time for years since. I couldn't find a Wikipedia page so I'll explain the rules below. Dice Cricket Rules Premise Dice Cricket is a game similar to scoring a game of cricket as you watch it but rather than watching and recording the r...
Given a binary number A as input with d > 1 digits, output a binary number B with d digits according to the following rules for finding the nth digit of B: The first digit of B is zero if the first and second digits of A are equal; otherwise, it is one. If 1 < n < d, then if the (n-1)th, nth and (n+1)th digits of A ar...
Merge sort is a sorting algorithm which works by splitting a given list in half, recursively sorting both smaller lists, and merging them back together to one sorted list. The base case of the recursion is arriving at a singleton list, which cannot be split further but is per definition already sorted. The execution of...
The Pareto Distribution is a probability distribution that comes up a lot in nature. It has lots of special properties, such as an infinite mean. In this challenge, you will output a number sampled from this distribution. The Pareto Distribution is defined to be greater than or equal to x with probability 1/x, for all ...
Normally, I'd open with some flavor text here about being bored and/or lazy but looking through the stack-exchange-api questions that would be far from original. So instead I'm going to open with a meta and self-referential flavor text describing this lack of originality that then describes itself and how meta and self...
Challenge For any string that is composed of alphabetical characters of any case, make a function that returns a list of all of it's variations, order and case-wise empty strings returns empty list. Test Cases "" -> [] "a" -> ['a', 'A'] "ab" -> ['ab', 'Ab', 'aB', 'AB', 'ba', 'Ba', 'bA', 'BA'] "abc" -> ['abc', 'Abc', '...
(2 Jan 2018) Because of the winning criteria I am going to accept the Jelly answer, but I am also giving upvotes to all other answers which all use astounding methods as well Introduction There are lots of challenges asking for a shortest program to calculate mathematical constants. I saw some with restrictions like ba...
Unary numbers typically only represent nonnegative integers, but we can extend them to represent all integers as follows: A positive integer N is represented as N 1's: 5 -> 11111 A negative integer -N is represented as a 0 followed by N 1's: -5 -> 011111 Zero is represented as 0 We can then represent a list of these ...
Given a nonnegative integer, return whether it is a three digit number ending in one, in any consistent integer base. In other words, the number needs to be represented in base-N, N being an integer greater than zero. Rules This is code-golf, so shortest answer wins. Since unary behaves weirdly, the behavior with inpu...
Given a fraction in the format m/n (where m and n are coprime integers), output the corresponding Unicode fraction. Your program/function will not be expected to take in any input that does not correspond to a Unicode character. Arrays, e.g. [2, 3] as opposed to 2/3, are accepted. m / n as opposed to m/n is also fine. ...
We all know that whenever a rational number is written in decimal, the result is either terminating or (eventually) periodic. For example, when 41/42 is written in decimal, the result is 0.9 761904 761904 761904 761904 761904 761904 761904 ... with an initial sequence of digits 0.9 followed by the sequence 761904 repe...
The partitions of an integer N are all the combinations of integers smaller than or equal to N and higher than 0 which sum up to N. A relatively prime partition is an integer partition, but whose elements are (overall) coprime; or in other words, there is no integer greater than 1 which divides all of the parts. Task G...
Challenge: Your task is to use any language to output that language's name times the number of character's in its name. Use the common name or acronym of the language. If there are multiple versions of a language, you need not include the version number. The capitalization matters. Examples: PHP -> PHPPHPPHP Java -> ...
A pleasing number (according to this definition) is a number that can be passed through the following process (let's use 41802000 as an example): Separate the trailing identical numbers (41802000 => [41802, 000]) Sort the first half of the digits and take the maximum ([41802, 000] => [8, 000]) Take the length of the f...
Introduction In this challenge you should split an integer into two pieces. Since nobody likes getting the smaller piece of cake, your goal is to be as fair as possible. For example if you wanted to split the integer 7129 into two pieces, there are 3 possible ways of doing so. 7,129, 71,29 and 712,9 are all possibiliti...
Just for fun, I wanted to see how little lines I could solve this problem in, using python. I managed to condense my code into 9 lines. size = int(input("Size: ")) a = [x for x in range(size-2, -1, -1)] if size % 2 == 0 else [x for x in range(size-2, 0, -1)] b, counter = a[::-1], 0 print("\n"+"\\"+"#"*size+"/") #top f...
Description Output the rhyme scheme for a very long Terza Rima. Input None. Output ABA BCB CDC DED EFE FGF GHG HIH IJI JKJ KLK LML MNM NON OPO PQP QRQ RSR STS TUT UVU VWV WXW XYX YZY Rules You can pick between separating stanzas with whitespace or newlines, so either: ABA BCB... OR ABA BCB ... A single trailing whit...
Task Write a program/function that, given three integers n,a,b prints a regular expression which matches all of the base-n integers from a to b (and no integers outside of that range). Your algorithm should, in theory, work for arbitrarily large integers. In practice, you may assume that the input can be stored in your...
If you have a small child in your house, you may have come across foam bath letters. These can be moistened and stuck to flat surfaces such as tiles and the side of the bath to make words and messages. The range of words and messages is somewhat limited if you only have one set though, since you only get 36 characters:...
Thanks to your help in the Mark My Mail challenge, PPCG-Post has successfully stamped all of its parcels with the generated barcodes! Now, it's time to decode them. In this challenge your program will, given a barcode generated from the Mark My Mail challenge, decode it and return the encoded integer. But watch out! Th...