instruction
stringlengths
34
53.1k
Game In this challenge you will play a made-up turn-based game. The game is made up of the following elements: A 8x8 grid with each spot containing nothing (space), a robot (*), a wall (#), or HP (@) A public stack Robots In this challenge, you will be playing as a robot. Each robot has health (starts at 10HP and ca...
I am quite surprised that a variant of linear regression has been proposed for a challenge, whereas an estimation via ordinary least squares regression has not, despite the fact the this is arguably the most widely used method in applied economics, biology, psychology, and social sciences! For details, check out the W...
Let n be a positive integer then n = a + b + c for some a, b, and c that are palindrome integers. What is the largest possible integer a for k = 1 to 1_000_000? Golf this or have the fastest running time. NOTE: it's NOT the same as this question as I am asking for the largest palindrome component. The question just ask...
Introduction Today we're gonna take care of the bane of first-year linear algebra students: matrix definiteness! Apparently this doesn't yet have a challenge so here we go: Input A \$n\times n\$ symmetric Matrix \$A\$ in any convenient format (you may also of course only take the upper or the lower part of the matrix)...
Challenge Your task is to encode an integer as a string of ASCII characters, then successfully decode it after said string has been randomly shuffled. You will write two programs/functions, which will be referred to as Encoder and Decoder. Encoder Input: an integer \$n\$ in the range \$[0,2^{31}-1]\$. Output: a string...
Tomorrow is the Mid-Autumn festival, and in the spirit of that holiday, I will introduce a gambling game that we (people from Xiamen) play during the holiday! Rules The game is played with six 6-sided dice. Different combinations of numbers have different ranks, with a special emphasis on fours and ones. Your job is to...
True color (24-bit) at Wikipedia is described in pertinent part as 24 bits almost always uses 8 bits of each of R, G, B. As of 2018 24-bit color depth is used by virtually every computer and phone display and the vast majority of image storage formats. Almost all cases where there are 32 bits per pixel mean that...
Requirement: Write a program (in any language) that counts the number of lines of code in files matching *.sh in the directory tree starting from the directory that the program is executed in, excluding lines that are empty, only contain whitespace, or are just single-line comments (a line which the first character tha...
Awhile back I encountered a simple programming puzzle to determine whether a string was a pangram, or a perfect pangram. (Although it's worth noting that this particular challenge gave a different meaning than the standard definition of a "perfect pangram," to mean any sentence where every letter appears n times for so...
The idea for this code-challenge is simple: given a matrix of integers, let's sort it by applying Rubik-style movements. This means that you can select a single row or column and rotate its elements in any direction: [1, 3, 2, 4] => [3, 2, 4, 1] (rotate left for rows/up for columns) [1, 3, 2, 4] => [4, 1, 3, 2] (rota...
Description The task of this challenge is to devise a program or function that tracks a given object in an \$n×n\$ space. I/O Your program will be given 3 inputs, which may be taken in any sensible way: n will be the size of the plane's side. (so, for \$n=5\$, your plane will be \$5×5\$). You may assume n will always b...
Write a function or program that accepts a date (as a string in YYYY-MM-DD format) as input and returns a truthy value if that date is "alphabetical," and a falsey value if it isn't. An alphabetical date is a date whose month, day and year are in alphabetical order when expressed as a string (and when considered speci...
Given a word, treat every letter as its number in English alphabet (so a becomes 1, b becomes 2, z becomes 26 and so on), and check if all of them, including duplicates, are pairwise coprime. The input is exactly one word of lowercase English letters. The output is the fact if the word is coprime: any truthy/falsey val...
We all know of different fancy sorting algorithms, but none of these give us numbers in a way that's easy to pronounce. To remedy this, I propose using PronunciationSort™, the most natural way to sort lists of numbers. Pronunciation The official rules for pronouncing numbers (in this challenge) is that the digits are p...
In this task your code will be given an integer \$n\$ as input. Your code should then output the greatest number of multiples of \$3\$ that can be concatenated (in base \$10\$) to form \$3n\$ (with no leading zeros). For example if you were given \$26042\$ as input, \$26042\times3=78126\$ and \$78126\$ can be made ...
Your task here is simple: Given a list of integer sets, find the set union. In other words, find the shortest list of integer sets that contain all the elements in the original list of sets (but no other elements). For example: [1,5] and [3,9] becomes [1,9] as it contains all of the elements in both [1,5] and [3,9] [...
Given a value x find the smallest numerical value greater than y that is capable of being multiplied and divided by x while retaining all original digits. The new numbers do not lose digits. The new numbers do not gain digits. For example: Input: x = 2, y = 250000 Original: 285714 Division: 142857 Multiplicat...
We've recently reached the threshold of 10,000 questions on PPCG. Hooray! Let's celebrate this with a simple challenge. Input Two integers \$A\$ and \$B\$, both in \$[1..9999]\$, such that \$A+B<10000\$. Task Your task is to add one single digit to one of these integers or one single digit to both of them such that \$A...
We have a challenge to output your own score, but it seems like all the answers there just hardcode the output and that's boring1. So lets have a new challenge. Your program must output its own length in bytes followed by the string " bytes", but in order to prevent hardcoded solutions if we reduce its size by removi...
Challenge You are given an array \$a\$ of integers. With a move you can increase or decrease an element of the array by 1. Your task is to equalize the array, that is make all the elements of the array equal by performing some moves. But that's not enough! You also want to make as few moves as possible. Input A non-em...
In this challenge, you will write a bot that play's the prisoner's dilemma. Here's the catch: you will not have access to the history of previous games. Instead, you will have access to the opponent itself. In this version, both players get +2 points if they both cooperate, +1 points if they both defect, and if one coo...
Problem Given a value n, imagine a mountain landscape inscribed in a reference (0, 0) to (2n, 0). There musn't be white spaces between slopes and also the mountain musn't descend below the x axis. The problem to be solved is: given n (which defines the size of the landscape) and the number k of peaks (k always less tha...
I just had a genius idea for making the work-life easier - a countdown to a specific date which only counts workdays. The basic task is to create a countdown to a specific date which only includes the workdays in the countdown. As workday counts Monday, Tuesday, Wednesday, Thursday and Friday. The Input should be a sp...
You have 2 numbers, both stored separate as numeric data type. First number is always 6 digits long. Second number can vary between 1 and 4 digits. If it's less than 4 digits, it needs to be padded with numeric value 0. End result always needs to be 10 digits number. Order has to be respected. n1|n2 Example #1: n1 = 11...
Using the word “conemon” print each character 2 times more than the last. The first letter, “c”, should be printed 10 times, the second 12 and so on. Each repeated-letter-string should be printed on a new line. So the end-result becomes: cccccccccc oooooooooooo nnnnnnnnnnnnnn eeeeeeeeeeeeeeee mmmmmmmmmmmmmmmmmm ooooooo...
This challenge is created in celebration of my first esoteric language, Backhand! Backhand is a one dimensional language with a non-linear pointer flow. The pointer moves three steps at a time, only executing every third instruction. The program 1..1..+..O..@ will add 1+1 and output 2 before terminating. The intermedia...
Display numbers from one to one-hundred (in increasing order), but number 2 shouldn’t appear anywhere in the sequence. So, for example, the numbers two (2) or twenty-three (23) shouldn't be in the sequence. Here is an example output, with newlines separating the numbers: 1 3 4 5 6 7 8 9 10 11 13 14 15 16 17 18 19 30 31...
Final Standings +----------------------------------+---------+---------+---------+----------------------------+ | Name | Score | WinRate | TieRate | Elimination Probability | +----------------------------------+---------+---------+---------+----------------------------+ | 1. SarcomaBo...
Letters of the words want fairness. They decided to appear same number of times in a sentence equally. Example: Priorities Will become: Ppprrioooritttieeesss Each letter appears 3 times, as the most common letter was i, appearing 3 times. It does not matter where you put the repeated letters, as long as they are next...
You are given a string of terrain, with molehills and mountains: /\ / \ _/\__ / \ ___/ \_/ \_ ____/\___/ \___ Your job is to replace every molehill in the string with an equivalent mountain centered in the same col...
This is the Cops' thread. Robbers' thread is here. Background Boggle is a board game where the players have to find English words on a 4-by-4 board of random alphabets. Words can be constructed by selecting sequentially adjacent cells on the board. ("adjacent" means horizontally, vertically or diagonally adjacent.) A...
This is the Robbers' thread. Cops' thread is here. Background Boggle is a board game where the players have to find English words on a 4-by-4 board of random alphabets. Words can be constructed by selecting sequentially adjacent cells on the board. ("adjacent" means horizontally, vertically or diagonally adjacent.) A...
Supreme Sum String Given an input string, return the word with the highest sum of each of its unicode characters. Rules The input should be seperated by whitespace The value of each word is based on the sum of each character in the word's UTF-16 code The output should be the first word with the highest value (in case...
Inspired by this Stack Overflow question. The challenge Input An array of square matrices containing non-negative integers. Output A square matrix built from the input matrices as follows. Let \$N \times N\$ be the size of each input matrix, and \$P\$ the number of input matrices. For clarity, consider the following ex...
Intro A friend posed this question today in a slightly different way - "Can a single [Python] command determine the largest of some integers AND that they aren't equal?". While we didn't find a way to do this within reasonable definitions of "a single command", I thought it might be a fun problem to golf.  Challenge "R...
Make a program that simulates the basic logic gates. Input: An all-caps word followed by 2 1 digit binary numbers, separated by spaces, such as OR 1 0. The gates OR, AND, NOR, NAND, XOR, and XNOR are needed. Output: What the output of the entered logic gate would be given the two numbers: either 1 or 0. Examples: AND ...
Determine the length of a UTF-8 byte sequence given its first byte. The following table shows which ranges map to each possible length: Range Length --------- ------ 0x00-0x7F 1 0xC2-0xDF 2 0xE0-0xEF 3 0xF0-0xF4 4 Notes on gaps in the table: 0x80-0xBF are continuation bytes, 0xC0-0xC1 would start an ...
If you have ever had any exposure to Japanese or East Asian culture you will have surely encountered the Amidakuji game: As Wikipedia explains, it is a type of lottery drawn on paper and used to randomly select a permutation of N items. For example, it may be used to randomly assign a starting sequence to N people, o...
Let us define the "multiplicative deltas" of values \$[\; a_0, \cdots a_N, \;]\$ as: $$ [\; a_1 / a_0, \cdots, a_{i+1} / a_i, \cdots, a_N / a_{N-1} \;] $$ The reverse operation - namely "multiplicative undelta" - returns values such that the above operation results in the given values. Example Given values \$[\; 1, 5, ...
Your task is to create the given target string. Starting with an string that is empty, you will have to add characters to it, until your string is the same as the one we want. You can either add a character to the end of you string with cost x, or you can clone you string with cost y. What we want is the cheapest way t...
Given a random coordinate (x,y), determine in which square (squares are referenced by their sidelength) it is (or the borders of which squares). The squares are drawn in a counter clockwise direction, that is, the first square is drawn in the first quadrant, the one after is to the right, the one after that above, th...
Chinese Hearts, also known as Gong Zhu (拱猪, Chase the Pig), is a variance of the Hearts game. It is a 4 player card game with the aim to earn the highest amount of points. You may read more about it on Wikipedia. This time, we want implement a program (full or function) to calculate ones score. Scoring The player who p...
Given a list of positive integers, write code that finds the length of longest contiguous sub-list that is increasing (not strictly). That is the longest sublist such that each element is greater than or equal to the last. For example if the input was: \$[1,1,2,1,1,4,5,3,2,1,1]\$ The longest increasing sub-list would ...
About Zeckendorf Representations/Base Fibonacci Numbers This is a number system which uses Fibonacci numbers as its base. The numbers consist of 0 and 1's and each 1 means that the number contains the corresponding Fibonacci number, and 0 means it does not. For example, let's convert all natural numbers <=10 to base Fi...
You are given a list, L, with the length N. L contains N random positive integer values. You are only able to select from the outer edges of the list (left/right), and after each selection every value in the remaining list increase by a factor of the current selection. The goal is to maximize the total sum of the selec...
Sometimes when you're lying in bed and reading a message, your phone screen will pop into landscape mode right in the middle of a sentence. Only being able to read left to right, you find yourself incapacitated, unable to process the text in front of you. To ensure that this won't happen again, you decide to make every...
Input: An integer n in the range 2 <= n <= 10 A list of positive integers Output: Convert the integers to their binary representation (without any leading zeroes), and join them all together. Then determine all binary substrings that form a 'binary fence' using n amount of fence posts. The spaces (zeros) between each...
In Java/.NET/C/JavaScript/etc. you can use ternary-ifs to shorten if-statements. For example (in Java): // there is a String `s` and an int `i` if(i<0)s="Neg";else if(i>0)s="Pos";else s="Neut"; Can be shortened with a ternary-if to: s=i<0?"Neg":i>0?"Pos":"Neut"; Challenge: Input: A regular if-else (possible with nes...
The Challenge The goal of this challenge is to determine whether a given String can be typed using only one line of a standard UK QWERTY keyboard. This is code golf, so shortest solution in bytes wins! IO Input will be a single String of zero or more characters in the ASCII decimal range of 32-126 inclusive. You may ...
Introduction Large meetings waste working time. Our aim is to split a large meeting into a number of smaller meetings, so the average number topics that a person discusses is minimized but every person has to be in every meeting they are interested in. Input Given is a function from a set of topics \$T\$ to a set of pe...
Given a list of activities and their start time/date, output an ASCII-art calendar showing the activities on the appropriate days. All activities are guaranteed to be in the same month, no two activities will be on the same day, and all activities are guaranteed to fit within the calendar box. The calendar has the date...
Consider you have a hash function \$\mathcal{H}\$ which takes strings of length \$2n\$ and returns strings of length \$n\$ and has the nice property that it is collision resistant, i.e. it is hard to find two different strings \$s \neq s'\$ with the same hash \$\mathcal{H}(s) = \mathcal{H}(s')\$. You would now like to ...
Yesterday while playing with my kid I noticed the number in his toy train: So we have $$4281$$ that can be split into $$4-2-8-1$$ or $$2^2-2^1-2^3-2^0$$ So simple challenge: given a non-negative number as input, return consistent truthy and falsey values that represent whether or not the string representation of the n...
This question was inspired by Tom Scott's video here. The English language has plenty of words, but what's the longest one that can be displayed on a seven segment display? Your challenge is given a list of letters that may not be displayed, display the longest English word in a 7 segment display format? Input Input w...
Introduction: Unfortunately an Accordion Solitaire Solver challenge already exists (Solve a game of Accordion), so instead this easier related challenge. Let's start by explaining how Accordion Solitaire works: You start with all 52 cards (or 53 if you add a Joker) in one big row. You pile up cards from right to left ...
From this stackoverflow question Given a 2D array of size \$ M \times N \$, output the values in a anti-clockwise fashion. The output must start from the outside to the inside and the initial point always is going to be \$(0,0)\$. Example Given: $$ \begin{bmatrix} \color{blue}1&\color{red}2&\color{red}3&\color{red}4 \\...
As you most probably now, there are 2339 solutions to pentomino puzzle in a 6x10 grid. There are different labeling schemes for the 12 pentominoes, two of them are shown on the image below: Image credit: Wikipedia For the purposes of the current task we will say that a normalized pentomino solution is a solution that ...
Input A string s of printable ASCII characters, newlines, and spaces (0x20 ( ) to 0x7E (~)), and a non-negative integer n. Challenge To write a program that outputs either another program, or s depending on n. If n = 1, Then your code should output code which outputs s. If n = 2, Your code should output code which outp...
Two dimensional chiral objects are not chiral in three dimensional space. This is because you can flip them over which is equivalent to taking the mirror image unlike in two dimensions where only rotations in the plane of the object are allowed which cannot reproduce the effect of a mirror operation. In this challenge,...
While I was writing numbers I noticed after a while that my keyboard had the Shift key pressed and blocked and all I wrote was $%&-like characters. And even worse, I had been switching between the English and Spanish keyboard layouts so I don't know which one I used for each number. Challenge Given a string containing ...
Background Tatamibari is a logic puzzle designed by Nikoli. A Tatamibari puzzle is played on a rectangular grid with three different kinds of symbols in it: +, -. and |. The solver must partition the grid into rectangular or square regions according to the following rules: Every partition must contain exactly one symb...
With the given text below, there are some words in the text that repeats several times in the text. Use any programming language to write a short code that compresses the text to display it. Or in other words, use the smallest number of bytes to display the text. The Text is: Peter Piper picked a peck of pickled peppe...
(language-specific challenge) Specification: Language: ECMAScript, any version[1] Challenge: Somewhat like python's itertools.groupBy: Your function Array.group(f) should take as input an "equivalence function" f whose output defines our notion of an "equivalence key" for array elements (like a sort key). The return va...
Idea: Consider a 2-bit bitmap of arbitrary side-lengths overlaid on a coordinate grid and imaged with random data (1's represent an element of the image, 0's represent the "blank" canvas background): y x—0 2 4 6 8 10 14 18 | 0 0000000000111100000000 0000000011111110000000 2 0000111111111111000000 0000...
A numerical polynomial is a polynomial \$p\$ in one variable with rational coefficients such that for every integer \$i\$, \$p(i)\$ is also an integer. The numerical polynomials have a basis given by the binomial coefficients: $$p_n = {x \choose n} = \frac{x(x-1)\cdots(x-n+1)}{n!}$$ For instance: \$p_0 = 1\$ \$p_1 = x\...
The minimal power iteration of a number \$n\$ is defined as follows: $$\text{MPI}(n):=n^{\text{min}(\text{digits}(n))}$$ That is, \$n\$ raised to the lowest digit in \$n\$. For example, \$\text{MPI}(32)=32^2=1024\$ and \$\text{MPI}(1234)=1234^1=1234\$. The minimal power root of a number \$n\$ is defined as the number o...
Write two programs A and B. Program A (the encoder) takes 1024 pairs of integers \$(k,v)\$, where \$0≤k<2^{32}\$ and \$0≤v<1024\$, and all \$k\$ will be different. It will output a single positive integer (likely a few thousand digits long). Program B (the decoder) takes two inputs: the output-integer of program A, a...
In the Anno video game series there are 6 games with a 7th one announced for early 2019. Their titles always feature a year in a specific pattern: Anno 1602, Anno 1503, Anno 1701, Anno 1404, Anno 2070, Anno 2205, Anno 1800 The digital sum is always 9. The years are four digits long. They contain at least one zero. Wi...
An palindrome is a word that is its own reverse. Now there are some words that might look like palindromes but are not. For example consider the word sheesh, sheesh is not a palindrome because its reverse is hseehs which is different, however if we consider sh to be a single letter, then it's reverse is sheesh. This...
Challenge Write a program or function that takes in a string s and integer n as parameters. Your program should print (or return) the string when transformed as follows: Starting in the top-left and moving down and to the right, write s as a wave of height n. Then, from top to bottom, combine each row as a string (with...
Your challenge is to turn a Japanese word and a dictionary pitch accent number into a new string where the rises and falls in pitch are marked: e.g. (2, ウシロ) → ウ/シ\ロ. To help you out with this, I'll explain a little about Japanese phonology. Background: on moras For the purpose of this challenge, we will write Japane...
Here's a pretty common pattern for sorting algorithms: def sort(l): while not is_sorted(l): choose indices i, j assert i < j if l[i] > l[j]: l[i], l[j] = l[j], l[i] These algorithms work well because the indices i and j are chosen carefully, based on the state of the list l....
Use any programming language to display "AWSALILAND" in such a way, so that each letter is in a new line and repeated as many times as its position in the English alphabet. For example letter, (A) should be displayed just once because it is the first letter of the alphabet. Letter D should be displayed 4 times because ...
When I write documentation, comments, etc. I love making ASCII tables. They usually end up looking pretty good, but I always feel that they could look even better - especially since UTF-8/Unicode includes the box drawing characters. However, these characters are very burdensome to use, requiring several key presses to ...
Consider an array A of length n. The array contains only positive integers. For example A = (1,1,2,2). Let us define f(A) as the set of sums of all the non-empty contiguous subarrays of A. In this case f(A) = {1,2,3,4,5,6}. The steps to produce f(A) are as follows: The subarrays of A are (1), (1), (2), (2), (1,1), ...
Background A binary tree is a rooted tree whose every node has at most two children. A labelled binary tree is a binary tree whose every node is labelled with a positive integer; moreover, all labels are distinct. A BST (binary search tree) is a labelled binary tree in which the label of each node is greater than the l...
Challenge Inspired by this video. As you may know, a palindrome is a word that is spelled the same forward as it is backward. The word "PULP" is not a palindrome, but when translated into Morse Code (with the spacing between letters removed), "PULP" becomes ".--...-.-...--." which is a palindrome. Your task is to write...
You have to make something that takes in one input from a default I/O method (as an integer), and prints out the sum of all the permutations of that number (not necessarily unique) For example: 10 would return 11 because 10 can have 2 permutations (10 and 01), and the sum of those two numbers would be 11 202 would have...
In Excel, the columns range from A-Z, AA,AB,AZ,BA,..,BZ and so on. They actually each stand for numbers, but rather are encoded as alphabet strings. In this challenge, you will be given a string of alphabets, and you must calculate the column it corresponds to. Some tests: 'A' returns 1 (meaning that it is the first c...
Background Sudoku is a number puzzle where, given an \$ n \times n \$ grid divided into boxes of size \$ n \$, each number of \$ 1 \$ to \$ n \$ should appear exactly once in each row, column and box. In the game of Chess, the King can move to any of (at most) 8 adjacent cells in a turn. "Adjacent" here means horizonta...
This question has a similar set up to Find an array that fits a set of sums although is quite different in its goals. Consider an array A of length n. The array contains only positive integers. For example A = (1,1,2,2). Let us define f(A) as the set of sums of all the non-empty contiguous subarrays of A. In this cas...
You probably all know the 7-segment display which can display among other things all digits from \$0\dots 9\$: Challenge We only consider the segments \$\texttt{A}\dots\texttt{G}\$, your task is to decode a single digit given which segments are turned on. This can be encoded as an 8-bit integer, here's a table of each...
There is a challenge Let's play tennis by Daniel. He proposes to place a court in the North-South direction. My proposal is to create a court to play tennis in the East-West direction too. You have to print a tennis court, but you have to do it in the fewest bytes possible because of confidential reasons. Tennis court...
Your network scanning tool is annoyingly picky about input, and immediately crashes if you feed it an IPv4 address that contains improper characters or isn't properly formatted. An IPv4 address is a 32-bit numeric address written as four numbers separated by periods. Each number can be zero to 255. We need to write a...
Input: A valid 6 HEX digit color code wihout a # prefix Valid: 000000 FF00FF ABC123 Your job is to find to which one of these: Red: FF0000 Green: 00FF00 Blue: 0000FF White: FFFFFF Black: 000000 the input color is the closest too, in this case you try to only match it to black or white when the RGB is the same v...
A barcode of EAN-13 symbology consists of 13 digits (0-9). The last digit of this barcode is its check digit. It is calculated by the following means (the barcode 8923642469559 is used as an example): Starting from the second digit, sum up all alternating digits and multiply the sum by 3: 8 9 2 3 6 4 2 4 6 9 5 5 9 |...
Here's a reasonably trivial sequence which is not in the Online Encyclopedia of Integer Sequences. Start with an empty sequence then define each term as the number of characters required to write out, in English, all of the digits of the sequence so far without spaces.* For reference the number of characters of all of ...
Goal In light of the World Series being around the corner, I need a program that can read the box scores and tell me what inning it is. This is complicated slightly because baseball uses an odd method to record the score. They don't write down the at-bat team's score for the inning until they've scored a run (and are s...
Given an inconsistently indented piece of html code your task is to return the same text but correctly indented Indent space = 4 Assume input will be non-empty. Input can be taken as string or array/list of lines Opening and closing tags must be on the same line as long as there is not any other tag inside. <td></td>...
My two kids like to play with the following toy: The colored areas with the shapes inside can be touched and the turtle then lights the area and plays a sound or says the name of the color or the shape inside. The middle button changes the mode. There is one mode in which the areas play different musical notes when to...
Given an input array having minimum length 2 and maximum length 9 having any initial values output an array having length 2 consisting of the 1-based indexes of the array represented as either an integer or string in forward and reverse order. The values of the array or string do not matter and are ignored. For example...
Background Variable declaration statement in C consists of three parts: the name of the variable, its base type, and the type modifier(s). There are three kinds of type modifiers: Pointer * (prefix) Array [N] (postfix) Function () (postfix) You can specify a list of function arguments inside the parens, but for the s...
Input Two lists with binary values (list_a, list_b) of equal length=>3. Output Two lists with binary values (smoothed_a, smoothed_b) with minimal Forward Difference while keeping the same sum before and after processing sum(list_a) + sum(list_b) == sum(smoothed_a) + sum(smoothed_b). Forward Difference being the absolut...
The premise of this is simple: A 10% chance is pretty unlikely, but everyone knows that a one-in-a-million chance is a sure thing! So, write code that implements the following "dramatic" probability rules: Take in a floating point P from 0 to 1 representing the unmodified chance of some plot-related event, and a boole...
The non-negative integers are bored of always having the same two* neighbours, so they decide to mix things up a little. However, they are also lazy and want to stay as close as possible to their original position. They come up with the following algorithm: The first element is 0. The \$n^{th}\$ element is the smalle...
My birthday is in a month, and this is a slice of tasty cake. .-""-. .-" "-. |""--.. "-. | ""--.. "-. |""--.. ""--..\ | ""--.. | | ""--..| ""--.. | ""--.. | ""--..| In the fewest number of bytes, construct this slice of cake for me. Y...
Let's say I've got some ASCII art: ___ ,"---". : ; `-.-' | | | | | | _.-\_/-._ _ / | | \ _ / / `---' \ \ / `-----------' \ /,-""-. ,-""-.\ ( i-..-i i-..-i ) |`| |-------| |'| \ `-..-' ,=. `-..-'/ `------...
Introduction A recursive acronym is an acronym that contains or refers to itself, for example: Fish could be a recursive acronym for Fish is shiny hero, notice how that also contains the acronym itself. Another example is Hi -> Hi igloo. Or even ppcg paints -> ppcg paints cool galaxies pouring acid into night time star...
This tweet lists the possible orders for Wings of a Chinese restaurant1: When ordering Pizza I usually calculate what size gives me the best Pizza-price ratio which is a simple calculation. However minimizing the price of an order at this restaurant isn't such a simple task, so I'd like to be prepared for my next orde...
Background Challenge is inspired by this question. The 1-expression is a formula that in which you add and multiply the number 1 any number of times. Parenthesis is allowed, but concatenating 1's (e.g. 11) is not allowed. Here is an example to get the 1-expression for \$19\$: (1+1)*(1+1)*(1+1+1+1)+1+1+1 = 19 Total num...