instruction
stringlengths
34
53.1k
Write a few lines of Python code, X, that does not reference any global variables, such that def method(): X print(a) method() prints 1 but def method(): X X print(a) method() prints 2. So, I hate to be a stickler, but it seems like vars and locals are actually global variables in Python: def t...
I found an old post on Jon Skeet's blog that pointed out a puzzle from a tweet by Vladimir Reshetnikov: C# quiz: write a valid C# program containing a sequence of three tokens ? null : that remains valid after we remove the null. Note that the wording "three tokens" is important: "? null :" is a single string literal...
Challenge Given the equation of a line and the coordinates of the vertices of a shape, output the coordinates of the shape when reflected across the given line. Further Information The line's equation will be given with a y and an x separated by an equals sign (there may not always be a y and an x). Some examples: y=x ...
Background A bijective base b numeration, where b is a positive integer, is a bijective positional notation that makes use of b symbols with associated values of 1 to b. Unlike its non-bijective counterpart, no symbol has a value of 0. This way, each non-negative integer n has a unique representation in bijective base ...
When you search something on google, within the results page, the user can see green links, for the first page of results. In the shortest form possible, in bytes, using any language, display those links to stdout in the form of a list. Here is an example, for the first results of the stack exchange query : Input : yo...
Input Two integers: A non-negative integer W in the range 0 to 2^64-1, specifying the weave. A positive integer S in the range 1 to 255, specifying the side length. These can be taken in whichever order suits you. Output An S by S ASCII representation of the requested weave (S newline separated strings of S character...
In 2D Mario, Bullet Bill cannons are two units tall. The Bullet Bill is fired out of the upper unit and travels in a straight line (parallel to the x axis). Mario is two units tall when standing up and one unit tall when ducking. His jump height is three units. It takes him 0.5 seconds to reach the full height and 0.5 ...
Background One-hundred and thirteen years ago, amateur cryptographer Félix Delastelle published his work on the four-square cipher, a digraphic substitution cipher that accepts two permutations of a 25-letter alphabet as keys and encodes messages consisting of those letters. Like most pen-and-paper ciphers, the four-sq...
Context: A reclusive billionaire has created a game show to attract the world's best and brightest programmers. On Mondays at the stroke of midnight, he chooses one person from a pool of applicants to be the contestant of the week, and provides them with a game. You are this week's lucky contestant! This week's game:...
A subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. A strictly increasing subsequence is a subsequence in which every element is bigger than the preceding one. The heaviest increasing subsequence of a sequence is the stric...
Symbolic Differentiation 1: Gone Coefishin' Task Write a program that takes in a polynomial in x from stdin (1 < deg(p) < 128) and differentiates it. The input polynomial will be a string of the following form: "a + bx + cx^2 + dx^3 +" ... where the coefficient of each term is an integer (-128 < a < 128). Each term is...
When is it beneficial to use inline, single use importing in Python? For example: __import__("x").doSomething() Is the above ever shorter than the below? import x x.doSomething() Or from x import* doSomething()
This is the second in a series of puzzles that I will be posting every Monday at Midnight PST. The first puzzle is located Here. Context: A reclusive billionaire has created a game show to attract the world's best and brightest programmers. On Mondays at the stroke of midnight, he chooses one person from a pool of app...
Given an input, calculate the correct suffix and output the number in a readable format in short scale (where 1 billion is 10^9). The suffixes must go to at least 10^3000, in which the rules for calculating them can be found here, or a list can be found here. There is no need to output the exact numbers, this is focuse...
The Myriad System is an alternative system for naming large numbers proposed by Donald Knuth in 1981. In this system, numbers up to 999 are named as they are normally, but 1000 is not given a special name and is instead named as "ten hundred"; the next benchmark number being 10000, or "one myriad" (which, of course, co...
You are a talented young chef who has just been offered the position of sous chef at the world's most prestigious Indian restaurant. You have little experience with preparing Indian cuisine, but you're determined, so you set out to prove yourself. You decide to become the leading dosa expert. To do this, you must not o...
Challenge Code an ASCII cookie of a kind according to the input. Input The cookie kind. This is one of the three strings: "Plain", "Chocolate", or "Nuts". May be function arguments, stdin (or closest equivalent), or file arguments. Output An ASCII cookie. See below. Must be ___ / \ | | \___/ f...
Enabling delayed expansion variables in Batch chews up a lot of bytes. The shortest I have managed to make it is: @!! 2>nul||cmd/q/v/c%0&&exit/b Saving 11 bytes over @echo off&setLocal enableDelayedExpansion. The method is explained here - Tips for Golfing in Batch. Basically, it runs a command (!!) which fails initia...
X Marks the spot Your goal is to add a cross-hair around the capital X: Example Input / Output Input: mdhyyyyyyyhhhddmmm mdyyssoo oooosyyyhhhdmm hsso oossoooooyyhhdhhdmmm yoooooo oo ssysssyhhdyyyhmmmm myso oso...
Untouchable Numbersα An untouchable number is a positive integer that cannot be expressed as the sum of all the proper divisors of any positive integer (including the untouchable number itself). For example, the number 4 is not untouchable as it is equal to the sum of the proper divisors of 9: 1 + 3 = 4. The number 5 ...
Write a program or function which, given a positive integer as input, outputs the representation of that integer in Maya numerals. Maya numerals Maya numerals is a vigesimal system (base 20) using only 3 symbols : < > for Zero (The correct symbol is some sort of shell that can't easily be represented using ASCII). . ...
In a few British newspapers there is a game known as Hidato. It is somewhat similar to Sudoku, albeit instead of having 1-9 in a line and block, it's about placing numbers such that they connect in order from 01 all the way up to the highest one, so they are all touching horizontally, diagonally or vertically. Inputs w...
Sort the Textbooks School is starting soon (if it hasn't already) and so it's time to get our textbooks in order. You need to sort your books in alphabetical order but that takes too long so you decide to write a program to do it. Examples Input: _ | | _ |F| | | |o|_|P| |o|B|P| | |a|C| | |r|G| |_|_|_| Output: _ ...
Definition There is infinite row of concatenated natural numbers (positive integers, starting with 1): 1234567891011121314151617181920212223... Challenge Write program in any language, that accepts position number as an input, and outputs digit from that position in the row defined above. Position number is arbitrary ...
Overview Given a number of hexagons, arrange them into a connected shape within the confines of a 50 by 50 ASCII art image. The shape you choose can be arbitrary - whatever you find most amenable to golfing - as long as it is connected. It may have holes provided they are larger than one hexagon (otherwise the number o...
Take a string as input. This string can be as long as you'd like, however, it may only include letters and spaces––no numbers, punctuation, etc. When a word is passed into your function, an image will be made out of it. This image is the input word written out using only these characters: –, /, \, and |. You do not nee...
Zeckendorf's theorem shows that every positive integer can be uniquely represented as a sum of non-adjacent Fibonacci numbers. In this challenge, you have to compute the sum of two numbers in Zeckendorf representation. Let Fn be the n-th Fibonacci number where F1 = 1, F2 = 2  and for all k > 2, Fk = Fk - 1 + Fk -...
The challenge Implement the C equivalent of the pow() function (exponentiation) for natural numbers, in a language of your choosing, using only addition, subtraction (which includes negation and comparisons), bit-shifting, boolean operations on signed and/or unsigned integers, and of course looping. (Note that this is ...
Introduction "Yarr!! We had a laddie who called himself a "programmer" make a map t' our hidden treasure! But 'tis written wit' weird numbers 'n letters! "E5, N2, E3"... what does it even mean? Madness! Can't even scribe a proper treasure map, t' useless cretin. Fix it fer us! We'll gift ye a share o' t' treasure!" Cha...
Balancing Act Overview Given an input of 3 single-digit positive integers representing a set of weights, output an ASCII representation of a seesaw with the weights placed on it so that it is in balance around a central pivot, taking lever effects into account. Each number has a weight equal to its value. The torque of...
Challenge In the shortest amount of code: Compute the length of the permutation cycle of a perfect shuffle on a deck of cards of any size n (where n ≥ 2 and n is even). Output a table of all cycle lengths for 2 ≤ n ≤ 1000 (n even). Note that there are two basic ways of defining a perfect shuffle. There is the out-shu...
Ascii Pong The challenge is to recreate the classic game "pong" in ASCII characters in the shortest code possible. Requirements/specifications The "screen" should be 45x25 characters. White space should actually be white space. The paddles should be 9 equals signs: ========= and should be on the top-most and bottom-mo...
I've been using a library called Djangular recently, which integrates Django and Angular. After a while I thought 'Wouldn't it be fun to programmatically generate portmanteau?' Here are some examples (e.g. testcases): Django + Angular -> Djangular Camel + Leopard -> Cameleopard Spoon + Fork -> Spoork Ham + Hammer -> Ha...
For a given positive integer n, consider all binary strings of length 2n-1. For a given string S, let L be an array of length n which contains the count of the number of 1s in each substring of length n of S. For example, if n=3 and S = 01010 then L=[1,2,1]. We call L the counting array of S. We say that two strings S...
Usually when performing an internet challenge, there's no problem with having to specify a user agent, but when it comes to dealing with Google, it changes. Google blacklists the Urllib user agent, presumably to stop spambots, so you have to specify a user agent. This takes up many bytes, and is frankly rather annoyin...
For the purpose of this question, a magic square is an n×n square of (not necessarily distinct) positive integers, where all rows, columns, and main diagonals add to a "magic constant" m. Your Task Create a function or full program that, given the magic number m and a list representing a square with at most one wrong n...
This question brought to you by a game I like to play when stuck in long phone meetings. Given any two times from a 24 hour clock (from 00:00 to 23:59), how many valid mathematical equations can be generated with all of the times in between using only basic arithmetic operations? Input: two four digit strings (no colon...
We have a strictly increasing sequence of non-negative integers, like: 12 11 10 Wait! This sequence isn't strictly increasing, is it? Well, the numbers are written in different bases. The least possible base is 2, the biggest is 10. The task is to guess bases each number is written, so that: the sequence is strictly ...
Cryptic Kicker A common but insecure method of encrypting text is to permute the letters of the alphabet. In other words, each letter of the alphabet is consistently replaced in the text by some other letter. To ensure that the encryption is reversible, no two letters are replaced by the same letter. Your task is to de...
Which language usually produces shorter golfed code: Pyth, CJam or Golfscript? In asking this, I do not mean which has a prettier syntax or which has the most useful commands, I mean overall, which one is usually the shortest? What types of problems would we expect each language to have an advantage in?
What tricks do you know to make CoffeeScript code shorter? CoffeeScript is language that compiles into JavaScript ("transpiles" into ES3, to be exact). The golden rule is "It's just JavaScript", meaning there's no runtime overhead. Most of JavaScript Tips & Tricks apply as well. As a side-effect that also means: develo...
What general tips do you have for golfing in INTERCAL? I'm looking for ideas which can be applied to code golf challenges and are also at least somewhat specific to INTERCAL (i.e. "remove comments" is not a useful answer). I know exotic languages can be really useful to win golf contests, but I don't see much INTERCAL ...
Context: You are a cryptographer. You have stumbled upon a mysterious group of individuals, who present you with a challenge, which you must solve in order to join their secret society. Description: You have been given a binary stream consisting of 3 byte sequences that have a random width (unchanging per-stream). T...
This is the third in a series of puzzles that I will be posting every Monday at Midnight PST, and the final variant of "Take It or Leave It". The first puzzle is located Here The second puzzle is located Here Context: A reclusive billionaire has created a game show to attract the world's best and brightest programmers...
The Compiler Language With No Pronounceable Acronym, abbreviated INTERCAL, is a very unique programming language. Among its unreproducible qualities are its binary operators. INTERCAL's two binary operators are interleave (also known as mingle), and select. Interleave is represented with a change (¢), and select is rep...
The challenge is to write a brainf*** program that searches sequentially through memory for the first NON-zero cell. The program should start somewhere in fairly low memory (there will probably be some overhead/counters/etc.). Once the program starts checking cells, it should continue to the right, checking every cell...
Overview Write a program that prints out simple fractal patterns given a bit pattern encoding the fractal, plus the per-generation scale factor of the fractal and number of generations. Explanation Here is an ASCII representation of the Sierpinski Carpet: Generation 0: # Generation 1: # # # # # # # # Generation...
You have a swimming pool that is filled to the brim with water. You need to empty it, but you can't think of an efficient method. So you decide to use your red solo cup. You will repeatedly fill the cup all the way and dump it outside the pool. Challenge How long will it take to empty the pool? Input [shape of pool] [...
Your goal is to write a program that will print out the Laplace transform of a polynomial function with integer coefficients \$f(x)\$. The Laplace transform of \$f(x)\$ is defined as \$\int_0^\infty f(x) e^{-sx} dx\$. The standard input for the polynomial function will be a+bx+cx^2+dx^3+... If the coefficient is zero,...
NOTICE - This challenge is now closed. Any new answers will be ignored and the accepted answer will not change Challenge Write a valid program which, when just two characters in the program are changed, removed or added, completely changes the output. The changed output must have a Levenshtein Distance of 15 or more ...
For the main cops' challenge, click here NOTICE - This challenge is now closed. Any cracks which are posted now will not be counted on the leaderboard and the accepted answer will not change. Challenge Given the original program, its output and the output of the changed program, you have to find out which characters ...
You need to build a pyramid from cubes. Cubes can be viewed from 2 angles: _____ _____ /\ \ / /\ / \____\ /____/ \ \ / / \ \ / \/____/ \____\/ This is an example for 2-size cubes from the 2 possible angles. The height of the cubes is $size slashes (or back-slashes), and the w...
You have N lists A = [5, 6, 10, 15] B = [3, 0, 7, 4] C = [49, 59, 29] D = [19, 29, 39] E = [9, 15, 3, 10] You have to combine them such that: Two lists which have a common elements they should be next to each other. In this case answer is: A,E,B,C,D [5, 6, 10, 15, 9, 3, 0, 7, 4, 49, 59, 29, 19, 39] E comes after A a...
Find the shortest way to generate a random number between 0-9 without repeating the last generated number. Here is an example written in javascript. var n=t=0; while(n==t){ t=Math.floor(Math.random()*9); } n=t; I don't know if it is possible, but it would be interesting if there is a solution using only one variabl...
Synopsis: Find characters that are enclosed by MYPOCKET. Example Input MYPHEIF YFOCKVH MBNDEIF TEUFTMY ESNDUWP KBOVUVO CENWFKC OPYMTEB Example Output F BND EUF SNDUW BOVUV ENWF Huh? How did we get that as an output? The "pocket" can sometimes be difficult to see. This will make it clearer: MYPHEIF YFOCK...
Prindeal (pronounced prin-dee-al) is a new esoteric programming language that only has four commands: print, increment, decrement, and alias. Despite its minimalism, complex mathematical operations can be done in Prindeal by cleverly combining the four commands. Your task in this code golf challenge is to write the sho...
Challenge Find the shortest regex that validates, i.e. matches, every possible date in the Proleptic Gregorian calendar (which also applies to all dates before its first adoption in 1582) and does not match any invalid date. Output Output is therefore truthy or falsey. Input Input is in any of 3 expanded ISO 8601 d...
Task Given the page of a book P on stdin, count all occurrences of the digits 0-9 in each member of the range 1 to P. There is no page zero and your program should handle any number less than 1,000,000. Since putting a constraint on how you can do it is difficult to explain there will be a time limit of 3 seconds inste...
Brief Print an ASCII representation of a binary search tree. You should write your own minimum implementation logic of a BST (node, left, right, insert) (50,30,70,20,80,40,75,90) gives: __50__70__80__90 | | | |__75 | |__30__40 | |__20 Detailed requirements Items are inserted ...
Challenge You've given a map to a friend that looks a bit like this: | / | / | \ | \ D A simple map that starts at the top and ends at the bottom. Sadly, your friend doesn't get it. Can you decode the map so that he can read it? Input The input is a string of characters co...
Given a list of integer coordinates, find the area of the biggest convex polygon you can construct from the list such that - every vertex is in the list no element of the list is contained within the polygon. Example: (0, 0) (8, 0) (0, 1) (3, 1) (7, 1) (1, 2) (5, 2) (9, 2) (2, 3) (5, 3) (7, 3) (3, 4) (5, 5) (11, 5)...
The Challenge: Print every 2 letter word acceptable in Scrabble using as few bytes as possible. I have created a text file list here. See also below. There are 101 words. No word starts with C or V. Creative, even if nonoptimal, solutions are encouraged. AA AB AD ... ZA Rules: The outputted words must be separated so...
Background theme Introduction Obi-Wan Kenobi, Qui-Gon Jinn and Darth Maul are about to fight! However, they've all forgotten to bring their respective lightsabers. Write a program or function which, given the string Jedi as input, generates an image similar to this*: and given the string Sith, generates an image sim...
The goal of this challenge is the write the shortest function/program to take input text, encrypt it using the method below, and return the result. As an example, I will use the string hello world. First, get the input text. hello world Second, convert the string into ternary (base 3). Use this key: a = 000 b = 001 c ...
Write a program or function that takes in a positive integer and prints or returns an ASCII art depiction of an archery arrow, scaled according to the input. If the input is 1 the output is /\ / \ \__/ || || || || || || || || /||\ / || \ / || \ // \\ / \ If the input is 2 the output is /...
The Library of Babel is defined as a universe in the form of a vast library containing all possible 410-page books of a certain format and character set. For the purposes of this question, each page of the book contains 40 lines of 40 characters each. The formatting rules are as follows: Legal characters are the...
Write a function (such as placeAt) that takes an array of non-negative integers and an index that is a non-negative integer. It should place a 1 at the given index, possibly shifting other entries by one spot to vacate that spot, with 0's standing for empty spots. If the entry at the desired index is 0, fill it with a...
Write a program that takes in (via stdin or command line) a string with the recursive form PREFIX[SUFFIXES] where PREFIX may be any string of lowercase letters (a-z), including the empty string, and SUFFIXES may be any sequence of strings with the recursive form PREFIX[SUFFIXES] concatenated together, including the e...
Just about every store nowadays uses Universal Product Code (UPC) barcodes to simplify the checking out process. If the name doesn't mean anything to you, you will surely recognize what they look like: Format The most common system is UPC-A, which uses 12 digits to represent each specific product. Each digit is encode...
I came up with this challenge independently, but it turns out to be the inverse to this challenge by Doorknob. As I really like his spec, I decided to steal large parts of it instead of cooking up my own explanations. The Challenge Given the abbreviation of one of the 32 points on the compass, print the corresponding d...
Challenge You must write a program which correctly identifies the language a passage is written in. Rules The passage will be a string passed to your program either via STDIN or function arguments. You may not use any external sources except for a local text file with words. The length of the text file must be included...
I spent all of today at a Super Smash Bros. tournament, and I started thinking about some of the terminology we use when describing sets. These are the three kinds of sets that I see played at tournaments: Best of 3 (Bo3) Three games are played. The winner of the set is the player who won the majority of the games. ...
This challenge is loosely inspired by the Zachtronics game Infinifactory. You are given a top-down view of a rectangular grid of conveyors, represented by >v<^. There may be cells without conveyors, represented by spaces. Here is an example: > <vv < v ^ >v v >v^^>vv^ ^>^ v > v<v >> >v v<^ This setup ...
When dealing with long numbers when code golfing, getting the length of your code down can be difficult, so do you have any tips for making a number shorter and easier to manage? For example, the following Pyth code prints "Hello world", but at 44 bytes, that is unsatisfactory: Vcjkj85942000775441864767076 2 7=k+kCiN2...
Congratulations to Dennis who won both the cops' and the robbers' challenge! Calvin's Hobbies has already delivered on his promise and wrote this challenge for Dennis for winning the robbers' challenge. Notice: This challenge is closed for further cop answers as of 2015-09-01 02:00:00 UTC. Any new answers posted wil...
According to this page, the best strategy to guess English hangman words is to calculate the odds of each letter in a word list that meet our conditions. But, as I'm really lazy, I don't really want to compute every word in the dictionary by myself. But, as I know that you are always here to help me, I'm sure you will ...
In this challenge, you are to draw the chessboard below, and allow for moves to be made. 1. Drawing Each white square has 5x9 spaces. Each black square has 5x9 colons. The board is surrounded by a border of colons. The pieces are 5 characters wide and sit on the bottom row of the square in the centre. The pawns are 4 c...
You work for the military as a coder and are responsible for writing software to control missiles. Your task is to write a program or function that will output a code sequence (any length ASCII string) to launch a missile. The program should be based on a loop taking the code sequence from memory and output it in a par...
Challenge: Your challenge (should you choose to accept it) is to compress and decompress the 5MB "Complete Works of William Shakespeare" as found here: http://www.gutenberg.org/cache/epub/100/pg100.txt (MD5: a810f89e9f8e213aebd06b9f8c5157d8) Rules: You must take input via STDIN and output via STDOUT... ...and you must...
What is a Word Signature? The signature of a word are all of it's letters put in order - the signatures of this, hist and hits are all hist. The Challenge Write a program program should ask for an input, then print out the signature of that word. So an example program run might look like this: Give me a string: this T...
Inspired by this question on Math.SE. Starting with 1 you can repeatedly perform one of the following two operations: Double the number. or Rearrange its digits in any way you want, except that there must not be any leading zeroes. Taking an example from the linked Math.SE post, we can reach 1000 via the following st...
You are given the RGB values of a color. Your task is simple: to calculate the hue, in the simplest definition. Say the channels with highest, middle and lowest value are X, Y, Z (which are either red, green or blue) and their values are x, y, z. The hue of this color is (h(X)-h(Y))*(1 + (x-y)/(x-z))/2 + h(Y), where: h...
Given two parameters lane pattern and road length, print an ASCII representation of the lane markings for Roads and Traffic Service to paint the roads. Example input/output Input: BTHMLRPHU, 21 I don't care if you take two parameters or concatenate the number onto the end of the string, it's unambiguous. Input may be t...
The challenge is to write the shortest function/program to find a polynomial given the roots. The function or program should take valid input; that is, a list of integers representing the roots of the polynomial, and return valid output. Output should return a sequence of numbers representing the polynomial. For exampl...
There is an app called Hard Puzzle which is a game where there is a red circle, and you have to fill all of the surface area with five smaller white circles it may seen easy, but it's harder than it looks (it just takes a while to figure out). The circle dimensions change from device to device in the image above the re...
You are given a set of logic statements. Your challenge is to remove any ones that contradict the others, but in the optimal way (i.e. removing a minimal number of statements). Challenge You will write a program or a function that takes as input a list of statements, removes the minimal number of statements such that t...
Twisting Words! Given a string and a positive integer. You must twist the string, back and forth. Example Input / Output Input Programming Puzzles & Code Golf 4 Output Prog mmar ing zzuP les oC & de G flo Input The input can be taken in through STDIN, or function argument. The input will consist of a string and a ...
Introduction In the land of [Insert cool name here], people don't buy things with money, because everyone has a severe allergy to paper. They pay eachother with words! But how is that? Well, they give each letter number values: a=1,b=2,c=3,etc. (With some other special rules that will be described later) In this chal...
This challenge is loosely inspired by the unimplemented esolang Pada. Consider an array of 8 bits, all initialised to zero. We'll introduce a very minimalistic instruction set to print arbitrary strings. There are two instructions, both of which take a parameter N which is the index of a bit: t N for toggle: This chan...
Your challenge is to take input as a line of text and output it like this. Input / output The input will be a string that contains only printable ASCII characters. The first or last characters will never be spaces, and there will never be two spaces in a row. It will always be at least two characters long. Your output...
I encountered this question in an interview and could not figure it out. I believe it has a dynamic programming solution but it eludes me. Given a number of bricks, output the total number of 2d pyramids possible, where a pyramid is defined as any structure where a row of bricks has strictly less bricks than the row be...
Sign that word 2! Not that long ago, I posted a challenge called Sign that word!. In the challenge, you must find the signature of word, which is the letters put in order (e.g. The signature of this is hist). Now then, that challenge did quite well, but there was one key issue: it was WAY too easy (see the GolfScript a...
Zig-zag strings Given a string and a positive integer, output the string in a zig-zag wave pattern with a peak amplitude and character spacing equal to the integer. This is similar to this question but also includes character spacing. Input Input can be read from STDIN or taken as function arguments. Input is a string...
Challenge Write a program to factor this set of 10 numbers: 15683499351193564659087946928346254200387478295674004601169717908835380854917 24336606644769176324903078146386725856136578588745270315310278603961263491677 39755798612593330363515033768510977798534810965257249856505320177501370210341 45956007409701555500308213...
Magic: the Gathering is a trading card game where, among other things, players play cards representing creatures, which can then attack the other player, or defend against the other player's attacks by blocking. In this code-golf challenge, your program will be in the place of a Magic player deciding how to block in co...
Write the shortest program that waits for every key of a Standard 101 key US Keyboard* to be pressed and then exits writing OK! Every time a key is pressed the program displays on a new line the remaining number of unpressed unique keys that need to be pressed until all key are pressed at least once. The program should...
Given a list of integer points in an n-dimensional space, output the geometric median. Note that the output is not necessarily integer. Your answer must be precise to at least two digits after the decimal point. You may assume that n < 16 and that every component of each point fits in a 32-bit signed integer. You may w...
Almost all operating systems allow you to run multiple programs at the same time. If your system does not have enough processors to run all the programs you want to run, it starts to give each program just a tiny slice of time on the processor it runs on. This is normally not noticeable but can lead to strange artefact...
In this challenge you'll be using be distributing a product over sums and differences of numbers, as explained here. Examples Input | Output -------------|------------- 23(12+42) | (23*12)+(23*42) 9(62-5) | (9*62)-(9*5) 4(17+8-14) | (4*17)+(4*8)-(4*14) 15(-5) | -(15*5) 2(3) | (2*3) 8...
Write a piece of JavaScript code that calls alert with an array containing the first 50 Fibonacci numbers in order. You may only use the following characters: +!()[]. As a reference, your code must be functionally equal to the following: var fib = [], a = 1, b = 1; for (var _ = 0; _ < 50; _++) { fib.push(a); va...