instruction stringlengths 34 53.1k |
|---|
Poker hands are ranked from best to worst as follows:
Straight flush - five cards of sequential rank, all of the same suit
Four of a kind - four cards of the same rank and one card of another rank
Full house - three cards of one rank and two cards of another rank
Flush - five cards all of the same suit
Straight - five... |
I need help making a brick road to go beside my brick wall!
\ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \
\__\ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \__
__\ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \__\
\ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \_... |
Task
Your goal, should you choose to accept it, is to write a program, that, given an input string (or array of characters), outputs every possible permutation of the letters in that string. I'm finicky with my output, so it should be sorted alphabetically, with no duplicates.
Example:
Input: buzz
Output:
buzz
bzuz
bzz... |
There's something (well, many things ) that really annoys me. It is when dictionaries (English, not Pythonic) use the defining word itself to define the word, also called circular definitions. Example:
reticence: the quality of being reticent
-- Apple Dictionary
Circular definition: a definition that is circular
--... |
This challenge is based on another similar challenge. Because finding the most efficient packing of rectangles is NP-hard (that is, its solution is easy to check but hard to find), this challenge is a lot easier than this one here
This Challenge
Given a bunch of rectangles, figure out whether or not they fill a rectang... |
Introduction
I have a room full of magic mirrors.
They are mysterious artifacts that can duplicate any item, except another magic mirror.
More explicitly, a duplicate version of the item will appear on the other side of the mirror, at the same distance.
However, if there is another magic mirror in the way on either sid... |
A "Giza number", also colloquially known as a Timmy Number is any number where the digits represent a pyramid (A134810). For example, "12321" is a giza number because it can be visualized like this:
3
2 2
1 1
However, something like "123321" is not a Giza number because there are two digits at the top of the py... |
Problem
The goal is as the title says to find the \$n\$th prime such that \$\text{the prime}-1\$ is divisible by \$n\$.
Explanation
Here is an example so you understand the question, this is not necessarily the way it ought to be solved. It merely as a way to explain the question
given \$3\$ as an input we would first ... |
Introduction:
I think we all know it, and it has probably been translated in loads of different languages: the "Head, Shoulders, Knees and Toes" children song:
Head, shoulders, knees and toes, knees and toes
Head, shoulders, knees and toes, knees and toes
And eyes and ears and mouth and nose
Head, shoulders, kne... |
And in particular the second law: the entropy of an isolated system undergoing an irreversible process increases with time.
For this challenge,
An "isolated system" will be taken to be a program or function (abbreviated as "program" from now on);
The "irreversible process" will be execution of code;
The passing of "ti... |
Input: Two integers n and k given in any form that is convenient for your code
Output A random non-decreasing sequence of k integers, each in the range 1 to n. The sample should be chosen uniformly from all non-decreasing sequences of k integers with integers in the range 1 to n.
The output can be in any reasonable f... |
In mathematics, matrix multiplication or the matrix product is a binary operation that produces a matrix from two matrices. The definition is motivated by linear equations and linear transformations on vectors, which have numerous applications in applied mathematics, physics, and engineering. In more detail, if A is an... |
Input
A dictionary with string keys and string values.
Output
The 'inversedict' of this dictionary.
How to make an inversedict
An inversedict is a dictionary with string keys and string array values. The keys are the values from the original dictionary, and the values are the keys from the original dictionary with th... |
A stochastic matrix is a matrix of probabilities used in the context of Markov chains.
A right stochastic matrix is a matrix where each row sums to 1.
A left stochastic matrix is a matrix where each column sums to 1.
A doubly stochastic matrix is a matrix where each row and each column sums to 1.
In this challenge, we ... |
Given only a straightedge and compass, inscribe a rhombus inside the given rectangle, sharing two opposite points.
Input
Input is the dimensions of the rectangle. In the example shown, that would be 125, 50. You can take input in whatever way is most convenient (as two integers, list, strings, etc).
The larger dimensi... |
A Hilbert Curve is a type of space-filling curve, and it basically maps a line to a plane. Each point in the line corresponds to just one point in the plane, and each point in the plane corresponds to just one point on the line. Shown are iterations 0 through 4 of the Hilbert Curve:
Iterations 0 up to 4:
The objec... |
For today's fractal challenge, draw at least 5 iterations of Sierpinski's triangle! (Shown below is Sierpinski's trinagle)
The resolution of the image must be sufficent that the smallest triangles are at least one pixel in size, and all triangles should be approximately equillateral - pixel art that draws a right-tria... |
How well do you know the site? Let's find out.
This is a cops-and-robbers challenge. Robber's thread.
As a cop, you need to:
Find a non-deleted, non-closed challenge on this site to answer. The challenge cannot have the following tags: cops-and-robbers, popularity-contest, code-trolling, underhanded, busy-beaver, k... |
How well do you know the site? Let's find out.
This is a cops-and-robbers challenge. Cop's thread.
As a robber, you need to:
Find a non-deleted, non-closed challenge that matches a cop's submission. The challenge cannot have the following tags: cops-and-robbers, popularity-contest, code-trolling, underhanded, busy-... |
Introduction
The Sierpinski Arrowhead Curve is a curve that's limit is Sierpinski's Triangle.
It first starts like this:
_
/ \
Then, each line is replaced with a rotated version of the first one:
_
/ \
\ /
_/ \_
Next:
_
/ \
\ /
_/ \_
/ \
\_ _/
_ \ / _
/ \_/ \_/ \
Your task
Given a ... |
Given a non-empty string, keep removing the first and last characters until you get to one or two characters.
For example, if the string was abcde, your program should print:
abcde
bcd
c
However, if it was abcdef, it should stop at two characters:
abcdef
bcde
cd
Trailing newlines and trailing spaces at the end ... |
Inspired by Find the “unwrapped size” of a list.
Define the Recursive Size, RS, of a list containing no lists as its length (number of items contained) and the Recursive Size of a list containing any lists as the sum of its length and the Recursive Size of those lists.
Challenge
Write a program or function that outputs... |
Let me tell you about a simple number system. (which I made up just for this challenge)
This system contains the functions (), [], {}, and <>.
1. ()
When () is given no arguments, it evaluates to 0.
When () is given one or more arguments, it evaluates to the sum of the arguments.
2. []
When [] is given no arguments, it... |
Thanksgiving in the United States is coming up on November 24th. Many people will have a large dinner with their families, traditionally including turkey and many side dishes. This typically means the family members must coordinate who's going to bring each of the various dishes. In this challenge, the goal is to write... |
Once I wrote a JavaScript program that would take as input a string and a character and would remove all characters except for the first one and the character given as input, one by one.
For example, computing this with inputs codegolf.stackexchange.com and e for the character yields:
codegolf.stackexchange.com
cdegolf... |
Challenge
Implement a program that given three strings a, b, and c, substitutes all instances of the substring b in a with c.
In other words, implement Ruby's String#gsub with strings instead of regexes (a.gsub b, c).
Rules
Standard loopholes apply.
You may not use a builtin that performs this exact task.
This is code... |
This challenge is inspired by this other challenge, which you may want to read first for some context. However, a competitive answer is likely to look very different, so after reading some posts on Meta I decided it was best posted as a separate question.
The goal here is to write a polyglot program; that is, a program... |
Background
We already have a challenge about throwing SIGSEGV, so why not a challenge about throwing SIGILL?
What is SIGILL?
SIGILL is the signal for an illegal instruction at the processor, which happens very rarely. The default action after receiving SIGILL is terminating the program and writing a core dump. The sign... |
Many old Game Boy games often required string input from the user. However, there was no keyboard. This was handled by presenting the user with a "keyboard screen" like so:
The 'character pointer' would begin on letter A. The user would navigate to each desired character with the D-Pad's four buttons (UP, DOWN, LEFT a... |
I'm new to Japanese Mahjong and have trouble calculating the scores. Please help me write a program to calculate it.
Introduction
(aka you can skip this boring part)
Mahjong is a popular tile game in Asia. Different rules have evolved and systematically established in various regions. Japan, being an isolated island st... |
You task for today: draw a dragon curve!
In case you don't know what a Dragon Curve is, here is an introductory ViHart video (Really cool, please watch!)
Your task: draw a dragon curve, iterated at least 9 times. You don't have to show iterations 1 through 9, you just have to show the final curve produced after complet... |
Brief Problem Explanation
Write a program to find the minimum distance between two points traveling only on rays emanating from the origin and circles centered on the origin.
Explanation of Premise
Now let's imagine we are on a plane, and on this plane we are only allowed to travel in special ways. We are allowed to tr... |
Write a program that outputs as many characters as possible, with two conditions:
The program must be 256 bytes or shorter
The program must almost surely eventually halt. In other words, the only thing not permitted in response to this question is an infinite loop.
For the purposes of this problem, any built-in psudo... |
Background
This question is similar to this one. I have provided all of the information needed below. If you are familiar with the other challenge then note that we are ranking all defenses instead of seeing the effectiveness of a single attack. This is important because it means that the tables are inverses of each ot... |
Definitions:
A line is a possibly empty sequence of characters terminated by a “newline character.”
A “newline character” is a character that cannot be a component of the aforementioned character sequence.
A line number comment is a character sequence that does not alter the meaning of source code in the programming l... |
The Challenge
Given a CSV input, output a proper unicode table using box characters.
Formatting
The table will be formatted using the following rules:
Column width will be equal to the longest value of that column
All table data will be left justified
Each table will assume the first csv row to be the header
The table... |
What's great about golfing is not having to deal with errors. Except this time you won't get off so lightly! I need to do some arithmetic with certain limitations, and I wan't to know what goes wrong if anything.
Challenge
Given a list of signed integer values [n1..n11], give the following result or the first error tha... |
Challenge description
Let's start with some definitions:
a relation is a set of ordered pairs of elements (in this challenge, we'll be using integers)
For instance, [(1, 2), (5, 1), (-9, 12), (0, 0), (3, 2)] is a relation.
a relation is called transitive if for any two pairs of elements (a, b) and (b, c) in this rel... |
Let's take a look on a typical loop, which usually performs 8 iterations:
for (int x=0; x<8; ++x);
You have to make it infinite!
It's a popularity-contest for all languages that support such form of for loop. So solution with highest score (upvotes minus downvotes) wins.
If your language has the other form of for loo... |
Remember those brute-force programs to crack password that show every combination they are trying? More precisely, at one point, the n first characters are fixed (they have been guessed successfully), and every possible character for the remaining ones is being tested. You've probably seen some in movies, or in some so... |
Introduction
A disk is a linear container with blocks indexed 0 through size-1.
A file is a named list of block indexes used by that file.
An example filesystem is expressed like this:
15 ALPHA=3,5 BETA=11,10,7
"The disk has 15 blocks, the first block of file ALPHA is the disk block at index 3..."
The disk map could b... |
Your challenge is to create a regex that matches every string permutation of itself, and nothing else. The match must also be case-sensitive.
So, for example, if your regex is:
ABC
It should match (and only match) these strings:
ABC
ACB
BAC
BCA
CAB
CBA
It shouldn't match things like:
AABC (contains an extra A)
ABCD (... |
Output a full formal poof of such statements such as 1+2=3, 2+2=2*(1+1) etc.
Introuction
If you know Peano Arithmetic you can probably skip this section.
Here's how we define the Natural Numbers:
(Axiom 1) 0 is a number
(Axiom 2) If `x` is a number, the `S(x)`, the successor of `x`, is a number.
Hence, for example S(S... |
You are a traveller crossing the desert between two towns. You cannot carry enough water to get across without stopping. This is a variation of a classic puzzle.
The Rules
A desert looks like this: a WxH grid of mostly empty space. The space marked S is where you start, E is where you want to end, and a square marked w... |
Generate a cipher given a number and string
Your task is simple. Given a string s and a number 0 <= n <= 9 as inputs, insert a pseudo-random printable ASCII character between each character of the string n times. Such that for each character of s there are n random characters between them. Spaces should be trimmed.
Inp... |
Wikipedia says about Polar Coordinates:
In mathematics, the polar coordinate system is a two-dimensional coordinate system in which each point on a plane is determined by a distance from a reference point and an angle from a reference direction.
This seems perfect for describing hexagonal grids. Take the following he... |
Goal:
A tree can be represented as a nested list: the list elements represent nodes, and a node is a pair of the node name and node children.
Your program takes as input a nested list of pairs, and should output a pretty tree.
Examples:
Here are four example test cases below
["stump",[]]
["trunk",[["branch",[["leaf... |
Today we're going to build a pyramid out of letters! Here's an example letter pyramid for the first 5 letters:
Write the first 5 letters with a space between, first ascending and then descending.
A B C D E D C B A
Do the same thing for the first four letters on the line above, but with two extra leading spaces:
A B... |
Summary
Implement FizzBuzz in Python, with the fewest possible tokens.
Challenge
Write a program that prints the decimal numbers from 1 to 100 inclusive. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print... |
I love /usr/share/dict/words; it's so handy! I use it for all my programs, whenever I can! You're going to take advantage of this ever so useful file to use, by testing a word's individuality.
Input
A word; defined in this challenge as any string of characters
/usr/share/dict/words in some format; you may hard code i... |
This challenge is based on the game Layerz.
Given, on stdin or as a function argument, a 2D rectangular array of cells where each cell contains either a blank (you may choose to use 0s instead of blanks at no penalty), a 1, a 2, a 3, or a 4; find a way to divide it into valid regions (as defined below) such that each n... |
The challenge is to calculate the digit sum of the factorial of a number.
Example
Input: 10
Output: 27
10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800,
and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27
You can expect the input to be an integer above 0.
Output can be of any type, but the answer sh... |
Your task, if you choose to accept it, is simple.
Objective
You must make a program that, when run, prints some (as many as you want) terms in a sequence that you choose. The sequence must be a valid OEIS sequence. The twist is that when you take the characters from your code that make up your sequence, string them tog... |
First line is made with ceil(n/2) elements where each element is: <space><odd-number><space>
Second line is made with ceil(n/2) elements, but each element is / \ only.
You may assume n >= 0 and n <= 10.
Examples
Input: 3
1 3
/ \/ \
Input: 10
1 3 5 7 9
/ \/ \/ \/ \/ \
Example in Python 3, 103 bytes:
lambda a:p... |
Inspired by Display a chain of little mountains with an odd number on the top of it! by @sygmei.
Why have a chain of mountains when you can have one massive one?
Make a program that takes an input number and prints a mountain with every odd number up to the input number.
(Where "south west" means directly below and to ... |
EDITS:
Added link to the plain-text (multiple strings) test data
Added BLANK,EDGE and TIE2 test cases (see Test Data section) (11/25)
Updated the JSON test cases (some lines were ill-formatted) (11/24)
Renju match gone bad ! (well, technically these guys are playing Go, but who cares) Wikisource
TL;DR
Take a 15x15 ... |
Take a non-nested array as input. Turn it into a matrix by using the following method:
Let's say my array is [1, 2, 3, 4, 5]
First, I repeat that array 5 times: (the length)
[[1, 2, 3, 4, 5],
[1, 2, 3, 4, 5],
[1, 2, 3, 4, 5],
[1, 2, 3, 4, 5],
[1, 2, 3, 4, 5]]
Then, I read it along the diagonals:
[[1],
[2, 1],
[3... |
Tamagotchi and Giga Pets were small electronic devices which simulated a little virtual pet. This pet had several stats, like health, hunger, etc.
I recently wrote this example:
import msvcrt,os,sys;d=m=100;h=s=t=p=0;f=10
while 1:
os.system('cls'if os.name=='nt'else'clear');print("health:",d,"\nhunger:",h,"\nsleep:",... |
Write a program with the following properties:
When run as-is, the program produces no output (i.e. 0 bytes of output).
There is a location within the program (of your choice: it could be at the start, end, or somewhere in the middle) with the following property: modifying the program via placing any string there will... |
Introduction
Today I went fishing alone with my canoe, unfortunately I fell asleep and the stream brought me away, I lost my oars, now it's night and I am lost in the ocean! I can't see the coast so I must be far away!
I have my cell phone but is malfunctional because it got wet by the salty water, I can't talk or he... |
Task
Given a Boolean matrix, find one (or optionally more) subset(s) of rows which have exactly one True in each column. You may use any algorithm, but must support very large matrices, like the last example.
One possible algorithm (Knuth's Algorithm X)
While there is no requirement to use this algorithm, it may be you... |
The Golfer Adventure
This is the first challenge ! There will be more challenges later that will require data from the previous challenge :)
Chapter 1 : The Vase
Let's imagine a minute.. You are a powerful God, your powers are limitless but require one thing : Souls.
Each soul is here represented by a byte, each byte y... |
Introduction
I'm a real big fan of the SBU (Short But Unique) challenges that crop up on PPCG all of the time. The CUSRS is a system designed to refactor strings, a CUSRS function takes 2 parameters and outputs 1 String.
Challenge
Produce a program, function, lambda or acceptable alternative to do the following:
Given ... |
Background
An unlabelled tree may look like this:
o
/ | \
o o o
| / \
o o o
To linearize this tree, we first label each node o with it's number of child nodes:
3
/ | \
1 0 2
| / \
0 0 0
and then write the numbers in a list in a breath-first manner, meaning line by line and left to right:
[3... |
Your challenge is to write a program or function that hiccups a string. It should take a string as input (via any standard method), then follow these steps:
Generate a (not necessarily uniformly) random integer n between 1 and 10, inclusive.
Wait n seconds.
Print the initial/next n chars of the input, or the rest of t... |
...but hey, no need to be strict.
Given a non-empty array of strictly positive integers, determine if it is:
Monotone strictly decreasing. This means that each entry is strictly less than the previous one.
Monotone non-increasing, but not strictly decreasing. This means that each entry is less than or equal to the pre... |
A sculptor is tasked to creating icicle sculptures for the new museum in Greenland. He has been given specifications by his boss, which consists of two numbers: [s, m] or size and melt. Size must be an odd number. He was given some photos of real icicles:
vvvvv [5, 0]
vvv
v
vvvvvvv [7, 0]
vvvvv
vvv
v
vvv... |
Your task is to, given an array of signed 32 bit integers, recompile it with its inverse deltas. For example, the list
1 3 4 2 8
holds the deltas:
2 1 -2 6
which are then negated, yielding:
-2 -1 2 -6
and recompiled, yielding:
1 -1 -2 0 -6
as the final result.
Input/Output
You will be given a list/array/... |
Challenge
Write a full program/function to Demolish a given building at the rate 1 floor per second.
INPUT
Input is a building through STDIN(or whatever is called in your language) or through an ARGUMENT of a function.
t=0 s
|
|#|
{#}
|# #|
|# # #|
|# # #|
|# # #|
TTTTTTT
input consists of :
| marks sta... |
You will write a simple program that prints exactly 1 2 3 4 5 6 7 8 9 10 to STDOUT, Console, or your language's closest output method. No other visible output should be seen. Any other code executed must be back-end only.
This is answer-chaining, so the catch is that you must include the previous answer's source code i... |
Let's use the four basic operations, addition +, multiplication *, subtraction - and division / (float, not integer).
Stewie's sequence is defined as follows:
x = [x(1), x(2)] // Two initial numbers (one indexed)
x(3) = x(1) + x(2)
x(4) = x(2) * x(3)
x(5) = x(3) - x(4)
x(6) = x(4) / x(5)
x(7) = x(5) + x(6)
... and s... |
Given two positive integers X and Y, output any combination of the following three ASCII-art animals such that the output contains exactly X commas (,) and Y periods (.), if it is possible.
Koala: 1 comma, 2 periods
<.,.>
Crab: 2 commas, 2 periods
,<..>,
Commapillar: 3 or more commas, 1 period
<,,,.>
or <,,,,.> or ... |
A polyglot is a program that can be run in 2 or more different programming languages.
What general tips do you have for making polyglots, or choosing languages that are easy to write polyglots for a specific task?
Please post the tips that could be applied in most situations. I.e. they shouldn't work only in polyglots ... |
What general tips do you have for golfing in Nim? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Nim (e.g. "remove comments" is not an answer).
Please post one tip per answer.
|
After all the fun we've had with polyglot challenges in the (recent) past, how about a challenge where the output can be in two languages?
Your answer needs to accept boolean input b and output the text "true" or "false". The same code needs to output, when run in another language, "waar" or "onwaar" or any other trans... |
Introduction
A xenodrome in base n is an integer where all of its digits in base n are different. Here are some OEIS sequences of xenodromes.
For example, in base 16, FACE, 42 and FEDCBA9876543210 are some xenodromes (Which are 64206, 66 and 18364758544493064720 in base 10), but 11 and DEFACED are not.
Challenge
Given ... |
B-splines are defined using a set of "knots", "control points", and degree. For the purposes of this challenge, the control points are not needed.
The knots are simply a list of strictly increasing real values (note that real B-splines may have repeated knots, for the purposes of this challenge assume knots are all uni... |
(This is part 1 in a two-part challenge.)
Your task is to solve a Hexasweep puzzle.
A Hexasweep puzzle is set out on a grid of diamonds arranged in hexagonal shapes, of which the board looks like a hexagon, like so:
_____
/\ \
_____/ X\____\_____
/\ \ / XX /\ \
/X \____\/____/X \____\
\ X/... |
This is a potato:
@@
@@@@
@@@@@@
@@@@@@
@@@@
@@
More generally, a size N potato is defined as the following shape:
If N is even, it is 2 centered @ symbols, followed by 4 centered @ symbols, followed by 6 centered @ symbols, all the way up to N centered @ symbols; then, N centered @ symbols, followed by N-2 ce... |
Introduction
Dobble/SpotIt is a card game, where people have to spot same symbol on pair of cards in shortest time, indicate it and move to next pair. Each card has multiple symbols (8 in normal version), but exactly one is common between each pair of cards.
Example from physical copy of game:
Challenge
Write a progr... |
An unspeakable number is a number which is divisible by seven or has seven as one of its digits. A children game is to count skipping unspeakable numbers
1 2 3 4 5 6 ( ) 8 9 10 11 12 13 ( ) 15 16 ( ) 18 ...
Cantor's version of the game is the sequence defined by recursively filling in the sequence "1 2 3 4 5 6 ( ) 8..... |
Given three sidelengths of a triangle, evaluate its aspect ratio AR given the following formula:
where
The closer to equilaterality a triangle is, the closer to 1 its aspect ratio is. The aspect ratio is bigger or equal to 1 for valid triangles.
Inputs
The input is three real positive numbers which can be encapsulate... |
Background of Lucas Numbers
The French mathematician, Edouard Lucas (1842-1891), who gave the name to the Fibonacci Numbers, found a similar series occurs often when he was investigating Fibonacci number patterns.
The Fibonacci rule of adding the latest two to get the next is kept, but here we start from 2 and 1 (in th... |
Source: Wikipedia
For this challenge, you should write two programs which resemble the figure and ground of the above image, such that one of them prints figure and the other prints ground. Specifically:
Write a program which takes no input and prints the string figure. The only allowed whitespace characters in your ... |
Your challenge is to make an infinite loading screen, that looks like this:
Or, to be more specific:
Take no input.
Output Loading..., with a trailing space, but no trailing newline.
Infinitely cycle through the chars |, /, - and \: every 0.25 seconds, overwrite the last one with the next in the sequence. You can ov... |
Write a program that can validate a PNG file. Your program should follow the PNG spec and must validate the PNG signature and the 4 critical chunks: IHDR, IDAT, PLTE and IEND. Your program must not validate the contents of ancillary chunks, except for their CRC checksums.
Your program must validate the presence of the ... |
Introduction
In the game The Witness (possible spoilers ahead) there is a group of puzzles that involve drawing a Tetris piece with your line while making sure that the symbol for the Tetris piece your currently drawing stays contained within the shape you've drawn.
For the image above the drawing works because the ... |
Write a program or function that alters the file at a user-specified filename via replacing all instances of UNIX line endings with Windows line endings and vice versa.
Clarifications:
For the purposes of this problem, a UNIX line ending consists of the octet 0A in hexadecimal, except when it is immediately preceded b... |
(Inspired while drawing on a dry erase board)
Challenge:
Given an input string containing characters that represent different colors of dry erase markers on a white board, output the order in which they were drawn, from first to last.
Input:
A string which contains dry erase marker colors which are represented by alpha... |
Challenge
Given a rectangular grid of printable ascii characters as a string or through standard input, write a function or program that collapses the non-space characters into a pile on the bottom.
The rules:
The output has the same dimensions and characters as the input.
A non-space character at (row a,column b) can... |
Given a nonempty array of positive integers, "increment" it once as follows:
If all the array elements are equal, append a 1 to the end of the array. For example:
[1] -> [1, 1]
[2] -> [2, 1]
[1, 1] -> [1, 1, 1]
[3, 3, 3, 3, 3] -> [3, 3, 3, 3, 3, 1]
Else, increment the first element in the array that is the array's mi... |
Take a positive integer X. This number is part of the sequence we are interested in if the sum of all digits of X is a divisor of X, and if the product of all digits of X is a divisor of X.
For example, 135 is such a number because 1 + 3 + 5 = 9 which divides 135 = 9 * 15 and 1 * 3 * 5 = 15 which also divides 135.
This... |
Challenge
Create the shortest program that meets the requirements
Requirements
The code must generate a 5x5 grid of 0s, like so:
00000
00000
00000
00000
00000
The code must accept an input (column, row, character). The grid must change accordingly:
Start:
00000
00000
00000
00000
00000
Input:
(2,5,*)
Output:
0*000
0... |
A brace string is defined as a string consisting of the characters *()[] in which braces match correctly:
[brace-string] ::= [unit] || [unit] [brace-string]
[unit] ::= "" || "*" || "(" [brace-string] ")" || "[" [brace-string] "]"
This is a valid brace-string:
((())***[]**)****[(())*]*
But these are not:
)(
**... |
What tips do you have for golfing in Wierd? Tips for golfing other languages don't seem to help one golf Wierd programs so I'm looking for ideas that can be applied to code golf problems that are specific to Weird - especially if it helps me reduce the size of this answer at "Hello, World!"
|
Playing tetris is fun. Watching an AI play tetris is also fun.
Some tetris AIs will always ignore the possibility of maneuvering a piece under an overhang, which makes me sad.
It means that the programmer said to himself, "What are all the possible places the tile could be at the top of the board, and from each place,... |
Write a program which will take for input 2 integer arrays and return a truthy value if there exists an element which is present in both of arrays, or a falsy one otherwise. The obvious solution to this problem would be to iterate through each element in the first array and compare it against each element in the second... |
Imagine this, we have an environment with a global scope containing just a single object, called codegolf. This object has a single child called stackexchange, which has a property called com.
Accessing this property would look like codegolf.stackexchange.com.
The challenge
The input of your program/function will be a ... |
N children, with no two sharing their exact size, are lined up in some order. Each can only compare heights with their immediate neighbours. When the teacher shouts "raise hands if you are the tallest", they do so if they are taller than both their neighbours, and they do so simultaneously. If only one raises their han... |
Year of 2010, an Icelandic Vulcano, concisely named Eyjafjallajökull erupted, resulting in my long-planned flight being canceled.
In case this ever happens again, I would really like to know in advance, so please help me build a simple visual alert system !
Input
Take the Icelandic Meteorological Office volcanic activ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.