instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Consider the problem of N queen on an (NxN) chessboard. Two queens are said to attack each other if they are on the same row, column,
or diagonal. Implements backtracking algorithm to solve the problem i.e. place N non-attacking queens on the board.
| stackexchange_codegolf |
Introduction
This is a follow-up of this challenge where you're taking the role of that person's evil twin. Being evil you don't want to maximize your share, but rather be as unfair as possible and you're not going to make it too obvious, that's why you came up with the following scheme:
You're going to tell the others... | stackexchange_codegolf |
Input
A calendar year from 927 to 2022.
Output
You can use any three distinguishable outputs. As an example,
“K” (short for King)
or
“Q” (short for Queen)
depending on which of the two England had in that year. If there was both a King and Queen in that year you can output either.
If there was no King or Queen for th... | stackexchange_codegolf |
Given a number \$n ≥ 2\$, a blackbox function \$f\$ that takes no arguments and returns a random integer in the range 0...n-1 inclusive, and a number \$m ≥ n\$, your challenge is to generate a random integer in the range 0...m-1 inclusive. You may not use any nondeterministic builtins or behaviour, your only source of ... | stackexchange_codegolf |
Suppose a new fairy chess piece named the Wazir is introduced to chess. Wazirs can move from a position (x, y) to:
(x+1, y)
(x, y+1)
(x-1, y)
(x, y-1)
That is, they move orthogonally like the rook, but only one step at a time like the king. How many such wazirs can be placed on an N×N chessboard so that no two wazi... | stackexchange_codegolf |
Inspired from Is this site down or is it just me?
Challenge
You have to print if a website server is online or not, for you.
Input
The domain name, like codegolf.stackexchange.com
Output
1/True if online
0/False if offline
Rules
Any kind of web access is allowed
URL shorteners allowed
Except 2 no. Rule, all standa... | stackexchange_codegolf |
Input
The board: A 2D container (matrix, list of lists, etc.) of letters like:
["B", "C", "C", "C", "C", "B", "B", "C", "A", "A"],
["B", "A", "C", "B", "B", "A", "B", "B", "A", "A"],
["B", "C", "B", "C", "A", "A", "A", "B", "C", "B"],
["B", "B", "B", "A", "C", "B", "A", "C", "B", "A"],
["A", "A", "A", "C", "A... | stackexchange_codegolf |
You are given 4 positive integers: volume of the first container (v1), volume of the second container (v2), volume of the liquid in the first container (l1), and volume of the liquid in the second container (l2). Your task is to move some of the liquid from container 1 to container 2, making the amount of empty space i... | stackexchange_codegolf |
I was playing with the Fibonacci sequence in binary like so (note that the binary representations are written here from smallest bit to largest bit):
1 1
1 1
01 2
11 3
101 5
0001 ... | stackexchange_codegolf |
Write a program that prints "Hello, world!" without using any kinds of literals.
Don't use string literals, numeric literals, byte literals, char literals, etc. Default values are allowed in languages that have them.
Printing data from external files/websites/arguments is not encouraged.
edit: probably don't use Bool... | stackexchange_codegolf |
We can arrange the positive integers like this:
1_| 2 | 5 | 10
4___3_| 6 | 11
9___8___7_| 12
16 15 14 13
That is, in L-shaped brackets expanding down and right infinitely.
Then, we can read it off with the antidiagonals:
1 2 5 10
/ / /
4 3 6 11
/ / /
9 8 7 12
/ / /
16 15 14 13
For the above, we rea... | stackexchange_codegolf |
You will be given a positive integer as input.
The integer is the board of a seesaw.
Th integer will not have leading zeroes. You may take this input however you like.
Your task is to output the location of the pivot point of this seesaw, such that the board would balance.
A board balances if the moments on each side a... | stackexchange_codegolf |
I've been enslaved in a quine factory. The other workers and I can't communicate with the outside world, we can only slave away making quines all day. The masters will reject any work that isn't a proper quine. I'll have to put messages into the quines I make to let people know we're trapped here.
The Challenge
Help us... | stackexchange_codegolf |
Question
If you are currently on a cell with a value x, you can move to any
cell in the same row or column, provided it has a value y such that x >
y. This move is called a switch.
The input consists of:
two integers 0 < m,n < 50
an integer k indicating the number of switches allowed 0 < k < 20
an m by n grid ... | stackexchange_codegolf |
Objective Write a full program that outputs (to STDOUT or closest alternative) an arbitrary string of text, no more than 64 characters long. Simple enough, right? Well, here's the catch: You may not use any characters that were present in the previous answer's output. That's right, none of them.
Thus, you are trying to... | stackexchange_codegolf |
At time of writing, my reputation is \$16,256\$. As I noted in chat,
Oh cool my rep is the concatenation of two powers of 2: 16,256
Or even the concatenation of a power of 2 and its square, which is much more interesting
which then spawned a CMC about checking if a number has this property.
Given an integer \$n > 0\... | stackexchange_codegolf |
There are some iron particles on a board. We pass a current carrying wire through that board and the particles form circles. Show these circles if input given is the position of the wire.
Consider the board to be a grid of size 7x7 (fixed)
No extra white spaces are allowed.
Input can be 0-indexed or 1-indexed. (0-index... | stackexchange_codegolf |
Your task is to print the text Good morning, Green orb!, with every character repeated in place as many times as the most frequent byte in your source (the mode). A trailing newline is permitted and need not be repeated.
For example if your source was
print p
Since p appears twice and every other byte appears once yo... | stackexchange_codegolf |
Task
Given two integers \$d\$ and \$n\$, find the number of ways to express \$n\$ as a sum of \$d\$ squares. That is, \$n = r_1^2 + r_2^2 + ... + r_d^2\$, such that \$r_m\$ is an integer for all integers \$1 ≤ m ≤ d\$. Note that swapping two different values (e.g. \$r_1\$ and \$r_2\$) is considered different from the o... | stackexchange_codegolf |
Input
The input will be a year between 1583 and 2239. We just want to know when Hannukah was or will be in that year. This is information used by millions of people every year and put in calendars across the world. What could be easier?
Output
The Gregorian date of the first evening of Hannukah that year. That is the ... | stackexchange_codegolf |
I would like to propose a new kind of challenge: Anti Code Golf! (as anti-golf, not anti-code). The idea is to write the longest program you can write to do something.
That would be Code Bowling, as pointed out by ProgramFOX.
Rules
No ridiculously unnecessary whitespace (e.g. 3 lines between each statement, etc. inden... | stackexchange_codegolf |
In this challenge, you will remove duplicate words from each sentence.
Examples
Hello Hello, World!
Hello, World!
Code Code! Golf Code
Code! Golf Code
Hello hello World
Hello World
Programming Golf Programming!
Programming Golf!
Specification
Input will be a string of ASCII characters.
A sentence is defined a... | stackexchange_codegolf |
This challenge is to take an alphabetical string as input and to apply the following conversion:
The first of each type of character of the string must stay, and must be immediately followed by an integer representing how many of these characters were in the original string. Any repeating characters must be omitted.
Al... | stackexchange_codegolf |
There's a river and there are wolves and chickens on one side of the river. They have a raft and they all need to get to the other side. However, the raft cannot travel on its own. The raft will sink if more than two animals are on it. None of the animals want to get wet because the river's cold and dirty. None of the ... | stackexchange_codegolf |
It is quite simple, any language, make output show the time in the HH:MM or HH:MM:SS while the numbers and the colons being ascii art(The output is ascii art not the program)
Sample output:
____________ ________ _____ .________ ________
/_ \_____ \ /\ \_____ \ / | | /\ | ____// _____/
| ... | stackexchange_codegolf |
A simple one:
Take a list of positive integers as input and output the numbers modulus their 1-based index in the list.
If the input integers are {a, b, c, d, e, f, g} then the output should be {a%1, b%2, c%3, d%4, e%5, f%6, g%7} where % is the modulus operator.
Test cases:
10 9 8 7 6 5 4 3 2 1
0 1 2 3 1... | stackexchange_codegolf |
This is the inverse of negative seven's question.
Write a program or function which, given any single, possibly-empty string of printable ASCII (codes \$[32,126]\$) outputs or returns two strings of printable ASCII.
For any two ordered, possibly empty strings \$s_1\$ and \$s_2\$, there must be third string \$s_0\$, whi... | stackexchange_codegolf |
Related, both rope, nail and falling, but reversed and some other differences
Consider a loop of rope hanging on n nails on a row. Given a table showing whether the rope would fall down when each possible set of nails were removed, please provide a possible roping way. You may assume such a solution exist.
Here, "fall ... | stackexchange_codegolf |
Given a non-negative integer Excel-style date code, return the corresponding "date" in any reasonable form that clearly shows year, month, and "day".
Trivial, you may think. Did you notice the "scare quotes"? I used those because Excel has some quirks. Excel counts days with number 1 for January 1st, 1900, but as if 19... | stackexchange_codegolf |
Given a sequence of the bases Adenine, Cytosine, Guanine and Thymine (encoded as ACGT), you're to produce an ASCII art representation of a corresponding double strand of DNA.
The strand will extend vertically. The left-hand strand is the one you are given as input. The right-hand strand will be its complement. For thos... | 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 |
In this challenge you will receive as input a list of binary lists. The list represents a game board with each element representing a location on the board. The list at each location represents the tiles on the board, with a 0 being a white tile (□) and a 1 being a black tile (■). Each place can have any number of t... | stackexchange_codegolf |
Introduction:
Ever used Dropbox with some other people and you both modified the same file? Ever had a multi-user application with a relational database, and two people were modifying (or worse, one was deleting and the other modifying) the same object? Well, let's simulate that with this challenge (sort-of).
For the s... | stackexchange_codegolf |
In Wordle, you try to guess a secret word, and some letters in your guess are highlighted to give you hints.
If you guess a letter which matches the letter in the same position in the secret word, the letter will be highlighted green. For example, if the secret word is LEMON and you guess BEACH, then the E will be high... | stackexchange_codegolf |
This question is about moving stacks around in the card game FreeCell, but here it will be presented more abstractly.
Given three integers \$0\le n,m<10000,0<k<10000\$.
There are \$m+2\$ columns, \$m\$ of them empty and two of them contain cards (from bottom to top) \$[0,-2,k]\$ and \$[0,-3,k-1,k-2,\cdots,1,0]\$. Besid... | stackexchange_codegolf |
Challenge
Your task is to write a program or function which, given a positive integer \$N\$, finds all positive integers less than or equal to \$N\$ that can be expressed as a perfect power in more than one way.
Definition
A perfect power is defined as a number \$i\$ found by \$m^k\$, where:
\$m\$ and \$i\$ are positi... | stackexchange_codegolf |
Given a non‑empty string containing only printable ASCII (codepoints 0x20 to 0x7E), write the shortest program or function that swaps the cases of A-Z and a-z.
If a character is in [A-Z], convert it to its lowercase version.
If a character is in [a-z], convert it to its uppercase version.
Otherwise, leave the characte... | stackexchange_codegolf |
Frequently while I'm code-golfing, I'll want to know what the ASCII value of a certain character is. One of my favorite resources for quickly looking up all of the printable ASCII characters is ASCIItable.com. This has a really nice image that not only shows the printable ASCII characters and their values, but also the... | stackexchange_codegolf |
You are given three parameters: start(int), end(int) and list(of int);
Make a function that returns the amount of times all the numbers between start and end are multiples of the elements in the list.
example:
start = 15; end = 18; list = [2, 4, 3];
15 => 1 (is multiple of 3)
16 => 2 (is multiple of 2 and 4)
17 => 0
18... | stackexchange_codegolf |
Objective
Write a program or function (or equivalent) that sorts out and returns the odd letter in the matrix of random size.
Details
You will be passed a matrix (as a string) as input of random dimensions such as this.
bbbbbbbbbb
bbbbbdbbbb
bbbbbbbbbb
bbbbbbbbbb
bbbbbbbbbb
Your job is to find the letter that doesn't... | stackexchange_codegolf |
Introduction:
I think most people will know how darts work. But since some might not, here are the rules of playing Darts in a nutshell:
Amount of players: 2
Starting points: 501
Goal: Get your points to 0 first
Darts per player: 3
Available numbers on the board: 1 through 20, and Bulls-eye
Here is the layout of a Da... | stackexchange_codegolf |
Groups
In abstract algebra, a group is a tuple \$(G,\ast)\$, where \$G\$ is a set and \$\ast\$ is a function \$G\times G\rightarrow G\$ such that the following holds:
For all \$x, y, z\$ in \$G\$, \$(x\ast y)\ast z=x\ast(y\ast z)\$.
There exists an element \$e\$ in \$G\$ such that for all \$x\$ in \$G\$, \$x\ast e=x\... | stackexchange_codegolf |
Given text, remove leading and trailing whitespace (spaces, tabs, and newlines).
Alternate title: Implement your own string trimming.
Input
ASCII text (printable + spaces, tabs (\t), and newlines (\n)), in whatever format you would like. Carriage returns (\r) are outside of the scope of the input.
Output
The same text ... | stackexchange_codegolf |
Code-Bowling Quine Challenge
You must bowl a quine following the rules of code bowling and quines but the source code must be in the shape of a rectangle (details specified below)
Quine
Quines returned must be returned via the ways defined in the standard I/O rules.
Rules
Code-Bowling Rules
Character : Byte Ratio I... | stackexchange_codegolf |
So I have the situation where I have one boolean value a and, if that one is true and b<c I want it to end up as true, if a is false and b>c I want it to resolve as true as well. If b=c I want it to be always false, no matter the value b and c are both numbers. My best approach so far is a?b<c:b>c or maybe b^c^a^b<c. I... | stackexchange_codegolf |
I'm trying to shorten a bash solution to a Code Golf challenge, which requires an output of true or false. I've managed to condense the key piece of the code down to a substring check, to determine if the provided argument, $1, is a substring of a particular hard-coded fixed string, of the form:
[[ FIXEDSTRING = *$1* ]... | stackexchange_codegolf |
You can determine the volume of objects based on a given set of dimensions:
The volume of a sphere can be determined using a single number, the radius (r)
The volume of a cylinder can be determined using two numbers, the radius (r) and the height (h)
The volume of a box can be determined using three numbers, the lengt... | stackexchange_codegolf |
Given a sequence of three integers, determine if the sequence is arithmetic (of the form [a, a+d, a+2*d]) or geometric (of the form [a, a*r, a*r^2]) by outputting a fourth term that completes it (a+3*d for arithmetic, a*r^3 for geometric).
Examples:
[1, 2, 3] -> 4 (This is an arithmetic sequence with a difference of 1)... | stackexchange_codegolf |
It's lunch time, I am hungry and I came to your Sushi Bar. You are the Sushi Chef and you have to produce a full program or function to make me some sushi!
Credits: Wikipedia
Disclaimer: The image is for illustration purposes only and do not necessarily represent the exact product.
Although you have limited ingredien... | stackexchange_codegolf |
Drunk Uncle (sorry M.E. and AUS for region lock) is a fictional character from Saturday Night Live. He often confuses words for others that sound like them. For this challenge you need to convert normal speech into drunkspeak.
Algorithm
Translating to drunkspeak requires swapping the order of words in the text. Swappin... | stackexchange_codegolf |
Your goal is to write a program that takes no input and outputs the following text:
ca e na ŋa va o sa;
þa ša ra la ła.
ma a pa fa ga ta ča;
în ja i da ða.
ar ħo ên ôn ân uħo;
carþ taŋ neŋ es nem.
elo cenvos.
But there's a catch: for each letter (any character whose general category in Unicode starts with L) in your s... | stackexchange_codegolf |
The recent volume of MAA's Mathematics Magazine had an article "Connecting the Dots: Maximal Polygons on a Square Grid" by Sam Chow, Ayla Gafni, and Paul Gafni about making (very convex) \$n^2\$-gons where each vertex is a different point of the \$n \times n\$ grid.
One is not allowed to have two consecutive segments ... | stackexchange_codegolf |
Dedicated to Martin Gardner, taken from his book
Background
In the old days, the Slavs had a divination method for finding out whether a girl would get married. The girl would clutch six straws in her hand so that the ends would poke out the top and bottom of her fist. Then her friend would join together the ends of pa... | stackexchange_codegolf |
Inspired by this challenge, and similar to this and this.
After seeing these, I figured I would continue the trend as there was no inclusive/exclusive sum.
The goal here is to sum an interval of integers, either inclusive and exclusive, and output the total to stdout.
Input format: either a ( or [ followed by 2 comma s... | stackexchange_codegolf |
In R print(x, digits=n) does something a little complicated.
It always shows all the digits to the left of the decimal point and then, if there are any digits to the right it rounds the whole number so that at most n digits are shown. However, leading 0s are not counted. Here are examples to show how the function work... | stackexchange_codegolf |
Inspired by this question.
Challenge
Let L be a list of n distinct elements. Let P be the set of all (unordered) pairs of positions in P. Let R be a result of applying a pair-swap operation on L by every pair in P in any order.
Example:
L = [1, 7, 8]
P = {(1, 2), (0, 1), (0, 2)}
L = [1, 7, 8] -> [1, 8, 7] -> [8, 1, 7] ... | 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 |
Task
A reverse checkers position is a chess position where every piece for one player is on one colour and every piece for the other player is on the other colour. Your task is to find if the given (valid) position meets these criteria.
For example, this position does (click for larger images). Every white piece is on ... | stackexchange_codegolf |
What general tips do you have for golfing in TypeScript's type system? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to TypeScript's type system (e.g. "remove comments" is not an answer).
Please post one tip per answer.
If you're not familiar with program... | stackexchange_codegolf |
Given an input string containing only letters and numbers, write a program or function that prints the possible printable ASCII characters (Hex 20-7E) that correspond with the string's value in bases 8, 10, and 16 (where possible). The characters must be written in increasing order in terms of the bases with which they... | stackexchange_codegolf |
Determining whether a Turing machine halts is well known to be undecidable, but that's not necessarily true for simpler machines.
A Foo machine is a machine with a finite tape, where each cell on the tape has an integer or the halt symbol h, e.g.
2 h 1 -1
The instruction pointer starts by pointing to the first cell:
2 ... | stackexchange_codegolf |
This is much more advanced than How to randomize letters in a word and Cambridge Transposition because of the rule about which letters may be swapped with which. A simple regex will not suffice here.
It is well known that a text can still be read while the innards of its words have been scrambled, as long as their fir... | stackexchange_codegolf |
In this challenge you must write a computer program that creates a stack of a thousand identical \$1 \times 1\$ frictionless homogeneous blocks such that each block is supported and the stack is stable under gravity when placed on the edge of a table which spans from \$x = -\infty\$ to \$0\$ horizontally, with the surf... | stackexchange_codegolf |
Challenge
Given a real number as input, calculate the number of times which the natural logarithm function ln can be applied to it before the resulting number becomes imaginary.
Explanation
Applying ln to a negative number results in a non-real number. This means that, by repeatedly applying ln to a number, you will ev... | stackexchange_codegolf |
A simple one today. Write the shortest program that draws a "sawtooth alphabet" given a positive integer for the height. You must write the name of your programming language when you come to the letter it starts with.
For example, if your language is Python and the input is 1 the output should be:
ABCDEFGHIJKLMNOPython... | stackexchange_codegolf |
Word changer is a game where you are trying to turn one word into another via single-character edits, with each step being its own word. For this challenge, edits may be replacements, insertions, or deletions. For example, WINNER → LOSER can be done with this route (there may be others):
WINNER
DINNER
DINER
DINE
LINE
L... | stackexchange_codegolf |
Background
So, nowadays the popular Prisoner's Dilemma variant is the Prisoner's Trilemma, where there are three options. I can easily see that being increased, so I figured
Why settle for three options, when we can have INFINITE options?
Therefore, I created the Floating Point Prisoner's ?Lemma.
Equations:
Each roun... | stackexchange_codegolf |
Your challenge is to output this:
https://stackoverflow.com/
https://serverfault.com/
https://superuser.com/
https://meta.stackexchange.com/
https://webapps.stackexchange.com/
https://gaming.stackexchange.com/
https://webmasters.stackexchange.com/
https://cooking.stackexchange.com/
https://gamedev.stackexchange.com/
ht... | stackexchange_codegolf |
Alienese refers to two "languages" in the show Futurama. In actuality, they are two ciphers of English text with a pictographic alphabet. The first is a simple substitution cipher, but the second is slightly more complex. The second is a type of autokey cipher that follows these steps:
Take a word to be encrypted, e.g... | stackexchange_codegolf |
Short and sweet description of the challenge:
Based off the ideas of several other questions on this site, your challenge is to write the most creative code in any program that takes as input a number written out in English and converts it to integer form.
Really dry, long and thorough specifications:
Your program wil... | stackexchange_codegolf |
Your task is to make a script with the shortest byte count, that reverses a word then replaces each letter with the next letter next in the alphabet.
Examples:
input: hi
output: ji
input: hello
output: pmmfi
input: test
output: utfu
A few notes:
Should the letter's value be 27 (z+1), assume it is an a.
Symbols, num... | stackexchange_codegolf |
"Set" is a card game played with a deck of 81 cards, twelve of which are pictured below:
Each card has four attributes, each of which may assume three values:
Number: the number of symbols, either 1, 2, or 3
Shape: the shape of the symbol, either squiggle, diamond or oval
Colour: either purple, red or green
Shading: ... | stackexchange_codegolf |
The challenge
Quite simple, given an input x, calculate it's infinite power tower!
x^x^x^x^x^x...
For you math-lovers out there, this is x's infinite tetration.
Keep in mind the following:
x^x^x^x^x^x... = x^(x^(x^(x^(x...)))) != (((((x)^x)^x)^x)^x...)
Surprised we haven't had a "simple" math challenge involving this... | stackexchange_codegolf |
Write a program or function that:
Takes as input a list or array of 128 numbers.
Sends that array to a GPU
Performs a calculation on the GPU to square each element of the array and then sum them
Gets the answer from the GPU, and returns or displays it
So your program will simply return the sum of the squares of its i... | stackexchange_codegolf |
Given a positive integer N, output the number of pairs of integers 0 <= a <= b < 2**N such that a*b >= 2**N.
Rules
You may assume that N is less than or equal to the maximum bit width for integers in your language (e.g. for C, N will not exceed 32 or 64, depending on the architecture of the machine). If your language ... | stackexchange_codegolf |
In Wordle, you try to guess a secret word, and some letters in your guess are highlighted to give you hints.
If you guess a letter which matches the letter in the same position in the secret word, the letter will be highlighted green. For example, if the secret word is LEMON and you guess BEACH, then the E will be high... | stackexchange_codegolf |
You are given an array A of length N and an array B of length N-1.
You need to output array where items alternates:
A[0], B[0], A[1], B[1], ..., B[N-2], A[N-1]
Restrictions:
N>0
Type of items is not specified, but code should work at least for unsigned integers.
Sample input:
A = [1,2,3,4]
B = [7,8,9]
Sample output:... | stackexchange_codegolf |
You will be given a String consisting of printable ASCII (without newlines). Your task is to build a nice Stairway for my Castle.
How to build a nice Stairway?
First off, you should get all the rotations of the String. For example, the String abcd has the following rotations: abcd, bcda, cdab, dabc (each character is ... | stackexchange_codegolf |
Rules
Given an ISO3166-1-Alpha-2 country code your task is to decide on the traffic direction for that country:
Input will be a valid country code (valid as in it's an element of the two lists provided)
Input may be a list of two characters instead of a string if it helps
You may choose to take input in lowercase
You ... | stackexchange_codegolf |
Print this text:
_________
| |
| |
| |
|_________|
Shortest code wins. Notice the space at the start of the first line.
| stackexchange_codegolf |
Reversible computation refers to computation in which little or no information is deleted. Reversible computation a major component of quantum computation, and reversible computation is potentially many times more energy efficient than conventional computation. I want to know how easy it is to compute the conjugacy of ... | stackexchange_codegolf |
Write a program that outputs
Do not repeat yourself!
Your program code must respect the following constraints :
its length must be an even number
each character that is in position 2n (where n is an integer > 0) must be equal to the character in position 2n-1. The second character of the program is equal to the firs... | stackexchange_codegolf |
You know those letterboards outside old-style cinemas which show upcoming films - perhaps you have a miniature one in your home?
If you've operated one, you'll know that you can normally add letters from either side of a row. But the slots (in which you slide letters) are thin, so it's impossible to swap the order of ... | stackexchange_codegolf |
In this cops-and-robbers challenge, robbers must crack cop answers by finding out which languages the cops used.
This is the Cops thread. For the Robbers' challenge, see here
Cops, you are to write a program, which, when executed in a specific language, does one of the following:
Outputs one of the 5 phrases below
Out... | stackexchange_codegolf |
Subleq is a Turing-complete esolang with only one instruction, SUBLEQ. This instruction takes in three parameters, A, B, and C, all of which are memory addresses. The instruction subtracts the value in memory address A from that in memory address B, storing it in address B. If the value at B is now less than or equal t... | stackexchange_codegolf |
If you wanted to compute a very large long problem, that on a machine that you could buy today for an inflation adjusted price, will take some amount of years/decades. The issue is, if you only have that budget, and so can only purchase one machine. So if you purchase the machine now, it may actually take longer to com... | stackexchange_codegolf |
Write a program that takes an undirected graph and finds the minimum cut, i.e., the set of edges that, if removed, would disconnect the graph into two or more connected components. The program should have a time complexity of \$O(n^2m)\$, where n is the number of vertices and m is the number of edges in the graph.
One ... | stackexchange_codegolf |
I'm sure you're all familiar with Z̃͗̇̚͟Ḁ̬̹̈̊̂̏̚L̜̼͊ͣ̈́̿̚G̱̮ͩ̃͑̆ͤ̂̚Õ̷͇͉̺̜̲ͩ́ͪͬͦ͐ ̪̀ͤͨ͛̍̈͢ĝ̭͇̻̊ͮ̾͂e̬̤͔̩̋ͮ̊̈ͭ̓̃n͖͎̘̭̯̳͎͒͂̏̃̾ͯe͕̖̋ͧ͑ͪ̑r̛ͩa̴͕̥̺̺̫̾ͭ͂ͥ̄ͧ͆t͍̻̘̆o͓̥ͤͫ̃̈̂r̹̤͇̰̻̯̐ͮ̈́ͦ͂͞. If not, you can play with the classical generator a bit. Zalgo text is unicode text that started as English text and had a bunch of combining ... | stackexchange_codegolf |
Based on this question from Code Review.
Given precisely three positive integers, return the product of all of the distinct inputs. If none of the inputs are distinct, return 1. That is, implement the function:
\$ f(a,b,c) = \cases{1 & $a = b = c $ \\ a & $ b = c $ \\ b & $ a = c $ \\ c & $ a = b $ \\ a b c & otherwise... | stackexchange_codegolf |
I have a combinatorics problem that I'd like to put on the OEIS—the problem is that I don't have enough terms. This code challenge is to help me compute more terms, and the winner will be the user with the submission containing the greatest number of terms.
The Problem
Suppose I give you a triangular array of light bu... | stackexchange_codegolf |
Challenge
Given a string and a number, divide the string into that many equal-sized parts. For example, if the number is 3, you should divide the string into 3 pieces no matter how long the string is.
If the length of the string does not divide evenly into the number provided, you should round down the size of each pie... | stackexchange_codegolf |
Given an integer \$N\$ consider a permutation \$p=p_1,p_2,p_3,\ldots\$ of \$1,\ldots,N-1\$. Let \$P = p_1 , p_1+p_2 \bmod N, p_1+p_2+p_3 \bmod N, \ldots\$ be its prefix sums modulo \$N\$. Sometimes \$P\$ will be a permutation of \$1,\ldots,N-1\$ itself.
For example, \$N=4: p=3,2,1 \rightarrow P=3,1,2\$
Negative example... | stackexchange_codegolf |
Bounties
No. 1 (awarded)
I'll throw in 50 rep for the first valid answer
No. 2 (awarded)
I'll throw in another 100 rep for the shortest valid answer.
No. 3 (open for submissions)
I'll throw in 200 rep for the first one with a significant shorter valid answer.
Significant being at most 45% of currently shortest a... | stackexchange_codegolf |
In this fastest-code challenge, you are provided with a set of \$n\$ identical blocks and need to determine how many unique buildings can be constructed with them. Buildings must satisfy the following rules:
No overhangs - each block must either be on the ground or supported by one or more blocks directly underneath i... | stackexchange_codegolf |
Or, "Swap the first and last letters of each word"
Your challenge is to, given a string of alphabetical ASCII characters as well as one other character to use as a delimiter (to separate each word), swap the first and last letters of each word. If there is a one-character word, leave it alone.
The examples/testcases us... | stackexchange_codegolf |
Number fight game
Setup
Each ai is given a random number from 1 to 100. The starting number is the average of these two numbers.
Gameplay
Each ai knowing its own target, the opposite target and the current number, chooses which function to apply to the current number.
WIN conditions
The first ai that reaches its ... | stackexchange_codegolf |
I made this because, although we have a bunch of other questions involving smiley faces, there is nothing for just printing an ASCII smiley face with as little code as possible.
Anyway, print this exactly (Trailing spaces allowed):
**********
******************
**********************
******* ****** ***... | stackexchange_codegolf |
Can you decrypt me?
Cops
Cops, post obfuscated code that hides a number \$n\$ (n must not be greater than the program length) inside its code. If \$n\$ chars are changed (no additions or deletions), the program outputs exactly one \$n\$ (any amount of whitespace before or after is allowed.) Otherwise, it outputs someth... | stackexchange_codegolf |
Introduction
This challenge appeared in the 2020 Estonian Open Informatics Olympiad and was created Sandra Schumann. I thought it was interesting because it involves symmetry and is quite hard even to brute force by hand.
The problem author said that it's ok for me to post it here:
Challenge
You may use a modified vers... | stackexchange_codegolf |
Letters of the words want fairness.
They decided to appear same number of times in a sentence equally.
Example:
Priorities
Will become:
Ppprrioooritttieeesss
Each letter appears 3 times, as the most common letter was i, appearing 3 times.
It does not matter where you put the repeated letters, as long as they are next... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.