instruction
stringlengths
34
53.1k
This is similar to prime factorization, where you find the smallest prime factors of a number (i.e. 8 = 2 x 2 x 2). But this time, you are to return an array/list of the smallest composite factors of any given positive integer n. If n is prime, simply return an empty list. Examples: Prime: n = 2 Result: [] Composite ...
Inspired by this challenge Given an integer in the range 0 <= n < 2**64, output the minimum sized container it can fit in out of bit: 1 nibble: 4 byte: 8 short: 16 int: 32 long: 64 Testcases: 0 -> 1 1 -> 1 2 -> 4 15 -> 4 16 -> 8 123 -> 8 260 -> 16 131313 -> 32 34359750709 -> 64 This is code-golf, so the shortest ans...
You're sick of other players smugly announcing "BINGO" and walking triumphantly past you to claim their prize. This time it will be different. You bribed the caller to give you the BINGO calls ahead of time, in the order they will be called. Now you just need to create a BINGO board that will win as early as possible f...
You are Ruby, a railway engineer. Your task is to lay track in any given valley such that it visits every station (M). The amount of track laid is not important, but it must be laid in one continuous path which starts and ends at the valley entrance/exit point (>) and does not, at any point cross itself. There are a fe...
Gaussian blur is a method used for blurring images smoothly. It involves creating a matrix which will be used by convolving it with the pixels of an image. In this challenge, your task is to construct that matrix used in Gaussian blur. You will take an input r which will be the radius of the blur and an input σ which w...
This is a 3x3 ASCII jigsaw puzzle: _____ _____ _____ | _| |_ | | (_ _ _) | |_ _|_( )_|_ _| | (_) |_ _| (_) | | _ _) (_ _ | |_( )_|_ _|_( )_| | _| (_) |_ | | (_ _) | |_____|_____|_____| This is also a 3x3 ASCII jigsaw puzzle: _____ _____ _____ | |_ _| | | _ ...
This challenge is in honor of the tacky Christmas lights at my in laws' house. The challenge is to create a graphical output showing the decoration in "real time". The video (gif or other format) will have n-by-m vertical and horizontal "lights". 5 <= m,n <= 40. The frame size and resolution may vary dependent on n a...
This is based off a previous deleted challenge of mine with the same name Introduction You are tasked with writing a program that returns a truthy or falsey value based on if the input has all its XML-like1 tags appropriately opened and closed and in the right order. Consider the following as input: <Apple> This would...
Goal: Given any natural number k such that k<256, produce an deadfish program that gives the smallest solution possible. Background: Deadfish is a joke esoteric programming language. It has a single unsigned byte of memory, called the accumulator, initialized at 0. There are four commands which form a string. i = accu...
The presents have been opened. The mince-pies have been eaten. The Star Wars have been watched. The Christmas Season is beginning to wind down. By now you may well have pulled a few Christmas Crackers. If you're lucky, instead of the usual useless plastic toys, you may have won a Mystery Calculator with which you ...
Today is Bacon Day which is probably why the name of the hat for participating today is "Mmmm Bacon". What better way to celebrate bacon day with fun filled 2d matrices made out of bacon! A 1 by 1 bacon strip is represented by this: ----- )===) (===( )===) ----- You goal here is given two coordinates in a tuple, (x,...
Yes, really. Print it with a hardware printer to create a hard copy. Send the necessary commands/data to your printer such that the following text is printed on a piece of paper: Hello, World! You may use any local- or network-connected printer that is available to you. If your printer allows, you should use 8pt or...
Mini-Flak is a subset of the Brain-Flak language, where the <>, <...> and [] operations are disallowed. Strictly speaking it must not match the following regex: .*(<|>|\[]) Mini-Flak is the smallest known Turing complete subset of Brain-Flak. A little while ago I was able to make a Quine in Mini-Flak, but it was too...
A vector partition is splitting a vector up a series of vectors such that their sum is the original. Here are a couple partitions: [3, 1, 2] = [3, 1, 2] [3, 1, 2] = [0, 0, 1] + [0, 0, 1] + [0, 1, 0] + [1, 0, 0] + [2, 0, 0] [3, 1, 2] = [1, 1, 2] + [2, 0, 0] Here vector addition is done element-wise. A valid partition d...
Introduction From Wikipedia: A tessellation of a flat surface is the tiling of a plane using one or more geometric shapes, called tiles, with no overlaps and no gaps. A fairly well known tessellation is shown below: The rhombi are tiled in a fashion that results in no overlaps or gaps, and simulates interchanging c...
Given an integer between 0 and 141 (inclusive), list all 24-hour times whose hour, minute, and second units add to that integer. Rules of addition Numbers are added by their time units, not by single digits. For example, take 17:43:59 17+43+59=119 Remember, that is an example of digits being added. In reality, you wou...
Challenge The challenge is simple: Taking no inputs and output the following message: _ __ __ | | | | | |_ |__| | | A number of times equal to the number of hours before or after midnight UTC on 31st Dec 2016. Examples For example if it is 19:01 UTC dec 31st you should output: _ __ __ |...
You probably all know the fibonacci sequence: fibonacci(n)=fibonacci(n-1)+fibonacci(n-2) fibonacci(0)=0 fibonacci(1)=1 Your task is as simple as it could be: Given integer N compute fibonacci(n) but here is the twist: Also do negative N Wait. What? fibonacci(1)=fibonacci(0)+fibonacci(-1) so fibonacci(-1)=1 and f...
For this challenge, you are to output the result of the sum of some numbers. What are these numbers? Well, you are given input, (a, b), which are integers (positive, negative, or zero) , a != b, and a < b , and each integer within a and b (including them) will have exponents according to the Fibonacci numbers. That's c...
In this challenge you'll be building a program that grows as it traverses through the ages… Until it's 2017. Challenge Whenever this challenge description says “program”, you can also read “function”. Your submission, when executed, will output a program that is THE LENGTH OF YOUR SUBMISSION + 1 bytes long. When that p...
(Note: although related, this challenge is not a duplicate of this one because it requires determining leap seconds automatically rather than hardcoding their times, and is not a duplicate of this one because most of the difficulty comes from determining the time without leap second skewing, something that most time A...
Your bird has been itching for some exercise and is sick of being stuck in static positions all the time. Write a program that will show a randomly dancing ascii bird, updating every 100ms*n or 200ms*n depending on the dance move. The bird always begins with the dance move <(")>. The program should accept one input whi...
Out of all the years I've been making this challenge, 2017 is the first year that's been a prime number. So the question will be about prime numbers and their properties. Your task is to produce a program or function that will take an arbitrarily large positive integer as input, and output or return whether or not the ...
Introduction Similar to the Fibonacci Sequence, the Padovan Sequence (OEIS A000931) is a sequence of numbers that is produced by adding previous terms in the sequence. The initial values are defined as: P(0) = P(1) = P(2) = 1 The 0th, 1st, and 2nd terms are all 1. The recurrence relation is stated below: P(n) = P(n - ...
Given a polynomial \$p(x)\$ with integral coefficients and a constant term of \$p(0) = \pm 1\$, and a non-negative integer \$N\$, return the \$N\$-th coefficient of the power series (sometimes called "Taylor series") of \$f(x) = \frac{1}{p(x)}\$ developed at \$x_0 = 0\$, i.e., the coefficient of the monomial of degree ...
Background The computer game NetHack dates from 1987, before the use of graphics in computer games was widely established. There are lots of monsters in the game, and potentially a lot need to fit on screen at once, so monsters are drawn in a very minimal way: a monster is simply drawn as an ASCII character on screen. ...
This is the ASCII version of this challenge. The initial post was separated per request by Martin Ender Introduction Similar to the Fibonacci Sequence, the Padovan Sequence (OEIS A000931) is a sequence of numbers that is produced by adding previous terms in the sequence. The initial values are defined as: P(0) = P(1) =...
Many electronic devices, specially old ones, will show a blinking 12:00 when the time has not been set. The purpose of this challenge is to recreate this. Specifically, the task is to display 12:00 and --:-- alternatively in an infinite loop. The period should be 1 second, divided evenly in two periods of 0.5 seconds. ...
I'm always forgetting Pokemon type matchups. This is a challenge to print the pokemon type chart! Attacking Type No Fi Fl Po Gr Ro Bu Gh St Fr Wa Gr El Ps Ic Dr Da Fa Normal 1.0 2.0 1.0 1.0 1.0 1.0 1.0 0...
0xUsernames There's so many people using a messaging service that they're running out of space to store all the usernames! To fix this, they are going to start storing usernames as hexadecimal, where possible. If a username consists of only the characters 0123456789ABCDEF (case insensitive), it can be converted to a ...
Challenge Given a colour raster image* with the same width and height, output the image transformed under Arnold's cat map. (*details see below) Definition Given the size of the image N we assume that the coordinates of a pixel are given as numbers between 0 and N-1. Arnold's cat map is then defined as follows: A pixe...
The Wilson score interval is a confidence interval of the probability of success, based on the proportion of successes in a set of Bernoulli trials (a Bernoulli trial is a trial in which exactly two outcomes are possible: success or failure). The interval is given by the following formula: The two values given by the ...
About a year ago on Dec 31, 2015, I had the idea that: We should make a time capsule string. Everybody gets to add one character and next new years we'll see who can make the best program out of all the characters with the esolangs that exist then. Doorknob graciously collected characters from the PPCG community and ...
This challenge is simple enough that it's basically all in the title: you're given a positive integer N and you should return the smallest positive integer which is not a divisor of N. An example: the divisors of N = 24 are 1, 2, 3, 4, 6, 8, 12, 24. The smallest positive integer which is not in that list is 5, so that'...
Introduction Consider a sequence of integers \$f\$ defined as follows: \$f(2) = 2\$ If \$n\$ is an odd prime, then \$f(n) = \frac{f(n-1) + f(n+1)}2\$ If \$n = p\cdot q\$ is composite, then \$f(n) = f(p)\cdot f(q)\$ It's not very hard to see that \$f(n) = n\$ for every \$n \ge 2\$, and thus computing \$f\$ wouldn't be...
Challenge description Dominoes is a game played with tiles with two values on it - one on the left, one on the right, for example [2|4] or [4|5]. Two tiles can be joined together if they contain a common value. The two tiles above can be joined like this: [2|4][4|5] We'll call a sequence of n joined tiles a chain of le...
Introduction The well-known "Die Hard with a Vengeance" water jugs puzzle challenges the two heroes to get 4L of water in a 5L container, provided an unlimited supply of water and another container of 3L. This problem has a solution because 4 is less or equal than the largest container and is a multiple of the gcd(5, 3...
There seems not to be a contest for this one yet. The task is simple. Add the first n numbers of the Fibonacci sequence that are even and output the result. This is given by OEIS A099919, except that sequence is shifted by one, starting with fib(1) = 0 instead of fib(1) = 1. This is code golf. Lowest byte count wins. E...
Using the 74 characters from the 2016 time capsule string H@~*^)$.`~+1A|Q)p~`\Z!IQ~e:O.~@``#|9@)Tf\eT`=(!``|`~!y!`) Q~$x.4|m4~~&!L{% write N code snippets all in the same language where: The 1st snippet outputs 1. The 2nd snippet outputs 2. The 3rd snippet outputs 3. ... etc. ... The Nth snippet outputs N (the number...
Preface The available keys are the keys of the A through G and A minor through G minor. The Challenge Create a program that creates and saves to a playable audio file a "song" of using (uniformly distributed) random chords. The song must be of length n and in key k. The chords in each "song" must conform to the key. If...
The question's pretty much described by the title: write a program or function that takes a positive integer n as input, and returns the smallest positive output which has all integers from 1 to n as factors. (Another way of looking at this is that you're looking for the least common multiple of the integers from 1 to ...
Word's A▲ and ᴀ▼ buttons change the font size according to these rules: The starting font size is 11. If ᴀ▼ is pressed when the font size is 1, the size stays 1. The font size changes with 1 point in the range 1 – 12. The font size changes with 2 points in the range 12 – 28. The choices are 28, 36, 48, 72, and 80 in t...
This challenge is about converting 2D mazes into 1D mazes. Overview +-+-+-+-+-+-+ +-+-+-+-+-+-+ graph { | | | | |A| | B| A B A -- D + + + + +-+-+ + + + + +-+-+ \ | C -- D | | | | | | | | \ | D -- E +-+-+ +-+-+ + +-+-+...
So you are given a POSITIVE base 10 (decimal) number. Your job is to reverse the binary digits and return that base 10 number. Examples: 1 => 1 (1 => 1) 2 => 1 (10 => 01) 3 => 3 (11 => 11) 4 => 1 (100 => 001) 5 => 5 (101 => 101) 6 => 3 (110 => 011) 7 => 7 (111 => 111) 8 => 1 (1000 => 0001) 9 => 9 (1001 => 1001) 10 => ...
Given a 2D string as input, either as a string with newlines or a list of lines, output the coordinates (x, y) of all the hashes (#) in the list. The input will only contain hashes and spaces. (and newlines, if you choose to take input as a 2D string) If there are no hashes, you can output anything. Output should be...
The task at hand is, given a number n, find the smallest prime that starts with AT LEAST n of the number 2 at the beginning of the number. This is a sequence I found on OEIS (A068103). The first 17 numbers in the sequence are given below, if you want more I'll have to actually go implement the sequence, which I don'...
Related: Music: what's in this chord?, Notes to Tablature, Generating guitar tabs?, Translate number pairs to guitar notes Given a guitar fingering, output the chord it represents. You can use standard input and output, or write a function that returns a string. The input fingerings will be classifiable as one of the f...
(Inspired by this comment on an old question.) Background An error quine (also known as a "Kimian quine") is a program which, when compiled or run, causes the compiler/interpreter/runtime to print an error message that has identical text to the program itself, and nothing else. For the purposes of this challenge, we're...
Challenge Print the following characters: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 The catch is that you may not use any one of them in your code. You may print them in arbitrary order, with or without a leading or trailing newline, but you may not print any other characters. Rules You may not ...
Given 2 integer inputs representing the size of the field, x and y, output a path through the field. Example output for 5, 4: # # # ### ### # The whole field is 5 by 4, and there is a path made of hashmarks crossing the field. The path should always start in the top left corner, and go to the bottom right. T...
While similar to the other water-carrying puzzle, the unique aspects of this challenge make it entirely different. Beth is located at an oasis in the middle of a desert. There is plenty of water in the lake, but unfortunately there are only X buckets, each of which has a capacity of Y liters of water. Beth can carry 2...
Today's challenge is to draw a binary tree as beautiful ascii-art like this example: /\ / \ / \ / \ / \ / \ ...
Below is a (schematic) Digital timing diagram, for the XNOR logic gate. ┌─┐ ┌─┐ ┌─────┐ ┌─┐ ┌─┐ ┌───┐ A ──┘ └─┘ └─┘ └─┘ └─┘ └─┘ └── ┌───┐ ┌───┐ ┌─┐ ┌─────┐ ┌─┐ ┌─┐ B ┘ └─┘ └─┘ └─┘ └───┘ └─┘ └ ┌─────┐ ┌─┐ ┌─┐ ┌───┐ X ──┘ └───┘ └───┘ └───┘ └──── Your goal is to reproduce ...
Amazingly, this simple task doesn't seem to exist already, so... Your task is to write a program that takes as input a 12 hour time, and converts it into "military time", or 24-hour time format. Input will be in the form: HH:MM am/pm Although slight variations are allowed: The space separating the am/pm from the res...
Challenge: Create a program that accepts a positive integer and checks if it can be written in the form of (3^x)-1, where X is another positive integer. If it can, output X If it can't, output -1 or a falsy statement. Example inputs/outputs Input: 2 It can be written as (3^1) - 1, so we output x which is 1 Output: 1 ...
Help! Here is my good friend Mr. Snowman: \(.,.) < Hello! ( : )> He is an amazing dancer, but he tends to get stage fright. He knows all the moves, but just needs someone to tell him which moves to do. Here are all of his moves: Arms Up \(.,.)/ ( : ) Arms Down (.,.) <( : )> Right Arm Up \(.,.) ( : )> Left Arm Up ...
To find the digital hardness of an integer, take its binary representation, and count the number of times both a leading and trailing 1 can be removed until it either start or ends with a 0. The total number of bits removed is its digital hardness. That's quite a wordy explanation - so let's break it down with a wor...
Introduction: Combinatory Logic Combinatory logic (CL) is based off of things called combinators, which are basically functions. There are two basic "built-in" combinators, S and K, which will be explained later. Left-associativity CL is left-associative, which means brackets (containing stuff) which are at the far-lef...
Challenge: In the programming language of your choice, accept an integer as input in base 10, and output it in the negadecimal notation, which is also known as base -10 Example algorithm: This is an algorithm taken from Wikipedia to convert base 10 to any negative base in VB.NET: Function toNegativeBase(Number As Inte...
Frequently while I'm code-golfing, I'll want to know what the ASCII value of a certain character is. One of my favorite resources for quickly looking up all of the printable ASCII characters is ASCIItable.com. This has a really nice image that not only shows the printable ASCII characters and their values, but also the...
Introduction You are a supervisor of a parking lot and your manager is preparing for shrinking the size to the extreme. It is a simplified and adapted version of a problem in last year's PAT top-level. Challenge You are asked to calculate how many cars are in the lot at the same time, at most. Standard rules apply. And...
Shuffling a deck of cards is hard for kids, so they must figure out ways to get a reasonable well shuffled deck as simply as possible. One way to do this that gives reasonably good results is: Take the top card out and insert it a random place in the deck Take the bottom card out and insert it in a random place in the...
Inspired by this video of Infinite Series. Introduction Pi is defined as the ratio of the circumference to the diameter of a circle. But how is a circle defined? Usually a circle is defined as the points with constant distance to the centerpoint (let us assume that the center is at (0,0)). The next question would be: H...
A Window is an ASCII-art square with odd side length of at least 3, with a single character border around the edge as well as vertical and horizontal strokes in the middle: ####### # # # # # # ####### # # # # # # ####### An MS Window is a window where the border is made only of the characters M and S. Your tas...
Your challenge: Connect to the Online Encyclopedia of Integer Sequences OEIS.org, access any random valid sequence, output it's ID, and ouput all of the members of the sequence provided by the OEIS entry. The only website you're allowed to connect to is OEIS.org. Hints: Sequences are found in URLs such as http://oeis.o...
Challenge Create a program that returns a truthy value when run on Microsoft Windows (for simplicity we'll stick with Windows 7, 8.1 and 10) and a falsey value when run on any other operating system (OSX, FreeBSD, Linux). Rules Code that fails to run/compile on a platform doesn't count as a falsey value. Winning crit...
In this challenge, you need to solve 4 different tasks using the same set of characters. You can rearrange the characters, but you can't add or remove characters. The winner will be the submission that solves all tasks using the smallest number of characters. All tasks must be solved in the same language. Note that i...
Challenge Given a nonempty list of real numbers, compute its median. Definitions The median is computed as follows: First sort the list, if the number of entries is odd, the median is the value in the center of the sorted list, otherwise the median is the arithmetic mean of the two values closest to the center of the ...
When you resize an image down to a very small size, it looks very blocky when you scale the pixels back up individually. In extreme cases, as above, you can no longer reconstruct the original image, as too much information has been lost. Your task is to build a program that will imagine what the original, unscaled im...
Input: Two decimal integers. These can be given to the code in standard input, as arguments to the program or function, or as a list. Output: Their product, as a decimal integer. For example, the input 5 16 would lead to the output 80. Restrictions: No standard loopholes please. This is code-golf, answer in lowest amou...
Challenge Origami (folding paper) is a creative form of art. As far as I know, master of Origami prefers square paper. Let's start from beginning - convert a rectangular paper to a square one. So the paper is divided into squares. We remove the biggest square which shares one shorter edge with the current shape, step b...
This challenge is a little tricky, but rather simple, given a string s: meta.codegolf.stackexchange.com Use the position of the character in the string as an x coordinate and the ascii value as a y coordinate. For the above string, the resultant set of coordinates would be: 0, 109 1, 101 2, 116 3, 97 4, 46 5, 99 6, 11...
Overview Consider the following task: Given a positive integer n > 0, output its integer square root. The integer square root of a number n is the largest value of x where x2 ≤ n, usually expressed with the formula floor(sqrt(n)). Examples: 25 -> 5, 24 -> 4, 40 -> 6, 1 -> 1. This task is easy enough on its own. Howev...
Ice mazes have been one of my favorite staples of Pokémon games since their debut in Pokémon Gold and Silver. Your task will be to make a program that solves these types of problems. Ice mazes primarily consist of, as the name suggests, ice. Once the player moves in a direction on ice they will continue to move in th...
Introduction Consider a nonempty list L of integers. A zero-sum slice of L is a contiguous subsequence of L whose sum equals 0. For example, [1, -3, 2] is a zero-sum slice of [-2, 4, 1, -3, 2, 2, -1, -1], but [2, 2] is not (because it doesn't sum to 0), and neither is [4, -3, -1] (because it's not contiguous). A collec...
Goal: Given any non-zero natural number a, find the smallest non-zero natural number b such that a•b is palindromic, e.g. it reads the same forwards and backwards. Input a through any reasonable means (STDIN, function argument, etc.), And output b through any reasonable means (STDOUT, function return value.) Notes: In...
Edit: I will be posting a newer version of this question on meta-golf soon. Stay tooned! Edit #2: I will no longer be updating the challenge, but will leave it open. The meta-golf version is available here: https://codegolf.stackexchange.com/questions/106509/obfuscated-number-golf Background: Most numbers can be writte...
Given a list of 1s and -1s, determine whether or not it is a valid OVSF code (by outputting a truthy or falsey value). OVSF codes are defined as follows: [1] is an OVSF code. If X is an OVSF code, then X ++ X and X ++ -X are both OVSF codes. Here ++ is list concatenation, and - negates every element in the list. No ...
If you sort a string you'll typically get something like: ':Iaaceeefggghiiiiklllllmnnooooprrssstttttuuyyyy Yes, that was the first sentence sorted. As you can see, there are a lot of repeated characters, aa, eee, ttttt, 9 spaces and so on. If we add 128 to the ASCII-value of the first duplicate, 256 to the se...
Challenge You have been assigned a task to write a program which takes a multigraph as its input and if it contains an Eularian circuit to return one. Otherwise, the program's behavior is undefined, according to the specifications you're handed by your boss. However, you recently caught your new coworker Steven several...
You're a professional hacker and your boss has just ordered you to help a candidate win an upcoming election. Your task is to alter the voting machines data to boost the candidate's results. Voting machines store voting results as two integers : the number of votes for your candidate (v1) and the number of votes for th...
Balanced bases: Balanced bases are essentially the same as normal bases, except that digits can be positive or negative, while in normal bases digits can only be positive. From here on, balanced bases of base b may be represented as balb - so balanced base 4 = bal4. In this challenge's definition, the range of digits i...
Given two string inputs of "Rock", "Paper", or "Scissors", determine the outcome of the RPS round. Output 1 if the first player wins, -1 if the second player wins, or 0 for a tie. Rock Rock -> 0 Rock Paper -> -1 Rock Scissors -> 1 Paper Rock -> 1 Paper Paper -> 0 Paper Scissors -> -1 Scissors Rock -> -1 Scissors Paper ...
This is a tips question for golfing in Python. In Python golfing, it's common for a submission to be a function defined as a lambda. For example, f=lambda x:0**x or x*f(x-1) computes the factorial of x. The lambda format has two big advantages: The boilerplate of f=lambda x:... or lambda x:... is shorter than the de...
Basically, between every character of a uni-line string, add a space, but there can't be two spaces in between one character. aesthetic becomes a e s t h e t i c. The quick brown fox jumps over the lazy dog becomes T h e q u i c k b r o w n f o x j u m p s o v e r t h e l a z y d o g. I'm Nobody! Who are you? becomes ...
Your task is to write a program that will output a readable list of every five letter words with the structure: consonant - vowel - consonant - vowel - consonant The output should be sorted alphabetically with one word per line and no words repeated twice. It can be lowercase or uppercase but not mixed. So the list cou...
There are lots of different ways to explain matrix multiplication. I'll stick with a single figure since I believe most people here are familiar with it (and the figure is very descriptive). If you want more detailed information, I suggest you visit the Wikipedia-article, or the explanation on WolframMathWorld. Simple ...
Note, challenge copied from question asked at math.stackexchange. Recently, I attained quite some skill at blowing bubbles. At first I would blow bubbles like this: But then things started getting strange: After a while, I was blowing some pretty weird bubbles: After blowing hundreds, maybe even thousands of such bu...
This was inspired by part of the 2016 ARML competition Team Problem #6. Here's the challenge: You're given a "wildcard sequence", which is a sequence of digits and another character. A string matches this wildcard sequence by the following pseudocode: w = wildcard s = string # s matches w iff for all 0 >= i > wildcard....
Lets create a system of numbers where the biggest digit in the nth place value (counting from right to left) of a number length m is always equal to m - n + 1. To give an example the largest 5 digit number expressible in this system is written 12345. Apart from the number of digits available to be used in a particular ...
Given an integer n > 0, output the length of the longest contiguous sequence of 0 or 1 in its binary representation. Examples 6 is written 110 in binary; the longest sequence is 11, so we should return 2 16 → 10000 → 4 893 → 1101111101 → 5 1337371 → 101000110100000011011 → 6 1 → 1 → 1 9965546 → 100110000000111111101...
It's lunch time, I am hungry and I came to your Sushi Bar. You are the Sushi Chef and you have to produce a full program or function to make me some sushi! Credits: Wikipedia Disclaimer: The image is for illustration purposes only and do not necessarily represent the exact product. Although you have limited ingredien...
Write a program which, according to whether the script has access to the internet, produces an output which is "Truthy/Falsey". You may try and connect to any existing site, at your own discretion (don't use a shady site which only has 10% uptime - try to keep to above 80% annual uptime). If the site is down, your prog...
Paul is one of your Belgian acquaintances, and he would like you to create a program that outputs at least one of the following five strings: 12496=>14288=>15472=>14536=>14264 14264=>12496=>14288=>15472=>14536 14536=>14264=>12496=>14288=>15472 15472=>14536=>14264=>12496=>14288 14288=>15472=>14536=>14264=>12496 It ...
As we all know, modern operating systems have thread schedulers that can pick different orders to schedule your threads based on internal logic which your code is not privy to. Normally you architect your multithreaded code to ensure that this nondeterminism imposed on you does not meaningfully affect your output. The ...
Intro There are 3 nails in the wall. You've got a piece of string that is fixed to the picture frame with both ends. To hang the picture, you entangled the string with the nails. But before letting the picture go: Can you predict whether the image is going to fall, just by looking at how the string is wrapped around th...
Your challenge is to exactly output the following box: .................................................. .................................................. .. .. .. .. .. ++++++++++++++++++++++++++++++++++++++++++ .. .. ++++++...
About a year ago you were asked to find the XOR primes. These are numbers whose only factors are 1 and themselves when performing XOR multiplication in base 2. Now were are going to spice things up a bit. We are going to find the XOR primes in base -2 Converting to Base -2 Base -2 is a lot like every other base. The...
This impossible object is Reutersvärd's triangle: Draw your own version according to these rules: Exactly 9 cubes total Each side is made up of exactly 4 cubes The cubes appear to overlap such that the rendered object is in fact an impossible object 4 distinct colours are used - one for the background and 3 for each ...
Challenge Given a size s, print a cube net of that size made of hash symbols (#) and spaces (). Examples: 1: # # # # # # 2: # # # # # # # # # # # # # # # # # # # # # # # # 3: # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #...