instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
(l, r) defines a line whose left end is at l and the right end is at r, on a 1-dimensional space.
Given 2 lines b = (0, bz) and f = (i, i + fz), v = (l, r) is the overlapping part of these lines. When b and f do not overlap (when v cannot have a positive length), v = (0, 0).
(input) -> (output)
bz, fz, i -> l, r
The... | stackexchange_codegolf |
Objective
Given a date, spell it out in Romanized Japanese.
I/O Format
The input format is flexible. The output format is <month spelling> <day spelling>; note the space. You can freely mix cases in output. You may output trailing newline.
Mapping
Months
Month
Spelling
January
Ichigatsu
February
Nigatsu
Mar... | stackexchange_codegolf |
I though this would be a good challenge : http://adventofcode.com/2016/day/1
Task description
Given a sequence of rotations and distances following the pattern (L|R)[1-9][0-9]*, give the manhattan distance between the start and the ending points, that is the minimal number of vertical and horizontal moves on a grid.
Ex... | stackexchange_codegolf |
As someone who can't be bothered to look at their pentominos to see if it makes a rectangular shape, I've decided to make you write a program that does it.
Your task
Given some input split by newlines containing 12 unique characters, decide if it is a valid solution.
A valid solution MUST
Have 5 of each character (exc... | stackexchange_codegolf |
Given an integer n ≥ 0 , output it in a non-positional base-3 notation, using digits 139ABCDE… and a 1-character separator. Every digit is a consecutive power of 3 and the digits on the left side of the separator are negated, e.g. A931|B → 81−(1+3+9+27) → 41. A digit may appear only once.
Rigorously, let ... | stackexchange_codegolf |
Telephones in the United States (and perhaps some other places) have letters associated with some of the numbers.
2 = A, B, C
3 = D, E, F
4 = G, H, I
5 = J, K, L
6 = M, N, O
7 = P, Q, R, S
8 = T, U, V
9 = W, X, Y, Z
No letters are associated with the number 0 or 1.
Your challenge: Given any phone number in seven-digit... | stackexchange_codegolf |
plorcly borglar is a "mod" created by jan Misali for the constructed language toki pona that makes words sound funny.
It involves substituting the 14 toki pona letters for funnier versions plus 2 extra rules. The substitutions are:
toki pona letter
plorcly borglar letter
m
bl
n
gl
p
b
t
pl
k
cl
s
scr... | stackexchange_codegolf |
Your task is to improvise a hardware random-number generator with whatever hardware you have lieing around.
Challenge
Write a program with the following properties:
It prints either 0 or 1 (and nothing else).
The output depends on a physical process and not just the internal state of the computer.
There is no relation... | stackexchange_codegolf |
Write some code to do the following:
Take as its input a signed integer in either signed decimal or signed octal
(explained below)
If the number is decimal convert it to octal. If it's octal, convert it to decimal
Output the number!
Instead of starting with a 0, negative octal numbers will start with a Z (capital zed... | stackexchange_codegolf |
The Four color theorem States that no more than four colors are required to color the regions of a map.
The challenge
Given a list of State borders assign each state ID a color so that no two adjacent states have the same color. The output Should be a CSS stylesheet assigning the color to the state's 2 letter ID code. ... | stackexchange_codegolf |
Challenge
Premise
Bob lost1 Alice's precious grand piano. Big mistake. Alice has now stolen Bob's low-orbit ion cannon.
Alice refuses to just make up with Bob, so let's help her give him a light tap on the roof. Suppose that from the top Bob's house looks like a lattice polygon, where all points have integer coordinate... | stackexchange_codegolf |
A donut distribution (for lack of a better term) is a random distribution of points in a 2-dimensional plane, forming a donut-like shape. The distribution is defined by two parameters: the radius r and spread s, in which the distance to the origin follows a normal (Gaussian) distribution around r, with a standard devia... | stackexchange_codegolf |
The cop's thread is here
The robber's task is to find a program of size equal to or less than the cop's program, which, when given an itself as input, produces the same output as the cop's program.
Additionally, even if a cop's answer is provisionally marked Safe and has been revealed, you can still crack it by finding... | stackexchange_codegolf |
The Bernoulli numbers (specifically, the second Bernoulli numbers) are defined by the following recursive definition:
Where denotes a combination.
Given a nonnegative integer m as input, output the decimal representation OR a reduced fraction for the mth second Bernoulli number. If you output a decimal representation... | stackexchange_codegolf |
The crazy mathematician owns a wide collection of numbers, and therefore the space he has left is quite limited. To save some, he must fold his integers, but unfortunately he is really lazy. Your task, if you wish to help him, is to create a function / program that folds a given positive integer for our number maniac.
... | stackexchange_codegolf |
Perfect License Plates
Starting a few years ago, I made myself a little game while driving around: checking if nearby license plates are "perfect". It's relatively rare, but exciting when you find one.
To check if a license plate is perfect:
Sum up the characters, with A = 1, B = 2, ... Z = 26.
Take each consecutive... | stackexchange_codegolf |
Lists can contain lists and we have nested lists. But we don't like nested lists and want to flatten them. By flattening I mean create a list which does not contain any list, but elements of lists it contained before. I'll explain it more.
Input
An arbitrary size list which has the below properties:
it can contain int... | stackexchange_codegolf |
Write a proper quine whose every rotation is itself a proper quine.
For example, if your source code is abcdef, then:
abcdef would output abcdef
bcdefa would output bcdefa
cdefab would output cdefab
defabc would output defabc
efabcd would output efabcd
fabcde would output fabcde
A rotation "is made by splitting a str... | stackexchange_codegolf |
Challenge :
Given a string split at specific positions and capitalize the first character of the given word. Capitalize the first word's first char if and only if it was already capitalized
Input :
A string s and a character c.
Ouput :
The string with each occurrence of c replaced with the first char capitalized
Exam... | stackexchange_codegolf |
Challenge
Given two strings in any default I/O format, do the following:
NOTE: The challenge will refer to the first string as the "data" and the second referred to as the "program".
Change the program to an infinite string which is just the program repeated infinitely (e.g. 10 --> 1010101010...). The challenge will r... | stackexchange_codegolf |
Task
Write a program/function that, given three integers n,a,b prints a regular expression which matches all of the base-n integers from a to b (and no integers outside of that range).
Your algorithm should, in theory, work for arbitrarily large integers. In practice, you may assume that the input can be stored in your... | stackexchange_codegolf |
Make a program that takes a length and list of intervals and outputs a ruler of that length with longer ticks for each interval using the line drawing characters ┌ ┬ ┐ │ ╵
The first row of the output should begin with the tick for 0 with ┌ and end with a tick for the length with ┐, with a ┬ being used for every charac... | stackexchange_codegolf |
Given an integral polynomial \$p\$, determine if \$p\$ is a square of another integral polynomial.
An integral polynomial is a polynomial with only integers as coefficients.
For example, \$x^2+2x+1\$ should gives truthy, because \$x^2+2x+1 = (x+1)^2\$.
On the other hand, \$2x^2+4x+2\$ should gives falsy: \$2x^2+4x+2 = ... | stackexchange_codegolf |
EDIT: I'm getting a lot of comments about this not terminating - I will give the "correct answer" tag to either the first person who gives me FF(3) (as in provides it in their answer) or proves that FF(3) does indeed blow up indefinitely.
Task:
Your task is make the smallest program possible that generates the list of ... | 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 |
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 ... | stackexchange_codegolf |
In this challenge, you have to implement a basic spell checker and autocorrector. Your program will use the first input as a source for a dictionary of words, and will use that to autocorrect the second input, finding a close match to some incorrectly spelt words, outputting the result
Specifications
You will receive ... | stackexchange_codegolf |
Background
You know how in text editors and just text fields in general, there's always that blinking bar where you type? Yeah, simulate typing there.
You'll be given 3 inputs: The current text field, the position of the cursor, and the input sequence.
Here's an example:
Hello, World!
5
[U];[U];[B];[B];[B];[B];[B];[U];... | stackexchange_codegolf |
Input
A non-empty shuffled string consisting of ASCII characters in the range \$[32..126]\$.
Output
The output is obtained by applying successive rotations to the input string.
For each letter ([a-zA-Z]) in the input string, going from left to right:
if the letter is in upper case, rotate all characters before it by o... | stackexchange_codegolf |
Inspired by Expand exponentation.
Knuth's up arrow notation is used for big numbers such as Graham's number.
If we look deeper, we can see how it makes big numbers.
One arrow means exponentiation. e.g. 2↑3 equals 2^3 = 8.
Two or more arrows means repeating the instructions of n-1 arrows. e.g. 2↑↑3 equals 2↑2↑2 equals 2... | stackexchange_codegolf |
Jack is a little businessman. He found out a way to earn money by buying electricity on days when it's cheap and selling it when it's much more expensive. He stores the electricity in a battery he made by himself.
Challenge
You are given N (if required), the number of days Jack knows the cost of electricity for, and X,... | stackexchange_codegolf |
The Len(language,encoding) family of languages is a variety of Lenguage derivatives. To encode a program into a Len language, you replace every character with its representation in a certain encoding, then turn that into a giant integer.
Your challenge is to write a function or program that encodes your language into a... | stackexchange_codegolf |
Your task is to output a spaceship of size n with shooters/guns and n bullets of character - (with spaces in between each bullet) for each gun
Rules
If n is odd, you must output the guns every even numbered row
If n is even, you must output the guns every odd numbered row
All rows with guns must have n+1 # character... | stackexchange_codegolf |
The Hilbert curve is a space filling fractal that can be represented as a Lindenmayer system with successive generations that look like this:
Thanks to http://www.texample.net/tikz/examples/hilbert-curve/ for the image.
Goal
Write the shortest program possible (in bytes) that takes a positive integer n from stdin and ... | stackexchange_codegolf |
Background
A rooted tree is an acyclic graph such that there is exactly one path from one node, called the root, to each other node. A node v is called the parent of another node u if and only if the path from the root to u goes through v and there is an edge connecting u and v. If node v is the parent of node u, node ... | stackexchange_codegolf |
Write the shortest possible program or function that will join a list of columnar strings.
For this challenge, columnar strings are defined as one-character-wide strings spanning across multiple lines. Each character, except for the last one, is separated by a newline character. Some examples, separated by ---:
a
b
c
d... | stackexchange_codegolf |
Imagine you place a knight chess piece on a phone dial pad. This chess piece moves from keys to keys in an uppercase "L" shape: two steps horizontally followed by one vertically, or one step horizontally then two vertically:
+-+
|1| 2 3
+-+
`-------v
| +-+
4 | 5 |6|
| +-+
|
... | stackexchange_codegolf |
Background
The Sidi polynomial of degree \$n\$ – or the \$(n + 1)\$th Sidi polynomial – is defined as follows.
$$S_n(x) = \sum^n_{k=0}s_{n;k}x^n \text{ where } s_{n;k} = (-1)^k\binom n k (k+1)^n$$
The Sidi polynomials have several interesting properties, but so do their coefficients. The latter form OEIS sequence A0755... | stackexchange_codegolf |
We have a group of stealthy computer-savvy geeks who are also musicians with a very subversive element to their songs that the authorities in their totalitarian country just can't stand, and are itching to show up at one of the concerts, fire off rubber bullets and tear gas at the audience, and arrest the band members ... | stackexchange_codegolf |
Conway's Game of Life is a well known cellular automaton "played" on an infinite grid, filled with cells that are either alive or dead. Once given an initial state, the board evolves according to rules indefinitely. Those rules are:
Any live cell with 2 or 3 living neighbours (the 8 cells immediately around it) lives ... | stackexchange_codegolf |
The Challenge
Given a list of words and a grid of letters, your job is to determine which of the given words can be found on the grid in all 8 directions (forward, backward, up, down, and the 4 diagonal directions), much like a word search. The grid is toroidal, so the grid wraps around on the edges. Letters can be reu... | stackexchange_codegolf |
Given two natural numbers (less than 100) as input print the sequence of intermediate results obtained when computing the sum of the two numbers using only the following operations1:
n <-> (m+1) for integers nand m satisfying that equation
(a+b)+c <-> a+(b+c) for integers a,b and c (associative law)
You are not allow... | stackexchange_codegolf |
PARI/GP is a free computer algebra system. It is designed for (algebraic) number theory, not golfing, but that's part of the attraction. Unsurprisingly, it fares best at mathematical tasks; its support for string manipulation is primitive. (Having said that, advice for golfing non-mathematical tasks is also welcome.)
A... | stackexchange_codegolf |
What is Typoglycemia?
Typoglycemia is a term that refers to the phenomenon where readers are able to understand text even when the letters in the middle of words are jumbled, as long as the first and last letters of each word remain in their correct positions. For example,
Aoccdrnig to a rscheearch at Cmabrigde Uinerv... | stackexchange_codegolf |
People on this site really love to embellish their post titles...
Stewie's sequence: + * - / + * - /
However, when this title needs to be included in the page URL, it is simplified:
stewies-sequence
The Challenge
Your task is to create a program or function which, given a string representing a post title, outputs/re... | stackexchange_codegolf |
Not to be confused with Is my OS 32-bit or 64-bit.
This one is very simple, tell me whether or not my CPU supports 64-bit instructions. If my CPU supports 32-bit instructions, print '32', if my CPU supports 64 bit instructions, print '64', if my processor naitively supports other lengths of instructions, print 'other'.... | stackexchange_codegolf |
Task:
Consider the problem: "given a chessboard with one square missing, cut it into 21 L-triominoes". There is a well-known constructive proof that this can be done for any square chessboard size that is a power of two. It works by splitting the chessboard into a smaller chessboard with the hole in it and one big trio... | stackexchange_codegolf |
You are given four numbers. The first three are \$a\$, \$b\$, and \$c\$ respectively, for the sequence:
$$T_n=an^2+bn+c$$
You may take input of these four numbers in any way. The output should be one of two distinct outputs mentioned in your answer, one means that the fourth number is a term in the sequence (the above ... | stackexchange_codegolf |
Exposition
Your mathematics teacher is a big fan of Vieta's formulas, and he believes that you should use them to solve quadratic equations. Given the equation
ax^2 + bx + c = 0
the product of its roots is c/a, and their sum is -b/a. When all of a, b and c are nonzero integers, assuming the roots are rational numbers,... | stackexchange_codegolf |
You step into the restroom, and notice that the toilet paper has missing! It occurs to you that someone had stolen it. Strangely enough, the first thing you would like to know is the amount of toilet paper the thief stole.
Task
You are given three integers \$ I \$, \$ R \$, and \$ G \$, the details of the toilet paper,... | stackexchange_codegolf |
As you probably know, there have been multiple lovely Jimmy challenges recently popping up. In these challenges, you were challenged with our beloved friend's acrobatics skills. Now we've got a different challenge for you. Today you will be identifying different types of Jimmys!
Explanation
There are three varieties o... | stackexchange_codegolf |
The input will be two five letter words. They don't actually have to be dictionary words, just any five letters each, all lowercase or all uppercase, your choice. Only A-Z will appear in the input words and they will always be 5 characters in length.
Your program is to score them both as though they were poker hands an... | stackexchange_codegolf |
Credit to Geobits in TNB for the idea
A post without sufficient detail recently posited an interesting game:
2 children sit in front of an array of candy. Each piece of candy is numbered 1 to x, with x being the total amount of candy present. There is exactly 1 occurrence of each number.
The goal of the game is for the... | stackexchange_codegolf |
This is a variant on the self-replicating program, defined here as a program that outputs its source (or a quine). Below is an example of a self-replicating program in Python:
s = 's = %r\nprint(s%%s)'
print(s%s)
When run from a file, this script should output itself.
Instead of a self-replicating program, I want you ... | stackexchange_codegolf |
In this challenge you are to write a program or function, that takes a string as input and outputs one of two possible values. We will call one of these values truthy and one falsy. They do not need to actually be truthy or falsy. For an answer to be valid it must meet four additional criteria
When you pass your pro... | stackexchange_codegolf |
A Ken Thompson virus is a virus that infects your compiler and other programs. Since it infects all your tools, you can not detect it without using tools from before the virus was introduced.
Your will create a prototype for inserting the Ken Thompson virus into code. The goal of this virus will be to allow you to (fak... | stackexchange_codegolf |
Credits to Calvin's Hobbies for nudging my challenge idea in the right direction.
Consider a set of points in the plane, which we will call sites, and associate a colour with each site. Now you can paint the entire plane by colouring each point with the colour of the closest site. This is called a Voronoi map (or Voron... | stackexchange_codegolf |
In this challenge, the goal is to create a pristine truth machine in as few bytes as possible. For reference, a truth machine does the following:
Takes input, which is always 0 or 1
If the input is 0, it is printed and the program terminates
If the input is 1, it is printed forever
A pristine program is one that does... | stackexchange_codegolf |
After your disastrous canoe ride, you ended up falling off a waterfall at the end of the river rapids. Your canoe exploded, but you managed to survive the explosion. However, your river journey went completely off the map - you have now found yourself lost in the midst of a forest. Luckily, you still have your programm... | stackexchange_codegolf |
Given a string as input, output one or more variants of the string such that:
No character is in it's original position
No character is adjacent to a character that it was originally adjacent to
You can assume this will always be possible for the given string, and will only contain single case alphabetical characters... | stackexchange_codegolf |
Background
One of the commonly meme'd aspects of javascript is its incredibly loose type coercion that allows for +!![]+[+[]] == '10' this technique can also be used to create letters as seen in the following example:
[[][[]]+[]][+[]][-~[]] == 'n'
[undefined+[]][+[]][-~[]] // [][[]] -> undefined
['undefined'][+[]][-~[]... | stackexchange_codegolf |
Steganography hides a given message inside a given carrier, producing a package that does not look suspicious. For this challenge, you will write a program that takes an ASCII message and an ASCII carrier as input, and return or print a package that is identical to the carrier except characters corresponding to the mes... | stackexchange_codegolf |
Given a positive integer \$N >= 4\$, output an RSA key pair (both the private and the public key) whose key length is \$N\$ bits.
The RSA key generation algorithm is as follows:
Choose an \$N\$-bit semiprime \$n\$. Let the prime factors of \$n\$ be \$p\$ and \$q\$.
Compute \$\lambda(n) = LCM(p-1, q-1)\$.
Choose an int... | stackexchange_codegolf |
Roll for Initiative!
Introduction
In tabletop games like Dungeons and Dragons, when you begin a battle, all involved parties roll for initiative. In DnD 5e, this is 1d20 + DEX + Other bonuses, where DEX is the bonus given by your Dexterity stat. The characters that roll higher numbers go first. We'll use a similar, det... | stackexchange_codegolf |
Your task is, given a family tree, to calculate the Coefficient of Inbreeding for a given person in it.
Definition
The Coefficient of Inbreeding is equal to the Coefficient of Relationship of the parents. The Coefficient of Relationship between two people is defined as weighed sum over all common ancestry as follows:
E... | stackexchange_codegolf |
Does anyone have tips on how to golf in this language? Please one tip per answer and avoid posting simple and general tips such as "remove whitespace".
Here is the github link and here is the esolang page.
| stackexchange_codegolf |
Given a string of printable ASCII text (including newlines and spaces) that contains at least one character that is neither a newline nor a space, output a truthy value if the string is rectangular, and a falsey value otherwise. Additionally, the source code for your solution must be rectangular.
A string is rectangula... | stackexchange_codegolf |
Taking some output from xxd and turning it into usable shellcode by hand is no fun, so your job is to automate the process.
Rules
Your submission can be a function, lambda, script, or any reasonable equivalent of those. You may print the result, or if your submission is a function/lambda then you may also return it.
Yo... | stackexchange_codegolf |
The set of necklaces is the set of strings, where two strings are considered to be the same necklace if you can rotate one into the other. Your program will take nonnegative integers k and n, and generate a list of the k-ary (fixed) necklaces of length n.
Necklaces will be represented by any representative string. So t... | stackexchange_codegolf |
Given an expression like 4 / 2 + 3, determine whether the expression has the same value in Python 2 and Python 3. Recall that in Python 2 division rounds down (so that 5 / 2 -> 2), whereas in Python 3 division returns a float (so that 5 / 2 -> 2.5).
For simplicity's sake, we will only consider expressions of the form:
... | stackexchange_codegolf |
Vowels rhyme: Apples and Bananas
There is a traditional children's song that repeats the same text over and over, only each time every vowel is replaced with a random vowel, but constant across the current stanza.
Challenge
The objective is to propose the shortest code that performs such a transformation on an input te... | stackexchange_codegolf |
As the title says, you are to create a pristine program in as many languages as possible. A pristine program, taken from here, is:
Let's define a pristine program as a program that does not have any errors itself but will error if you modify it by removing any contiguous substring of \$N\$ characters, where \$1 \le N ... | stackexchange_codegolf |
Introduction
In this challenge, a 2×2 matrix is indexed like this:
0 1
2 3
We define a family of fractal-like patterns F(L), where L is a length-n list of these indices and F(L) has size 2n-1 × 2n-1.
If L == [], then F(L) is the 1×1 pattern #.
If L != [], then F(L) is constructed as follows. Let P be the pattern obta... | stackexchange_codegolf |
Write a program that takes in a string and spells that word out using the NATO Phonetic Alphabet.
The mapping is as follows:
'A' -> 'Alfa'
'B' -> 'Bravo'
'C' -> 'Charlie'
'D' -> 'Delta'
'E' -> 'Echo'
'F' -> 'Foxtrot'
'G' -> 'Golf'
'H' -> 'Hotel'
'I' -> 'India'
'J' -> 'Juliett'
'K' -> 'Kilo'
'L' -> 'Lima'
'M' -> 'Mike'... | stackexchange_codegolf |
Your program must contain all your language's keywords. Ideally, you should have each one exactly once (see Scoring). Of course, this means your language must actually have keywords, so esoteric languages are probably excluded, but just in case...
Any language used must have a dedicated Wikipedia article created more ... | stackexchange_codegolf |
Given an array a that contains only numbers in the range from 1 to a.length, find the first duplicate number for which the second occurrence has the minimal index. In other words, if there are more than 1 duplicated numbers, return the number for which the second occurrence has a smaller index than the second occurrenc... | stackexchange_codegolf |
Introduction
Kerning means adjusting the spacing between the letters of a text.
As an example, consider the word Top written with the following three glyphs:
##### ..... .....
..#.. ..... .....
..#.. ..##. .###.
..#.. .#..# .#..#
..#.. .#..# .#..#
..#.. ..##. .###.
..... ..... .#...
..... ..... .#...
We could just fil... | stackexchange_codegolf |
One way to generalize the concept of a range from the integers to the Gaussian integers (complex numbers with integer real and imaginary part) is taking all numbers contained in the rectangle enclosed by the two ends of the range. So the range between two Gaussian integers a+bi and c+di would be all Gaussian integers x... | stackexchange_codegolf |
The task is a rather simple quine challenge with a twist, you must output your source code in the shape of a pyramid. The shape of a pyramid is defined below:
1
234
56789
ABCDEFG
HIJKLMNOP
QRSTUVWXYZa
bcdefghijklmn
......etc......
The main limitation of this challenge is that your quine mus... | stackexchange_codegolf |
Input:
A positive integer n=p^q where p and q are prime.
Output:
Output the result of q^p
Test cases (in, out):
4, 4
8, 9
25, 32
27, 27
49, 128
121, 2048
125, 243
343, 2187
1331, 177147
3125, 3125,
16807, 78125,
823543, 823543
161051, 48828125
19487171, 1977326743
Scoring:
This is code-golf, so may the shortest code... | stackexchange_codegolf |
Robbers thread
In this cops-and-robbers challenge, your task is to write a program h that outputs "Hello Shue!". Next, you have to choose a string i and also write a Shue program p, so that p(i)=h. Your score is len(p)+len(i). Your answer will contain the language of h, i and your score (please write the score as len(p... | stackexchange_codegolf |
Introduction:
I saw there was only one other badminton related challenge right now. Since I play badminton myself (for the past 13 years now), I figured I'd add some badminton-related challenges. Here the second (first one can be found here):
Challenge:
Some rules about badminton serves:
A serve will always be done di... | stackexchange_codegolf |
Given an unordered collection of positive integers by any reasonable input method, return all of the sub-collections that have an odd number of odd elements (i.e. have an odd total).
This is code-golf so you should aim to minimize the byte count of your program.
Since some languages only have ordered collections (lists... | stackexchange_codegolf |
Given an input string and a wrapping string, find the location of the first input string char in the wrapping string and replace it with the wrapping string char 1 step to the right of that, find the second char in the wrapping string and replace it with the char 2 steps to the right, find the third and replace it with... | stackexchange_codegolf |
Consider a NxN pixel grid with up to M objects drawn on it, either squares or diamonds:
square
diamond
The objects may overlap, so recognition is hard. The task is to give the minimal possible numbers of objects per shape that can be "seen" in the picture and tell how many squares, how many diamonds, and how many ob... | stackexchange_codegolf |
In this challenge, you will write a bot that play's the prisoner's dilemma. Here's the catch: you will not have access to the history of previous games. Instead, you will have access to the opponent itself. In this version, both players get +2 points if they both cooperate, +1 points if they both defect, and if one coo... | stackexchange_codegolf |
Given a variable a (non array) or (any[]) convert to (any[])
function example(s: string | string[]) {
const e = Array.isArray(s) ? s: [s]
return e
}
Is Array.isArray(s) ? s: [s] the shortest way?
| stackexchange_codegolf |
Given two non-empty 01 strings, check if there is string containing both given strings, and their first appearance end at same position.
Test cases:
01, 1 => true (01)
0, 00 => false (0 would at least come 1 character earlier)
01, 11 => false (can't meet on same position)
01, 0 => false (can't meet on same position)
11... | stackexchange_codegolf |
Background
Complex floor is a domain extension of the mathematical floor function for complex numbers. This is used in some APL languages to implement floor ⌊, ceiling ⌈, residue |, GCD ∨, and LCM ∧ on complex numbers.
For the rest of this challenge, an integer refers to a Gaussian integer, i.e. a complex number whose ... | stackexchange_codegolf |
Problem
Given no input write a program or a function that outputs or returns the following string:
(<(<>(<>.(<>.<(<>.<>(<>.<>)<>.<>)>.<>).<>)<>)>)
Rules
Shortest program wins.
Trailing whitespace allowed.
Trailing newlines allowed.
Unused parameters for functions allowed.
| stackexchange_codegolf |
Given a 2-dimensional jagged array and a fill value, pad the array in both dimensions with the fill value to ensure that it is square and not jagged (i.e., all rows are the same length, and that length is the same as the number of rows).
The fill values should always be added to the "edges", which may be the start or t... | stackexchange_codegolf |
Input
A string.
Output
The sum of all integers in the line.
Constraints
1≤Length of line≤500
Sample test Case
Input
the 5is 108 seCONd4 a
Output
117
Explanation
Sum is: 5+108+4=117
| 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 |
This is the cops' post. The robbers' is here.
You make a program and a regex.
For most inputs, one of the following happens:
the regex doesn't match, and the program returns a falsey value
the regex doesn't match, and the program returns a truthy value
the regex matches, and the program returns a truthy value
But for... | stackexchange_codegolf |
This challenge is simple: Take a path to an png image file as input and overwrite that file with a copy of itself rotated 90 degrees clockwise. You may assume that the file has dimensions of 128x128 pixels. You may not use image metadata modifications (like Exif) to rotate the image; the pixels themselves must be trans... | stackexchange_codegolf |
Your job is to create the longest period iterating quine, where the length of each program in the sequence is bounded by 500 bytes.
That is, if you repeat the following steps:
Start with your initial program
Run the current program
Go back to step 2
You will eventually get back to your original program. The number of... | stackexchange_codegolf |
Looking at
Arnauld's answer, it seems like this version is not really more difficult than the other version, so I made it an optional requirement of the other challenge
The absolute value of a number \$x\$ is normally written as \$|x|\$. The left and right side of the absolute value uses the same symbol, so it is not i... | stackexchange_codegolf |
Create a function which takes a polynomial equation, a value for x and returns the result of the operation.
Example: given 4x^2+2x-5 and x=3 output 37. This is the result of 4(3)^2+2(3)-5
Assume all polynomials are valid
Polynomial format will always be coefficient(variable)^exponent => 4x^2 except :
When exponent ... | stackexchange_codegolf |
Surprised that we don't have a symmetric difference challenge yet.
Given two lists only containing positive integers, return all items among these two lists that aren't contained in both of the lists.
Rules
From the set definition:
A set is a collection of definite distinct items.
So you can assume the items in the ... | stackexchange_codegolf |
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
There's a good news and a bad news.
Good news: you got a Christmas present from Santa. (Already?! Christmas is two weeks away!)
Bad news: the present is locked with a laser lock. And a note next to it says:
Only the ones who can prope... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.