instruction stringlengths 34 53.1k |
|---|
This challenge is simple, given a decimal number, convert to binary, and calculate the sum of the sub-strings of the binary number, whose length is shorter than the original number. Here is an example:
Input:
11
Binary:
11 -> 1011
Substrings:
101 = 5
011 = 3
10 = 2
01 = 1
11 = 3
1 = 1
0 = 0
1... |
Given an input of a list of slices of a string, output the original string.
Each slice will be given as a list of length 2, containing the start position
of the slice (an integer ≥0) and the slice itself. If your language does not
support arrays of arbitrary types, you may also take this as a struct or
similar, or simp... |
If you've ever learned about primes in math class, you've probably have had to, at one point, determine if a number is prime. You've probably messed up while you were still learning them, for example, mistaking 39 for a prime. Well, not to worry, as 39 is a semiprime, i.e., that it is the product of two primes.
Similar... |
Input description
A string (for best results, all characters should be printable and be the same width).
Output description
A character star following the pattern:
0 0 0
1 1 1
222
0123210
222
1 1 1
0 0 0
where 0, 1 ... are subsequent characters of the string. The output does not necessarily have to be ... |
Introduction
You are probably familiar with the "puts on sunglasses" emoticon-meme:
(•_•)
( •_•)>⌐■-■
(⌐■_■)
In this challenge, your task is to take the first line as input, and output the last one, effectively putting sunglasses on that little button-eyed person.
To make the task a bit more difficult, the characters ... |
Taxicab Numbers or OEIS A011541 are the least numbers that are able to be represented as \$n\$ different sums of two positive cubed integers, for successive \$n\$.
You'll need to print out the \$n\$th taxicab number. This should work for any \$n\$ in theory.
However, as only 6 taxicab numbers have been discovered so fa... |
A lipogram is a block of words that omits a particular symbol. Right now, I am avoiding our fifth symbol of 26 that commonly show up. You should know by now what I am omitting. If not, look up "lipogram" and you will know.
Your Task
With a char, a blank, and a following string (blanks may show up in this; with only ASC... |
Inspired by Draw a timeline.
Given a timeline of events, output the date for each event.
A timeline will be given in the form
2000
--AF-C-------E--D---B--
Where the first line shows a known point in time. The known year is always the character below the first digit of the known year
You may assume:
On the timelin... |
Given a number > 0, output the sum with all digits (1 .. n) concatenated and reversed and add them up. For example, with n = 6:
The numbers 1 to 6 concatenated:
123456
Reversed:
654321
Adding them up together will result in: 777777. Another example is n = 11:
1 2 3 4 5 6 7 8 9 10 11 > 1234567891011
and
11 10 9 8 7 6... |
Challenge
You will be given a positive integer n as input. Output should be a pyramid-like sandpile built on the rules specified below:
Each integer "falls" downward from the same initial starting point, like sand falling into a conal-shape.
Numbers greater than the number directly below it when it hits the sandpile ... |
Related: Program my microwave oven and Generate lazy values.
My colleague is so lazy that he doesn't even bother to move his finger when programming the microwave oven. (This is actually true!)
Help him find the microwave input that gives the time closest to what he wants, but where all digits are the same. If two inpu... |
Related: Program my microwave oven. Inspired by Generate lazy microwave input.
The lazy value of the non-negative integer N is the smallest of the integers that are closest to N while all their digits are identical.
Return (by any means) the lazy value of a given (by any means) N.
N ≤ the largest integer that your lang... |
While bored in high-school (when I was half my current age...), I found that \$f(x) = x^{x^{-1}}\$ had some interesting properties, including e.g. that the maximum \$f\$ for \$0 ≤ x\$ is \$f(e)\$, and that the binding energy per nucleon of an isotope can be approximated as \$6 × f(x ÷ 21)\$...
Anyway, write the shortes... |
Write a function or program which, given a number of lines and columns, generates a corresponding tabular environment for LaTeX with no data in it.
Table format and tabular Environment
Here is an example of a table with 2 rows and 4 columns:
As you can see, we do not count the first row nor do we count the first colum... |
Sliding doors have varying prices based on the width of the doors. The different prices are as follows:
60 - 80 cm: ¤150
81 - 100 cm: ¤200
101 - 120 cm: ¤220
When buying a closet you would obviously want to minimize the cost, so your task is to find the width of the doors that minimizes the total cost based on the... |
Inspired by Copied from this question at Stack Overflow.
Given a matrix A, create a matrix B such that the columns of A are arranged in a block-diagonal fashion. For example, given
1 2 3
4 5 6
the output would be
1 0 0
4 0 0
0 2 0
0 5 0
0 0 3
0 0 6
Rules
Input and output may be in the form of 2D arrays, nested arrays... |
I hope this picture looks familiar to you.
It's one of Pacman's ghosts in his "vulnerable" state, after Pacman has eaten a power pill.
The challenge
Picture our ghost in a little frame, using ASCII art. At normal scale (more about this later), each square in the above image should correspond to one character, and the ... |
A friend of yours has given you directions to the best restaurant in town. It's a series of left and right turns. Unfortunately, they forgot to mention for how long you need to go straight ahead between those turns. Luckily you have a street map with all the restaurants on it. Maybe you can figure out which restaurant ... |
The SAS programming language is a clunky, archaic language dating back to 1966 that's still in use today. The original compiler was written in PL/I, and indeed much of the syntax derives from PL/I. SAS also has a preprocessor macro language which derives from that of PL/I as well. In this challenge, you'll be interpret... |
Context
Straw Poll is a website that is meant for the creation of simple/informal polls. Provided with a list of options, the user can select their choice(s), and the votes are tallied up. There's two very important features of a Straw Poll:
It is possible to view the current results before voting
It is often possib... |
As we learned from The Holy Numbers, there are 5 holy digits (0, 4, 6, 8, 9), and positive integers consisting solely of those digits are holy. Additionally, the holiness of a number is the sum of the holes in the number (+2 for every 0 or 8, and +1 otherwise).
Now, there is an additional property to take into consider... |
In almost every row nowadays, the people tends to order themselves as militaries would do.
Challenge
Suppose 4 people where:
person 1 has priority against person 2, 3 and 4,
person 2 has priority against person 3 and 4,
person 3 has priority against person 4,
person 4 has the lowest priority.
Then, when ordering thos... |
The task
This is a simple challenge.
Your input is a single non-empty string, containing only digits 0123456789 and hashes #.
It will contain exactly one run of digits, which encodes a nonnegative integer and may wrap around the end of the string, and at least one #.
The integer may have leading zeroes.
For example, ##... |
While Rust is very, very rarely competitive in code golfing competitions (Java is often shorter), it can still be fun to golf in. What are some tricks for making Rust code shorter?
Please post only one tip in each answer.
|
Note: This challenge has been changed to eliminate the strict whitespace manipulation requirements that made this challenge low-quality. Some rules regarding whitespace have been changed.
I'm rather good at mental math, particularly adding positive integers in my head. Here is my method for adding the numbers together... |
Totally not inspired by Visualize long division with ASCII art ;)
Your job is to show long hand addition with ASCII art. You solve longhand addition by adding up the columns right to left, placing the value of the ones place in the result, and carrying the tens place over to the top of the next column.
Input
Input can ... |
A struggling manufacturer named Tennessee Instrumental is desperate to get into the calculator business. Problem is, they don't have any software engineers on payroll, and the deadline is coming up fast.
It's your job to help TI configure a basic calculus-ready calculator that can simplify expressions input as strings... |
It's become somewhat of a tradition in PPCG that some users temporarily change their names by an anagram (a new name formed by reordering the letters of the old).
Sometimes it gets difficult to find out who is who. I could use a program or function to tell if two phrases are anagrams of each other.
The challenge
The pr... |
Welcome to BBC Casting. We need a program that we can use to select a new actor to play The Doctor on Doctor Who. In the spirit of the show, your program will perform a regeneration from one actor's name to the next.
We will test your program by running through the 13 names of actors who have already played The Doctor ... |
Background
I wanted to make a pretty word cloud, like this:
these are
words
floating
I computed the (x,y)-coordinates of the first letter of each word, plugged them into my word cloud generator, and let it do its job.
However, I accidentally used (y,x)-coordinates, so the result looks like this:
these ... |
No one is quite certain what the emoticon >:U is intended to represent, but many scholars believe it looks like an angry duck. Let's assume that's the case.
Task
Given an integer n between 0 and 3 inclusive, print or return
quack
if n = 0,
>:U
if n = 1,
U U
> : U U
> U U
> : U U
UUU
if n = 2,... |
This challenge is similar to this old
one, but with some unclear
parts of the spec hammered out and less strict I/O requirements.
Given an input of a string consisting of only printable ASCII and newlines,
output its various metrics (byte, word, line count).
The metrics that you must output are as follows:
Byte count... |
The Challenge:
Find if a number contains a digit. The number and the digit are to be taken as input. Output must be a boolean value. But you are not allowed to use the string representation of the number at any time. Now don't count upon a char* either. You must devise a mathematical way to do it.
Rules:
• You can't us... |
π(n) is the number of primes less than or equal to n.
Input: a natural number, n.
Output: π(n).
Scoring: This is a fastest-code challenge. Score will be the sum of times for the score cases. I will time each entry on my computer.
Rules and Details
Your code should work for n up to 2 billion ( 2,000,000,000 ).
Bui... |
Given a set of letters, output all strings made of those letters. (This is Kleene star of the set.) For example, for {'a','b'}, the strings are:
'', 'a', 'b', 'aa', 'ab', 'ba', 'bb', 'aaa', 'aab', ...
Input: A non-empty collection of distinct letters a..z. These may be characters or single-character strings.
Output: A... |
Introduction
As an example, let's take the number 7. We then duplicate this and place 7 spaces in between. We get this:
7_______7
After that, we are going to decrease the number, until there are no spaces left. We get the following for the number 7:
7_______7
6543210
Then, we just merge the two of them, so:
7___... |
Ever wonder what countries surround another? I do too, sometimes, and, well, here's the challenge for it.
I have provided a list of countries and the countries that they touch that you must recognize at the bottom of this post in a code block. You need to create a full program that outputs (in the most convenient way p... |
Task: Given an input consisting of exactly one of the characters <>^v, output a second input consisting of the printable ASCII characters (from space to tilde), oriented with the arrow.
Let's assume the second input to the program is ABC. This is what it should do:
Input >: print ABC.
Input <: print CBA.
Input ^: prin... |
The challenge
Given a list of words ["Programming", "Puzzles", "Code", "Golf"] output the words crossword-style:
P r o g r a m m i n g
u
z
z
G l
C o d e
l s
f
The Algorithm
You have to process the list in the given order.
The words are printed in alternating orientations, starting h... |
What general tips do you have for golfing in D? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to D (e.g. "remove comments" is not an answer). Please post one tip per answer.
|
A standard domino set has 28 unique pieces:
Given a list of 28 or fewer unique dominoes, output the list required to make a complete set.
Input and output dominoes are specified by two digits - the number of pips on each side of the domino, e.g. 00, 34, 40, 66.
The digits may be given in any order, so 34 is the same d... |
Challenge
Given the following C# method:
private static bool Test(bool a, bool b)
{
if (a && b) return false;
if (a) if (b) return true;
return false;
}
Supply the values a and b so that true is returned.
Winning condition
The first entry who can supply the correct arguments to make the given method evalua... |
Challenge description
For every positive integer n there exists a number having the form of 111...10...000 that is divisible by n i.e. a decimal number that starts with all 1's and ends with all 0's. This is very easy to prove: if we take a set of n+1 different numbers in the form of 111...111 (all 1's), then at least ... |
Given an input of a program written in oOo
CODE, output the BF code that it
represents.
Here is a short description of how oOo CODE works:
First, all non-alphabetic characters are removed (everything not in the range
A-Za-z).
For example, take the program PROgRam reVERsES giVeN iNPut sEqUENcE (an
example given on the ... |
In a twist on finding a needle in a haystack, you need to find the largest contiguous haystack containing exactly one needle. Note that you cannot connect cells on diagonals, only left/right/up/down.
Input
An array (or a number of user input lines, your pick) of 'N' (needles) and '#' (hay) characters. Input only contai... |
I think about if I was turned into an ant, I'd want my loved ones to
know, so I thought of a plan- I'd gather twigs and leaves and write my
name on the ground, Then I'd wait for my family and friends to crowd
round But now I'm thinkin'- that when they saw it They'd think the
human me wrote it and an ant was cr... |
Pike is a dynamically typed interpreted scripting language, heavily influenced by C, which typically compiles to C99 with a few #defines. (It even has a preprocessor!)
What general tips do you have for golfing in Pike? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat... |
Create a Pascal's Triangle that is a nested list and contains zeros in the unused spots.
In the output array, the numbers of Pascal's Triangle are separated by zeroes and padded by zeroes on each side so that they are centered. For example, the bottom row (last sub-array) must have no zeroes on the left and the right; ... |
In the ASCII art world, there is water, hash walls and letter mechanisms.
You are in a room made up of hash walls (# signs):
#######
# #
# #
# #
# ### #
# #
#######
You install an S water source (S sign) and an E water tank (E sign) which can receive water from any direction, but you only have one S so... |
Your task is to write a program, that given a list of chat messages, count how many times each person gets pinged, so I can know how popular everyone is. But, since I have to do it surreptitiously, I need it to be as small as possible so I can hide the code.
Specs
The input comes in a list of 2-tuples, with each item... |
For mostly historical reasons, bash is quite a hodge-podge of syntax and programming paradigms - this can make it awkward and sometimes frustrating to golf in. However it does have a few tricks up its sleeve that can often make it competitive with other mainstream script languages. One of these is brace expansion.
Th... |
A highly composite number is a positive integer that has more divisors than any smaller positive integer has. This is OEIS sequence A002182. Its first 20 terms are
1, 2, 4, 6, 12, 24, 36, 48, 60, 120, 180, 240, 360, 720, 840, 1260, 1680, 2520, 5040, 7560
For example, 4 is in the sequence because it has 3 divisors (nam... |
Task description
Sometimes, you really need to fit something you’re writing in a small space. It may be tempting to drop the vowels and wrt lk ths – and failing that, who really needs spaces? Thssprfctlrdbl!†
Write a function or program that removes lowercase vowels aeiou, and then spaces, and then any characters from ... |
Given an image, output the [width in pixels of a full vertical section]1 (if one exists). If no vertical section exists, output 0.
Input may be provided as a local file or a nested array. If you choose to take input as a nested array, white pixels should be represented by a truthy value while non-white pixels should be... |
You have a deck of cards, consisting of cards with non-negative numbers on them, and you haven't shuffled it yet, and no player trusts the other players to be fair at shuffling. You devise a way to shuffle the deck that is completely deterministic, but chaotic enough that the other players are okay with using it. Here'... |
Jason has a big JSON but it's unreadable, so he needs to prettify it.
Formatting Spec
The JSON has 4 different types:
Numbers; Just 0-9
Strings; Double quoted " strings escaped with \
Arrays; Delimited by [], with items separated by ,, items can be any of these types
Objects; Delimited by {}, format is key: value wher... |
Introduction
There are often times that we have challenges which require communication of some sort (such as in team KOTH), where density of information may be more important than density of code. There are a number of compression techniques that can allow us to convey more information in less space, but for simple dat... |
Given an input of an ASCII art picture, output the ASCII art italicized.
To italicize the ASCII art:
Insert zero spaces before the last line, one space before the second-last
line, two spaces before the third-last line, etc.
Remove any extra leading whitespace that may have been created. That is, if
each line has at l... |
Write a program or function that prints an input string around the discrete circle that has the minimum possible radius. For example, for input This is an example, your program should output:
a si
n s
i
e h
x T
a
m
p
le
Circle generation
You shall use the M... |
Background
I have a ladder leaning on a wall, and a remote-controlled robot that can climb it.
I can send three different commands to the robot:
UP: the robot takes one step upwards. If it was on the highest step, it trips over, falls down and explodes.
DOWN: the robot takes one step downwards. If it was on the lowest... |
Similar to the Catalogue of hello world. I want to produce a catalogue of short ways to produce CSV.
CSV Definition
In this case CSV meaning the more literal interpretation of;
A string representation of a list or array separated by commas.
The input types should not be mixed i.e [1, "hello"] is NOT valid input
The out... |
Suppose we define a simple program that takes an array L of natural numbers with some length N and does the following:
i=0 #start at the first element in the source array
P=[] #make an empty array
while L[i]!=0: #and while the value at the current position is not 0
P.append(L[i])... |
You may have seen puzzles like this:
Find the 0:
OOOOOOOOOOOOOOOOOOOO0OOOOOOOOOOOOOOOOOO
The challenge is to write a program that finds the index of the different letter given an image.
Input
Input will be an Image. The image will consist of one line of black text in the Helvetica 24 pt. font on a white background. T... |
In this challenge, your task is to make write a program with less than 300 characters that takes a short paragraph or a few sentences that a candidate has said and output who said it.
Input: Can be taken as a parameter to a function, input to a program etc. It will be a short paragraph, properly punctuated.
Output: The... |
Symbolic Differentiation 2: Back on the Chain Gang
Task
Write a program that takes in a certain sort of function from stdin and differentiates it with respect to x, using the chain rule.* The input function will be a string of the following form:
"trig_1 trig_2 trig_3 ... x"
where trig_n is a trigonometric function si... |
This challenged is highly inspired by what @Mego created with his Holy and Holier numbers, lots of thanks to him and his puns.
Holy numbers are numbers composed of only the digits with holes, which are:
04689
Numbers with at least one unholy digit are considered unholy. Unholy digits are evil by definition, but being ... |
List all of the combinations with replacement (or combinations with repetition) of size k from a set of n elements.
A combination with replacement is an unordered multiset that every element in it are also in the set of n elements. Note that:
It is unordered. So a previously printed set with a different order shouldn'... |
This is a window:
---
| |
---
Let's add some walls |. Put two spaces on either side of it so that the window has plenty of room.
| --- |
| | | |
| --- |
Now let's add a roof and a ceiling. To keep the window in the middle of the room, let's add one more row above it and below it.
---------
| |
| --- |
|... |
The Challenge
I was reading Google's Java Style Guide the other day and stumbled over their algorithm to convert any arbitrary string into camelCase notation. In this challenge you have to implement this algorithm since you don't want to do all this stuff in your head when you are writing your super competitive Java su... |
Given the name of a Stack Exchange site which doesn't have their own design yet, decide how many ASCII characters (non-ASCII ones are counted separately) are there on their icons. Your code should distinguish these 4 cases:
1 character:
Astronomy
Beer
Freelancing
Health
History
Law
Music: Practice & Theory
Parenting
Th... |
Introduction
File names can be wildly varying things, ranging from a simple blah.txt to 303549020150514101638190-MSP0.txt. The former is usually human generated, while the latter is often machine generated. Wouldn't it be nice to have a simple function to make educated guesses on whether or not a file might be consider... |
Introduction
Say you have a population of people. This population is made up of 100 Alices and 25 Bobs. So, 80% of the population are Alices and 20% are Bobs. We want to change the proportional makeup of the population to be 62% Alices and 38% Bobs.
Rules
You can only add to the population. You cannot take any away... |
Shifty-eyes ASCII guys like to shift ASCII Ii's:
>_> <_< >_< <_>
Given a string of shifty-guys, spaced apart or separate lines, shift the Ii's side to side, left the wall and right the skies:
Ii
The shortest shifter wins the prize.
Say What?
Write a program or function that takes in a string of an arbitrary list of t... |
Given an input of a list of words and their abbreviations, output the pattern
by which the abbreviations can be formed.
Let us take the example input of
potato ptao
puzzle pzze
as an example (that is, the abbreviation for potato is ptao, and the
abbreviation for puzzle is pzze).
Consider all possible ways to obtain pt... |
It's Friday... so let's go golfing! Write code that determines the player's scoring on a hole in a game of golf. The code can be either a function or entire program. As the genre suggests, shortest code wins.
Input (parameters or stdin, your choice):
An integer representing the hole's par, guaranteed to be between 3... |
Cellular Automata are truly fascinating. The ones that are usually talked about are the binary ones, i.e., the ones representable by a number. However, those, in my opinion, have been done to death. Ternary CAs are more interesting, but we have all of ASCII to consider! What fun could that be!
Instead of deciding a rul... |
Consider some binary sequence, using 1 and 2, e.g.:
1, 2, 1, 1, 2, 2, 1, 2, 1, 2, 2, 1 ...
Let's write down the run lengths of that:
1, 2, 1, 1, 2, 2, 1, 2, 1, 2, 2, 1 ...
_ _ ____ ____ _ _ _ ____
1, 1, 2, 2, 1, 1, 1, 2, ...
In this case we happen to get another binary sequence. Of course, that's not g... |
Given a vector of \$n\$ values \$(x_1,x_2,x_3,\ldots,x_n)\$ return the determinant of the corresponding Vandermonde matrix
\$V(x_1, x_2, \ldots, x_n) = \begin{bmatrix}1 & x_1 & x_1^2 & x_1^3 & \ldots &x_1^{n-1} \\1 & x_2 & x_2^2 & x_2^3 & \ldots &x_2^{n-1} \\ \vdots & & & \vdots & & \vdots \\ 1 & x_n & x_n^2 & x_n^3 & ... |
Introduction
Let's say that S1 = a...b and S2 = ..c... If we place them on top of each other, we get:
a...b
..c..
We merge both strings, with the . as the liquid character (which can overlapped). We get this:
a.c.b
If one of the string is longer than the other, we just apply the same algorithm:
a.....b
..c..
becom... |
You are given the positions of the minute and hour hands of an analog clock as an angle of clockwise rotation from the top (12). So a hand pointing at 9 is at an angle if 270, and a hand pointing exactly in between 12 and 1 is at an angle of 15.
Input will be two integer angles (in any order of your choice) between 0 a... |
I asked random.org for 128 random integers between 0 and 232 - 1. Since the random number generator was so eager to give the first 64 numbers first, they're obviously more random than the other 64.
Write a full program or function that returns a truthy result when one of the following 64 integers is input:
[1386551069,... |
Write a program or function that extracts a word from a wordsearch using its start and end coordinates.
The Input
Your program or function should accept three parameters: the start coordinate, the end coordinate, and a wordsearch from which to extract the word.
The start coordinate can be taken in any format.
It will... |
Given a list with number, output the ranges like this:
Input: [0, 5, 0] would become [0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0].
This is mapping a range through the array, so we first have to create the range [0, 5], which is [0, 1, 2, 3, 4, 5]. After that, we use the 5 to create the range [5, 0]. Appended at our previous range... |
The Challenge
Given a rectangular grid of characters
A B C D E
F G H I J
K L M N O
P Q R S T
and a grid with the same dimensions of dots and spaces
. . .
. . .
. .
. . .
Output the string which is generated by following the dots through the grid starting in the upper left corner. This example woul... |
You have a coin that produces 0 or 1. But you suspect the coin may be biased, meaning that the probability of 0 (or 1) is not necessarily 1/2.
A well known procedure to "transform" a biased coin into a fair coin (i.e. to obtain equally likely results), as proposed by von Neumann, is as follows. Produce (non-overlappin... |
Your goal is to compute the set intersection of two lists of integers. The intersection is defined as the unique un-ordered group of integers found at least once in both input list.
Input
The input may be in any format desired (function parameter, stdio, etc.), and consists of two lists of integers. You many not assume... |
The Challenge
Given a n x n matrix of integers with n >= 2
1 2
3 4
and a list of integers with exactly 2nelements
[1,2,-3,-1]
output the rotated matrix. This matrix is contructed in the following way:
Take the first integer in the list and rotate the first row to the right by this value.
Take the next integer and ... |
Given an input of a pair of nonnegative integers describing a
leaper in chess,
output a diagram of the squares to which the leaper can move.
From Wikipedia's description:
An (m,n)-leaper is a piece that moves by a fixed type of vector between its
start square and its arrival square. One of the coordinates of the vec... |
Write a program or function that takes a mathematical expression in Morse code as input, and returns the solution in Morse code.
Valid operations are plus: + and minus: _ (underscore). You can assume you will only receive non-negative integer input, and that the result will be non-negative.
The expression will contain... |
In math, a permutation σ of order n is a bijective function from the integers 1...n to itself. This list:
2 1 4 3
represents the permutation σ such that σ(1) = 2, σ(2) = 1, σ(3) = 4, and σ(4) = 3.
A square root of a permutation σ is a permutation that, when applied to itself, gives σ. For example, 2 1 4 3 has the squa... |
The puppy utility takes a filename as input, and does exactly what you would expect a puppy to do: it shreds it!
How to shred
Rip out the pages with your teeth Split the input file on newlines.
Tear up each page with your paws For each line (not including the linefeed), pick a random integer n such that 2 <= n <= # o... |
Your task is write a program or function that can fill a given rectangle with
prime numbers. The width and height of the rectangle will be the input. The
output must be a list of height strings consisting of width digits and
spaces. Each horizontal (left to right) and vertical (top to bottom) digit
sequence (delimited ... |
Here is a quick Monday morning challenge...
Write a function or program in the least number of bytes that:
Takes as input a list of [x,y] coordinates
Takes as input a list of the [x,y] coordinates' respective masses
Outputs the calculated center of mass in the form of [xBar,yBar].
Note:
Input can be taken in any for... |
In the game Yahtzee, players roll five six-sided dice, and attempt to create certain hands to score points. One such hand is a small straight: four consecutive numbers, not necessarily in order. The three possible small straights are 1, 2, 3, 4, 2, 3, 4, 5, and 3, 4, 5, 6.
For example, [3, 5, 6, 1, 4] contains the smal... |
This is a follow-up question to my Puzzling.SE question: I asked if there’s a function f mapping Boolean strings to Boolean strings, so that f(f(b)) = reverse(b) for all input strings b. (By reverse, I mean the function that reverses the order of bits.)
The above link contains a positive answer, with proof, by the grea... |
The Challenge
Your task is to create a program that can solve an algebraic equation.
Input
Input will consist of a String. The string will be an equality involving the variable x, and follows the following rules:
the equation will always be linear
The valid operations in the equation are + - * /
Parenthesis will not b... |
Input
A integer n ( ≥ 1) and a digit d (an integer such that 0 ≤ d ≤ 9).
In either order; from stdin or parameters or whatever; to a program or function; etc.
Output
The integers from 1 to n inclusive (in order) whose decimal representations contain an even number of ds. (That is, the integers in the list are the integ... |
The winner (pretty obviously) is Dennis ♦, who used Jelly with 10 bytes!
This challenge will still be up here, however results won't be taken anymore.
The powertrain of a number is a concept by John Conway (who is also notable for making Conway's Game of Life, but that's not the point). It is defined as so:
For any nu... |
We're graduating to a full site soon, and there's only one thing left to do before graduation: pull a senior prank! I think we should do a variation on the classic "fill a hallway with cups of water" gag.
Challenge
Your program will read in text and output that text, covered in upside-down cups of water. An upside-down... |
I'm at position (0, 0) of an infinite two-dimensional city, which is perfectly divided into blocks centered at each lattice point, some of which contain buildings. A building at a certain point (x, y) takes up the entire square with opposite corners at (x-.5, y-.5) and (x+.5, y+.5), including its border. A building is... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.