instruction
stringlengths
34
53.1k
Background Celebrating the release of Dyalog APL 16.0, where the solution to this problem is {⊢⌺(≢⍵)⊢⍵}Explanation Task Given a printable ASCII string of odd length n, make an n × n square with the string centered horizontally, duplicated to be centered vertically, and with acrostics of the same string in each row and ...
Given a positive integer as input, your task is to output a truthy value if the number is divisible by the double of the sum of its digits, and a falsy value otherwise (OEIS A134516). In other words: (sum_of_digits)*2 | number Instead of truthy / falsy values for the true and false cases, you may instead specify any ...
The Goldbach conjecture states that: every even number that is greater than 2 is the sum of two primes. We will consider a Goldbach partition of a number n to be a pair of two primes adding to n. We are concerned with numbers is of increasing Goldbach partition. We measure the size of a number's Goldbach partitions ...
Overview Given a 3 line string, figure out if the structure falls to the left, balances, or falls to the right. Input structure You can imagine the structure as metal rod with stuff on top, all being balanced on top of a vertical rod. 1 7 4 a =============== | The first line is the items. Each item's w...
Given a string s and a positive integer N, gradually duplicate each character more and more until N duplicates, and then staying at N duplicates until N characters away from the end, then step down again. For example, given abalone and 3: a we start with 1 copy bb then 2 copies aaa then 3 copies, which is our sec...
The task is the following. Given an integer x (such that x modulo 100000000003 is not equal to 0) presented to your code in any way you find convenient, output another integer y < 100000000003 so that (x * y) mod 100000000003 = 1. You code must take less than 30 minutes to run on a standard desktop machine for any in...
Challenge: Given a square input matrix \$A\$, pad the matrix with one row and one column on all four sides. The value of each element in the top and bottom row should be the sum of the elements in each corresponding column. The value of each element in the left and right column should be the sum of the elements in eac...
Program A outputs program B's code when run, and B outputs A's source. Requirements: Only one language across both programs Programs are different. One program that outputs itself does not qualify. Both programs are non-empty, or at least 1 byte in length. Trailing newlines in both source and output are ignored st...
You will be given a positive, whole number (that will never contain a 0) as input. Your task is to check whether it is a Lynch-Bell number or not. A number is a Lynch-Bell number if all of its digits are unique and the number is divisible by each of its digits. In fact, there are actually only 548 Lynch-Bell numbers, s...
Overview Given a list of digits, find the fewest operations to make 100 Input A string of digits, which may or may not be in numerical order. The order of the digits cannot be changed, however plus (+) or minus (-) operators may be added between each so that the total sum is equal to 100. Output The number of operators...
A balanced string is a string of parentheses () so that every parenthesis is can be matched with another one. More rigorously they are the strings spanned by this grammar: S → (S)S | ε We can turn a string "inside out" by: Switching all occurrences of ( and ) with each other Moving characters from the front of the s...
NOTE: This question is different than Draw an ASCII Rectangle because the user has to input only 1 number to generate a box, unlike the other question, where the user has to input the x and y size of the box. Your task is to create a box based upon user input. Let's say I inputted 2. The box generated would look like: ...
Given, in any way and order, dimensions (in whichever order you want) a probability (in whatever format you want) number of iterations (you may choose whether to count the initial state or not) do one of the following: animate, or output each step of, or return a list of states of a spaces-filled sky of those...
Given an input string containing only alphanumeric ASCII characters and starting with a letter, swap each letter run with the digit run which follows. A run is a sequence of consecutive letters or digits. Note that in the case where the input string ends with a run of letters, this run is left untouched. Walk-through e...
Cyclic Polyglot Challenge This is the robbers thread. You can find the cops thread here. Cyclic Polyglot A N-element cyclic polyglot is a complete program that can be run in N different languages. In each language, when the program is run with no input (possibly subject to this exception), it should print the name of a...
Cyclic Polyglot Challenge This is the cops thread. You can find the robbers thread here. Cyclic Polyglot A N-element cyclic polyglot is a complete program that can be run in N different languages. In each language, when the program is run with no input (possibly subject to this exception), it should print the name of a...
Warning: This challenge is only valid for languages with a compiler. Make a program (which is perfectly valid code) that outputs Hello, World, even before runtime. How? Let me explain. Many languages have a compiler. Some operations are made in the compile-time, and others, in runtime. You trick the compiler to outpu...
Compress a sparse matrix using Compressed sparse row (CSR, CRS or Yale format). These are all the same form of compression (ignore new Yale). Input may be any 2d data structure (list of lists, etc): e.g [[0 0 0 0], [5 8 0 0], [0 0 3 0], [0 6 0 0]] And the output should be three 1d data structures (list etc), that d...
Continuing my It was just a bug challenge: Input: A string consisting of printable ASCII characters without white-spaces nor new-lines. Output: First turn the input into a palindrome by reverting the input, and adding it before itself, excluding the middle character (i.e. with an input 1234567890, it will becomes 09876...
Goal You are given an integer n (n > 1). You must output how many permutations of the integers 1 to n there are which start at 1, end at n, and don't have two consecutive integers which differ by 1. Alternatively, if you take the complete graph K_n and remove the edges of the path 1-2-3-...-n you must count the Hamilto...
Warm up: Regex, Paper, Scissors This is the challenge I originally wanted to post, before realising that some very short solution exist. Nevertheless, it can be an interesting problem to think about in preparation for the actual challenge below. Write three regexes R, P and S such that they match each other in a cyclic...
You might already be familiar with the game: Basketball FRVR in facebook. There are two types of score you can make: A virgin-shot:(we call it so in our country :D) When the ball enters the basket without touching the rim or A stale shot: When the ball enters the basket, but after touching the rim. The game is over ...
In golf, the standard scratch of a course is calculated using this formula: (3*num_of_3_par_holes + 4*num_of_4_par_holes + 5*num_of_5_par_holes) - difficulty_rating Your task is to calculate the standard scratch of a golf course, given these 4 inputs. You should take input in any standard form in the format [num_of_3_...
In this challenge, you are given two overlapping rectangles, and you need to calculate the rectangles created by removing one from the other. For example, if you remove the red rectangle from the black one: You end up with one of the following two rectangle sets: You'll also need to handle the following: To be more...
Getting the average of a list (e.g [2,6,7]) Get the length of the list: [2,6,7] -> 3 Sum the numbers in the list: 2 + 6 + 7 = 15. Divide the sum by their count: 15 / 3 = 5. You should compare the averages of two lists of positive integers N and M, by returning a value if N has a higher average, another value if M ha...
Pascal's Rhombus (which is actually a triangle) is obtained by adding in the pattern: * *** x instead of * * x This means that each cell is the sum of the three cells on the row directly above it and one cell on the row 2 above it. Just like Pascal's triangle the zeroth row has a single 1 on it that generates...
Given a positive integer, find its smallest positive integer multiple which is a run of 9 followed by an optional run of 0. In other words, find its smallest positive integer multiple which is matched by the regex /^9+0*$/. For example, if the given positive integer is 2, then return 90, since 90 is a positive integer ...
Note: Anders Kaseorg warns me that this could be a duplicate of another previous question. It seems so, and I'm sorry I did not find that question before posting this one. Nonetheless, that question only received one answer and this one is simpler, just in case you all want to try this time. I'll understand if this qu...
Let us play a little golfing game. Given a single line of N space separated numbers from STDIN, one must output those numbers on N lines. So far, I came up with the three following bash solutions : xargs -n1 (9) tr \ \\n (8) fmt -1 (6) Can anyone do better? I am eager to learn new tricks
Ok I've been on a bit of a triangle kick recently so here's another one. Clark's Triangle is a triangle where the leftmost entry of each row is 1 and the rightmost entries are made up of multiples of 6 which increase as the row number increases. Here's a visualization 1 6 1 . 12 1 . . 18 1 . . . 24 1 . ...
Whenever you make a move on a Rubik's Cube, there is a reverse move which undoes the first move. Because of this, every algorithm (set of moves) has a reverse algorithm which undoes the first algorithm. The goal of this challenge is to find the reverse of a given algorithm. Specification: The input consists of an array...
Given a positive integer n ≤ 500: Find the smallest positive integer k such that all digits in the decimal representation of n*k are either 0 or d, with 1 ≤ d ≤ 9. Print or return d in less than 30 seconds (read more about that in the Clarifications and rules section). Easy examples Here are the first 30 values of d....
Inputs: Two single digits (let's call them m and n) and two chars (let's call them a and b) in your input format of choice. Output: For the walkthrough, pretend m=2, n=5, a='a', b='b'. Your output will be a string built from your four inputs. Let's call the string result, with value "". First, concatenate a onto result...
Although related challenges have been asked, this one is different to warrant its own question. Challenge Given a positive integer, return the longest sequence of consecutive positive odd integers whose sum is the given integer. If no such sequence exists, you may report an error in whatever way makes sense for your l...
Inputs A list (array) of numbers, or numerical strings if that makes it easier. You can assume there will always be at least two elements in the list and every element will be a natural number (integer larger than zero). Outputs A single number, or again, a numerical string. Problem The idea is to reduce the list of nu...
Related: Interquine Program A outputs program B's code when run, and B outputs C's source, and C outputs A's source. This time you can't exchange two characters and exchange again :) Requirements: Only one language across all programs Standard loopholes restrictions apply All programs are different. One program th...
Background There's a common riddle that goes something like this: A snail is at the bottom of a 30 foot well. Every day the snail is able to climb up 3 feet. At night when they sleep, they slide back down 2 feet. How many days does it take for the snail to get out of the well? The intuitive answer is 30 days, becau...
your task is to write a program that uses the Lucas-Lehmer primality test to check whether an input number is prime or not. This prime number candidate has the form 2p-1 with p being prime. (Mersenne prime number) The Lucas-Lehmer-test The n-th Mersenne number is prime if it is a divisor of the (n-1)-th Lucas-Lehmer nu...
The task is as follows: Given a positive integer x and a prime n > x, output the smallest positive integer y such that (y * y) mod n = x. An important part of this question is the time limit specified below which excludes brute force solutions. If there is no such value y then your code should output N. Test cases (2...
If we write a sequence of numbers as the coefficients of a power series, then that power series is called the (ordinary) generating function (or G.f.) of that sequence. That is, if for some function F(x) and series of integers a(n) we have: a(0) + a(1)x + a(2)x^2 + a(3)x^3 + a(4)x^4 + ... = F(x) Then F(x) is the gener...
In the game of chess, there is piece called the queen that may attack any other piece that is on the same row, column or diagonal. In chess there are typically two sides, black and white, with each piece belonging to one of the teams. Pieces may not attack pieces belong to the same team. Your goal is to find out the ...
Introduction This is the evolution of this previous challenge which was about checking satisfieability of normal formulae in conjunctive normal form (CNF). However, this problem is NP-complete and watching algorithms finish is just boring, so we're gonna simplify the problem! Specification Input You may tune the follow...
Two numbers are coprime if their greatest common divisor is 1. Given a positive integer N, your task is to compute the first N terms of OEIS A061116, which is the sequence of positive integers higher than 1 that are coprime to all their decimal digits. Here are the first few terms of the sequence: 11, 13, 17, 19, 21, 2...
Background A super-prime is a prime number whose index in the list of all primes is also prime. The sequence looks like this: 3, 5, 11, 17, 31, 41, 59, 67, 83, 109, 127, 157, 179, 191, ... This is sequence A006450 in the OEIS. Challenge Given a positive integer, determine whether it is a super-prime. Test Cases 2: f...
Given a string and integer n, split the string at n character, and print as follows: Ex) laptop 3 should print lap top laptop 2 should print la pt op (see how it splits the string at every 2nd char) Special cases: laptop 0 should print laptop (since we split at every 0th char, thus none) laptop 9 should print laptop (...
Challenge Given a string, make it into a triangle as shown below: Input Hello, world! Output H He Hel Hell Hello Hello, Hello, Hello, w Hello, wo Hello, wor Hello, worl Hello, world Hello, world! The first line contains the first character of the string. The following lines contain one more character on each line, u...
Lorem Ipsum is placeholder text used when preparing layout without wanted to have content already filled. One of its key features over using some arbitrary text is that it is nonsense. It isn't even valid latin (though it is close). This prevents anyone being shown the layout from becoming distracted reading the text. ...
Challenge Given a positive integer, return the product of its divisors, including itself. This is sequence A007955 in the OEIS. Test Cases 1: 1 2: 2 3: 3 4: 8 5: 5 6: 36 7: 7 8: 64 9: 27 10: 100 12: 1728 14: 196 24: 331776 25: 125 28: 21952 30: 810000 Scoring This is code-golf, so the shortest answer in each language...
Your task will be to write a Haskell function that takes a list of integers and returns a sorted version of the same list. You are to do this without the use of builtins What are builtins? To keep ourselves from having to navigate edge case hell we are going to limit answers to Haskell (sorry if Haskell is not your fa...
Description Given a length n, and an alphabet size k>0, your program must determine the number of strings with those parameters which have a maximal number of unique substrings. In the case of k=2, this generates OEIS A134457. Example For example, 2210 has the substrings , 2, 22, 221, 2210, 2, 21, 210, 1, 10, and 0, ...
A prime is weak if the closest other prime is smaller than it. If there is a tie the prime is not weak. For example 73 is a weak prime because 71 is prime but 75 is composite. Task Write some computer code that when given a prime greater than 2 as input will determine if it is a weak prime. This is a standard decisio...
The Fibtraction sequence (as I call it) is similar to the Fibonacci sequence except, instead of adding numbers, you subtract them. The first few numbers of this challenge are: 1, 2, -1, 3, -4, 7, -11, 18, -29, 47, -76, 123, -199, 322, -521, 843, -1364... The sequence starts with 1 and 2. Every next number can be calcu...
The task is to find a non-trivial factor of a composite number. Write code that finds a non-trivial factor of a composite number as quickly as possible subject to your code being no more than 140 bytes long. The output should just be the factor you have found. Your code can take input and give output in any way that i...
Imagine travelling to a point lying A miles away horizontally and B miles away vertically from your current position. Or in other words, travelling from (0, 0) to point (a, b). How far would you need to end up travelling? This seems like a straightforward question, but the answer depends on who you ask. If you're a cro...
Say I have an expression: 9 * 8 + 1 - 4 This expression can be interpreted in six different ways, depending on operator precedence: (((9 * 8) + 1) - 4) = 69 (* + -) ((9 * 8) + (1 - 4)) = 69 (* - +) ((9 * (8 + 1)) - 4) = 77 (+ * -) (9 * ((8 + 1) - 4)) = 45 (+ - *) ((9 * 8) + (1 - 4)) = 69 (- * +) (9 * (8 + (1 - 4))) = ...
A Sophie Germain Prime is a prime number P such that 2P+1 is prime as well. Given a prime number as input, your task is to determine whether it is a Sophie Germain Prime. Standard Input/Output rules and Default Loopholes apply. This is a decision-problem, so standard rules for this tag apply (returning two distinct and...
Using named matching groups is often easier to understand than numbering groups but takes up more bytes. Given a regular expression as specified below, your program or function must convert named groups to numbered groups. Task These specifications are based on python 3's re module. A named group takes the form of (?P<...
General rules The universe of the Game of Life is an infinite two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, alive or dead. Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in tim...
A biquadratic number is a number that is the fourth power of another integer, for example: 3^4 = 3*3*3*3 = 81 Given an integer as input, output the closest biquadratic number. Here are the first 15 double-squares: 1, 16, 81, 256, 625, 1296, 2401, 4096, 6561, 10000, 14641, 20736, 28561, 38416, 50625 This is code-golf s...
Version 2 here. Simple challenge: given an integer, draw a house of cards with the given number of stories. If the number is negative, draw the house upside-down. Examples: Input: 2 Output: /\ -- /\/\ Input: 5 Output: /\ -- /\/\ ---- /\/\/\ ------ /\/\/\/\ -------- /\/\/\/\/\ Input: 0 Output...
A number is a Chen prime if it satisfies two conditions: It is prime itself Itself plus two is either a prime or a semi-prime. A prime is a number where it has exactly two divisors and those divisors consist of itself and one. A semi-prime is a number which is the product of two primes. (Note that 12 = 2*2*3 is not s...
Introduction Don't worry - no knowledge in mathematics is needed. It is possible to just skip the motivation part, but I think it is nice if a puzzle has a background story. Since the title contains the number I there will be more puzzles of this kind, if you like them. Feedback is highly appreciated. I hope you have f...
INTRO Let's say you write a passage and you are close to the end of the line wanting to write down a large word. In most languages, you just leave some blank and move to the next line, like a sir. Example - English: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah this man is ...
Given a non-negative integer, return the absolute difference between the sum of its even digits and the sum of its odd digits. Default Rules Standard Loopholes apply. You can take input and provide output by any standard Input / Output method. You may take input as a String, as an Integer or as a list of digits. Th...
You are going to participate in a gameshow. One of the challenges works as follows: The first room contains a large number of identical balls. The second room contains a series of chutes, each of which has a sensor which counts how many balls have been placed in it. A ball which is placed in a chute cannot then be rec...
You are to write a program that takes a list of strings as input. For every string in the list you are to determine the smallest N such that no other string in the list begins with the same N characters as the string in question. Now compose a new list with all these strings. Here is an example, on the left we have ...
Related Your goal, is to write a set of programs, that progresses from one to the other, one character at a time. For example. Given the starting program abcd and the ending program wxyz, you should have 5 valid programs, with the respective outputs. abcd -> wbcd wbcd -> wxcd wxcd -> wxyd wxyd -> wxyz wxyz -> wxyz As ...
Help! My Completely Automated Lights From Darks Separator V3001.01 broke! :( Guidelines Task Write a program that will take an input of an array (or a list in some languages) of any amount of strings that are either the letter L or the letter D (representing lights or darks) and output an array that contains two arra...
This challenge is based off of Helka Homba's question Programming a Pristine World. From that question, the definition of a pristine program is: Let's define a pristine program as a program that does not have any errors itself but will error if you modify it by removing any contiguous substring of N characters, where ...
You have to write a program or a function in any language that outputs this pattern: ~|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||~ |~|||||||||||||||||||||||||||||||||||||||||||||||||||||||||~| ||~|||||||||||||||||||||||||||||||||||||||||||||||||||||||~|| |||~|||||||||||||||||||||||||||||||||||||||||||||...
Thanks to FryAmTheEggman for the idea for this second version. Version 1 here. Not-so-simple challenge: given a number of cards, build the biggest house of cards you can with that number of cards, according to the following building order: /\ /\ /\ /\/\ ...
Guidelines Scenario John has an important number, and he doesn't want others to see it. He decided to encrypt the number, using the following steps: His number is always a non-decreasing sequence (ie. "1123") He converted each digit into English words. (ie. "123" -> "ONETWOTHREE") And then, rearrange the letters random...
Your task is simple: write a program that receives an integer as input and outputs it if it was odd, and does nothing otherwise (not halting is allowed). The challenge is, that you can only use odd bytes. You can optionally append a trailing newline to the output. This is code-golf, shortest answer in (odd) bytes wins....
We seem to quite like digit runs lately, so here's a fairly simple challenge. Given a positive integer, split it into it's digit runs, and return the product. For example: 11122333 would become 111, 22, 333, the product of which is 813186 Input may be taken as an integer, string, or list/array of digits/characters. You...
Given a list (array) of names, your challenge is to join the items using some glue and abbreviate the longest items first until the joined string fits a maximum length. And output that string. Since the glue is part of the final string, the length of the glue is included too Abbreviation is done using the … character ...
Task Write a program that will take (as input) a positive integer. It will then count up from 0, appending each integer to a String, only continuing if the length of the String is less than the value of the input. A serialized integer is defined as the fully-formed integer with the maximum value belonging to the Strin...
Lets say your job is to paint poles, and a client asks you to paint a pole with 4 red sections and 3 yellow sections. You can do that pretty easily as follows: r y r y r y r With just yellow and red stripes. Now lets say your client asks you to paint a pole with 2 red sections, 2 yellow sections, and 1 green section...
A Harshad number is a number that is divisible by the sum of its digits. This is obviously dependent on what base the integer is written in. Base 10 Harshad numbers are sequence A005349 in the OEIS. Your Task: Write a program or function that determines whether a given integer is a Harshad number in a given base. ...
There was a challenge up a while ago about multiplying strings. It showed us how we can multiply not only numbers, but also strings. However, we still can't multiply a number by a string properly. There has been one attempt to do so but this is obviously wrong. We need to fix that! Your Task: Write a function or pr...
Given a positive integer n (Example: n=1234444999) Separate into consecutive digit runs: [1, 2, 3, 4444, 999] Take the digital product of each run. [1, 2, 3, 4*4*4*4, 9*9*9] = [1, 2, 3, 256, 729] Sum it... 991 Repeat until this converges to a single number: 1234444999 991 82 10 1 Return last number. Test...
Write 3 programs that do the following task: Let A, B, C source codes of those three programs; if A runs BC is produced as output, if B runs CA is produced, if C runs AB is produced; so each program writes a string (cycled for each program) and hides itself from it. Additional, but essential constraints: standard lo...
Note: This is related to a variation of the game Rummikub Background & Rules Rummikub is a tile-based game. There are four colors: red, orange, blue and black. For each color there are 13 tiles (labeled from 1 to 13), and there are also 2 Jokers which are color-independent, hence there are 54 pieces in total. In this ...
Probably a simple code-golf challenge. Given 2 positive integers m and n, make a list of n values that are positive integers whose sum is equal to the number m. Either all values in the output are the same value or the difference is exactly 1. Examples For example m=6 and n=3 would become 2, 2, 2 m=7 and n=3 would bec...
Let's define a sequence of positive integers. We will define the value of the sequence at every even index to be double the previous term. The odd indices of the sequence will be smallest positive integer not yet appearing in the sequence. Here are the first couple terms. 1,2,3,6,4,8,5,10,7,14,9,18,11,22,12,24,13,26,...
Background Python 3 has many types of string literals. For example, the string this 'is' an exa\\m/ple can be represented as: 'this \'is\' an exa\\\\m/ple' "this 'is' an exa\\\\m/ple" r"this 'is' an exa\\m/ple" '''this 'is' an exa\\\\m/ple''' """this 'is' an exa\\\\m/ple""" r'''this 'is' an exa\\m/ple''' r"""this 'is' ...
A Gaussian integer is a complex number whose real and imaginary parts are integers. Gaussian integers, like ordinary integers, can be represented as a product of Gaussian primes, in a unique manner. The challenge here is to calculate the prime constituents of a given Gaussian integer. Input: a Gaussian integer, which i...
A slightly more challenging one compared to my previous challenge. Given a list of positive integers (>0) and the positive integer m, output a list of positive integers that are capped values of the input values so that the sum of the capped values equals m. Cap the highest values first. And keep the same order. Cases ...
Inspired by github.com/JackToaster/Reassuring-Parable-Generator, in turn inspired by xkcd.com/1263. The possible words are derived from the reassuring.cfg of that repository. Having a look at the reassuring.cfg (use the 12th commit) is suggested to see the grammar the output matches (The output is a list of all strings...
The task is to write code to identify which key is pressed on the keyboard. You can assume that only one key is pressed at a time and that there is a standard US keyboard layout. That is the layout with the @ over the 2. Your code should output a unique identifier for any key pressed. This includes PrtScn, Scroll Lock,...
An integer is binary-heavy if its binary representation contains more 1s than 0s while ignoring leading zeroes. For example 1 is binary-heavy, as its binary representation is simply 1, however 4 is not binary heavy, as its binary representation is 100. In the event of a tie (for example 2, with a binary representation ...
The first two MU-numbers are 2 and 3. Every other MU-number is the smallest number not yet appeared that can be expressed as the product of two earlier distinct MU-numbers in exactly one way. Here are the first 10 2, 3, 6, 12, 18, 24, 48, 54, 96, 162 Task Given a positive number calculate and output the nth MU-number...
There are lots of challenges that just pick a sequence from oeis and ask you to print n-th number or first n numbers or whatever. It's time to stop automate! Task Your task is to parse a sequence page from oeis.org and print its index, description and example values. The page's index should be chosen and random, sele...
Title stolen inspired by Greg Hewgill's answer to What's the difference between JavaScript and Java? Introduction Java and JavaScript are commonly used languages among programmers, and are currently the most popular tags on Stack Overflow. Yet aside from similar names, the two have almost nothing in common. In honor of...
Imagine a histogram. Pour an infinite amount of water on to it. Then stop. How much water does the histogram hold? Let's say we have a histogram with columns of these heights: 1 3 2 1 4 1 3 That would look like this: # # # # ## # # ####### 1321413 If we pour an infinite amount of water on this histogram, some ...
Write a program or function to produce the following output in the correct order. EDIT: The symbols are not mathematical! The numbers just represent unique data and the + and - could be any two arbitrary symbols. Take an non-negative integer input n. The first line is always -, even for n=0. If the current line is -, ...
Background I play D&D on a regular basis with some friends. While talking about the complexity of some systems/versions when it comes to rolling dice and applying bonuses and penalties, we jokingly came up with some additional complexity for dice rolling expressions. Some of them were too outrageous (like extending sim...
Seahorses, of course, need shoes. However, a seahorse, having just one tail, needs just one shoe. Unfortunately, the shoes only come in pairs. Money is tight for the seahorse government, so they need to buy as few pairs as possible. Each seahorse has a shoe size x where x is a positive integer. However, a seahorse can ...
A Bell number (OEIS A000110) is the number of ways to partition a set of n labeled (distinct) elements. The 0th Bell number is defined as 1. Let's look at some examples (I use brackets to denote the subsets and braces for the partitions): 1: {1} 2: {[1,2]}, {[1],[2]} 3: {[1,2,3]}, {[1,2],[3]}, {[1,3],[2]}, {[2,3],[1]}...
As everyone knows, adding inator-3000 to the end of any noun makes it way cooler. But what else can make a word cooler? Given an ASCII string as input, output the coolness of the word. Calculating the coolness There are 4 elements to calculating the coolness of a word. The word itself. The base score is the number of ...
Task Given an input, evaluate it as a mathematical equation following the order of operations. But, instead of the using PEMDAS, we drop the parentheses and exponentiation and introduce spaces - SMDAS - spaces, then multiplication & division, then addition & subtraction. How does that work? Every operator with more spa...