instruction
stringlengths
34
53.1k
Definition A number is positive if it is greater than zero. A number (A) is the divisor of another number (B) if A can divide B with no remainder. For example, 2 is a divisor of 6 because 2 can divide 6 with no remainder. Goal Your task is to write a program/function that takes a positive number and then find all of it...
A perfect power is a number of the form \$a^b\$, where \$a>0\$ and \$b>1\$. For example, \$125\$ is a perfect power because it can be expressed as \$5^3\$. Goal Your task is to write a program/function that finds the \$n\$-th perfect power, given a positive integer \$n\$. Specs The first perfect power is \$1\$ (which...
This challenge is a harder version of this one. A variable number of trits is an array of 0 or more trits (a trit is a ternary digit). So [0, 2, 2, 1] is a variable number of trits, but so is []. Write a function or program that, given an non-negative integer returns a variable number of trits such that every integer h...
For example, if n is 5 and r is 2, it would mean the number of lists below: [1,1,1,1,1] [1,1,1,2,2] [1,1,2,2,2] [2,2,1,1,1] [2,2,2,1,1] [2,2,2,2,2] which is 6. If n is 4 and r is 3: [1,1,1,1] [1,1,2,2] [1,1,3,3] [2,2,1,1] ... [3,3,3,3] which is 9. where each item has a neighbour whose value is the same. For example, ...
Mary has given John two sticks of lengths a and b respectively, where a and b are positive integers. John is very curious. He would like to know how many triangles with integer perimeter can be formed, by having one additional side. Please help him find it out. (This is my first time composing this kind of stupid stori...
A polygonal number is the number of dots in a k-gon of size n. You will be given n and k, and your task is to write a program/function that outputs/prints the corresponding number. Scoring This is code-golf. Shortest solution in bytes wins. Example The 3rd hexagon number (k=6, n=3) is 28 because there are 28 dots abov...
This question got me nostalgic: Build a word generator! In the '80s I wrote a simple word generator in under 42kB (code and working memory) that would take a collection of strings and use them to create new words and phrases. Your task is to recreate this program in as few bytes as possible, with a few minor updates. Y...
You are trying to guess my emotion. I will give you an adjective, as the input to the function/program. Your task is to output my emotion, either :) for happy, or :( for sad. Details For these adjectives, you must output the happy face :) contented delighted merry overjoyed pleased blessed chipper content convivial gle...
Automatic house building nanobots have been fabricated, and it's your job to code them. Here is the house created by input 7 4 2 /-----/| / / | |-----| | | | | | | / |_____|/ The input is a string containing the house's dimensions. 7 is the width. |_____| ---7--- 4 is the height. | | | | 2 is the d...
Introduction Let's observe the following array: [1, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1] A group consists of the same digits next to each other. In the above array, there are 5 different groups: [1, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1] 1, 1, 1 2, 2 1, 1, 1, 1 ...
You are trying to guess my emotion. I will give you an adjective, as the input to the function/program. Your task is to output the state of my eyes, either O_O for open, or ._. for closed. Details For these adjectives, you must output open eyes O_O animated breezy brisk driving enterprising fresh indefatigable industri...
Congratulations! You have just been hired by a Fortune 499 company specializing in oil drilling. Your job is to write a program to determine the optimum placement of OilRUs' drill (represented by a single alphabetical character of your choice, I use a capital "O" in the examples), given a length of piping, and a two-di...
Clarification: Basically, you need to make this Euler's totient function has the name phi. Let's try to calculate phi(8) First, list all numbers 8 and under backwards, not including 0 or under 8 7 6 5 4 3 2 1 Now find which numbers don't share a factor with 8 (1 doesn't count), and place a # in their place. 8 # 6 # 4 ...
In information theory, a "prefix code" is a dictionary where none of the keys are a prefix of another. In other words, this means that none of the strings starts with any of the other. For example, {"9", "55"} is a prefix code, but {"5", "9", "55"} is not. The biggest advantage of this, is that the encoded text can be...
In this challenge about prefix code, we learnt that prefix codes are uniquely concatenable. That means, they can be joined together without separator, and without ambiguity. For example, since [1,2,45] is a prefix code, I can join them together without separator as such: 1245245112145, and there will be no ambiguity. H...
Your task is to write a program/function to scale up an image (list of strings) by a factor of n. Specs You will receive two inputs: an image, and a positive integer. The image will only contain ASCII printable characters (U+0020-U+007F). Scoring This is code-golf. Shortest solution in bytes wins. Testcases Testcase ...
Final results available Introduction After my previous KOTH with heavy themes (fantasy war, worldwide pandemic...), I'm back with a new lighthearted game. This time, you are facing off in a "board game-like" situation. A pile of upside down coins is placed at the center of a really big table, and you are determined to ...
Encrypting Challenge Your encrypting program must be able to do following things: Input password Generate random key Encrypt random key with set key Then, the decrypting program must be able to these things: Input encrypted password Input encrypted random key Decrypt random key Decrypt password with decrypted random ...
Note: This challenge is not the same. Challenge Believe it or not, we haven't got ONE challenge for reversing one-dimensional arrays (although we've got one for n-dimensional ones)! This should operate only on the 1st dimension, not on all dimensions of an array. Rules Standard loopholes are denied [[1, 2], [3, 4]] be...
Text to DNA golf Challenge Convert input into a DNA output. Algorithm Convert text into ASCII code points (e.g. codegolf -> [99, 111, 100, 101, 103, 111, 108, 102]) String the ASCII codes together (e.g. 99111100101103111108102) Convert to binary (e.g. 1010011111100110100101101000100001100110101101111000011001011111101...
This challenge is about gradually shifting hues in an image to make pretty pictures like this: (original) Challenge Write a program or function that takes in two non-negative integers and an image in any common image file format of your choosing (you can take a path to the image or the raw image data). We'll call the ...
What are some tips for code-golfing in Swift? Its focus on safety seems to make it difficult to golf in, but that makes little tips and even more useful. Are there any features in Swift that may help it excel in code-golf in certain applications? Please post one tip per answer.
Your task is to build a natural number using the fewest number of ones and only the operators + or -. For example, the number seven can be written 1+1+1+1+1+1+1=7, but it can also be written as 11-1-1-1-1=7. The first one uses 7 ones, while the latter only uses 6. Your task is to return the minimum number of ones that ...
Look at these photographs of natural scenes, with one of the RGB channels taken out of them: Source (with red): https://en.wikipedia.org/wiki/File:Altja_j%C3%B5gi_Lahemaal.jpg Source (with green): https://commons.wikimedia.org/wiki/File:2007_mather-lake_hg.jpg Source (with blue): https://commons.wikimedia.org/wiki/F...
Write a program or function, that given a success probability p, a number n and a number of trials m returns the chance of at least n successes out of m trials. Your answer must be precise to at least 5 digits after the decimal. Test cases: 0.1, 10, 100 -> 0.54871 0.2, 10, 100 -> 0.99767 0.5, 13, 20 -> 0.13159 0.5...
An Indian legend tells the story of the alleged inventor of the chess game, who impressed the emperor of India with his game so much that he would get rewarded with anything asked. The man said he wanted to be paid in rice. He wanted a grain of rice for the first square of the chessboard, two for the second, four for t...
A palindromic number (in case you don't know) is a number which reads the same backwards and forwards (example, 11). The first 15 non-palindromic numbers are: 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26. This is A029742. I constantly need these numbers, but my sticky note pad is very small, so your code ...
This was inspired by a Minecraft mini-game. The rules are pretty simple: you run and jump around, and every block you step on disappears once you've stepped on it. The goal is to be the last one left. Your bot should be a complete program. It should accept input as a command line argument. The input will be a map of th...
While doodling around on square-ruled paper the other day, I came up with the above negative-space font for digits. In case you haven't spotted it yet, the spaces between the above shapes yield the golden ratio 1.618033988749. In this challenge, your task is to take a number as input and render it exactly as the examp...
Challenge: Read a string from user, print number of each vowel, then place all remaining chars in a line. Shortest answer wins! Output must look like this: Enter String: Input Vowel Count: a: #, e: #, i: #, o: #, u: # Remaining characters: Vowel-less Input For example: Enter String: LoremIpsumDolorSitAmetConsecuteurA...
I am a very casual code golfer, and don't often see posts until they show up in the "Hot Network Questions" sidebar over on StackOverflow. Usually, I'm late to the game, and since the only language I know is Python, there is little point in me answering as there are already several Python answers. Your challenge is t...
Gamma function is defined as It is a well-known fact that for positive integers it coincides with a properly shifted factorial function: Γ(n) = (n - 1)!. However, a less famous fact is Γ(1/2) = π1/2 Actually, the Gamma function can be evaluated for all half-integer arguments, and the result is a rational number mult...
The task is to generate all the strings from 'a' to '999' including upper case characters like so: 'a', 'b', 'c' ... 'y', 'z', 'A', 'B', 'C' ... 'Y', 'Z', '0', '1', 2' ... '8', '9', 'aa', 'ab', 'ac' ... 'az', 'aA', 'aB' ... 'aZ', 'a0' ... 'a9', 'ba' and so on (filling in the gaps), optionally starting with the empty ...
Your task is to write a program that will filter out some characters in a string, so that the remaining spells out (part of) the other string. Let's say we received the string "123456781234567812345678", and the second string is "314159". First, we put a pointer on the second string: 314159 ^ So the pointer is now on ...
Piano keys are 3 characters wide, and 7 characters tall. However, if every key was 3 charactes wide, there wouldn't be enough room for the black keys. That's why some of the white keys have parts of them cut out. There are 3 types of white keys. Keys with the right half missing (R): ____ | | | | | | | | | | |...
K-means is a standard unsupervised clustering algorithm, which, given a set of "points" and a number of clusters K, will assign each "point" to one of K clusters. Pseudo-Code of K-means Note that there are many variants of K-means. You have to implement the algorithm I am describing below. You may have some variation o...
Interpret DOGO DOGO is a lesser known programming language. While the original DOGO (a joke language from a Usenet post) has never been implemented, a language resembling it has been created. The commands for the language are: +===========+================================================================+ | Command | ...
Coordinates in the flat-Earth world consist of latitude (x) and longitude (y), which are integers in the range 0...9999. Much like Gaussian integers, but they are always written using this notation: 411S 370E That is, with S or N appended to the latitude, and E or W appended to the longitude, with space(s) between the...
EDIT: The incorrect A rhomb substitution has been fixed. Apologies to anoyone who had started working on a solution. Consider the following substitutions, where the substituted rhomb(us) is scaled up and shown in red: EDIT: Note the anchor points (circle) created where a corner of each new rhomb touches the substituted...
(Taken from https://en.wikipedia.org/wiki/File:Tangential_quadrilateral.svg) A tangential quadrilateral (see example above) is a quadrilateral in which a circle can be inscribed. Your task is to find the possible value of d given a, b, and c. Specs a, b, c will all be positive integers. If no possible value of d exis...
Your task is to build a bridge to connect two cliffs given an input d, the distance apart. d will always be even However, the bridge needs columns to hold it up. Each column can hold a max of 6 spaces on each side. For this example: ________ ________ | | A | ...
This challenge is about reading random lines from a potentially huge file without reading the whole file into memory. Input An integer n and the name of a text file. Output n lines of the text file chosen uniformly at random without replacement. You can assume that n is in the range 1 to the number of lines in the f...
You are given a string composed with the characters 0123456789+*(). You can assume that string is always a valid mathematical expression. Your task is to remove the unnecessary parentheses, assuming multiplication has higher priority than addition. The parentheses should be removed only when they are not needed structu...
Intro (semi fictional) I'm the solo developer of a game, I'm already struggling with character design as is. Hence I've thought of a smart solution, I'll just use images for regular monsters, outline them a bit and suddenly they are boss monsters! That will save me from thinking up new bosses yay. However, I have appro...
Given a list of N integers, each with N digits, output a number which differs from the first number because of the first digit, the second number because of the second digit, etc. Example Given this list: 1234 4815 1623 4211 The number 2932's first digit is different from the first number's first digit, its second dig...
Introduction The two most common trigonometric functions, sine and cosine (or sin and cos for short), can be extended to be matrix-valued functions. One way to compute the matrix-valued analogs is as follows: Consider these two important trigonometric identities: $$ e^{i x} = \cos(x) + i \sin(x) \\ \sin^2(x) + \cos^2(x...
Challenge Write a program P, taking no input, such that the proposition “the execution of P eventually terminates” is independent of Peano arithmetic. Formal rules (In case you are a mathematical logician who thinks the above description is too informal.) One can, in principle, convert some Universal Turing machine U (...
The continued fraction of a number n is a fraction of the following form: which converges to n. The sequence a in a continued fraction is typically written as: [a0; a1, a2, a3, ..., an]. Your goal is to return the continued fraction of the given rational number (positive or negative), whether it is an: integer x frac...
Background I want to buy an plot of land and build my house on it. My house should be rectangular, and as large as possible; however, the available plots have lots of rocky areas that I cannot build on, and I'm having trouble fitting a potential house on the plots. I want you to write a program that analyzes the plots ...
You have to write a function/program that will draw an ASCII art of a square made with numbers. Challenge This program will take one input n as a positive integer and draw a hollow square using this number. The inside must be filled with spaces. The borders also must have the same width. The width and height of the squ...
Everyone knows what run-length encoding is. It has been the subject of many code-golf challenges already. We'll be looking at a certain variation. Example Normal: 11222222222222222222233333111111111112333322 Run-length: 112(19)3(5)1(11)2333322 The number in parentheses specifies the number of times the previous symbol...
Important note: Because this challenge only applies to square matrices, any time I use the term "matrix", it is assumed that I am referring to a square matrix. I am leaving off the "square" description for brevity's sake. Background Many matrix-related operations, such as computing the determinant, solving a linear sys...
Goal: Create the smallest possible code to open a separate window, in which there are 100 circles of random sizes and colors. Rules: All circles must be visible to the unassisted, naked eye, so in other words more than 2 pixels across, the background must be black, at least 5 different colors must be recognizable, and ...
What is the most frequent word? Given a sentence, your program must make its way through it, counting the frequencies of each word, then output the most used word. Because a sentence has no fixed length, and so can get very long, your code must be as short as possible. Rules/Requirements Each submission should be eith...
The Challenge Implement amb and its sister statement require in whatever language you wish. See http://community.schemewiki.org/?amb for an example implementation in Scheme. You can rename them to a and r. amb statements select a value passed to it arbitrarily, and require statements written after amb contain condition...
Lower level languages, such as C and C++ actually have no concept of multidimensional arrays. (Other than vectors and dynamic arrays) When you create a multidimensional array with int foo[5][10]; This is actually just syntactic sugar. What C really does is create a single contiguous array of 5 * 10 elements. This foo[...
The Laver tables provide examples of programs which have not been shown to terminate in the standard axiomatic system of mathematics ZFC but which do terminate when one assumes very large cardinal axioms. Introduction The classical Laver tables An are the unique finite algebras with underlying set {1,...,2n} and an ope...
Brain-Flak (a cross between Brainf**k and Flak-Overstow) is a stack-based esoteric language. Since this challenge was posted, the language has evolved and updated, but this first revision of the language is known as "brain-flak classic". You must write a program or function that takes a string of Brain-Flak classic cod...
Inspired by this question over at Mathematics. The Problem Let n be a natural number ≥ 2. Take the biggest divisor of n – which is different from n itself – and subtract it from n. Repeat until you get 1. The Question How many steps does it take to reach 1 for a given number n ≥ 2. Detailed Example Let n = 30. The...
Given an integer N >= 2, produce an image showing a Sierpiński knot of degree N. For example, here are knots of degree 2, 3, 4 and 5: Click on the images to view full size (the higher the degree the larger the image). Specification A Sierpiński knot of degree N is drawn using the vertices of a Sierpiński triangle ...
My electric garage door works like this: There is just one push button to control the door If the door is fully closed and I hit the button, the door starts to open. It takes 10 seconds to open fully If the door is fully open and I hit the button, the door starts to close. It takes 10 seconds to close fully If the d...
A Latin square is a square that has no repeated symbols in either the X or Y columns. For example: ABCD DABC CDAB BCDA is one such square. Notice how every column and row contains a permutation of the same 4 letters. However, our Latin square has a problem: If I were to rotate the second row (DABC) 1 to the lef...
This is somewhat similar to The centers of a triangle, but with a different point. The Fermat Point is the point P in triangle ABC such that the value of AP + BP + CP is minimized. There are two cases: If there is an angle greater than 120 degrees, that vertex is the fermat point. Otherwise, draw equilateral triangles ...
Introduction Nodes in tree structures (e.g. headings in a long document, law paragraphs, etc.) are often created by assigning a specific header level (h1, h2, etc.) to each item, but outputted with additional node numbers for each level (1., 1.1., etc.), e.g.: 1. Intro (h1) 1.1. About this (h2) 1.2. Target audience (h2...
Introduction In this challenge, we will be dealing with a certain infinite undirected graph, which I call the high divisor graph. Its nodes are the integers starting from 2. There is an edge between two nodes a < b if a divides b and a2 ≥ b. The subgraph formed by the range from 2 to 18 looks like this: 16-8 12 18 \|...
What general tips are these for golfing in Lisp (any dialect)? Please post one tip per answer, and only answers that are specific to a dialect of Lisp (e.g. "remove comments" is not an answer). Please post the dialect of Lisp your tip applies to with your tip.
I want to write 7 assembly instructions (28 bytes) that runs a logical equivalent of this C snippet: c = a + b + 6; while (c > 5) { c = c - a; b = b + 1; } However, there are restrictions to the allowed instructions: add, addi, sub, subi, slt, slti, bne a, b, and c are located in registers $t0, $t1, and $s0 respe...
Background Actually (the successor to Seriously) is a stack-based imperative golfing language I created in November of 2015. Like many other golfing languages, it has one-byte commands that perform different functions based on the contents of the stack. One of its specialties is mathematics - it has a wide variety of m...
Based on a recent question in StackOverflow Write a program/function that takes in one ARRAY/list and returns the number of pair-values which sums up to a given TOTAL. Explaining TOTAL=4, ARRAY=[1,3,7,1,-3] => RESULT=2 The result was 2 because 1 + 3 and 7 + -3 are valid pairs which sums up to TOTAL=4. When one pair i...
Given the coordinates of the upper left corners of two squares and their side lengths, determine whether the squares overlap. A square includes the top and left lines, but not the bottom and right lines. That is, a point (a,b) is inside a square with side length k that starts at (x,y) if and only if x <= a < x+k and y ...
Write a program or function that finds the number of zeroes at the end of n! in base 10, where n is an input number (in any desired format). It can be assumed that n is a positive integer, meaning that n! is also an integer. There are no zeroes after a decimal point in n!. Also, it can be assumed that your programming ...
Create a bootloader that executes given Brainfuck program. This is code-golf, so the program with least bytes wins. Being a bootloader, the size of the program is counted in non-zero bytes in the compiled code. Brainfuck 30000 8-bit overflowing cells. Pointer wraps over. Some notes about operations: Input must be read...
Koronkorko is the Finnish word for compound interest. We don't want compound interest in our strings, so let's find the shortest possible regular expression to exclude it. Given a string consisting only of the uppercase alphabetic characters A-Z, determine the shortest possible regular expression that matches the strin...
Introduction Turns out, aliens love memes just as much as we do. Every alien race we've encountered so far has their own version of 2spooky4me (see the following question) and equivalent, though, with some variation. The inhabitants of planet CUTE1f can't handle a lot of spook, so their preferred spook is 1spooky2me, w...
Columnar Transposition Cipher While I have plenty of programs I have written for more advanced ciphers, I just realised I don't actually have one for one of the simplest: Columnar Transposition. The cipher, in case you don't know, works as follows: First, you take the key, and write it as numbers. The numbers are made...
Fix my Basic Orthography While I am excellent at following the English capitalisation rules when writing, when I am typing I have a habit a capitalising almost everything (as you will see from the titles of my challenges). I need a program to fix that, but because I use so many capitals, and capitals are big letters, y...
You can decompose a number greater than 0 as a unique sum of positive Fibonacci numbers. In this question we do this by repeatedly subtracting the largest possible positive Fibonacci number. E.g.: 1 = 1 2 = 2 3 = 3 4 = 3 + 1 12 = 8 + 3 + 1 13 = 13 100 = 89 + 8 + 3 Now, I call a Fibonacci product the same lists as abov...
If elected president, Donald Trump plans to implement a system of four income tax brackets (full details can be found on his website here). Your job is to take two inputs, annual income and filing status (single, married, or head of household), and output the income tax that must be paid. Income Tax Brackets (We are o...
Inspired by this site, this question could potentially be a doozie. People on StackOverflow often overuse jQuery as an answer. Therefore, we need a way to recognize programmatically if a code snippet uses jQuery. Given a string (which may or may not contain new lines,) of valid Javascript, determine if jQuery is used....
Your job is to write a program that rewrites and makes itself longer on each run of the program. Challenge The program will print Hello, World!\n (\n denotes a newline). Then, it will modify its own file so that the new program length is exactly 2x the length at runtime. This modified file when run, will print Hello, W...
Adam7 is an interlacing algorithm for raster images, such as PNG. It is called the "Adam7" algorithm because it was invented by Adam M. Costello, and it is generated by following a certain pattern 7 times. One of the cool things about the Adam7 algorithm that makes it really fun for code golf, is that the pattern can b...
There's been challenges for the shortest cat program, but as far as I know, there hasn't been any for the longest one. A cat program is a program that copies its input to its output. Here's an example: Input: Hello Output: Hello Input: cat Output: cat So, the rules are simple: The program has to copy its input to it...
This challenge is inspired by a picture that often roams on Facebook that looks like this. Except our base square will look more like this: ┌─┬───┬─┐ ├─┼─┬─┼─┤ ├─┼─┴─┼─┤ ├─┼─┬─┼─┤ └─┴─┴─┴─┘ The square is made out of n x m 1x1 square, you have to count how many sub-squares (1x1, 2x2, 3x3, 4x4, 5x5, etc.) can fit within...
I'm trying to read 4 ints in C in a golfing challenge and I'm bothered by the length of the code that I need to solve it: scanf("%d%d%d%d",&w,&x,&y,&z) that's 29 chars, which is huge considering that my total code size is 101 chars. I can rid of the first int since I don't really need it, so I get this code: scanf("%*...
Does anybody have tips for golfing in Erlang? I'm looking for specific things that can be applied to Erlang, not any language. I know we already have tips for Elixir, but that is different. As usual, please post separate tips in separate answers.
Introduction Let's observe the following square, consisting only of the digits 0 - 9: 1034 4167 8414 3542 The outer shell of this square is: 1034 4 7 8 4 3542 It contains zeros, so we need to peel off the outer shell, leaving: 16 41 The outer shell of this square is: 16 41 It does not contain any zeros and is the...
Give credit to whom credit is due. Objective Given an integer N > 0, out the smallest integers A, B, and C so that: All of A, B, and C are strictly greater than N; 2 divides A; 3 divides B; and 4 divides C. This is a code-golf, so the shortest answer in bytes wins. Test cases N => A, B, C 1 => 2, 3, 4 4 => 6, 6, 8 43...
Given two non empty lists of integers, your submission should calculate and return the discrete convolution of the two. Interestingly, if you consider the list elements as coefficients of polynomials, the convolution of the two lists represents the coefficients of the product of the two polynomials. Definition Given th...
A pangram is a sentence or excerpt which contains all twenty-six letters of the alphabet, as is demonstrated in this code golf challenge. However, a pangrammatic window is a pangram in the form of some segment of text, which may end or begin halfway through a word, found somewhere within a larger work. These naturally ...
This is a quine variation. Introduction We all write short code, because some obscure reasons, but whatever we do, the'll take up at least 144 pixels/byte (with a 12px font). But what would happen, if we would encode our code in images? This is your task today. Challenge You task is to read in your own source code (non...
I have a list, l and a function f. f is not strictly increasing or decreasing. How can I find the item in the list whose f(item) is the smallest? For example, let's say the list is: l = [1, 2, 3, 4] and list(f(x)for x in l) is: [2, 9, 0, 3] f(3) is smaller than f of any of the other ones, so it should print "3". What...
This is my friend Thomas. He is half tree, half emoticon. | | | :D | | | He is lonely. Let's make him some friends! Given a text-based emoticon as input (e.g. ಠ_ಠ, :P, >_>, not , , or ), output the corresponding treemote. A treemote's length is how many characters it is lon (basically most builtin length functi...
My local ACM chapter gives out door prizes to people who come to the meetings. You get an increased chance of winning if you solve the programming puzzle, however (but I always solve that puzzle). Thus, some people have 1 entry, while others have 2. But wait! The way the raffle program works is not by adding in another...
Given three dice rolls (integer values from 1-6) in sorted order (so as to be indistinguishable), convert them to the sum of two fair dice with an identical distribution. The answer for three to one is summing them all, modulo 6. The end-result is a perfectly flat distribution, where each of the six numbers are equall...
In this challenge, your task is to create a program which takes in a nested array and returns a single-dimensional flattened array. For Example [10,20,[30,[40]],50] should output [10,20,30,40,50]. Input The input will be a nested array (eg. [10,20,[[[10]]]]). It will contain only Integers (both negative and positive),...
You teach a class of students with interesting preferences for how their chairs are arranged. There are 3 very specific requirements they have for how the chairs are arranged: They most be arranged in a rectangle, even if it means some chairs go empty. There must be as few empty chairs as possible. They must be as "...
Introduction The arithmetic mean is defined as being equal to the sum of the numerical values of each and every observation divided by the total number of observations. Symbolically, if we have a data set containing the values a1,…,an. The arithmetic mean A is defined by the formula Objective The challenge here is, gi...
TetraVex is a tile-based edge-matching game that was originally coded by Scott Ferguson for the Microsoft Entertainment Pack 3 back in 1990. The game consists of a grid upon which square tiles are placed. The tiles have numbers or letters on each edge, and the goal is to place all tiles in the grid, with each pair of e...
Steiner Chains are a set of N circles where each circle is tangent to 2 other non-intersecting circles as well as the the previous and next circles of the chain, as seen in the below images: In this challenge, you will write a program/function that draws Steiner chains recursively, that is, circles of a given chain ...
Write some code that acts as a cat program. That is, to input a string and output it as is. But the normal reversion of your code must output the normal reversion of the input string. And the visual reversion of your code must output the visual reversion of the input string. The normal reversion is the reversed charact...