instruction stringlengths 34 53.1k |
|---|
Your boss has found out that quite a bunch of his employees (including you) like to steal code from others. He ordered you to write him a program that he can use to find people who steal code from others.
Task:
Write a program/function that detects if somebody copied (part of) his code from somewhere else.
The progra... |
map is a very basic yet important function in functional programming.
All FP programming languages have it built-in but it is always fun to see how shortly you can define it yourself.
This will be scored in AST nodes, not bytes.
A token is the second-smallest building block of a program, over characters.
A token is:
a... |
Given a string of ASCII characters, output the character that is in the middle. If there is no middle character (when the string has an even length), output the ASCII character whose ordinal is the floored average of the two center characters. If the string is empty, an empty string should be output.
Test cases:
12345 ... |
Let's say I have a condition expression x and that I want to check if it is TRUE or FALSE depending on the value of a boolean y:
y ? x : !x
Is there a way to express it without repeating x expression? Something like how we can get a number or its opposite depending on a bool, without repeating the number in the expres... |
Background
Today (or Yesterday) is (or was) 11/23 or Fibonacci day! What better way to celebrate than to make a Fibonacci cake?
Examples
3
ii
i_i_ii_i_i
</>
8
ii
ii
ii
ii
ii ... |
Given a character, output (to the screen) the entire qwerty keyboard layout (with spaces and newlines) that follows the character. The examples make it clear.
Input 1
f
Output 1
g h j k l
z x c v b n m
Input 2
q
Output 2
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
Input 3
m
Output 3
(Program terminates witho... |
What is Toothpick Sequence?
According to Wikipedia
In geometry, the toothpick sequence is a sequence of 2-dimensional
patterns which can be formed by repeatedly adding line segments
("toothpicks") to the previous pattern in the sequence.
The first stage of the design is a single "toothpick", or line
segment. Each stag... |
There's a question on this site that is similar to this question, but I have added a twist.
You have three inputs, the number of people in the circle n, the k-th person counted out at each step, and the q-th person that survives. The people in the circle are numbered 1 to n.
For example, in a circle of 20 people, the 2... |
A typo is said to have occurred if:
A character is missing.
A character is extra.
A character is replaced with another wrong character.
For the purpose of this challenge, only lowercase characters and spaces are used.
Input will be a dictionary of words, followed by one line of input. You need to find the (minimum) n... |
Why a Simulator?
Kids these days don't have the time nor the ambition to actually go and stack boxes on the see-saw or play around with balancing physical objects. This leaves lots of room in the software market for a Lever Simulator which will, according to my models, sell like mad!
Programming Help Wanted
I've filed ... |
These days, I watched on TV a Gay Pride parade; at the time, I was thinking about quines and how they're a bit queer, outputting themselves (out of the closet?) and, well, why not combine both things into a Quine Pride Parade?
The challenge is to write a program that:
Is a quine.
Prints the sentence I am a quine writ... |
A fun programming exercise is to write a program that quizzes the user from a set list of questions and answers. However, this task goes a level beyond that.
Your task
Write a program/func/etc. that takes two lists: A list of questions and a list of answers.
Output a program that quizzes the user.
The output program s... |
I enjoy participating in math competitions run by Mu Alpha Theta, a mathematics honor society in the United States. At competitions, I take a 30-question multiple choice test. There are five choices per question, labeled A through E.
My score on a test is four points for each correct answer, zero points for a question ... |
Goal:
Your goal is to print out numbers within a given range (Also including given values).
Input Format:
The input will look like:
(int-int, int-int, ...)
... meaning the user can add as many int-int as they'd like.
Other Info:
You will only have to handle non-negative integer numbers.
The first integer in int-int wi... |
The goal of this challenge is to find the direction and area enclosed by a loop.
Input:
A rectangular grid consisting entirely of these characters: ^v<>
(Optionally, you may also be given the dimensions of the grid before the grid itself in decimal with a prefix, suffix, and separator character of your choice.)
A loop ... |
You are given a set of positive integers. You must arrange them into pairs such that:
Each pair contains 2 numbers, one of which is a multiple of another. For example, 8 is a multiple of 4, and 9 is a multiple of 9.
If the same number occurs many times in the initial set, it can be used that many times in the pairs; a... |
Come November 1, Programming Puzzles and Code Golf will graduate, so in the next 11 months, we'll want to save some memories from when we were ungraduated.
Write a program that produces the PPCG favicon, seen below.
The image must be at least 64x64 pixels.
The blue must be the color #62B0DF. The background can be whi... |
The goal of this challenge is to produce an animation of a chain drive system, comprised of a set of sprocket gears connected together by a chain.
General Requirements
Your program will be given a list of sprockets, specified as (x, y, radius) triplets.
The resulting chain drive system is comprised of these sprockets, ... |
Background
Some holidays have fixed, easy-to-remember dates, like Oct 31, Dec 25, etc. Some, however, want to be troublesome. They're specified as things like "the first Monday in September" or "the fourth Thursday in November". How am I supposed to know when that is?
All I know is that Thanksgiving is fast approaching... |
Introduction
You are the manager of the electronics department in a major retail store and the biggest sales day of the year is this Friday. To help manage the crowds, your store is implementing a ticket system for the biggest deals, where customers must present a ticket before purchasing an item. Your job is to write ... |
Given a non-negative number n, output the number of ways to express n as the sum of two squares of integers n == a^2 + b^2 (OEIS A004018). Note that a and b can be positive, negative, or zero, and their order matters. Fewest bytes wins.
For example, n=25 gives 12 because 25 can be expressed as
(5)^2 + (0)^2
(4)^2 + (... |
Background
You are bored in class, and having exhausted all the possible things to write on a standard calculator (Like 8008135) you turn to the periodic table. You want to figure out if you can write your message using the shorthand for chemical elements.
This is the inverse of this challenge.
The Challenge
Input: A... |
Background
You are sitting in chemistry class and your friend keep sending you these strange letters. It is your job to decrypt the messages into words.
This is the inverse of this challenge.
The Challenge
Input: A list or a string of integers from 1 to 118.
Output: The words for each chemical element if possible. Ot... |
dary!
In events entirely unrelated to what will hopefully happen to me in the next couple of days, I task you to write code that does the following:
Print
Legen... wait for it...
immediately, with a trailing newline.
Wait until the next full hour (when the cron job for awarding the badge runs).
Print
dary!
with an o... |
(Hopefully it's still Thanksgiving for you)
You got a turkey for your thanksgiving dinner but you don't know how to evenly distribute it. The problem is, some people eat more than others, so you need to find a solution
Input
There will be two inputs. The first will be an ascii art of various people.
o
o \|/
\|/ ... |
You should write 3 programs and/or functions in one language.
All of these programs should solve the same task but they all should give different (but valid) outputs. (I.e. for every pair of programs their should be some input which generates different (but valid) sets of output numbers.)
The task
You are given an int... |
The goal of this challenge is to determine the angle of a line in a image.
Rules on the image:
The image background will be white (#FFFFFF)
The stroke of the line will be black (#000000)
The line will NOT be anti-aliased
The image will be 100x100 pixels
The line will start at the center of the image
The line will sta... |
Goal
Write a full program that generates a map showing the local train stations and which train station is the closest to every point on the map.
Requirements
Input
A set of tuples. The first is the (Width,Height) dimensions of the map. The following tuples are the (X,Y) coordinates of each train station. Coordinate... |
One aspect of password strength testing is runs of adjacent letters on the keyboard. In this challenge, a program must be created that returns true if a string contains any runs of adjacent letters.
What counts as a run of adjacent letters?
For this simplified version of a password strength tester, a run of adjacent ch... |
Introduction
This is a very simple challenge: simply count the divisors of a number. We've had a similar but more complicated challenge before, but I'm intending this one to be entry-level.
The Challenge
Create a program or function that, given one strictly positive integer N, outputs or returns how many divisors it ha... |
It's friday! Which means it's time for beer!
Sadly though, today we will be golfing beer instead of drinking it. :(
Challenge
Output a beer and drink it. The amount of sips you take changes your output.
Sips
Your program should take one input string. This string can solely consist out of concatenated sips.
If the input... |
This challenge is based on a problem described in D. Parnas, On the criteria to be used in decomposing systems into modules, and elaborated upon in J. Morris, Real Programming in Functional Languages.
Write a program or function which takes a list of book titles from stdin or as an argument, in a reasonable, convenient... |
Challenge
Make an error-checker in the least amount of possible bytes! If you received an HTML program as a string through standard input, your program will be able to find all the errors and return to standard output. If the program is over 2000 characters, return that as an error too.
Errors
As there has been discrep... |
Challenge
You must output the current time continuously (until cancelled by an interrupt), once every second, by any of the following means:
It must be in 24-hour or AM/PM format.
If it is the former, it must be spaced out with colons (i.e. 15:47:36).
If it is the latter, it must be spaced out with colons and have t... |
Introduction
The LaTeX typesetting system uses macros for defining accents.
For example, the letter ê is produced by \hat{e}.
In this challenge, your task is to implement an ASCII version of this functionality.
Input
Your input is a non-empty string of printable ASCII characters.
It will not contain newlines.
Output
Yo... |
A man has two devices.
A time machine - He can control this machine by thinking. It allows him to travel from any point in time to another point in time in the past or future (or even the present point in time) in no time at all. Note that if he travels to the past from B to A, then all normal events (time machines, a... |
Pretty simple challenge today:
Write a program or function that takes in a positive integer N and prints or returns a sorted list of the unique numbers that appear in the multiplication table whose row and column multiplicands both range from 1 to N inclusive.
The list may be sorted in ascending order (smallest to larg... |
This one is inspired by Calvin's Hobbies recent multiplication table challenge.
Write a function or program that takes an integer N as input and prints or returns a N-by-N unique multiplication spiral. The code must (in theory) work for N between 0 and 1000 (outputting this can be hard though). The output should be equ... |
Whenever I search for the running length of a movie in IMDb, it is displayed in minutes. Immediately I would try to convert it into hour(s) and minute(s). It would be better if we could automate this.
Input:
150 min
Output:
2 hours 30 minutes
Input:
90 min
Output:
1 hour 30 minutes
Input:
61 min
Output:
1 hour 1 m... |
Introduction
By steganography we mean hiding a message along an existing text or image so the result would be unsuspicious of the existence of the original message. This challenge is about hiding data in Unicode variants of a grapheme called homoglyphs. For instance:
cyrillic Е (ye) appears the same as latin E which ap... |
Write a program or function that takes in three positive integers, W, H, and N. Print or return a W×H grid of .'s where every Nth . in normal English reading order is replaced with an X.
For example, given W = 7, H = 3, N = 3, the grid is 7 characters wide and 3 high, and every third character reading from the top left... |
Today your challenge is to produce all possible full parenthesizations of an expression.
Your input is a single line of printable ASCII containing one or more terms separated by operators. The input might also contains spaces - you must ignore these. A term is [a-zA-Z0-9], an operator is [^ ()a-zA-Z0-9]. You may assume... |
As part of a city planning project, you've gotten the assignment of creating a program or function that will display the city skyline, given some input from the architects. The project is only in the startup phase, so a very rough sketch is sufficient. The easiest approach is of course to simply draw the skyline in ASC... |
Write a program or function that takes in a positive integer N.
When N is 1, output
/\
\/
When N is 2, output
/\/\
\/ /
/ /
\/
When N is 3, output
/\/\/\
\/ / /
/ / /
\/ /
/ /
\/
When N is 4, output
/\/\/\/\
\/ / / /
/ / / /
\/ / /
/ / /
\/ /
/ /
\/
For larger N the pattern continues, a new layer is added every tim... |
In this challenge you will compute numbers from a curious sequence.
Your input is a single decimal nonnegative integer. Reverse the bits in this integer and then square the number to get the required output.
When reversing the bits you must not use any leading zeroes in the input. For example:
26 (base 10) = 11010 (bas... |
Implement a FUSE filesystem in minimum bytes.
Your program must do three things:
Mounting the virtual filesystem to a directory
Handling requests to enumerate files in that directory (showing one file)
Handling requests to read the file in that directory
Rules:
ls (a system program, you don't need to implement it) m... |
Romanization of Japanese is converting Japanese text into Latin characters. In this challenge, you will be given a string of Japanese characters as input and expected to convert them to the correct ASCII string.
What You'll Need To Know
The Japanese language has three writing systems: hiragana (the curvy one used for s... |
Count the number of sides on a polygon
The polygon-side-counting robot has decided to travel the world without telling anyone before, but it is crucial that the process of polygon counting is not stopped for too long. So you have following task: Given a black and white image of a polygon, your program/functoin should r... |
Write a program or function that takes in a string guaranteed to only contain printable ASCII characters except for space, and to be a positive triangular number (1, 3, 6, 10, 15, ...) in length.
Print or return the same string, but shaped into a triangle using spaces. Some examples will best show what I mean:
If the i... |
Given two inputs q n determine if q is a quadratic residue of n.
That is, is there an x where x**2 == q (mod n) or is q a square mod n?
Input
Two integers q and n, where q and n are any integers 0 <= q < n.
Output
A truthy or a falsey.
Optionally, print any (or all) x that is x**2 == q (mod n)
Examples
>>> quadratic_re... |
In a round of the prisoner's dilemma exercise, two players each decide whether to cooperate or defect for that round. The scoring for a round is:
Player A and Player B both cooperate: 1 point for both
Player A and Player B both defect: 2 points for both
Player A cooperates and Player B defects: 3 points for cooperatin... |
Relevant links here and here, but here is the short version:
You have an input of two integers \$a\$ and \$b\$ between negative infinity and infinity (though if necessary, I can restrict the range, but the function must still accept negative inputs).
Definition of the Kronecker symbol
You must return the Kronecker symb... |
The Bernoulli numbers (specifically, the second Bernoulli numbers) are defined by the following recursive definition:
Where denotes a combination.
Given a nonnegative integer m as input, output the decimal representation OR a reduced fraction for the mth second Bernoulli number. If you output a decimal representation... |
Background
This challenge is about the stochastic block model.
Basically, you are given an undirected graph, where the nodes represent people, and the edges represent social connections between them.
The people are divided into two "communities", and two people are more likely to have a connection if they are in the sa... |
A polynomial is divisible by a factor (x-n) if f(n)=0 for a function f. Your job: to determine if a polynomial function f(x) is divisible by (x-n).
The input
The input is in the form of (x-n), (Polynomial). Remember, if n is negative, (x-n) will be in the input form of (x+n). For the polynomial, all exponents will... |
So, like the title says, today you are going to guess my password (sort of). You need to make a big long list of every possible password I might be using on my 4 digit online vault.
Specifications:
It could contain any 26 letters of the alphabet in UPPER CASE.
It could contain any numbers 0-9.
So, basically, each di... |
The Method of Finite Differences is a technique used to find the next term in a sequence of numbers, given that the sequence is governed by consecutive values of a certain polynomial. Given a list of n terms, the Method will be able to determine the degree of the polynomial, which is a maximum of n+1.
The Method works ... |
Golf a Purple Interpreter
Purple is an esolang which is designed with two main purposes:
To be a minimization of Aubergine, since there just aren't enough self-modifying one-instruction languages around.
To admit the possibility of terrifyingly small golfed interpreters. My first pass at a reasonably full-featured Pyt... |
Can't see emoji? Click here.
You will simulate a vending machine. The items are 56 different emojis, which can be represented as two surrogate UTF-8 characters, from: (U+D83C U+DF45) to
(U+D83C U+DF7C). In HTML these emojis can be represented in UTF-16 form as 🍅 through 🍼. In base 10 the first UTF-8 char... |
This king-of-the-hill challenge is based off of the game show, Weakest Link. For those unfamiliar with the show, the crux of this challenge deals with who you vote off:
If the other players are smarter than you, then you have less of a chance of getting the pot.
If the other players are dumber than you, then you have... |
Introduction
A normal checkers board contains 8 x 8 = 64 squares:
You can see that in total, there are 12 white pieces. Black and white always have the same amount of pieces. If there are any more pieces on the board, the pieces would neighbouring, which is not allowed for this challenge. To clarify things, here are s... |
Time for another maze challenge, but not as you know it.
The rules for this challenge are a little different than most maze challenges. The tile types are defined as follows:
S: The location on the maze you start at
E: The location you are trying to get to
0: Wall that you can't cross
+: Floor that you can cross
You ... |
I recently ordered some new and colorful tiles to replace my boring old white tiling for my kitchen. However, when the tiles arrived, they were all in a weird shape! Therefore, I need a program to figure out how to arrange the tiles so that I need to use as few of my old boring white tiling as possible.
Even though t... |
You are given a nonnegative integer n and an integer p >= 2. You need to add some p-th powers (p=2 means squares, p=3 means cubes) together to get n. This is always for any nonnegative n, but you don't know many p-th powers (of any positive integer) you'll need.
This is your task: find the minimum number of p-th powers... |
Preamble
Integers are always either even or odd. Even integers are divisible by two, odd integers are not.
When you add two integers you can infer whether the result will be even or odd based on whether the summands were even or odd:
Even + Even = Even
Even + Odd = Odd
Odd + Even = Odd
Odd + Odd = Even
Likewise, when... |
You will be given a (possibly empty) string containing brackets ([{()}]) and any other characters (A-Z, a-z, 0-9, punctuation). You need to check if it adheres to the following rules:
Non-bracket characters are ignored.
Every open bracket [{( has a closing bracket )}]. So []( is not allowed.
Brackets are nested proper... |
I love ><>, ><> is life! 2D langages are amazing!
In this challenge, you will have to say if a "fishy" road has an end,
while code-golfing.
Definition
A fishy road is constructed with tiles, including the following ones:
v (go down)
> (go right)
^ (go up)
< (go left)
/ (mirror)
\ (mirror)
Any other character (except -... |
There's quite a few challenges on this site that ask you to print out a sequence, and this is no exception.
(The following explanation of the sequence for this challenge assumes the symbols in the sequence are 0 and 1.)
The recursive definition of the Thue-Morse sequence is that
T_0 = 0
T_2n = T_n
T_2n+1 = 1 - T_n
A ... |
Background
I have constructed a simple obstacle course by placing boxes in a rectangular room.
Now I want to count the number of essentially different ways in which it can be solved.
I need you to write me a program for that.
Input
Your input is a non-empty rectangular array of the characters .#.
The dots . are empty s... |
Write a program or function that takes an array of non-negative integers as input and outputs a set of vectors/arrays with the elements of the input array in order, split so that each vector sums up to 15. If the sum of the first N elements doesn't "hit 15", then the number that made it pass 15 must be cut off, and the... |
The formatting order of dates is one of the most complex and divisive issues the world faces today. Some of us vehemently argue that Month/Day/Year is appropriate, considering that's how we say dates out loud. Others loudly proclaim that Day/Month/Year is best, because it puts the terms in ascending order of the durati... |
Time for you to implement my new stack based language! It's called StackyMath. This will be a stack based language with 8 operations on the stack and ways to add numbers to the stack.
List of operations:
/: Division. Performed on the top 2 numbers of the stack. Pushes the result back on the stack.
*: Multiplication. P... |
Write a piece of code that is executable in at least three different languages. The code must output the integer 1 in language number one, 2 in language number two, 3 in language number three etc.
Rules:
The output must be only the integer, but trailing newlines are OK.
The code can't take input of any kind
Different... |
Introduction
The International System of Units is a system of measuring all around the world, except for a few countries including the US. The SI system (or metric system) is based on powers of ten, listed below (note that this is an incomplete table):
femto(f) pico(p) nano(n) micro(μ) milli(m) centi(c) (base unit) hec... |
Background
Alice and Bob are creating a golfing language to win every single PPCG challenge.
Alice wants to make a two-dimensional language, like ><>, but Bob prefers a prefix-infix syntax like in J.
As a compromise, they decide to create a two-dimensional prefix-infix language.
The parser is a pain to write, and they ... |
Your task is to analyse the input and output the formula for the n-th term if it is an arithmetic sequence, otherwise it should print "NAAP".
Input
Input (from STDIN) will consist of few numbers, between 4 to 10 numbers where each number will be in the range between -1000 and 1000 inclusive, separated by a delimiter (... |
The idea of this challenge is simple: create a bot to play the card game Euchre.
For those of you who don't already know them, I've written out the rules to Euchre here as they pertain to this challenge.
I recommend using python or something similar, but the only real restriction is that it has to be compatible with th... |
Challenge: make a program that outputs a MD5 hash of its source code.
You should not use tricks that would be considered cheating in a quine sense (discussed here).
Using built-in functions and external libraries is allowed. The program should be a full program (not a function/subroutine). Code-golf: shortest solution ... |
Challenge
¡We're going to give exclamation and question marks inverted buddies!
Given a body of text containing sentences ending in ., ?, or !, prepend inverted question marks, ¿, to interrogative sentences (sentences ending in ?) and inverted exclamation marks, ¡, to exclamatory (sentences ending in !). Sentences endi... |
Inspired by https://puzzling.stackexchange.com/questions/24334/to-catch-a-thief
You are given an n by n (n itself is optional input) grid filled with 0s and 1s (or any other character of your choice). You aim is to make every cell the same (either 0 or 1). You can make a series of moves as defined below (note dissimila... |
The objective of this challenge is to write a program to convert an inputed string of what can be assumed as containing only letters and numbers from as many bases between 2 and 36 as possible, and find the base 10 sum of the results.
The input string will be converted to all the bases in which the number would be defi... |
Inspired by this SO question
As input you will be given a non-empty list of integers, where the first value is guaranteed to be non-zero. To construct the output, walk from the start of the list, outputting each non-zero value along the way. When you encounter a zero, instead repeat the value you most recently added to... |
A numeronym (also known as a "numerical contraction") is when a word is shortened using numbers. A common contraction method is to use the length of the replaced substring to replace all but the first and last characters. For example, use i18n instead of internationalization, or L10n instead of localization. (The L is ... |
Introduction
When solving a rubiks cube, one often write down the times like this
11.91, (11.28), (12.32)
This is called a average of 3, while a average of 5 looks like this
13.36, (11.89), 12.31, (16.44), 12.26
Note how the worst and best times have parenthesis around them. When calculating the average of 5 these ti... |
Elixir is a relatively new functional language, which I've taken a deep interest in. I'd like to get general tips about golfing in Elixir and learn techniques that can be applied to code-golf problems that are somewhat specific to Elixir in general.
Based on so many similar questions about Python, Ruby, Javascript, et... |
Italian zipcodes are 5-digit numbers. Each number is linked to a province. There are 4610 zipcodes and 110 provinces (as of 2015) in Italy.
Given the list of zipcodes and the related province (in this file - Gist here) write a function (any language would be fine) that, accepting in input an Italian zipcode, writes out... |
Given a number N, the challenge is to get the sum of the pyramid of N primes. To clarify things, here is an example:
Input: 4
We will list the first 4 primes, and then compute the sum of them. After that, we will compute the sums of the sums, and so on:
2
> 5
3 > 13
> 8 > 33
5 > 20
> 12
... |
Write a function that takes two parameters: a positive integer n and a list of words.
Given a cube of n-by-n-by-n units, assign a random letter (A-Z) to each surface unit. (For a 3x3x3 cube, there would be 9 surface units on each face.)
Then determine whether it's possible for an ant walking along the surface (with th... |
Following the fine tradition of questions such as Find the largest prime whose length, sum and product is prime , this is a variant on a largest prime challenge.
Input
Your code should not take any input.
Definition
We say a prime p is good if p-1 has exactly 2 distinct prime factors.
Output
Your code should output the... |
A regular polygon is a polygon that is equiangular (all angles are equal in measure) and equilateral (all sides have the same length).
Your job is to find out if a given polygon is regular or not.
Specs
You will be given a list of Cartesian coordinate 2-tuples which describe the polygon's vertices.
The points will alw... |
Write a program or function that takes in a nonempty list of integers in any reasonable convenient format such as 4, 0, -1, -6, 2 or [4 0 -1 -6 2].
Print or return a string that depicts the list as an ASCII art forest where each number becomes a tree of proportional height. Each tree takes up four columns of text in t... |
Programming Puzzles & Code Golf has opened a taco truck! The word is out and now users from all over the Stack Exchange network are coming to try our tasty, authentic ASCII tacos. We need your help to ensure that everyone gets their orders in a timely manner. There isn't a whole lot of room inside food trucks, so you'l... |
Pythagoras had his leg blown up in the war. It had to be amputated, and though he nearly died, he pulled through and made a full recovery. Now, after a year of walking with crutches, he gets the privilege of getting a prosthetic leg! Thing is, though, there are several that fit, but which ones?
The Task
Given a positiv... |
Take a look at the sevens multiplication table from 7×0 to 7×9:
0, 7, 14, 21, 28, 35, 42, 49, 56, 63
If we just look at the digits in the one's place we get a permutation of the digits 0 through 9:
0, 7, 4, 1, 8, 5, 2, 9, 6, 3
Consider taking some positive decimal integer N and replacing each digit D in N with the th... |
This challenge is based off a riddle I read in some book a while ago, which I found again here. It is about bullets fired from a gun once per second at varying speeds that travel in a straight line forever. When one bullet hits another, both are destroyed completely. (Feel free to replace all instances of "bullet" with... |
Suppose one day you are digging through your big box of unused computer cords and adapters (USB to USB mini, VGA to DVI, etc.). There are tangled cords everywhere making quite a mess, and you wonder if you could simplify things by attaching all the cords together in one long strand, and then just rolling it up.
The que... |
Hilbert numbers are defined as positive integers of the form 4n + 1 for n >= 0. The first few Hilbert numbers are:
1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97
The Hilbert number sequence is given by OEIS sequence A016813.
A related number sequence, the Hilbert primes... |
Specification
This challenge is simple to state: your input is a non-empty array of nonnegative integers, and your task is to partition it into as few increasing subsequences as possible.
More formally, if the input array is A, then the output is an array of arrays B such that:
Each arrays in B form a partition of A i... |
Given an input n where 3 <= n <= 25, perform the following steps, starting with a single n-sided die (faces in the range [1, n], inclusive):
Print the result of rolling the current n-sided dice in play, in the form kdn: X (where X is the result and k is the number of dice in play).
If X is greater than or equal to n/2... |
Find the Intersection of 2 Sets in Unioned Interval Notation
Given two sets of real numbers described as the union of intervals, output a description of the intersection of these two sets as a union of the same type of interval.
The input sets will always consist of unions of intervals such that each interval begins a... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.