instruction
stringlengths
34
53.1k
A deck of cards is the Cartesian product of S suits and R ranks. Many, though not all, card games use S=4 and R∊{6,8,13}. A hand of H cards is dealt from the deck. Its distribution, a.k.a. "hand pattern", is an array that describes how many cards you got from each suit, ignoring suit order (so, it's like a multi-set). ...
An ordinary N-digit combination lock consists of N rotating discs. Each disc has digits 0-9 inscribed in order, and you need to turn them to the correct password to open it. Obviously, if you don't know the password, you will need to try at most 10N times before unlocking it. That's not interesting. So let's consider ...
Introduction Kerning means adjusting the spacing between the letters of a text. As an example, consider the word Top written with the following three glyphs: ##### ..... ..... ..#.. ..... ..... ..#.. ..##. .###. ..#.. .#..# .#..# ..#.. .#..# .#..# ..#.. ..##. .###. ..... ..... .#... ..... ..... .#... We could just fil...
Task Given a string of English names of digits “collapsed” together, like this: zeronineoneoneeighttwoseventhreesixfourtwofive Split the string back into digits: zero nine one one eight two seven three six four two five Rules The input is always a string. It always consists of one or more lowercase English digit nam...
I honestly don't know what the point of this sort of calculation would be, but it should make fun golfing. Shortest code wins. Input (in no particular order) An array of integers, a (All elements will be integers less than the length of the array.) An index therein, i An iteration count, n Processing Store a number ...
Introduction Street talk can be really difficult to understand, in particular to programmers, who aren't known to be very streetwise. It is your job to create an interpreter to help us all survive in the urban environment. Challenge Given an English sentence as input, create a program or a function that determines whet...
As an exercise, I've created a simple solution for this challenge, in x86 Assembly Language. I'm running this with FASM on Windows. Here's my source code: format PE console entry start include 'WIN32A.inc' section '.text' code executable start: push char ; Start at 'A' call [printf] ; ...
Historical Background The shield wall is a tactical war formation that dates back to at least 2500 BC. It consisted of warriors overlapping their shields with those of their companions to form a 'wall'. The appeal of the tactic comes from the fact that even the most unskilled warrior could fight in a wall as long as th...
I got inspired by this: Print every character your program doesn't have But with the exception that the letters have to be between ASCII 32 to 126. We started fooling around with it at the office with PHP and this is the best we could come up with: <? while($i++<95)if(!strstr(file(__FILE__)[0],$a=chr($i+31)))echo$a; Is...
A triangular number is a number that can be expressed as the sum of consecutive positive integers, starting at 1. They can also be expressed with the formula n(n + 1) / 2, where n is some positive integer. A number's digitangular counterpart is calculated in the following way: Split a number into an array of its digit...
Given a finite arithmetic sequence of positive integers with some terms removed from the middle, reconstruct the whole sequence. The task Consider an arithmetic sequence: a list of positive integers in which the difference between any two successive elements is the same. 2 5 8 11 14 17 Now suppose one or more integers...
Tomorrow, November 23rd, is Thanksgiving Day in the United States. To prepare, you need to cook up some ASCII turkeys. However, since you're late in planning, you need a program (or function) to help you with how many birds you need to prepare. .---. _ .' './ ) / _ _/ /\ =(_____) (__/_/== ======...
Your challenge is to compute the Lambert W function. \$W(x)\$ is defined to be the real value(s) \$y\$ such that $$y = W(x) \text{ if } x = ye^y$$ where \$e = 2.718281828...\$ is Euler's number. Sometimes, \$y\$ may not be real. Examples W(-1) = non-real W(-0.1) = -0.11183, -3.57715 W(1) = 0.56714 W(2) = 0.85261 Here'...
Definition If you take the sequence of positive integer squares, and concatenate them into a string of digits (i.e. 149162536496481100...), an "early bird" square is one that can be found in this string ahead of its natural position. For example, 72 (the number 49), can be found at an offset of 2 in the string, althoug...
Some of you may be familiar with the BigNum Bakeoff, which ended up quite interestingly. The goal can more or less be summarized as writing a C program who's output would be the largest, under some constraints and theoretical conditions e.g. a computer that could run the program. In the same spirit, I'm posing a simila...
A Sumac sequence starts with two integers: t1 and t2. The next term, t3, = t1 - t2 More generally, tn = tn-2 - tn-1 The sequence ends when tn < 0. Your challenge: Write a program or function that prints the length of a Sumac sequence, starting with t1 and t2. t1 and t2 are integers within your language's range. Standa...
My kids have an alphabet mat to play with, something like this: After months with the tiles of the mat randomly placed, I got tired and placed all the tiles of the mat grouped by sections according to their background colors. So, if the letters represent the background color, I got a mat like this: AABBCDDDE ABBCCCDEE...
We have a square 10x10 meter garden outside our house. We want to plant grass and make a terrace. We have decided how to divide the garden, but we haven't decided the ratio between amount of grass vs terrace. We need help visualizing it, and ASCII-art is clearly the best way to do so. Challenge: Take an integer in the...
Your pyramid The pyramid I want you to build is made entirely of cubes. It has 24 layers, and the Nth layer from the top contains N2 cubes arranged in an N by N square. The pyramid looks like this: To build the pyramid, you will need a supply of cubes. You are given 4900 cubes arranged in a 70 by 70 square that looks ...
One of my favorite definitions of the prime numbers goes as follows: 2 is the smallest prime. Numbers larger than 2 are prime if they are not divisible by a smaller prime. However this definition seems arbitrary, why 2? Why not some other number? Well lets try some other numbers will define n-prime such that n is t...
The Challenge There are N cities aligned in a straight line. The i-th city is located A[i] kilometers to the right of the origin. No two cities will be in the same place. You are going to build an electrical grid with some power plants. Power plants must be built inside a city. However, you are only allowed to build K ...
Introduction You have gotten a job as the minister of finance in your made-up country in your back yard. You have decided to make your own bank in your country for you and your less trustworthy friends. Since you don't trust your friends, you have decided to write a program to validate all transactions to stop your fri...
Given one line that consists of only letters, process as following: You maintain a string that's empty at the beginning. If the next input character is in the string, remove it from the string. If the next input character isn't in the string, append it to the string. Output the final state of the string. You can saf...
As most of you probably know, (byte-addressable) hardware memories can be divided into two categories - little-endian and big-endian. In little-endian memories the bytes are numbered starting with 0 at the little (least significant) end and in big-endian ones the other way round. Fun fact: These terms are based on Jon...
⢣⠃⢎⠆⣇⡇⡯⡂⠈⡏⢰⢵⢐⡭⢸⠪⡀⢸⢐⡭⠀⢹⠁⢎⠆⢸⣱⢸⡃⢎⠰⡱⢸⣱⢸⡃⠈⡏⢸⡃⡱⡁⢹⠁⢸⡀⡇⡗⢅⢸⡃⠈⡏⢸⢼⢸⢐⡭⠀ ⣇⢸⡃⢹⠁⢹⠁⣟⢸⢕⢐⡭⠀⡮⡆⡯⡂⣟⠀⡯⠰⡱⢸⣸⢸⢕⠀⣏⡆⢎⠆⢹⠁⣪⠅⢸⢼⢸⠰⣩⢸⢼⠀⡮⡆⡗⢼⢸⣱⠀⢎⠆⡯⠀⢇⠇⡮⡆⡯⡂⡇⡮⡆⣟⡆⣇⢸⡃⠸⡰⡸⢸⢸⣱⠈⡏⢸⢼⠀ ⢎⠆⡗⢼⢸⡃⢸⡃⡗⠔⡇⡯⠂⢹⠁⢣⠃⠸⡸⢸⡃⡯⡂⢹⠁⡇⢎⢰⢵⢸⡀⢸⡀⡇⡗⢼⢸⡃⢐⡭⢸⡃⡯⠂⡮⡆⡯⡂⡮⡆⢹⠁⣟⢐⡭⠀⢎⢸⢼⢰⢵⢸⢕⢰⢵⠰⡁⢹⠁⣟⢸⢕⢐⡭⠀ ⡮⡆⢐⡭⢸⠕⢰⢵⠰⡁⣟⠀⡇⣪⠅⢈⣝⢸⡃⡯⡂⢎⠆⠸⡰⡸⢸⢸⣱⠈⡏⢸⢼⠀ ⣪⠅⢎⠆⢸⠈⡏⠀⣇⠰⡱⠰⡱⢸⠪⡀⣪⠅⢸⡀⡇⡗⢅⢸⡃⠸⡰⡸⠰⡱⢸⢕⢸⣱⢐⡭⠀⡮⡆⡯⡂⣟⠀⣪⠅⣟⢸⠕⢰⢵⢸⢕⢰⢵⠈⡏⢸⡃⣏⡆⢸⣳⠘⡜⠀...
A standard ruler of length n has distance marks at positions 0, 1, ..., n (in whichever units). A sparse ruler has a subset of those marks. A ruler can measure the distance k if it has marks at positions p and q with p−q=k. The challenge Given a positive integer n, output the minimum number of marks required in a spars...
To normalize a vector is to scale it to a length of 1 (a unit vector), whilst keeping the direction consistent. For example, if we wanted to normalize a vector with 3 components, u, we would first find its length: |u| = sqrt(ux2 + uy2 + uz2) ...and then scale each component by this value to get a length 1 vector. û ...
The gravitational binding energy of a planet is the amount of energy required to separate every tiny piece of it so that no piece will orbit or collide with another piece. For a uniform sphere, Wikipedia gives this formula: $$E = \frac{3GM^2}{5R}$$ Where G is the gravitational constant (6.672e-11 m3•kg-1•s-2), M is mas...
Given a square matrix, output the matrix's eigenvalues. Each eigenvalue should be repeated a number of times equal to its algebraic multiplicity. The eigenvalues of a matrix A are scalar values λ such that, for some column vector v, A*v = λ*v. They are also the solutions to the characteristic polynomial of A: det(A - λ...
There are several questions regarding this game, even a king-of-the-hill contest here. But I think all those challenges and contests need a way to automatically determine the winner of a game. So: Challenge Given two inputs in the range ["rock", "paper", "scissors", "lizard", "spock"] representing the selections for pl...
It's all in the title... Take as input a positive integer n>=12 and... do what the title says. Yes, this is on OEIS A187924. Some test cases 12 -> 912 13 -> 11713 14 -> 6314 15 -> 915 16 -> 3616 17 -> 15317 18 -> 918 19 -> 17119 20 -> 9920 40 -> 1999840 100-> 99999999999100 This is code-golf. Short...
Forget BIDMAS! Write a program that takes an equation and an operator precedence order, and prints the result. Example input format: 1.2+3.4*5.6/7.8-9.0 */+- Rules & guidelines: The only operators that are defined are addition (+), subtraction (-), multiplication (*), and division (/). No parentheses, no exponentiati...
The famous constructed language Esperanto uses the Latin alphabet (mostly, see the linked wikipedia page for details). However, there are some characters with accents: ĉ, ĝ, ĥ, ĵ, ŝ, and ŭ. (C-circumflex, g-circumflex, h-circumflex, j-circumflex, s-circumflex, and u-breve.) Naturally, these characters are very hard to ...
Objective Write a program or function (or equivalent) that sorts out and returns the odd letter in the matrix of random size. Details You will be passed a matrix (as a string) as input of random dimensions such as this. bbbbbbbbbb bbbbbdbbbb bbbbbbbbbb bbbbbbbbbb bbbbbbbbbb Your job is to find the letter that doesn't...
Let's define fn(k) as the sum of the first k terms of the natural numbers [1, ∞) where each number is repeated n times. k | 0 1 2 3 4 5 6 7 8 9 --------+------------------------------------------------- f_1(k) | 0 1 3 6 10 15 21 28 36 45 deltas | +1 +2 +3 ...
Another sequence, another challenge.* Definition A prime p is in this sequence, let's call it A, iff for every digit d in p's decimal expansion, you replace d with d copies of d and the resulting integer is still prime; zeros are not permitted. For example, 11 is trivially in this sequence (it's the first number, incid...
Introduction As you all know, German has umlauts. They're these things: ¨ However, most keyboards don't have an umlaut key. That's fine, though, because you can write ö, ä, and ü as oe, ae, and ue. Challenge Your job is to to replace ö, ä, and ü with oe, ae, and ue (and likewise for their capital versions). You have t...
This is a QWERTY keyboard. Q W E R T Y U I O P A S D F G H J K L Z X C V B N M We can "spiral out" on this keyboard, starting from G. The spiral will start at G, go to H, then to Y, then to T, then F, then V, then B, then N, then J, then U, then R, then D, then C,... etc. Your challenge is to, given a number 1 ≤ N ...
The Challenge Given a string indicating the symbolic notation of UNIX permission of a file and its ownership (user ID and group ID), decide whether a given user A has permission to read / write / execute it. Related. Permissions in UNIX system In UNIX, every file has three classes of permissions (user, group and others...
Description While support is getting better and better for people to write in various scripts around the world using unicode, and now you can even write in emojis as well, unfortunately most fonts[citation needed] are still missing Latin characters based on the double acute accent, which is required to write properly i...
The Task Your task is to create a program or a function that, given an input, outputs the input text with random letters capitalized, while keeping already capitalized letters capitalized. Every combination of capitalizations of the lowercase letters should be possible. For example, if the input was abc, there should b...
Background The United States has a unique love of gerrymandering––the deliberate manipulation of an electoral district to predict certain voting results. Just recently there was a gerrymandering case brought before the Supreme Court. Gerrymandering, especially when related to race, is ruled illegal and results in the r...
Introduction Mathematicians often work with number sets. These are groups of numbers that share common properties. These are number sets are, in order from most specific to most broad: Natural numbers (symbol N): These are the counting numbers: 1, 2, 3, ... Integers (symbol Z): These are all the numbers with...
It's that time of year when many of us get our advent calendars! If you are unfamiliar with an advent calendar, these are special calendars used to count down advent in anticipation of Christmas. In my experience the doors are placed randomly, and part of the fun as a child was working out where tomorrow's door was! O...
The solar year is 365 days, 5 hours, 48 minutes, 45 seconds, and 138 milliseconds, according to this video. With the current Gregorian calendar, the rules for leap years are as follows: if year is divisible by 400, LEAP YEAR else if year is divisible by 100, COMMON YEAR else if year is divisible by 4, LEAP YEAR ...
You left your computer for too long, and it went to sleep. Wake it up again by printing the following coffee maker. ________._________ | | \ - / | || | \ - / | || |___\___/ | || | X | | ___ | | / - \ |______| / - \ | ____ | /_______\ ||7:30||__________ ||____| | |______...
Look at the following string. Notice a pattern? ABEFNOPEFGH DC G Q I M H R J LKJI S K D T L C U M BAZYXWV N E O D P C Q BAZYXWVUTSR As some might have noticed, it's basically a spiral of the alphabet, where the distances between rows / columns are gradually increasing b...
The challenge Given two integers as input (x and y), output x as a string with as many leading zeroes necessary for it to be y characters long without the sign. Rules If x has more than y digits, output x as string without modification. Output as integer is not accepted, even if there are no leading zeroes. When x is ...
Next >> Descriptive Keywords (for searching): Make Two Matrices Equivalent, Overlap, Array, Find Challenge Santa has had a history of elves stealing presents from his vault in the past, so this year he designed a lock that is very hard to crack, and it seems to have kept the elves out this year. Unfortunately, he has l...
4-state barcodes Many postal services (Royal Mail UK, Canada Post, US Mail, etc) use a 4-state barcode to encode information about their mail. Rendered in ASCII, it may look something like this: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A 4-state barcode is a row ...
You probably know the rhetorical question of whether a glass is half full or half empty. I'm getting a little tired of the phrase, so I decided that it's time to eliminate this confusion about glass fullness or emptiness programmatically. Your task is to write a program that takes an ASCII art representation of an ugly...
Given you have an infinite sequence of numbers defined as follows: 1: 1 = 1 2: 1 + 2 = 3 3: 1 + 3 = 4 4: 1 + 2 + 4 = 7 5: 1 + 5 = 6 6: 1 + 2 + 3 + 6 = 12 7: 1 + 7 = 8 ... The sequence is the sum of the divisors of n, including 1 and n. Given a positive integer x as input, calculate the lowest number n which will produ...
Inspired by this comment. Input The number of seconds on the timer. Output Here's our basic microwave: _____________________________________________________________ | | ___________ | | | | [display] | | | ____________________...
I'm (still) trying to make another submission to the Largest Number Printable question, and I've got the following bit of code: f=->a{b,c,d=a;b ?a==b ?~-a:a==a-[c-c]?[[b,c,f[d]],~-c,b]:b:$n} h=[],$n=?~.ord,[] h=f[h]until h==p($n+=$n)-$n Ungolfed: f=->{b,c,d=a if b if a==b # a is not an array return a-1 elsif a...
<< Prev Next >> Challenge Now that Santa has finally figured out how to get into his present vault, he realises that somehow the elves got in there before him and stole some of his presents! They haven't figured out how to leave the vault yet though, so Santa has to try and catch them all. Santa and the elves both have...
Given a natural number n write a program or function to get a list of all the possible two factors multiplications that can be used to achieve n. To understand better what is pretended you can go to http://factornumber.com/?page=16777216 to see when n is 16777216 we get the following list: 2 × 8388608 4 × 41943...
Introduction Suppose I have a list of integers, say L = [-1,2,2,1,2,7,1,4]. I like having balance in my life, so I'm happy to see it has as many odd elements as even elements. What's more, it also has an equal number of elements in all modulo classes of 3 that it has elements in: [-1,2,2,1,2,7,1,4] 0 mod 3: 1 ...
Oh no! I have a theory test soon and I don't remember the scales yet! Help me remember my major scales by printing the following: 7♯ - C♯ D♯ E♯ F♯ G♯ A♯ B♯ C♯ 6♯ - F♯ G♯ A♯ B C♯ D♯ E♯ F♯ 5♯ - B C♯ D♯ E F♯ G♯ A♯ B 4♯ - E F♯ G♯ A B C♯ D♯ E 3♯ - A B C♯ D E F♯ G♯ A 2♯ - D E F♯ G A B C♯ D 1♯ - G A B C D ...
<< Prev Next >> Unfortunately, Santa was not able to catch the elves in time! He has to go back to manufacturing presents now. Since the elves are definitely not Santa's slaves, he has to figure out the expenses for how much to pay them. Challenge Given some information for the presents, determine the cost of manufactu...
Introduction As is known, in 2017, Finland celebrates its 100 years of independence. To mark the occasion, it is your job to produce a Finnish flag for everyone's enjoyment. Challenge Create a program or a function that produces the flag of Finland (the grey border is there for presentation purposes only): Flag specif...
<< Prev Next >> Santa was able to remanufacture all of the presents that the elves stole overnight! Now he has to send them to the assembly line for packaging. He usually has a camera to supervise the assembly line both to make sure the elves are doing a good job and because assembly line pictures look nice on advertis...
Related: Iterated phi(n) function. Your challenge is to compute the iterated phi function: f(n) = number of iterations of φ for n to reach 1. Where φ is Euler's totient function. Related OEIS. Here's the graph of it: Rules: Your goal is to output f(n) from n=2 to n=100. This is code-golf, so shortest code wins. Here...
A traditional Western die is a cube, on which the integers 1 to 6 are marked on the faces. Pairs that add to 7 are placed on opposite faces. As it is cube, we can only see between 1 and 3 faces (inclusive)1 at any given time. Opposite faces can never be seen at the same time. Your task is to write a program or function...
Today's Google doodle is about Celebrating 50 years of Kids Coding: The goal is program the path of a little bunny so that it can eat all the carrots. There are 4 types of blocks (see pictures below): From left to right: O("...", k) = orange piece: these are for loops which executes k times the program "...". G = g...
Suppose you have a set of sets of integers. It's possible that some of the sets will overlap (i.e. sharing elements). You could get rid of the overlaps by deleting elements from the sets, but then some of them might end up empty; that would be a shame. Can we make all the sets disjoint without emptying any of them? Not...
Programs often list outcome statistics, such as this: 54% of participants received an award 69% of participants got a promotion 85% of participants increased their salary These percentages are the result of dividing a/x, where both a and x are whole numbers, and the result is rounded to the nearest hundredth. Your ta...
<< Prev Next >> Thanks to the PPCG community, Santa has managed to remanufacture all of his presents and after the assembly line, the presents are now ready to be moved into the transport docks! Each of Santa's transport docks only holds a range of present sizes because the transport sleighs are specialized for a speci...
Background: I originally posted this question last night, and received backlash on its vagueness. I have since consulted many personnel concerning not only the wording of the problem, but also its complexity (which is not O(1)). This programming problem is an evil spin on an Amazon interview question. Question: Given a...
Problem Consider a square 3 by 3 grid of non-negative integers. For each row i the sum of the integers is set to be r_i. Similarly for each column j the sum of integers in that column is set to be c_j. The task is to write code to enumerate all possible different assignments of integers to the grid given the row a...
The Challenge I am thirsty and need a drink, but I don't know what to order. Your task is to provide me with either a drink or options for one. I/O Input will be either a base or a drink name. If given a base, your program should output one random drink from a list of drinks with that base. If given a drink name, your ...
<< Prev Next >> Thanks to the PPCG community, Santa managed to sort his presents into the correct order for moving into the transportation dock. Unfortunately, the transportation dock signs are broken so he doesn't know where to put all the presents! The presents are all grouped together and not by their ranges, which ...
If you're sad, that's wrong. We need to scrub out ALL sadness. This is a sad face, for reference: ...... .S..S. ........ ...SS... ..SS..SS.. .S......S. ........ Where S is a consistent pixel, . is any pixel other than S, and is any pixel. Note that the sad face is not a perfect square, only the . shoul...
A half-exponential function is one which when composed with itself gives an exponential function. For instance, if f(f(x)) = 2^x, then f would be a half-exponential function. In this challenge, you will compute a specific half-exponential function. Specifically, you will compute the function from the non-negative integ...
Today's date is quite an interesting one. Let's take a look at why. The date 07/12/2017 (in DD/MM/YYYY date format) can be split into the year (2017) and the rest (07/12). You may notice that the digits in the year can be rearranged to match the digits in the rest of the date, which is the basis of this challenge. The ...
Problem Draw a hexagon chain x long, each with side of y length Input x - the length of the chain <= 50 y - the length of each side <= 50 Examples x=1,y=1 _ / \ \_/ x=4,y=1 _ _ / \_/ \_ \_/ \_/ \ \_/ \_/ x=3,y=2 __ __ / \ / \ / \__/ \ \ / \ / \__/ \__/ \ / \__/ Rules ...
Related but very different. A boustrophedon is a text where every other line of writing is flipped or reversed, with reversed letters. In this challenge, we will just reverse every other line, but leave the actual characters used intact. You may chose which lines to reverse, as long as it is every other one. You may ta...
I once saw on the xkcd fora a format for expressing numbers in an odd way. In this "factor tree" format: The empty string is 1. Concatenation represents multiplication. A number n enclosed in parentheses (or any paired characters) represents the nth prime number, with 2 being the first prime number. Note that this ...
<< Prev Next >> After some careful analysis, Santa was able to determine the dock size ranges and get the presents into the correct transportation dock. Now, he needs you to help him balance out the transportation carts and place the presents in them in the most balanced fashion. Challenge You will be given the size of...
Background I am currently in an AP Comp Sci A: Java class, and I want to start some of my friends on code golfing. I have a challenge from the course, and I would like to see how many bytes the community can do this challenge in. Challenge details: Given two input strings, the main string and the pivot string, do the ...
Given an integer \$x_1\$ and some black box function \$f: ℤ → ℤ\$ find a fixed point of \$f\$ in the sequence defined by \$x_{k+1} := f(x_k)\$. Details A value \$x\$ is said to be a fixed point of \$f\$ if \$x = f(x)\$. For instance if \$f(x) = \text{round}(\frac{x}{\pi})\$ and we have a starting point \$x_1 = 10\$ t...
Let's define a self-contained number as a positive integer, whose digits appear in runs of length equal to themselves only. In other words, any decimal digit d (excluding 0) occurs only in runs of length exactly d. Task You can choose any of the three methods listed below: Given an integer n, output the nth (either 0 ...
The main purpose of the RGB (Red Green Blue) color model is for the sensing, representation and display of images in electronic systems, such as televisions and computers HSL (Hue Saturation Lightness) is an alternative color model, designed in the 1970s by computer graphics researchers to more closely align with the ...
There has not been a challenge regarding slope fields, as a far as I can tell. So, I might as well make one. The challenge Given: A black box function f which takes two arguments, x and y (both real numbers) , and returns the value of the slope at point (x,y) (also a real number) A list of real numbers, X, representi...
Adapted from this FiveThirtyEight riddle. Background Examine the following infinite sequence: 3 3 3 2 3 3 3 2 3 3 3 2 3 3 2 3 3 3 2 ... Let's say the sequence is 1-indexed. The ith number in the sequence determines how many 3s there are before the ith 2 and following any previous 2s. So since the sequence starts with ...
Write an indefinitely-running program that reports how many instances of itself are currently running. Each instance of the program should also report the order in which it was opened out of all other currently-running instances. Example The user launches the program for the first time - we'll call this Instance 1. Ins...
A follow-up to this challenge Given a set of mixed dice, output the frequency distribution of rolling all of them and summing the rolled numbers on each die. For example, consider 1d12 + 1d8 (rolling 1 12-sided die and 1 8-sided die). The maximum and minimum rolls are 20 and 2, respectively, which is similar to rolling...
Background I was working on a StackOverflow helper program (that sends me notifications) when I noticed something rather interesting in StackOverflow's Network tab: StackOverflow uses WebSockets (not too surprising, but good to know)! For this challenge, we will be conquering StackOverflow's web socket server. This p...
Background: This question is a remix of the one that I made previously on this forum. The only difference with this one is: the range is significantly larger, AND dynamic. Details below! Also, I'm typing this question incredibly quickly, so if there are any grammatical errors, I do apologize and ask if anyone would edi...
Task Given two positive integers (dividend and divisor), calculate the quotient and the remainder. Normally it would be calculated as e = o*q+r where q*o<=e and 0<=r<o. For this challenge it still e = o*q+r but q*o>=e and -o<r<=0. For example e=20 and o=3, normally it would be 20/3 -> 20=3*6+2, since 18<=20 and 0<=2<3....
<< Prev Thanks to the PPCG community, Santa now has balanced his storage carts. Now, he needs to move them into the transport docks so that they can be sent to the loading bays. Unfortunately, the tracks to move the carts around are a mess, and he needs to figure out how to get them all around without them crashing tog...
GPA Calculator (GPA = Grade Point Average) You are a stressed out college student during finals week. Instead of studying for your exams coming up, you decide it is best to determine what GPA you will have at the end of the semester. This way you have data to back up your decision of staying up all night to get that A ...
In APL, you can write tacit functions, called trains. How they work is irrelevant for this challenge. Here are the different ways they can be grouped, using ⍴ as the function: ⍴ -> ⍴ ⍴⍴ -> ⍴⍴ ⍴⍴⍴ -> ⍴⍴⍴ ⍴⍴⍴⍴ -> ⍴(⍴⍴⍴) ⍴⍴⍴⍴⍴ -> ⍴⍴(⍴⍴⍴) ⍴⍴⍴⍴⍴⍴ -> ⍴(⍴⍴(⍴⍴⍴)) ... The order remains the same. The procedure is...
Near the middle of the semester in chemistry, we get problems like: Convert 1.283850057 to Scientific Notation and Convert 3.583✕106 to Standard Notation This is just stupid busy work for people who already know how to do this. So… The Challenge Given an input in any reasonable, convenient format, in either standar...
In atomic physics and quantum chemistry, the electron configuration is the distribution of electrons of an atom in atomic orbitals. For example, the electron configuration of the neon atom is 1s2 2s2 2p6 (From Wikipedia) Challenge Your challenge is to take a number representing the atomic number of an element and out...
For any String that is composed of lower cased alphabetical characters, make a function that returns a list of all of it's variations, empty strings returns empty list Test Cases "" -> [] "a" -> ["a", "A"] "ab" -> ["ab", "Ab", "aB", "AB"] "abc" -> ["abc", "Abc", "aBc", "ABc", "abC", "AbC", "aBC", "ABC"] This is Code-g...
Given an Integer array: Start from the first number Jump forward n positions where n is the value of the current position Delete the current position, making what was the next position the current position. Goto step 2 until there is one number remaining Print that number Rules The array wraps-around (the next number...
Yahtzee is a game played with five six-sided dice and a score sheet with thirteen different boxes to fill a score in. Each box has its own scoring rules: 1s, 2s, 3s, 4s, 5s, 6s all score points equal to the sum of the respective dice (that is, a roll of [3, 2, 3, 1, 5] scored as 3s would be awarded 6 points: 3 for eac...
In case you missed Encode Factor Trees, here is the definition of a Factor Tree: The empty string is 1. Concatenation represents multiplication. A number n enclosed in parentheses (or any paired characters) represents the nth prime number, with 2 being the first prime number. Note that this is done recursively:...
Given 2 random circle sections, return how many times they intersect. Rules/clarifications are as below. You are provided 10 total values, The center (x,y) of the circle section Angles of the circle (i.e. (0,90) would be a quarter circle "facing" the top-right corner. The radius of the circle section The circle s...
For another challenge I am writing, I need to verify that test cases are solveable with bounded integers. Specifically, I need to verify the following, for a non-empty array of integers A and an integer bit width n: All integers a in A satisfy -2**(n-1) <= a < 2**(n-1) (representable with n-bit two's complement intege...