instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
The Manhattan distance on a regular grid is the number of orthogonal steps one needs to take to reach one cell from another. Orthogonal steps are those that go through the edges of the grid cells (as opposed to the corners, which would give us the Chebyshev distance).
We can define a similar distance on other grids, fo... | stackexchange_codegolf |
Backstory
You own a tiny jewellery shop in the suburbs of the city. The suburbs are too much overpopulated, so your shop has a thickness of only one character to fit in the busy streets.
Recently, there has been lots of cases of robbery on the neighborhood, and you fear that robbers will also come to get your bounty.
T... | stackexchange_codegolf |
Write a program or function that finds the number of zeroes at the end of n! in base 10, where n is an input number (in any desired format).
It can be assumed that n is a positive integer, meaning that n! is also an integer. There are no zeroes after a decimal point in n!. Also, it can be assumed that your programming ... | stackexchange_codegolf |
Your task is to write a function that sorts an array.
Your function:
Cannot call other functions (excluding itself, of course);
Must receive an array of integers as input, and it must return the ordered array. Feel free to add other parameters as input, if you need them.
Cannot use any kind of loop (for, while...) ... | stackexchange_codegolf |
If we have a list of integers we can "squish" one of them by:
decrementing it
replacing adjacent values with its new value
For example in this list:
[1,2,8,3,6]
If we squish the 8 we get:
[1,7,7,7,6]
The question is:
Given a starting array, what is the largest we can make its sum by repeatedly squishing values?
For... | stackexchange_codegolf |
Introduction
How to prove that 1 = 2:
1 = 2
2 = 4 (*2)
-1 = 1 (-3)
1 = 1 (^2)
You can just multiply both sides by 0, but that's cheating. This is just bending the rules a little bit.
Your challenge:
Write a program/function that, when given two integers, outputs a "proof" that the two are equal.
Rules
Your program's... | stackexchange_codegolf |
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... | stackexchange_codegolf |
You are provided with a non-empty array \$A\$ of integers, all greater than 0. But what good is an array if the elements do not sum up to the number \$N\$ (also provided as input)...
So to change that, you can pick any integer of your choice present in the array and replace any of its digits with a different digit betw... | stackexchange_codegolf |
This competition is over. Thanks for the interesting non-esolang entries, and congrats to Jakuje for his winning JavaScript submission.
In the great tradition of ASCII Art Challenges on this site, here's another one. Given an input, draw a spiral.
&>----v
||>--v|
|||>v||
|||@|||
||^-<||
|^---<|
^-----<
Simple, yeah?... | stackexchange_codegolf |
You should write a program or function which receives a string representing an ascii-art polygon as input and outputs ot returns the area of the polygon.
The input is a string consisting of the characters _ / \ L V space and newline defining a simple polygon (which means no extra segments, no self-touch and no self-int... | stackexchange_codegolf |
The setup:
A social network reports the number of votes a post has in two ways: the number of net upvotes (total upvotes - total downvotes), and the % of votes that were upvotes, rounded to the nearest integer (.5 rounds up). The number of net upvotes is an integer (not necessarily positive), and the second is guarant... | stackexchange_codegolf |
A certain well-known cable company has a somewhat clumsy 'Search for Program' feature that works through the remote. It takes muchly much button pushing; so, being an admirer of economy of motion, I thought I'd seek out a programmer's help to minimize the number of finger movements I have to make.
The Craptastic Search... | stackexchange_codegolf |
Write a single line program two or more characters long that contains no line terminators and takes no input. For example, your program might be:
MyProgram
When your program is arranged into the shapes a clock's hands make at 12, 3, 6, and 9 o'clock, it needs to output the corresponding hour number. No other times nee... | stackexchange_codegolf |
I came up with a series of numbers the other day and decided to check what the OEIS number for it was. Much to my surprise, the sequence did not appear to be in the OEIS database, so I decided to name the sequence after myself (note that someone else who's a lot smarter than me has probably already come up with this, ... | stackexchange_codegolf |
Note: SmokeDetector is a bot that detects spam and offensive posts on the network and posts alerts to chat.
What to implement
Smokey's !!/alive command uniformly at random picks one of these messages:
Yup
You doubt me?
Of course
... did I miss something?
plz send teh coffee
Watching this endless list of new question... | stackexchange_codegolf |
Your challenge is to create a clock that displays the time as a hex number, and the background color as the hex color code of the time.
Requirements: No input. In the center of your output you should display the number sign and the current time in 24 hour format as "#hhmmss". The program should update to the current t... | stackexchange_codegolf |
Given a description of the base state of a recursive ASCII pattern, output an expanded state somewhere along the recursion steps.
More specifically: Let the following be an example:
##..
##..
..__
..__
Where # is filled, . is empty, and _ is recursive.
This describes a pattern wherein the top left quarter is filled, t... | stackexchange_codegolf |
A pyramidal matrix is a square matrix where all numbers increase or decrease from the center point, like the two matrices below:
1 1 1 1 1
1 2 2 2 1
1 2 3 2 1
1 2 2 2 1
1 1 1 1 1
Or:
3 3 3 3 3
3 2 2 2 3
3 2 1 2 3
3 2 2 2 3
3 3 3 3 3
Given a non-zero integer n, create a pyramida... | stackexchange_codegolf |
The famous game of Qwirkle has simple but intricate rules (See part 2 of this question for a summary of the rules!)
The Challenge
You are somehow (text input, function parameter, whatever) given a board of a Qwirkle game, like a snapshot from any current timeframe within a game. This board can be anything from complet... | stackexchange_codegolf |
Introduction
Apparently, this question has been asked here and it unfortunately closed. I thought it was a good idea to try again with it, but done right.
XKCD looks at the how we are trained to use "hard to remember passwords", thinking it's secure, but instead, would take a computer 3 days to crack. On the flip side... | stackexchange_codegolf |
Background
The computer game NetHack dates from 1987, before the use of graphics in computer games was widely established. There are lots of monsters in the game, and potentially a lot need to fit on screen at once, so monsters are drawn in a very minimal way: a monster is simply drawn as an ASCII character on screen.
... | stackexchange_codegolf |
Note, challenge copied from question asked at math.stackexchange.
Recently, I attained quite some skill at blowing bubbles. At first I would blow bubbles like this:
But then things started getting strange:
After a while, I was blowing some pretty weird bubbles:
After blowing hundreds, maybe even thousands of such bu... | stackexchange_codegolf |
The Rules
Each submission must be a full program or a function.
The program must take all instances of the string 2015 from the input (1 string), replace it with <s>2015</s>* (with <s> or <strike>). At the end, if there has been at least one 2015 in the string, you must add a newline and this string: *2016. I'm a year... | stackexchange_codegolf |
Your task is to write a non-empty computer program comprised of some sequence of bytes. If we choose a particular byte in the program and remove all instances of it from the program, the modified program should output the removed byte.
For example if our program were
aabacba
Then bcb would output a, aaaca would need ... | stackexchange_codegolf |
The challenge is to golf a program when given a string composed of any number of asterisks, then a comma, than any number of asterisks, say which side has more.
The asterisk-strings can be empty.
Output
0 for ties.
1 for the left.
2 for the right.
Examples
Input: ***,**** Output: 2
Input: ***, Output: 1
Input: ***,*** ... | stackexchange_codegolf |
Your task is pretty simple, calculate the n-th element of A190810.
Elements of A190810 are calculated according to these rules:
The first element is 1
The sequence is increasing
If x occurs in the sequence, then 2x+1 and 3x-1 also do
You can use 1-based or 0-based indexing, but if you use 0-based indexing, please say... | stackexchange_codegolf |
Let a counting tree be a rooted tree in which every node is labeled with the number of descendants it has.
We can represent such trees as ragged lists with each node being represented by a list containing its label followed by its children. For example the following is a counting tree:
[5,[2,[0],[0]],[0],[0]]
However ... | stackexchange_codegolf |
"All roads lead to Rome" is a saying that essentially means there are plenty of different ways of achieving an objective.
Task
Your task is to write a program that finds a set of link connections from one Wikipedia page to the Wikipedia page about Rome.
Notice that it is not enough to find the word Rome with a hyperlin... | stackexchange_codegolf |
I saw a cool gif of the twin dragon curve made from a square, and wondered what would happen if we started from another base image. So I wrote a program to do this.
It's so cool that I thought it would be fun to do it as a challenge.
Task
You will take in a square image with an ... | stackexchange_codegolf |
Implement a function or program which raises x to the power of y. Inputs are 16-bit signed integers. That is, both are in the range [-32768, 32767]. The output should be in the same range. I chose this range because it should make it possible to do exhaustive testing to ensure all edge-cases are covered.
If the output ... | stackexchange_codegolf |
Intro
In J. R. R. Tolkien's Lord of the Rings, this phrase is on the cover of each book.
Three Rings for the Elven-kings under the sky,
Seven for the Dwarf-lords in their halls of stone,
Nine for Mortal Men doomed to die,
One for the Dark Lord on his dark throne
In the Land of Mordor where the Shadows lie.
One Ring to... | stackexchange_codegolf |
From Wikipedia:
The number e is an important mathematical constant that is the base of the natural logarithm. It is approximately equal to 2.71828, and is the limit of (1 + 1/n)n as n approaches infinity.
Challenge
Calculate the number e to 15 digits after the decimal point.
This means that your output must start wi... | stackexchange_codegolf |
Output/print this block of text:
1234567890
2468013579
3691470258
4815926037
5049382716
6172839405
7306295184
8520741963
9753108642
0987654321
Acceptable formats include:
Trailing newlines/whitespace
List of strings
List of lists of characters
List of lists of integers
However, list of integers is not acceptable bec... | stackexchange_codegolf |
This is the follow up question to standard Sudoku solver.
You are given a Sudoku grid where . represents an empty cell and the other cells are filled with numbers 0-8 (inclusive).
Rules:
All the numbers in Sudoku must appear exactly once in all left-top to right-bottom diagonals.
All the numbers in Sudoku must appear ... | stackexchange_codegolf |
This sequence is defined as
Starts with 1, 2, 3
The next element of the sequence is the first number greater than the previous three that is co-prime with each of the previous 3 elements in the sequence.
In other words, if the previous 3 elements are a, b, c, then the next is the first integer n>c such that gcd(a,n)=... | stackexchange_codegolf |
In most programming languages, the string Hello, World! can be represented as "Hello, World!". But if you want to represent "Hello, World!" you need to escape the double quotes with backslashes for "\"Hello, World!\"", and to represent that you also need to escape the backslashes resulting in "\"\\\"Hello, World!\\\"\"... | stackexchange_codegolf |
Normally, I'd open with some flavor text here about being bored and/or lazy but looking through the stack-exchange-api questions that would be far from original. So instead I'm going to open with a meta and self-referential flavor text describing this lack of originality that then describes itself and how meta and self... | stackexchange_codegolf |
Consider the following spiral of positive integers:
We now define grambulation as a binary operation \$\lozenge : \mathbb N \times \mathbb N \to \mathbb N\$, using this grid. Some example inputs and outputs for grambulation are:
\begin{align*}
1 & \lozenge 9 = 25 \\
1 & \lozenge 2 = 11 \\
11 & \lozenge 10 = 25 \\
9 & ... | stackexchange_codegolf |
Inspired by I reverse the source code, ...
Your task, if you wish to accept it, is to reverse text and mirror select characters. Yes, yes, I know. Very surprising.
Input
A string, stdin, an array of characters, or any other source of text. All characters of the input are guaranteed to be in the printable ASCII range (3... | stackexchange_codegolf |
A mountain is defined to be a set of line segments whose first point has coordinates (0,a) where a > 0, and whose last point has coordinates (b,0), where b > 0. All intermediate points have a y-coordinate (ordinate) strictly greater than 0. You are given the points on the mountain sorted in ascending order of x-coordin... | stackexchange_codegolf |
Given latitude/longitude of two points on the Moon (lat1, lon1) and (lat2, lon2), compute the distance between the two points in kilometers, by using any formula that gives the same result as the haversine formula.
Input
Four integer values lat1, lon1, lat2, lon2 in degree (angle) or
four decimal values ϕ1, λ1, ϕ2, λ2... | stackexchange_codegolf |
Let n be a positive integer then n = a + b + c for some a, b, and c that are palindrome integers. What is the largest possible integer a for k = 1 to 1_000_000?
Golf this or have the fastest running time.
NOTE: it's NOT the same as this question as I am asking for the largest palindrome component. The question just ask... | stackexchange_codegolf |
Task
Given a positive integer n, draw the corresponding rocket.
Examples
From n = 1 to 4 the rockets are below. For your program's output, the trailing newline after a rocket is optional.
|
/ \
*---*
| o |
| o |
*---*
/_\
|
/ \
/ \
*-----*
| o o |
| o o |
| o o |
| o o |
*-----*
/___\
|
/ \
/ ... | stackexchange_codegolf |
A pleasing number (according to this definition) is a number that can be passed through the following process (let's use 41802000 as an example):
Separate the trailing identical numbers (41802000 => [41802, 000])
Sort the first half of the digits and take the maximum ([41802, 000] => [8, 000])
Take the length of the f... | stackexchange_codegolf |
Definition
\$a(1) = 1\$
\$a(2) = 2\$
\$a(n)\$ is smallest number \$k>a(n-1)\$ which avoids any 3-term arithmetic progression in \$a(1), a(2), ..., a(n-1), k\$.
In other words, \$a(n)\$ is the smallest number \$k>a(n-1)\$ such that there does not exist \$x, y\$ where \$0<x<y<n\$ and \$a(y)-a(x) = k-a(y)\$.
Worked out ... | stackexchange_codegolf |
The title of Numberphile's newest video, 13532385396179, is a fixed point of the following function \$f\$ on the positive integers:
Let \$n\$ be a positive integer. Write the prime factorization in the usual way, e.g. \$60 = 2^2 \cdot 3 \cdot 5\$, in which the primes are written in increasing order, and exponents of 1... | stackexchange_codegolf |
Input a list of strings a and a string s for search keyword. Find out all strings in a which contains s as subsequence. And sort them in the following order:
Exactly equals to s
Starts with s
Contains s as substring (continuous subsequence)
Contains s as subsequence
Detail
When two strings belongs to the same sortin... | stackexchange_codegolf |
If we take a positive integer \$n\$ and write out its factors. Someone can determine \$n\$ just from this list alone. In fact it is trivial to do this since the number is its own largest factor.
However if we take \$n\$ and write only the first half of its factors (factors that are smaller than or equal to \$\sqrt{n}... | stackexchange_codegolf |
Sandbox
A spin-off of a rip-off of a rip-off of a rip-off of a rip-off. Go upvote those!
Your task, if you accept it, is to write a program/function that outputs/returns its input/argument. The tricky part is that if I left shift your source code, the output must be left shifted too. Likewise, if I right shift your so... | stackexchange_codegolf |
Here’s how to backspace-and-retype from one string to another:
Start from the first string.
Remove characters at the end until the result is a prefix of the second string. (This may take 0 steps.)
Add characters at the end until the result equals the second string. (This may take 0 steps, too.)
For example, the path ... | stackexchange_codegolf |
Write a quine which attempts to invert the case of as many ascii characters in the source code as possible. For example in javascript:
(x=function(y){return ('(x='+y+')(x)').toUpperCase();})(x)
Standard quine rules apply.
The score is given by number of bytes in the source code - number of case inversions. For examp... | stackexchange_codegolf |
The prospect of this challenge is:
If your program is run normally, all of the code in the speech marks (" - double quotes) should be printed.
If your program is wrapped in double quotes (in turn inverting the speech marks), the code that is normally not in quotes should be printed.
E.g:
Let's say you have the follow... | stackexchange_codegolf |
Your task is to write a program which, given a number and a string, splits the string into chunks of that size and reverses them.
Rules
Your program will receive a positive integer n, as well as a string s with length at least one consisting of only printable ASCII (not including whitespace). The string should then be ... | stackexchange_codegolf |
Definition of long text
Long text usually shows emphasis, for instance, loooooool or yaaaaaaaaaay. Usually the vowel is replicated many times. In this challenge we require:
At least 3 times, which means yaaay and yaaaay are allowed, but yay and yaay are not.
Consistent, which means that shoes can turn out be shoooeee... | stackexchange_codegolf |
Sandbox
A spin-off of a rip-off of a rip-off of a rip-off of a rip-off. Go upvote those!
Your task, if you accept it, is to write a program/function that outputs/returns its input/argument. The tricky part is that if I left shift your source code, the output must be left shifted too. Likewise, if I right shift your so... | stackexchange_codegolf |
This question is a part of the lean LotM.
A ring is a type of structure that takes the rules of addition and multiplication we are familiar with and abstracts them, so we can reason about them. To do this we state a number of expected properties as axioms and see what we can say about systems that follow these axioms.... | stackexchange_codegolf |
EDIT
It appears that there has been some confusion following my typo in the original post which used a lowercase o to define the plane and then an uppercase later. Unfortunately this bug did not get picked up in the Sandbox. Since many members have written answers with both and since the typo was my fault I will allow ... | stackexchange_codegolf |
Background
A matryoshka doll (or Russian nesting doll) is a set of dolls that fit inside of each other. I've accidentally mixed up my collection of matryoshka dolls and I don't remember which one goes inside which.
Objective
Given a list of unique strings, sort them into nested matryoshka dolls. Each string is an indiv... | stackexchange_codegolf |
Well I think it is about time we have another proof-golf question.
This time we are going to prove the well known logical truth
\$(A \rightarrow B) \rightarrow (\neg B \rightarrow \neg A)\$
To do this we will use Łukasiewicz's third Axiom Schema, an incredibly elegant set of three axioms that are complete over proposit... | stackexchange_codegolf |
Given two points A and B, find the angle from line AO to line BO about point O where O is the origin ((0,0)). Additionally, the angle may be positive or negative depending on the positions of the points (see examples). Input will be points A and B, and may be given in any convenient form. Output will be the angle in de... | stackexchange_codegolf |
I have an ASCII-art box and I need a program to open it.
Examples
Input:
-------
| |
|_____|
Output:
/
/
/
/
/
/
/
| |
|_____|
Specification
The first line will only consist of -, at least 3 of them
The middle rows will start with | have spaces, and end with |
All the middle rows will b... | stackexchange_codegolf |
Whyte Notation is a classification method mainly for steam locomotive, that classifies by wheel arrangement. On a steam locomotive ( we're only focusing on non articulated locomotives here ), the wheels are generally disposed like this : you have a specific number of leading wheels, then a specific number of driver whe... | stackexchange_codegolf |
Objective
Given a matrix of connected box drawing characters, count its genus, the number of plane sections it encloses.
Valid input
The box drawing characters are ─│┌┐└┘├┤┬┴┼╴╵╶╷ (U+2500 U+2502 U+250C U+2510 U+2514 U+2518 U+251C U+2524 U+252C U+2534 U+253C U+2574 U+2575 U+2576 U+2577). The matrix shall contain these c... | stackexchange_codegolf |
This is mostly for the memes. I regret existing.
Rules
Your code has to output, by either printing or showing in stdout, the phrase This ain't it Chief. in that exact format.
You can only use the characters from the phrase in either format of
UTF-8 (Aa Cc Ee Ff Hh Ii Nn Tt Ss . ')
or hex bytes (41 61 20 43 63 20 45 ... | stackexchange_codegolf |
"First they came..." is a poem by Martin Niemöller:
First they came for the Socialists, and I did not speak out-
Because I was not a Socialist.
Then they came for the Trade Unionists, and I did not speak out-
Because I was not a Trade Unionist.
Then they came for the Jews, and I did not speak out-
Because I was not a... | stackexchange_codegolf |
In this challenge you have to find out which nth second it is now in this year, current date and time now. Or in other words, how many seconds have passed since New Year.
An example current Date is (it's not given, you'll have to find the current Date):
March 5, 2021 1:42:44 AM
For which the answer is 5449364 (or opti... | stackexchange_codegolf |
Related: Clearly parenthesize APL trains
Background
In the most basic form, APL has two kinds of tokens: arrays and functions. For this challenge, we will use a lowercase letter a-z for an array, and an uppercase letter A-Z for a function. Furthermore, we will assume each character is a token of its own; Fx is equivale... | stackexchange_codegolf |
Input a decimal number and round it to an integer, randomly rounding up or down with a probability based on its fractional part, so the expected value of the output equals to the input value.
If input \$x\$ is an integer, the program should output it as is. If \$x\$ is not an integer, the program has a \$x-\left\lfloo... | stackexchange_codegolf |
Given some raw HTML, sanitize it by formatting the spaces, as defined below.
Output rules:
Like many challenges, this one is inspired by XKCD.
First, "untag" all tags with nothing but spaces in them. (<i>te<b> </b>xt</i> becomes <i>te xt</i>). If a tag has nothing in it (like <b></b>, simply delete it and move o... | stackexchange_codegolf |
Background
The convex hull of a finite number of points is the smallest convex polygon that contains all of the points, either as vertices or on the interior. For more information, see this question on PGM which defines it very well.
Input
N+1 2-D coordinates (N >= 3) passed through STDIN (with other usual golf inputs ... | stackexchange_codegolf |
Note: This challenge has been moved to Polyglot the (non constant) OEIS! to avoid closure.
Introduction
We all know and love the on-line encyclopedia of integer sequences (OEIS). So what if we made an off-line version? Well, that would be kinda too easy, wouldn't it and how would you select a sequence with our standa... | stackexchange_codegolf |
After giving back the results of the last topology exam to his students, Pr. Manifold was worried about complaints.
Since he is aware his students know where his office is located, Prof. Manifold decided to transform his office into a bunker with a 10 digit password (all characters are digits).
But he suspected his st... | stackexchange_codegolf |
In this challenge you will remove one of my least favorite features, operator precedence from traditional math notation, to acheive the syntax of one of my favorite languages, APL. The APL subset we will be working with includes only a few functions and single digit numbers. (No arrays!)
Here is the grammar of the inpu... | stackexchange_codegolf |
Objective
Given a vertex figure consisting of regular convex polygons, determine whether it represents a convex uniform polyhedron.
What is a uniform polyhedron?
A uniform polyhedron is a polyhedron whose faces are regular polygons, while having the same vertex figure for each vertices. Generally a uniform polyhedron c... | stackexchange_codegolf |
Thanks to HyperNeutrino for making more test cases
Often in chat, someone will ask a question, and multiple people will answer it at the same time. Usually, the person who was beaten to the gun will say "ninja'd", creating even more unnecessary chat.
Given a chat log similar to the following:
Community: Hi
Test: Hi
Ran... | stackexchange_codegolf |
Consider the following spiral of positive integers:
We now define grambulation as a binary operation \$\lozenge : \mathbb N \times \mathbb N \to \mathbb N\$, using this grid. Some example inputs and outputs for grambulation are:
\begin{align*}
1 & \lozenge 9 = 25 \\
1 & \lozenge 2 = 11 \\
11 & \lozenge 10 = 25 \\
9 & ... | stackexchange_codegolf |
King of the Cards
Code available here!
In this King of the Hill challenge, you must write a bot that can play Crazy Eights. This is a card game often played by children, in which the objective is to empty your hand.
How to Play
The game of Crazy Eights is deceptively simple. At the beginning of the game, each player ge... | stackexchange_codegolf |
Blokus is a board game in which players take turns placing pieces on a \$ n \times n \$ square grid. In this version of the game, there will be just one person playing. The person is given \$ 21 \$ unique polyominoes, ranging from \$ 1 \$ to \$ 5 \$ tiles each. They then proceed to place down a subset of the pieces ont... | stackexchange_codegolf |
Strobogrammatic Numbers
Definition
A number which is rotationally symmetrical, i.e., it'll appear the same when rotated by 180 deg in the plane of your screen. The following figure illustrates it better,
(source: w3resource.com)
Task
Given a number as the input, determine if it's strobogrammatic or not.
Examples
Tr... | stackexchange_codegolf |
The reverse of an n-bit number is just its n binary digits in reverse order:
001010010 → 010010100
Given a number n, generate all n-bit integers ([0, 2n-1]) in an arbitrary order, with only one restriction: there must be a splitting point such that the reverse of an integer is on the opposite side of the splitting p... | stackexchange_codegolf |
Inspired by this Stack Overflow question.
The challenge
Input
An array of square matrices containing non-negative integers.
Output
A square matrix built from the input matrices as follows.
Let \$N \times N\$ be the size of each input matrix, and \$P\$ the number of input matrices.
For clarity, consider the following ex... | stackexchange_codegolf |
Given a 7-segment display with some segments switched on and some off, find a sequence of digits (0-9), such that after toggling the corresponding segments for each digit, all segments are switched off.
Example
_
_ [3] => | [1] => [OFF]
_ |
Numbers and their corresponding segments:
_ ... | stackexchange_codegolf |
I have a pile of clean socks that I want to sort into pairs. Unfortunately, I can only take socks from either end of the pile, not the middle. Further, I can only remove socks from the pile a matching pair at a time. My strategy is to first split the pile into one or more smaller piles. I think some examples will make ... | stackexchange_codegolf |
Summer Klerance, a senior in college, is what her teachers refer to as GBL*. Students in her probability class have been assigned individual problems to work on and turn in as part of their final grade. Summer, as usual, procrastinated much too long, and, having finally looked at her problem, realizes it is considerabl... | stackexchange_codegolf |
Write a script, program or function which takes one input of type string and outputs or returns some sort of indication wether the input string was 'hi whats up' (without the apostrophes) or not.
You can for example return true if it was and false if it wasn't. Or print something to the screen, like 1 or 0.
It just has... | stackexchange_codegolf |
In this challenge we considered a frog hopping around a lily pond. To recap the lily pond was represented as a finite list of positive integers. The frog can only jump forward or backwards by a distance equal to the number at its current location. So for example:
[2, 3, 1, 4, 1]
Here the frog is on a 1 so i... | stackexchange_codegolf |
Summer Klerance turned in her term assignment for this challenge. Her professor was miffed (but also amused) when he overheard a disgruntled classmate of Summer's saying she got her answers by simulation rather than by the probabilistic methods covered in the course. Summer received a note to see the prof during his ne... | stackexchange_codegolf |
Powerful numbers are positive integers such that, when expressed as a prime factorisation:
$$a = p_1^{e_1} \times p_2^{e_2} \times p_3^{e_3} \cdots \times p_k^{e_k}$$
all exponents \$e_1, e_2, ...\$ are greater than or equal to \$2\$. Note that the exponents do not include zero exponents, as exampled by \$200 = 2^3 \ti... | stackexchange_codegolf |
Challenge: Add two numbers. In O(n^m) time, where n and m are the two numbers given. Sleeping, or your language equivalent, is not allowed.
Input: Two integers, separated by a space.
Output: The sum of the two integers.
Additional notes: The exact timing doesn't matter, as long as the input 1000 2 takes roughly 1/1000t... | stackexchange_codegolf |
So I really like to mess with tables and shallow and deep copies and I can do it in 239 chars! I wonder if there's a shorter way to do it...
Rules:
It must be done in less than 239 chars.
You must set table.copy.shallow and table.copy.deep.
A deep copy must maintain recursion. (so if I had tx.t == tx, a deep copy must... | stackexchange_codegolf |
You've inherited a server that runs several apps which all output to the same log.
Your task is to de-interleave the lines of the log file by source. Fortunately, each line begins with a tag that indicates which app it is from.
Logs
Each line will look something like this:
[app_name] Something horrible happened!
App ... | stackexchange_codegolf |
Picolisp has a feature called "super parentheses":
Brackets ('[' and ']') can be used as super parentheses. A closing bracket will match [all parentheses to and including] the innermost opening bracket, or [if there are no unmatched opening brackets] all currently open parentheses. src
Taking a string containing only... | stackexchange_codegolf |
The Champernowne Constant is the irrational number 0.1234567891011... extending ad infinum.
We've done a question about it before. But this question is about its reciprocal, known as the Inverse Champernowne Constant. This is approximately 8.10000007.
Given a string of between one and three digits (every 3-digit stri... | stackexchange_codegolf |
Given two line segments, determine if the line segments intersect and if so, where. In the case that the two given line segments are co-linear and overlap, determine the midpoint of the overlapping segment. Lines will be specified in pairs of (x, y) coordinates.
Examples
[(-1, -1), (1, 1)], [(-1, 1), (1, -1)] => (0, 0... | stackexchange_codegolf |
"A picture is worth a thousand words"—so the old saying goes. The average word is about four characters long, so a picture conveys 4kB of information. But how much entropy, rather than information, can a picture convey?
Your task is to generate an image, exactly 4,000 bytes in size, with the highest entropy possible. Y... | stackexchange_codegolf |
The goal of this challenge is to show how many characters are in the name of a given integer. This is code golf, so the smallest code wins.
RULES
The input will be between 0 and 100 (inclusive). If it is not the program won't return anything.
The result has to be printed as input : answer
Result for 100 is hundred
Fo... | stackexchange_codegolf |
The challenge involve simply toggling a string within another string.
Explanation
If the toggle string is a substring of the main string, remove all instances of the toggle string from the main string; otherwise, append the toggle string at the end of the main string.
Rules
All string are composed of printable ASCII... | stackexchange_codegolf |
There are 10 types of people in the world, those who understand binary and those who do not.
Where are you? Let's see!
Challenge
Your task is to convert a decimal integer to binary, only using a set of arithmetic operators (+, -, *, / and %). You can use conditional statements, loops and variables. (No bitwise operator... | stackexchange_codegolf |
Given a list of countries in alphabetical order, put them in the same order as they are given in the song "Yakko's World".
Specifically, you are given the following list of countries* exactly:
Abu Dhabi, Afghanistan, Albania, Algeria, Algiers, Angola, Argentina, Australia, Austria, Bahamas, Bahrain, Bangladesh, Barbado... | stackexchange_codegolf |
Given input n, produce a word grid of size n, in as few bytes as possible.
Details
The number provided will always be odd. The centre square of the grid must always be empty (a space character). The letters that fill the grid must be chosen at random from the English Scrabble letter distribution of letters. That is, ea... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.