instruction stringlengths 34 53.1k |
|---|
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... |
Given a the name of a state of the United States as a string (with case), return the number of votes the state has in the Electoral College. Write a full program or function, and take input and output through any default I/O method.
A list of all inputs and outputs (source):
[['Alabama', 9], ['Alaska', 3], ['Arizona', ... |
You can determine the volume of objects based on a given set of dimensions:
The volume of a sphere can be determined using a single number, the radius (r)
The volume of a cylinder can be determined using two numbers, the radius (r) and the height (h)
The volume of a box can be determined using three numbers, the lengt... |
The Challenge
Given a n x m matrix with n > 1 and m > 1 filled with integers
1 2 3
4 5 6
and a list of integers with exactly as many values as 2x2 blocks in the matrix ((n-1)*(m-1) if you need the exact number)
[1, 2]
Output the matrix with every 2x2 block rotated by the current value in the list in the given orde... |
A simple pedometer can be modeled by a pendulum with two switches on opposite sides—one at x=0 and one at x=l. When the pendulum contacts the far switch, the ambulator can be assumed to have taken half a step. When it contacts the near switch, the step is completed.
Given a list of integers representing positions of th... |
ASCII boxes look like this:
++ +---+ +------+ +---+ +---+
++ | | | | | | | |
| | | | | | | |
+-+ | | | | | | | |
+-+ | | | | | | +---+
+---+ | | | |
+--+ | | | | ++
| | ... |
Ohm's law tells us that the current (I) in amps flowing through a resistance (R) in Ohms when a voltage (V) is applied across it is given as follows:
V = I / R
Similarly the power (P) in watts dissipated by that resistance is given by:
P = V * I
By rearrangement and substitution, formulae may be derived for calculati... |
Given a black-and-white image in any reasonable lossless format as input, output ASCII art that is as close to the input image as possible.
Rules
Only linefeeds and ASCII bytes 32-127 may be used.
The input image will be cropped so that there is no extraneous whitespace surrounding the image.
Submissions must be able ... |
Now that we're graduating, it's time to tally up the number of times someone suggested that PPCG was graduating, even before the annoucement! (see here)
Your program will receive a list of chat messages. Each message has three pieces of data: the user (e.g. Geobits), the timestamp (e.g. Aug 19 '15 2:41 PM), and the mes... |
A shape's volume is the measure of how much three-dimensional space that shape occupies.
Challenge
Given six integers: [L,W,H] as length, width and height of one container and [l,w,h] as length, width and height of some random item.
You will need to calculate how many items would fit completely if the item was a liquid... |
This is the 2-dimensional generalisation of this challenge.
For our purposes, one matrix (or 2D array) A is considered a submatrix of another matrix B, if A can be obtained by completely removing a number of rows and columns from B. (Note: some sources have different/more restrictive definitions.)
Here's an example:
A ... |
Your task is to print a number. Simple, right? It is simple, but not as simple as this. The first answer is to print the number 1, the second answer is to print the number 2, etc.
Rules
The first answer must print 1, and the nth answer must print n.
The first answer may be of any length.
Whitespace, comments, etc. are... |
So in 1st grade math, you learn the names of polygons. Three sides is a triangle, 4 is a square, and 5 is a pentagon. However, in 1st grade honors, you go a bit further.
Your challenge
There is a naming system for polygons above a few sides, so arbitrarily large polygons have a name.
Your task is to write a program or ... |
Resistors and other electronic components are typically manufactured with values that conform to one of the E-series of preferred numbers. IEC 60063 defines the following E-series:
E6:
10 15 22 33 47 68
E12:
10 12 15 18 22 27 33 39 47 56 68 82
E24:
10 11 12 13 15 16 18 20 22 24 27 30 33 36 39 43 47 51 56 62 68 75 82 ... |
Alphys, the Underground's Royal Scientist, has finished a prototype for a new puzzle. However, she can't seem to find anyone willing to test it.
The rules of her puzzle are as follows:
The goal is to get to the right side, starting from the centermost tile on the left side. For puzzles with even-numbered heights, star... |
Inspired by an old manual...
The challenge
I define the ath suffix vector of b as the boolean list of length a with b trailing truthy values.
Write a program or function that, given a and b by any means, returns the ath suffix vector of b by any means.
Now this may seem trivial, but here is the catch: Your score is the... |
Before 1994, Spanish dictionaries used alphabetical order with a peculiarity: digraphs ll and ch were considered as if they were single letters. ch immediately followed c , and ll immediately followed l. Adding the letter ñ, which follows n in Spanish, the order was then:
a, b, c, ch, d, e, f, g, h, i, j, k, l, ll, m, ... |
Introduction
I found this question that was closed because it was unclear, yet it was a nice idea. I'll do my best to make this into a clear challenge.
The Riemann Zeta function is a special function that is defined as the analytical continuation of
to the complex plane. There are many equivalent formulas for it which... |
Introductions
A 2×n Boolean matrix can be represented as a string of the four characters . ':.
The string has an "upper row" and a "lower row", with dots representing 1s and empty spaces representing 0s.
For example, the 2×6 matrix
1 0 1 0 0 1
0 0 0 1 0 1
can be represented as ' '. :.
Your task is to take a matrix in ... |
There is a great story to tell about regular hexagons found for example in honeycombs. But this busy bee needs your help in telling him which point is inside or outside his honeypot. So, given a regular hexagon as pictured below, centered at the origin and with edge size l, determine if a set of coordinates (x,y) are i... |
I'm a teacher, and in a few days I have to give my students a test. Now, I'm always worried about my loveliest students being hurt by the least loveliest ones when they cheat, so I want to randomize the tests so no one can cheat off of anyone.
Right now, I have my tests saved in this format:
When was Java invented?
W... |
I've been doing word searches recently, and I thought it would be so much easier if all of the words read left-to-right. But rewriting all the lines takes a lot of effort! So I'm enlisting code golfers to help.
(Disclaimer: The above story may or may not be remotely accurate.)
Your code will take a rectangular grid and... |
This was inspired by Problem 13 - Non-Repeating Binary of HP CodeWars' recent competition.
Let's take a random decimal number, say
727429805944311
and look at its binary representation:
10100101011001011111110011001011101010110111110111
Now split that binary representation into subsequences where the digits 0 and 1 a... |
For those who wish a lot more challenge then the old Spanish alphabetical order, let's take a look at how the Hungarian alphabet is ordered.
a, á, b, c, cs, d, dz, dzs, e, é, f, g, gy, h, i, í, j, k, l, ly, m, n, ny, o, ó, ö, ő, p, q, r, s, sz, t, ty, u, ú, ü, ű, v, w, x, y, z, zs
actually, q, w, x and y are not used... |
Introduction
Let's take the number 180. This is an interesting number because the sum of digits of this number is equal to:
1 + 8 + 0 = 9
And the squared version of this number, or:
180² = 32400 > 3 + 2 + 4 + 0 + 0 = 9
These are both 9. The sum of digits of the original number and the squared number are the same. Of ... |
The challenge is simple: Draw a rainbow in as few bytes as possible
The specs for the rainbow are as follows:
The figure must be exactly 400 pixels wide and 200 pixels high (optionally 401x201 if you want a single center pixel)
The red ring should touch all borders of the figure (outer radius = 200 pixels)
All rings s... |
Minimum Scalar Product
The inspiration for this code golf problem is from Google's code jam competition. The premise behind the problem is, given the input of two vectors of varying lengths, find the minimum possible scalar. A scalar can be found using the following formula:
x1 * y1 + x2 * y2 + ... + xn * yn
The probl... |
This is not a challenge but a question, I figured it was on topic because of
Non-challenge questions that are related to solving programming puzzles or a particular type of challenge are also on topic.
Now on to the question:
Is it possible to write any JavaScript code with only 5 letters? JSFuck already does this wi... |
The Scenario
You are given a matrix of size m x n (width x height) with m*n spots where there are a few obstacles. Spots with obstacles are marked as 1, and those without are marked as 0. You can move vertically or horizontally, but can visit each spot only once. The goal is to cover as much area/spots as possible, avo... |
If we have a list, say the list [9, 2, 4, 4, 5, 5, 7], we can do a moving average across it.
Taking a window of say, 3 elements, each element is replaced by a window like such: [[9], [9, 2], [9, 2, 4], [2, 4, 4], [4, 4, 5], [4, 5, 5], [5, 5, 7]], and then taking averages, we get [9.0, 5.5, 5.0, 3.3333333333333335,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.