instruction
stringlengths
34
53.1k
I recently had a problem to solve at work where I had two lists: a master list, and a smaller list that contains a subset of the items in the master list potentially in a different order. I needed to reorder the master list in such a way that the items in the subset would appear in the same order without changing the o...
Given a date as input in any convenient format, output a calendar with that date as the exact center of a five-week window. The header of the calendar must include the two-letter abbreviations for the days of the week (i.e., Su Mo Tu We Th Fr Sa). Three-letter or other abbreviations of the days are not allowed. For exa...
What to do? Starting from a, count in the sequence: a, b, c, d, ... , y, z, aa, ab, ac, ... , ay, az, ba, bb, bc, ... , zy, zz, aaa, aab, aac, ... , zzy, zzz, aaaa, aaab, aaac, ... Input The input, n, will an integer representing how far to count. Output The output should be n space-separated strings following the abo...
This question is inspired by Kevin Cruijssen's question. Now that the carpet is laid out, we want to roll it. Your task is to write a program that takes a string and returns a spiral made from this string (representing a rolled carpet viewed from the side). The procedure for one step of rolling the carpet is the follow...
Shocking news: Dr. Mad J Scientist has released a proof of P = NP to the world. But the proof is nonconstructive, and she's keeping the algorithm to herself. Worry not. Without even looking at her proof, we can still (almost) write a computer program that solves NP-complete problems in polynomial time. The Problem Inpu...
Given an input string, output at random the unique combinations with repetition of the characters in the input string, from length 1 up to the length of the input string, with an equal chance of each one occurring. Example: given the input abcd (or any combination thereof of the four characters a,b,c,d) , there is an e...
Summary A new string manipulation language has been made, using only the characters $+#-!*|@>! Your task is to implement an interpreter for it in as few bytes as possible. Input A string, which is a single line of this language. This can be taken in any reasonable way (stdin, function parameter, command line argument e...
Introduction I can type at a moderate pace, using the QWERTY keyboard layout. But if a word like yellowwooddoor has a ton of repeated letters, it takes a bit longer to type it. Even worse is when a word like "jump" has the same finger used for multiple different consecutive letters. Here's how long it takes me to type ...
Challenge Given two strings in any default I/O format, do the following: NOTE: The challenge will refer to the first string as the "data" and the second referred to as the "program". Change the program to an infinite string which is just the program repeated infinitely (e.g. 10 --> 1010101010...). The challenge will r...
Everyone knows the Fibonacci sequence: You take a square, attach an equal square to it, then repeatedly attach a square whose side length is equal to the largest side length of the resulting rectangle. The result is a beautiful spiral of squares whose sequence of numbers is the Fibonacci sequence: But, what if we didn...
Introduction (may be ignored) Putting all positive numbers in its regular order (1, 2, 3, ...) is a bit boring, isn't it? So here is a series of challenges around permutations (reshuffelings) of all positive numbers. This is the fourth challenge in this series (links to the first, second and third challenge). In this ...
Write a program/function that takes two integers in the range \$0\$ to \$255\$ inclusive, and returns whether the binary forms of the numbers are exactly one bit different. For example, \$1\$ and \$0\$ have binary forms 00000001 and 00000000, which are one bit apart. Similarly, \$152\$ and \$24\$ are 010011000 and 000...
The Arecibo message is a 1974 interstellar radio message carrying basic information about humanity and Earth sent to globular star cluster M13 in the hope that extraterrestrial intelligence might receive and decipher it... The message consisted of 1,679 binary digits, approximately 210 bytes... The number 1,679 was ch...
When writing a programm 1 missing character can ruin everything, wouldn't it be great if the programm told you what was missing ? Task: Create any (non Empty) programm, that takes no input and outputs nothing. That when 1 Character is removed from the programm, outputs that Character. Input: None Output: Output nothing...
Problem You're stuck in a cabin in the middle of the woods, with only an old scrabble set to entertain yourselves. Upon inspection you see that the scrabble letters are so worn, that only the points for each letter are visible. Nonetheless you decide to play a game. You pull seven letters from the bag and place them o...
Your task is to take two single-variable integer polynomial expressions and multiply them into their unsimplified first-term-major left-to-right expansion (A.K.A. FOIL in the case of binomials). Do not combine like terms or reorder the result. To be more explicit about the expansion, multiply the first term in the firs...
Challenge Given some input string, return a truthy value if it represents a correct roman numeral between 1 (=I) and 3999 (=MMMCMXCIX), and a falsey value otherwise. Details The input is a non-empty string that only comprises the characters IVXLCDM. The roman numerals (that we use here in this challenge) are defined a...
Background Recognizing primality seems like a poor fit for (artificial) neural networks. However, the universal approximation theorem states that neural networks can approximate any continuous function, so in particular it should be possible to represent any finitely-supported function one desires. So let's try to re...
Inspired by this chat mini-challenge. Given a string as input (ASCII printable characters only), output the string with the letters "raining" down. Each letter must be a random number of lines downward (random between 0 and the length of the string, each having non-zero probability), and only one character per column. ...
Your task is to make a program that takes in an integer n > 1, and outputs the roll of a single n-sided die. However, this dice follows the rules for exploding dice. When you roll the die, check what value you rolled. If you got the maximum for that kind of die (on a standard d4 that would be 4, or 6 on a d6, etc.), ro...
Test Driver • Challenge Discussion • Submit Adventurer (Image Source) Several rival adventurers are raiding the ruins for treasure, but they can only carry so much at a time and have their limits of endurance. They want to get the most valuable treasure and get out before they become too tired to continue. They are tr...
The Idea We've done matrix spirals before, and full rotations, and even diagonal rotations, but not, as far as I can find, snake rotations! What is a snake rotation? Imagine the rows of a matrix snaking back and forth, with dividers between them like the dividers of long queue: +--------------+ 1 2 3 4 5|...
Challenge You will be given an input represented by x, which is a string containing at least 3 characters. It will consist only of the standard numeric characters, 0 through 9. Your job is to find and output how many right triangles can be formed with the given numbers. Rules Numbers must be kept in the order they wer...
Introduction The idea is to use the asterisk character (star) * to display an ascii-art star at a specified dimension. The dimension is an input number greater than or equal to \$1\$ that specifies the height in lines of the upper point of the star. The stars here are intended to be six pointed stars with larger sizes ...
Introduction (may be ignored) Putting all positive numbers in its regular order (1, 2, 3, ...) is a bit boring, isn't it? So here is a series of challenges around permutations (reshuffelings) of all positive numbers. This is the fifth challenge in this series (links to the first, second, third and fourth challenge). I...
You are given an array/list/vector of pairs of integers representing cartesian coordinates \$(x, y)\$ of points on a 2D Euclidean plane; all coordinates are between \$−10^4\$ and \$10^4\$, duplicates are allowed. Find the area of the convex hull of those points, rounded to the nearest integer; an exact midpoint should ...
The New York Times has a daily online game called Letter Boxed (the link is behind a paywall; the game is also described here), presented on a square as follows: You are given 4 groups of 3 letters (each group corresponds to one side on the picture); no letter appears twice. The aim of the game is to find words made o...
Write a program, given an input n, will generate all possible n-tuples using natural numbers. n=1 (1),(2),(3),(4),(5),(6)... n=2 (1,1),(1,2),(2,1),(2,2),(1,3),(3,1),(2,3),(3,2),(3,3)... n=6 (1,1,1,1,1,1) (1,1,1,1,2,1) (1,1,1,2,1,1)... The output may be in any order that does not break any other rules. The program...
Your goal is to write a program that takes no input and outputs the following text: ca e na ŋa va o sa; þa ša ra la ła. ma a pa fa ga ta ča; în ja i da ða. ar ħo ên ôn ân uħo; carþ taŋ neŋ es nem. elo cenvos. But there's a catch: for each letter (any character whose general category in Unicode starts with L) in your s...
Python is the fastest-growing major programming language today. It is the most wanted language for the third year in a row, meaning that developers who do not yet use it say they want to learn it.[1] The reason for Python's popularity is its many versions.[citation needed] There are in fact 116 versions of Python, incl...
Given some positive integer \$n\$ that is not a square, find the fundamental solution \$(x,y)\$ of the associated Pell equation $$x^2 - n\cdot y^2 = 1$$ Details The fundamental \$(x,y)\$ is a pair of integers \$x,y\$ satisfying the equation where \$x\$ is minimal, and positive. (There is always the trivial solution \$...
This! is an RGB colour grid... Basically it's a 2-dimensional matrix in which: The first row, and the first column, are red. The second row, and the second column, are green. The third row, and the third column, are blue. Here are the colours described graphically, using the letters R, G, and B. Here's how we calcu...
You want to create a square chessboard. Adjacent tiles must alternate black and white like a standard chessboard, and the bottom left corner can be either black or white. Your program will take in two positive integers, the number of black and the number of white tiles. These will always be less than 1024. You don't ha...
Introduction: A 3x3x3 Rubik's Cube has \$43,252,003,274,489,856,000\$ possible permutations, which is approximately 43 quintillion. You may have heard about this number before, but how is it actually calculated? A 3x3x3 Rubik's Cube has six sides, each with nine stickers. Looking at the (external) pieces instead of sti...
Introduction: Inspired by these two SO questions (no doubt from the same class): print the elements in the subarray of maximum sum without adjacent elements java and Maximum sum of non adjacent elements of an array, to be printed. Challenge: Given a list of integers, output a subsequence consisting of non-adjacent elem...
I came up with a series of numbers the other day and decided to check what the OEIS number for it was. Much to my surprise, the sequence did not appear to be in the OEIS database, so I decided to name the sequence after myself (note that someone else who's a lot smarter than me has probably already come up with this, ...
Introduction (may be ignored) Putting all positive integers in its regular order (1, 2, 3, ...) is a bit boring, isn't it? So here is a series of challenges around permutations (reshuffelings) of all positive integers. This is the sixth challenge in this series (links to the first, second, third, fourth and fifth chall...
This happy individual is known in folklore as the Easter Bunny. Colours It is created using 4 colours: Light pink Dark pink White Black (I'm happy for these colours to be approximated in your answer. It does not need to be this precise shade) Shapes It is constructed of these shapes: Two tall ellipses in light pink...
Each day you put up a new word on a marquee sign with movable letters, buying just the letters you need to write it. You re-use letters you've bought for earlier words whenever possible. Given the words you want to write each day in order, output the letters you buy each day. Example Input: ['ONE', 'TWO', 'THREE', 'S...
Your task is to generate a nonsense word that is reasonably pronounceable with the specified number of 'syllables'. Each time the program is run possibly results in a different nonsense word. Pronounceability A pronounceable word is made up of syllables, which are in turn made up of a vowel group that is possibly sandw...
Codegolf challenge - mapping values in a multidimensional array [ [0, 0, 0], [0, 0, 0], [0, 0, 0] ] This 2D array is sick of being so false, and wants to find the truth about life, once and for all. Your task is to write a map function to act as a highway to all the values in this array. An example implementatio...
(Title with thanks to @ChasBrown) Sandbox The Background This challenge is inspired by a question that I recently posted on Puzzling Stack Exchange. Please feel free to follow the link if you are interested in the original question. If not then I won't bore you with the details here. The Facts Every printable standard...
This is taken from this question (with permission ofcourse). I'll quote: Create a function which takes a string, and it should return true or false based on whether the input consists of only a repeated character sequence. The length of given string is always greater than 1 and the character sequence must have a...
John, a knight wants to kill a dragon to escape the castle! The dragon has A heads and B tails. He knows, that: if you cut off one tail, two new tails grow if you cut off two tails, one new head grows if you cut off one head, one new tail grows if you cut off two heads, nothing grows To defeat the dragon, John needs ...
Input Integers a1, a2, a3, b1, b2, b3 each in the range 1 to 20. Output True if a1^(a2^a3) > b1^(b2^b3) and False otherwise. ^ is exponentiation in this question. Rules This is code-golf. Your code must terminate correctly within 10 seconds for any valid input on a standard desktop PC. You can output anything Truthy ...
This question is tricky (and in particular harder than Which big number is bigger?), for those who like more challenging puzzles. Input Integers a1, a2, a3, a4, a5, b1, b2, b3, b4, b5 each in the range 1 to 10. Output True if a1^(a2^(a3^(a4^a5))) > b1^(b2^(b3^(b4^b5))) and False otherwise. ^ is exponentiation in this...
A few hours earlier, I got this puzzle: Suppose, you toss a coin n times, then what is the probability of getting m number of heads? ( where m belongs to the set of all prime numbers) For instance, take n = 2, then SS = { HH, HT, TH, TT } So, output is 1/4 (for HH case) Then, for n = 3, SS = { HHH, HHT, HTH, THH, HTT...
J. E. Maxfield proved following theorem (see DOI: 10.2307/2688966): If \$A\$ is any positive integer having \$m\$ digits, there exists a positive integer \$N\$ such that the first \$m\$ digits of \$N!\$ constitute the integer \$A\$. Challenge Your challenge is given some \$A \geqslant 1\$ find a corresponding \$N \ge...
Bob got kidnapped and is stuck in a maze. Your job is to help him find a way out. But since it is a very dark and scary maze, he can't see anything. He can only feel walls when he runs in to it, and knows when he has found the exit, but doesn't know anything more that. Since he has to run your program by memory, it has...
Brain-Flak is a stack-based esoteric language with eight commands: () Evaluates to 1 <> Switch active stack; evaluates to 0 [] Evaluates to height of current stack {} Pop current stack; evaluates to the popped number (...) Execute block and push the result; evaluates as result <...> Execute block; eva...
Definitions: A triangle is considered a right triangle if one of the inner angles is exactly 90 degrees. A number is considered rational if it can be represented by a ratio of integers, i.e., p/q, where both p and q are integers. A number n is a congruent number if there exists a right triangle of area n where all thr...
Word changer is a game where you are trying to turn one word into another via single-character edits, with each step being its own word. For this challenge, edits may be replacements, insertions, or deletions. For example, WINNER → LOSER can be done with this route (there may be others): WINNER DINNER DINER DINE LINE L...
The challenge is simply; output the following six 2D integer arrays: [[ 1, 11, 21, 31, 41, 51], [ 3, 13, 23, 33, 43, 53], [ 5, 15, 25, 35, 45, 55], [ 7, 17, 27, 37, 47, 57], [ 9, 19, 29, 39, 49, 59]] [[ 2, 11, 22, 31, 42, 51], [ 3, 14, 23, 34, 43, 54], [ 6, 15, 26, 35, 46, 55], [ 7, 18, 27, 38, 47, 58], [10, 1...
Introduction: Aaron is a young game developer. He recently joined the development team of a game where the players select their character from a predefined set, aka "heroes". Unfortunately, the names of the existing heroes are not evenly distributed throughout the alphabet. For example, there are 6 heroes that have a n...
Given some positive integer \$n\$ generate all derangements of \$n\$ objects. Details A derangement is a permutation with no fixed point. (This means in every derangement number \$i\$ cannot be in the \$i\$-th entry). The output should consist of derangements of the numbers \$(1,2,\ldots,n)\$ (or alternatively \$(0,1,...
Upside-Down Pyramid Addition is the process of taking a list of numbers and consecutively adding them together until you reach one number. When given the numbers 2, 1, 1 the following process occurs: 2 1 1 3 2 5 This ends in the number 5. YOUR TASK Given the right side of an Upside-Down Pyramid (Ascen...
Given an infix expression, determine whether all constants are of the same type. Operators will consist only of these dyadic operators: +-/* Your program or function should take a valid expression string as input, and output a truthy value if the constants in the expression are of the same time, and a falsey value othe...
Input An integer n in the range 100 to 10^18 and an integer k in the range 1 to 18, inclusive. The swap operation A swap chooses two digits at different positions and exchanges their positions, as long as the swap does not result in a leading zero. For example if we start with the integer 12345 we can perform one swap ...
Challenge Given an IPv4 address in dotted-quad notation, and an IPv4 subnet in CIDR notation, determine if the address is in the subnet. Output a distinct and consistent value if it is in the subnet, and a separate distinct and consistent value if it is not in the subnet. The output values do not necessarily need to be...
In the original Shantae game, there are transformation dances that you have to input in time using the D-Pad, A, and B. If you complete a predefined sequence while dancing, you will transform into the corresponding form (or teleport or heal). Your task is to output the corresponding effect when given an input. The catc...
What is a Prime Square? A Prime Square is a square where all four edges are different prime numbers. But which ones? And how do we construct them? Here is an example of a 4x4 Prime Square 1009 0 0 3 0 1021 First we start from the upper left corner. We are working clockwise. We pick the smallest prime number having 4...
Given a list of words, output a square grid of characters, so that all the words can be read from the grid, by moving horizontally, vertically, or diagonally between characters, without reusing characters in the same word. The grid must be the smallest possible which allows all words to be read. Example B A D R E T E Y...
So glad I found this cool site. Wanted to try sharing a coding challenge a friend gave me, an interview question. Usually it is written in java, but you can use whatever language you want, just have fun! Challenge: write efficiently and securely a program that creates an array of n threads that communicate with each o...
Input A single integer \$1 \leq x \leq 10^{15}\$. Output The maximum number of distinct positive integers that have the product \$x\$. Examples Input: 1099511627776. Output: 9. One possible optimal list of factors is: (1, 2, 4, 8, 16, 32, 64, 128, 4096). Input: 127381. Output 4. One possible optimal list of factors is...
Some divisors of positive integers really hate each other and they don't like to share one or more common digits. Those integers are called Hostile Divisor Numbers (HDN) Examples Number 9566 has 4 divisors: 1, 2, 4783 and 9566 (as you can see, no two of them share the same digit). Thus, 9566 is a Hostile Divisor...
The dihedral group \$D_4\$ is the symmetry group of the square, that is the moves that transform a square to itself via rotations and reflections. It consists of 8 elements: rotations by 0, 90, 180, and 270 degrees, and reflections across the horizontal, vertical, and two diagonal axes. The images are all from this lo...
Keeping this challenge short. You are given 4 numbers: p1, p2, p3 and p4. The magic sum of the numbers are defined as follows: magic_sum = |p1 - p2| + |p2 - p3| + |p3 - p4| + |p4 - p1| You are only allowed to change one of the above integer values (p1, p2, p3 or p4). You need to change the value such that the magic su...
Challenge Create a function takes in two 2-dimensional arrays of characters (or strings if the programming language does not have characters as a datatype) as inputs: a and b. If your language does not support these inputs, you may use any other standard one-byte variable. Your task is to determine if b contains a. If ...
Giving a challenge involving a Star Trek reference just after May the 4th may be frowned upon, but here goes. You, Luke, Anakin, Palpatine, Yoda and Han Solo are involved in an insane tournament of Rock, Paper, Scissor, Lizard, Spock. The catch here is that you are only allowed to use a fixed order of moves. If your or...
In Emoji Math, a user created module for the video game Keep Talking And Nobody Explodes, numbers are written as strings of emoticons, where each emoticon represents a base 10 digit. Below is the conversion table between digits and emoticons. Digit | Emoticon 0 | :) 1 | =( 2 | (: 3 | )= ...
This is a sequence question of the usual type, as applied to OEIS sequence A038666. That is, do either of the following: Accept no or any input, and output A038666 until the heat death of the universe. Accept a positive integer as input, and output the \$n\$th term of A038666 or its first \$n\$ terms. (If using \$0\$-...
I'm a big fan of number theory. A big thing in number theory is modular arithmetic; the definition being \$a\equiv b\mod m\$ if and only if \$m\mid a-b\$. A fun thing to do is raising to powers: especially when the modulus is a prime number. In particular, it has been proven that if \$a\$ and \$m\$ are relatively prime...
One day, when I was bored in maths class, I learned of a neat trick for solving the real cube root of a number! Let's use the number \$79,507\$ as an example. First, take digit in the one's place and compare it to this table: \begin{array} {|r|r|} \hline \text{Extracted Digit} &\text{Resulting Digit} \\ \hline \text{1}...
Contest Finished! Read comments on blobs to view their score. This KoTH is loosely inspired by Primer's Natural Selection Simulation. Your bot is a blob. In order to survive, you must eat pellets to regain energy, which is used to move. With extra energy, blobs can split into two. Energy and Movement Your blob starts o...
A Munchausen Number in base \$b\$, also known as a Perfect digit-to-digit invariant or PDDI is a peculiar type of positive integer where the sum of its base-\$b\$ digits raised to themselves is equal to the number itself. They are named for the fictional Baron Munchausen, who apparently hoisted himself up via his own p...
The Mel calendar is used in the fictional world of Kaldia. Your goal is to convert dates into the Mel calendar. This calendar has 13 months of 28 days each, plus 1 or 2 extra days after the last month. A year that is divisible by 4 but not by 100, or divisible by 400 has 366 days, and other years have 365 (i.e. our lea...
Per the fundamental theorem of arithmetic, for a given number \$n\$, it is possible to find it's prime factors, and they are unique. Let's imagine we talk only of \$n\$ that is non-prime (composite). We can also find the factors of all the composite numbers smaller than \$n\$. For example if \$n\$ is 10, then it has f...
You are given a square matrix of width \$\ge2\$, containing square numbers \$\ge1\$. Your task is to make all square numbers 'explode' until all of them have disappeared. You must print or return the final matrix. More specifically: Look for the highest square \$x^2\$ in the matrix. Look for its smallest adjacent neig...
Background and Motivation: IOC Country Codes are three letter abbreviations that are commonly used when broadcasting the Olympic Games. The last two letters of some codes overlap with the first two letters of other codes (RUS -> USA, JPN -> PNG), etc. Clearly, you can transform the first country code into the second by...
Story Have you seen this post from 9gag? Maybe you got the feeling to make your own sentences. But then you realize that you could just golf a script in half an hour, and you will never have to deal time with that. The submission Your program will get an input string which it will return with added quotation marks as e...
Sandbox For the purposes of the current task, a cube of unit length is rendered in oblique projection with ASCII symbols as follows: +-----+ / /| +-----+ | | | + | |/ +-----+ + for the vertices. - for the X edges. The unit length along X is represented by five - between two vertices. | for the Y edges....
In a fictional document management system, input documents are structured with weighted headings. Lowest weighted headings are the most important. This is a sample document: H1 All About Birds H2 Kinds of Birds H3 The Finch H3 The Swan H2 Habitats H3 Wetlands From this document we would like to produce an outline usin...
Thanks to @ComradeSparklePony for the title. This challenge should be very simple. You are given three lists. The first is a list of first names, in title case. The second is a list of adjectives, in lower case. The third is a list of nouns, in lower case. Please randomly select a name, optional adjective, and noun, an...
The challenge is to write a deterministic program (any language/OS) which takes no arguments or other input and behaves differently in a debugger from how it behaves when not being debugged. For example, the program may output something when being debugged but not output anything when not being debugged. Or output some...
Introduction In number theory, we say a number is \$k\$-smooth when its prime factors are all at most \$k\$. For example, 2940 is 7-smooth because \$2940=2^2\cdot3\cdot5\cdot7^2\$. Here, we define a \$k\$-smooth pair as two consecutive integers which both are \$k\$-smooth. An example of 7-smooth pair will be \$(4374,43...
I am new to the sport of code golf. I am trying to generate a ladder of integers using the least number of unique characters in C++. Let's say we are given an integer 4. We will generate the following ladder: 1 1 2 1 2 3 1 2 3 4 In short, my program will read a positive integer from stdin and print this ladder to the o...
Two ambassadors at a UN conference want to speak to each other, but unfortunately each one only speaks one language- and they're not the same language. Fortunately, they have access to several translators, who each understand and speak a few languages. Your task is to determine the shortest chain of translators (since ...
Background Ada is a programming language that is not exactly known for its terseness. However, its array literal syntax can in theory allow for fairly terse array specifications. Here is a simple EBNF description of the array literal syntax (passable to bottlecaps.de: array ::= positional_array | named_array positional...
Given a natural number \$n\$, return the \$n\$-th cuban prime. Cuban Primes A cuban prime is a prime number of the form $$p = \frac{x^3-y^3}{x-y}$$ where \$y>0\$ and \$x = 1+y\$ or \$x = 2+y\$ Details You may use 0 or 1 based indexing, whatever suits you best. You can return the \$n\$-th prime given the index \$n\$ or...
Introduction In the strange world of integer numbers, divisors are like assets and they use to call "rich" the numbers having more divisors than their reversal, while they call "poor" the ones having less divisors than their reversal. For example, the number \$2401\$ has five divisors : \$1,7,49,343,2401\$, while its r...
According to http://en.cppreference.com/w/cpp/language/integer_literal, integer literals consist of a decimal/hex/octal/binary literal and a optional integer suffix, that is obviously completely unnecessary, wastes precious bytes and is not used in this challenge. A decimal literal is a non-zero decimal digit (1, 2, 3,...
"Bracket" numerals are a type of 'numerals' I made up once, and thought would be a nice challenge here. Basically, you convert the input number into base 6, and then transliterate the 012345 respectively with ()[]{}†, so every 0 becomes (, every 1 becomes ), etc. You don't have to use ()[]{} per se. As long as you spec...
The gambler's fallacy is a cognitive bias where we mistakenly expect things that have occurred often to be less likely to occur in the future and things that have not occurred in a while to be more likely to happen soon. Your task is to implement a specific version of this. Challenge Explanation Write a function that r...
Or, "Swap the first and last letters of each word" Your challenge is to, given a string of alphabetical ASCII characters as well as one other character to use as a delimiter (to separate each word), swap the first and last letters of each word. If there is a one-character word, leave it alone. The examples/testcases us...
I have so many secrets and nowhere to keep them! The goal is simple: write a program that lets you save a string and have it be protected by a password. The program will take an alias, password and (optional) secret as parameters. If this is the first time the program is called with a given alias, then it will store/re...
This challenge is about building a chessboard in which the square size, instead of being constant across the board, follows a certain non-decreasing sequence, as described below. The board is defined iteratively. A board of size \$n \times n\$ is enlarged to size \$(n+k)\times(n+k)\$ by extending it down and to the rig...
Given an ASCII art hexagon as input, output one whose sides are all one unit longer. _____ ____ / \ / \ / \ / \ / \ \ \ => \ \ \ / \ / \____/ \ / \_____/ ...
Given a string, you've to split it into groups of three characters (by padding _ at the end). Related, but still it's different. Sample I/O: 'abcde' -> 'abc', 'de_' '1234' -> '123', '4__' '' -> [] or falsey value 'Three spree!' -> 'Thr', 'ee ', 'spr', 'ee!' 6 MB string This is a code-golf, so fewest bytes wil...
Your task is to generate a graph with 54 vertices, each corresponds to a facet on a Rubik's cube. There is an edge between two vertices iff the corresponding facets share a side. Rules You may choose to output an adjacency list, adjacency matrix, edge list, or any reasonable format to represent a graph in an algorithm...
In this challenge, your bot has landed on an island with the stereotypical knights and knaves. Knights always tell the truth, and knaves always lie. The objective is to find the correct 32 digit hexadecimal string before anyone else, by asking knights and knaves and trying to trick other bots into giving you answers or...