instruction
stringlengths
34
53.1k
Introduction There is a tax collector that has some trouble managing the taxes of his kingdom: the historical records have burnt down in a great fire. He wants to find out how many possible pasts there could be in terms of where the current money was inherited from. Luckily, his kingdom is very simple. The kingdom can ...
The problem: Write a function which, given a cycle length n and a number of cycles m, where 'm' is within [2, n-2], generates m random cycles, each of length n, and all of which are derangements of each other. Then n=7, for example, m could be 2, 3, 4, or 5. All possible sets of m cycles of length n that fit the criter...
Write a program that will test the primality of a specified number, and give the output as a Boolean value (True is prime). Your prime test can (but doesn't have to) be valid for the number 1. Here's the catch: your program itself has to sum to a prime number. Convert every character (including spaces) to its Unicode/...
This is a Hello World challenge! Those plain ones! Yeah.... However, it's different this time. Because here, you can't use C or C++ or Stuck or ArnoldC or whatever you want. You can only choose raw x86 opcodes from this list, or any other x86 opcode lists. It is also assuming you have no Protected Mode or any other thi...
Challenge: In the programming language of your choice, shut down the machine that your code was executed on. Rules No shutting down by resource exhaustion (e.g.: forkbomb to force shutdown) You are allowed to write code that only works in a specific environment/OS, if you wish. Standard loopholes are forbidden This ...
Guide the Alphabet Given an array of directions, where the directions are defined as follows: NW N NE W . E SW S SE Or as indexes (you may use these indices for directions instead of the strings above): 0 1 2 3 . 4 5 6 7 You may choose either format, supporting both is not required by the challenge. Generate ...
Task You will be given a positive integer and you must output a "self-complementary graph" with that many nodes. If you don't know what a self-complementary graph is the wikipedia article wont help you much so below are two explanations, a technical and a non-technical one. Non-Technical A graph is a set of nodes that...
As George Orwell wrote in 1984: War is peaceFreedom is slaveryIgnorance is strength Write a program or function that takes in one of the six main words from the Orwell quote and outputs its counterpart. Specifically: [input] -> [output] war -> peace peace -> war freedom -> slavery slavery -> freedom ignorance -> stre...
Challenge: Write a code that, when executed will output the source code of a second program that can be executed in another language. The second program should output the source code of a third program that can be executed in a third language and so on. The last program should output PPCG with an optional single traili...
Challenge: In the programming language of your choice, take no input and output your programming language's name. Fair enough, right? Restrictions: You can't use any character that is included in your programming language's name in your code. E.g., if I use Batch, I must not use the chars 'B' 'a' t' 'c' 'h' in my code...
What is a home prime? For an example, take HP(4). First, find the prime factors. The prime factors of 4 (in numerical order from least to greatest, always) are 2, 2. Take those factors as a literal number. 2, 2 becomes 22. This process of factoring continues until you reach a prime number. number prime factors 4 ...
Golomb rulers are sets of non-negative integers such that no two pairs of integers in the set are the same distance apart. For example, [0, 1, 4, 6] is a Golomb ruler because all distances between two integers in this set are unique: 0, 1 -> distance 1 0, 4 -> distance 4 0, 6 -> distance 6 1, 4 -> distance 3 1, 6 -> di...
Introduction Long story short: a few days ago I accidentally started knitting a sock and the pretty logical structure of the plain stitches lead me to the idea: Why don't we just ASCII-knit a sock? Input The input is an even integer N in the range [2,30]. Output The output is a sock, obviously. Structure Because we wil...
One of the lesser known programming paradigms which seems rather fitting for code golfing is Overlapping Oriented Programming (OOP) *. When writing partly identical code, many bytes can be saved by simply overlapping the identical parts and remembering in some way where the two original code lines start. Your task is t...
Introduction Some of you may have heard of Hilbert's Grand Hotel. The manager there has lost his list of where the guests are staying but he still has the order in which they checked in. Each guest can not stay in a room with a room number less than their value and if a guest is added to a lower room, all guests in hig...
Write a program that produces an output such that: At least three distinct characters appear. The number of occurrences of each character is a multiple of 3. For example, A TEA AT TEE is a valid output since each of the 4 distinct characters, A, E, T and (space), occurs 3 times. Of course, a challenge about the numbe...
Create a program or function to unjumble a 9x9x9 cube of digits by rotating individual 3x3 cubes within it. This is similar to (but, I suspect, a bit harder than) my Flippin' Squares question. Input Input will be a 9x9x9 cube. I'm not going to be as strict over the input as I was last time, 3d arrays are allowed, array...
Write the shortest possible code which converts tabs to spaces in the input. Tab size should be supplied as a parameter or be hardcoded in the code in a single place. Spaces on output should point to the right column, e.g. (\t represents a tab character): a\tb aa\tb aaa\tb aaaa\tb should become (for tab size 4): a b...
Your very own "for" instruction Assuming you have the following input : a, b, c, d Input can be in one-line using any format "a/b/c/d" or "a,b,c,d" etc.. You can also have 4 inputs. You must code the following behaviour (pseudo-code here) : var i = <a> while (i <b> <c>) print i i = i + <d> print "\n" Here ...
A boring version of yourself Have you ever dreamed of a boring version of you which types the text you just typed ? No ? Because that's exactly what I'm challenging you to do ! The program needs to check how many time it took for the user to input a text at program launch and then retype the text again using the same p...
Brachylog is a language that's beginning to rise in prominence in code-golfing recently (and just received a major update with a terser syntax). Like Prolog, it has the advantage that it can often solve a problem (typically via brute force) merely from a sufficiently accurate description of what a problem looks like, a...
tinylisp is, in its essence, a very stripped-down version of Lisp, as the name suggests. It was made by @DLosc for an "interpret this language" challenge, which can be found here. It features a small amount of builtins, which can be used to create practically anything. There is a repository for the "official" tinylisp ...
Inspired by Sygmei's question, I'm interested in finding out what languages can "do this properly". Your task is to write a "for loop" function / macro / instruction. The arguments should be: an initializer a test an increment a body All of these are "pieces of code" and should be able to access variables in the con...
Your task is simple: write a program (or function) that takes no input and outputs (or returns) its source code. The catch is that when the program is wrapped in "quotes" (Unicode character 34), it should again output its (now quoted) source code. Standard rules for quines apply. This is code-golf, so the shortest prog...
The beautiful pattern drawer Good morning PPCG ! The other day, when I was trying to help someone on Stack Overflow, a part of his problem gave me an idea for this challenge. First of all, check the following shape : Where all black numbers are the index of the points in the shape and all dark-blue numbers are the ind...
Preface In the well known carol, The Twelve Days of Christmas, the narrator is presented with several gifts each day. The song is cumulative - in each verse, a new gift is added, with a quantity one higher than the gift before it. One Partridge, Two Turtle Doves, Three French Hens, and so on. At any given verse, N, we ...
The Pi function is an extension of the factorial over the reals (or even complex numbers). For integers n, Π(n) = n!, but to get a definition over the reals we define it using an integral: In this challenge we will invert the Π function. Given a real number z ≥ 1, find positive x such that Π(x) = z. Your answer must b...
Goal: Create a program to find the smallest file in the current folder. File size may be measured in bytes or characters. If multiple files have the same size, you can either choose one or display all of them. You can assume there will be at least one file in the folder, and no files will have a size of 0. Assume t...
Your task is to create a program that performs a bubble sort on a given array until it is sorted. Algorithm In order to qualify as a bubble sort, the program must operate as follows: Each pass goes through the array, looks at every two adjacent elements in turn, and potentially swaps them. Each pass goes through the ...
Implement a simple digital Stopwatch, which will display the time elapsed in seconds and minutes, as described below. Important Please read both Display and Controls sections ! Display Time elapsed, should be displayed in the MM:SS format, by replacing the previously displayed time string "in-place" (clearing the who...
A haiku is a poem with three lines, with a 5/7/5 syllable count, respectively. A haiku-w is poem with three lines, with a 5/7/5 word count, respectively. Challenge Write a program that will return true if the input is a haiku-w, and false if not. A valid haiku-w input must consist of 3 lines, separated by a newline. L...
Intro: You accidentally corrupted the flow of time with a device you made for fun, that turned out to be a time machine. As a result, you got pushed to the far future. You realized that computing, processing power, and computers in general have been evolved by a huge amount, an infinite amount to be precise. So you g...
Mike Bufardeci (Pyth) - 175 bytes Leo (Retina) - 175 bytes devRicher (Lua) - 182 bytes Peter Taylor (CJam) - Waiting for clarification Lyth (C++11) - Waiting for clarification Edit: Several changes made, should not affect any already submitted answers. Edit #2: Very few people are taking advantage of the 1024 b...
Sometimes lexicographical sorting of strings may cut it, but when browsing the filesystem, you really need better sorting criteria than just ASCII indices all the time. For this challenge, given a list of strings representing filenames and folders in a directory, do a filesystem sort, explained below: Split every stri...
A bronze plaque in the pedestal of the Statue of Liberty displays the poem "The New Colossus" by Emma Lazarus, part of which reads: Give me your tired, your poor, Your huddled masses yearning to breathe free, The wretched refuse of your teeming shore. Send these, the homeless, tempest-tost to me, I lift my lam...
The Challenge In this challenge, you are supposed to write a program or function that takes in a String, which will contain the simplified Markdown-like Markup, and outputs the corresponding HTML Markup. The Input You can take input in whatever way you wish to. The type of the input should be String. The Output You c...
You are providing tech support to the Bruce Dickenson as he produces a Blue Öyster Cult recording session. When he asks for more cowbell, you can give it to him. Your task Write a program or function that takes a string (or equivalent in your language) as input, and outputs a related string containing one more cowbell....
Write a program or function that given an integer radius r returns the number of unit squares the circle with radius r centered at the origin passes through. If the circle passes exactly through a point on the grid that does not count as passing through the adjacent unit squares. Here's an illustration for r = 5: Illu...
Many of you may have interacted with people from Russia on the internet at some point, and a subset of you may have noticed the slightly odd method they have of expressing themselves. e.g. удали игру нуб))) where the ))) are added for emphasis on the previous statement, I have been working on a theory that the ratio of...
Given an input string S, return truthy if all the letters in S are Lexically Ordered: their ASCII values need to be in either ascending or descending order. Return falsy in other cases. Input Input will be in the same case (all upper- or all lowercase). Your submission should be able to handle both. Input will consist...
This is a fairly simple challenge. Given a lower-case word, you must "interpolate" between letters. Here's some examples to hopefully clarify this: Input: test Output: tsrqponmlkjihefghijklmnopqrst Between letters you must add, in alphabetical order, the letters between those two letters. So if you have ad, you must ou...
Goal: Write a complete program or function which takes a formula in propositional logic (henceforth referred to as a logical expression or expression) and outputs that formula in conjunctive normal form. There are two constants, ⊤ and ⊥ representing true and false, a unary operator ¬ representing negation, and binary o...
CodeGolf Challenge PWSSHHHH! You wake up in a cryogenics lab in the year 3000. Upon being escorted to the assignment office to receive your career chip, presumably that of a delivery boy, a probe detects that you are from the year 2000. Because of this, and a few stereotypes, you are assumed stupid compared to today's ...
Pyramid Scheme is a language being developed by @ConorO'Brien. In Pyramid Scheme, the code that you write looks like this: ^ ^ / \ /3\ / \ --- / + \ ^-------^ /9\ /3\ /123\ --- ----- Now, that code has two obvious qualities: It's difficult to parse, and it's difficult...
A graphic sequence is a sequence of positive integers each denoting the number of edges for a node in a simple graph. For example the sequence 2 1 1 denotes a graph with 3 nodes one with 2 edges and 2 with one connection. Not all sequences are graphic sequences. For example 2 1 is not a graphic sequence because there ...
Definition The Alternating Power Fibonacci Sequence is formed as follows. Start with the empty sequence and set n to 1. Compute fn, the nth non-negative Fibonacci number, with repetitions. 0 is the first, 1 is the second and the third, 2 is the fourth. All others are obtained by summing the two previous numbers in the...
Your friend invited you to a high-stakes poker game at the last minute and, as a computer scientist, you've decided to use your skills to gain an edge on the game. Your task will be, given 2 cards (your hand) and 0, 3, 4 or 5 cards (the dealt cards), you must decide what the best possible hand you can get will be. If a...
Challenge: Create a program that takes input of a positive non-zero integer and outputs the 4 next numbers in the sequence described below. Note: Checking if the input is actually a positive non-zero integer is not necessary Sequence: Every number in this sequence (apart from the first, which is the input) shall be com...
The Challenge For this challenge, you are supposed to determine if a given number is in the Cantor set. So first, let's define the Cantor set. First, start with the numbers between 0 and 1. Any numbers outside this range are not in the Cantor set. Now, let's divide the numbers into three equal parts: [0,1/3], [1/3,2/3]...
Background You work for the police force as a programmer. A villain has planted a bomb in the city, luckily the police force has captured both him and the bomb. The bomb is really complicated to disarm, however it has a password input to disarm it. The villain, being cocky, has told you that there was no way you'd find...
An easy way to understand the unit n-dimensional hypercube is to consider the region of space in n dimensions that you can get if every coordinate component lies in [0, 1]. So for one dimension it's the line segment from 0 to 1, for two dimensions it's the square with corners (0, 0) and (1, 1), etc. Write a program or ...
We are all familiar with the Fibonacci sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765 However, instead of, f(n) = f(n-1) + f(n-2) we'll be taking digital sum of the previous 2 entries. The sequence should still start with 0, 1, after that the differences are rapid...
This challenge is inspired by xkcd: Challenge: You'll simulate the copying a large file (1 Gigabyte). The transfer rate will vary between 10 kB/second to 100 MB/second. Your task is to output the time remaining of the file transfer. The output should look like: Time remaining: 03:12 (meaning it's 3 minutes and 12 s...
At the opening scene of the Dark Knight rises, there is a rather awkward dialogue between a CIA agent and the villain Bane. CIA agent: “If I pull that [mask] off, will you die?” Bane: “It would be extremely painful…” CIA agent: “You’re a big guy.” Bane: “…for you.” It’s unsure if Bane intends to say “painful for you”...
OEIS has a variation (A111439) on Golomb's sequence. As in Golomb's sequence, A(n) describes how often n appears in the sequence. But in addition, no two consecutive numbers may be identical. While building up the sequence, A(n) is always chosen as the smallest positive integer that doesn't violate these two properties...
One of the interesting aspects of gravity is that, as far as I'm aware, you can't just have stuff floating in midair. However, it seems not everyone at the Association of Random Castle Builders is aware of this fact, leading to castles such as this one: # # # # # #...
Not entirely sure if this one or a similar challenge has already been posted, but here it goes anyway. Write a program that takes a string as input and writes its trucated/summarized output form such that a specific sep (separator) is placed in the middle, removing the necessary characters of the original string so tha...
TAS Golf In the style of a tool-assisted speedrun with a code-golf twist, the goal of this challenge is to complete World 1-1 of the original Super Mario Bros game for the NES in your chosen programming language in as few bytes as possible, using only the in-game controller inputs in the format I'll describe below. Yo...
Your task is to sort an array containing the strings "quarter", "dime", "nickel", and "penny" any number of times in no specific order and sort them so that they are in this order: quarter dime nickel penny (in other words, greatest to least monetary value). Rules Your program must take an array as input containing...
Write a program that keeps track of the number of consecutive days it has been run. The day resets at midnight (the local time of the computer on which the program is run). If there is a day that the program is not run, the counter is reset to zero. Every time the program is run, the counter should go up by one day ...
A symmetric polynomial is a polynomial which is unchanged under permutation of its variables. In other words, a polynomial f(x,y) is symmetric if and only if f(x,y) = f(y,x); a polynomial g(x,y,z) is symmetric iff g(x,y,z) = g(x,z,y) = g(y,x,z) = etc. For example, x^2+2xy+y^2, xy and x^3+x^2y+xy^2+y^3 are symmetric pol...
You're given a n-by-m matrix of integers, where n,m > 3. Your task is to find the 3-by-3 sub-matrix that has the lowest mean, and output this value. Rules and clarifications: The integers will be non-negative Optional input and output format The output must be accurate up to at least 2 decimal poins (if it's non-integ...
Goal This is a simple challenge. Your goal is to unscramble a string by swapping each letter with the next letter of the same case, while leaving non-letter characters unchanged. Step by step explanation The first character is a E. We look for the next letter in upper case: it's a C. We swap these characters, which l...
Scrolling through social media, one might encounter something like this: We can see that, following PEMDAS order of operations, the answer is clearly 11 9. For the sake of this challenge, PEMDAS means that multiplication will occur before division, so a/b*c = a/(b*c), not (a/b)*c. The same goes for addition and subtr...
Simple Mancala Game Create a mancala game using as few bytes as possible. The game Mancala is a family of games where a player has a control over a set amount of pots filled with stones/seeds. The particular version which you should implement has a board with 14 pots, of which two are designated as scoring pots. At the...
Write a program that creates a two-state checkbox that people can interact with using a mouse. Specifically, your program should achieve all of the following: Have a 8×8 pixel (or larger if desired) region of the screen that is the clickable area of the checkbox. Henceforth this region is simply called the checkbox. ...
Your task is to write a program or function which: When run for the first time, outputs its source code. On subsequent executions, it should output what it output previously, but with one random character change (defined below). It does not have to be a uniformly random change, but every possible change should have a ...
Create a function (preferably) or a program that takes an ordered collection and outputs the smallest possible palindrome that starts with the input. For example: >>> completePalindrome( [1, 2, 3] ) [1, 2, 3, 2, 1] >>> completePalindrome( [1, 2, 3, 4, 5, 4, 3, 2] ) [1, 2, 3, 4, 5, 4, 3, 2, 1] >>> completePalindrome( ...
In mathematics an exclamation mark ! often means factorial and it comes after the argument. In programming an exclamation mark ! often means negation and it comes before the argument. For this challenge we'll only apply these operations to zero and one. Factorial 0! = 1 1! = 1 Negation !0 = 1 !1 = 0 Take a string of ...
You're given a n-by-m matrix of integers, where n,m > 3. Your task is to find the 3-by-3 sub-matrix that has the lowest mean, and output this value. Rules and clarifications: The integers will be non-negative Optional input and output format The output must be accurate up to at least 2 decimal poins (if it's non-integ...
We've all heard of the ol' Fizz Buzz problem, but what happens when you try to apply it with more factors? Fizz Buzz Crackle Pop! The Challenge Write a full program that takes an integer input n, then n tuples containing an integer and a string, then another integer (>1) k, as such: n int1 str1 int2 str2 (...) intn st...
A prime power is a positive integer n that can be written in the form n = pk where p is a prime and k is a positive integer. For example, some prime powers are [2, 3, 5, 4, 9, 25, 8, 27, 125]. Next, consider prime powers of 2. These are [2, 4, 8, 16, ...] and can be written in the form 2k. They would all be included wh...
These are ASCII dandelions: \|/ \ / | /|\ | \|/ | | | | _\|/_ | | | /|\ ASCII dandelions have three parameters: Length of the stem (positive number between 1 and 256, number of seeds (positive number between 0 and 7), and orientation (^ or ...
Problem: Your task is to write a program that takes as input a height (in meters) and weight (in kilograms), and outputs the corresponding BMI category. BMI is a measure of the ratio of your weight to your height. It's dated and inaccurate for many people, but that doesn't matter here! BMI can be calculated using the f...
I only very recently discovered code golf and just found this part of the Stackexchange network, and naturally after looking at so many clever answers, I feel inferior. Inner me knows I'll get better over time, but inner me is also vain and needs validation. At the same time, I don't take kindly to pandering, so you'd ...
Write a quine, that when run, creates itself in the current directory, in a source file named itself. We will be using Windows in this, so the file name (and therefore quine) must have the following limitations: None of these characters \ / : ? * < > | Fewer than 211 255 characters Limitations and assumptions Your c...
Feb. 6 was a real weekday. Because it lies in the 6th week of the year. So a real weekday is a day with a a day number that equals the week number. But not all country have the same counting of weeks. in Germany a week starts with Monday and ends on Saturday in the US they start on Sunday. Write a program that checks a...
Background The 1-2-3-Tribonacci Sequence Imagine for a second that you could make a fibonacci sequence by replacing the standard iteration formula with the following: Basically, instead of summing the last two to get the next, you sum the last three. This is the basis for the 1-2-3-Tribonacci sequence. Brown's Criteri...
SmileBASIC deserves more attention. I've only seen 3 users here (including myself!) providing SB answers, and while that doesn't surprise me, it disappoints me. It being a paid lang as well as being a BASIC dialect certainly turns people off, but for those who own it it's actually pretty flexible and, surprisingly, gol...
Take a positive integer n as input, and output (some of the) decimal numbers that can be created using n bits, ordered in the following way: First list all the numbers that can be created with only one 1, and the rest 0 in the binary representation (sorted), then all the numbers that can be created with two consecutive...
Rules The program should receive a string/array of words as input. For each word in the string/array, it will reconstruct the word by taking characters in alternating fashion from the front and back of the word. 12345 678 9 -> 15243 687 9. It will then rearrange the words in an alternating fashion between the earliest ...
TikZ is a Latex package used for drawing precise images in Latex documents. It has a massive specification and a boatload of features that may be useful for graphical-output style questions. What tips do people have for golfing in TikZ? As always, tips should be specific to to TikZ (e.g. "Remove comments" is not an a...
In the location-based AR mobile game way of life Ingress the player can hack things called portals in order to get items. (If you are interested in Ingress, you can ping me in chat for more info. Trust me, it's better than Pokémon. If you end up downloading it, remember to choose the Resistance.) A way to increase hack...
EDIT: I'm getting a lot of comments about this not terminating - I will give the "correct answer" tag to either the first person who gives me FF(3) (as in provides it in their answer) or proves that FF(3) does indeed blow up indefinitely. Task: Your task is make the smallest program possible that generates the list of ...
(I am not sure that this is the best place to put this question, but I will give it a shot. Forgive me if it is improper. This is just a fun project with which I am tinkering and I am looking for advice on how best to implement it; but it is also something of a 'challenge' (not implying that it is hard!), so I thought ...
Input: A maze containing the characters: -- (horizontal wall); | (vertical wall); + (connection); (walking space); I (entrance); U (exit). I.e. an input could look like this: +--+--+--+--+--+--+--+--+--+--+ I | | | + +--+--+--+ + + + +--+ + | | | | | | +--+-...
Introduction: I'm a twisty puzzles collector. Here you can see my current collection of ± 300 puzzles. I think everyone knows the regular Rubik's Cube (3x3x3 Cube), which is a NxNxN Cube. There are also Cuboids (block-shaped puzzles), which come in different forms, perhaps better explained by SuperAntionioVivaldi here:...
Your task is to write a program or a function that prints an ASCII triangle. They look like this: |\ | \ | \ ---- Your program will take a single numeric input n, with the constraints 0 <= n <= 1000. The above triangle had a value of n=3. The ASCII triangle will have n backslashes (\) and vertical bars (|), n+1 line...
Your goal is to create an alphabet song as text in the following form (in order): A is for <word starting with A> B is for <word starting with B> C is for <word starting with C> ... Z is for <word starting with Z> Example output: A is for Apple B is for Banana C is for Carrot D is for Door E is for Elephant F is for F...
Intro Something I've played around with in recreational mathematics has been construction of a divisor table to visually compare/contrast the prime divisors of a set of numbers. The set of input numbers are across the top as column labels, the prime divisors are on the left as row labels, and a mark indicates where the...
The challenge You are given an integer n, and you have to use these operations to make it 1. Divide it by 3. Divide by 2. Subtract 1. Examples: Input Output 1 0 (Its already 1, guys) 5 3 (3->2->2 or 3->3->1) 10 3 (3->1->1) 255 10(3->3->3->1->1->2->2->3->1->2)
You will need to generate the smallest prime with n digits, and it will only contain digits specified in the list k. Examples: Input: 4 1 2 For this, you must generate the smallest prime with 4 digits, and that prime must only contain the digits 1 and 2. Output: 2111 Input: 10 0 4 7 Output: 4000000007 Input: 6 5 5...
Underload is a stack-based semi-functional tarpit created by ais523. I've recently been trying to golf in it, as it's a surprisingly elegant language. What tips do you have for golfing in Underload? (One tip per answer)
A simple but hopefully not quite trivial challenge: Write a program or function that adds up the kth powers dividing a number n. More specifically: Input: two positive integers n and k (or an ordered pair of integers, etc.) Output: the sum of all of the positive divisors of n that are kth powers of integers For examp...
You know it: keyboard or mouse input is just too mainstream to create Random Numbers through human behavior. Create the most unique (Pseudo)Random Number Generator that create its numbers through human behavior. Web-API's are not restricted! Anyone should use the code provided, so any special hardware is restricted. (I...
Write a program or function that draws a tree of trees, thus constructing a forest. The trees are drawn like stacking a pyramid. The first (top) row contains 1 tree, the next row down contains 2 (for a total of 3), the next contains 3 (for a total of 6), and so on. If there aren't enough trees to complete a full row, f...
Background I was inspired by 3Blue1Brown's recent video about the necklace splitting problem (or as he calls it, the stolen necklace problem) and its relationship to the Borsuk-Ulam theorem. In this problem, two thieves have stolen a valuable necklace consisting of several different types of jewels. There are an even n...
Find the outcome of a game of War When I was in elementary school, there was a "Rock-Paper-Scissors"-ish game we'd play during assemblies, when waiting for our teacher, at recess etc. We called it "War". After some searching however, it turns out this is a much simpler variant of the "Shotgun Game" (according to WikiHo...
I did the IMC this year. Did anyone else here do it? In a UKMT Intermediate Maths Challenge paper, there are twenty-five questions. The first fifteen questions give you five marks if you get them right. For the other ten questions, you get six marks for getting them right. In the last ten questions, you lose marks if y...
Inspired by this challenge (or, more specifically, by misreading it), I've come up with the following challenge: Given an input string S, reverse the order of all uppercase characters, and all lowercase characters. Leave all non-letter characters in place. For instance: Note that the uppercase W (the first uppercase l...