instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Given a permutation of the alphabet and an input string, encrypt the input string by replacing all characters with the one's you've been given.
The capitalization should be kept the same and non-letters are not to be changed.
[hnvwyajzpuetroifqkxmblgcsd], "Hello, World!" -> "Zytti, Giktw!"
As [abcdefghijklmnopqrstuvwx... | stackexchange_codegolf |
It's not too important anymore, but occasionally somebody needs to know.
Here is a simple golf: Taking no user input, tell me if the computer on which the code is run is on a 64-bit operating system, or a 32-bit operating system!
If the code is run on a 32-bit operating system, print "32", if the code is run on a 64 bi... | stackexchange_codegolf |
Key links:
Troll question
Chat room
Game
Controller Interface
Dwarf league table
<script src="https://ajfaraday.github.io/Thud/dist/data/tables.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><table> <thead> <tr> <th>Client</th> <th>Wins</th><th>Loses</th> <th>S... | stackexchange_codegolf |
Seeing that the current language for Learn You a Lang for Great Good is Piet, and that we don't seem to have a tips page for Piet yet, I decided to make one.
Piet is a stack-based esoteric programming language in which the programs are meant to resemble abstract drawings.
What are some general tips for golfing in Piet?... | stackexchange_codegolf |
The famous Fibonacci sequence is F(0) = 0; F(1) = 1; F(N+1) = F(N) + F(N-1) (for this challenge we are beginning with 0).
Your challenge: Given n, output the sum of all the dth Fibonacci numbers for all divisors d of the nth Fibonacci number. If you prefer more formal notation,
Input: a positive integer n
Output: the... | stackexchange_codegolf |
Challenge
This coding challenge is to figure out how many rounds the cat can live.
In a \$4\times4\$ matrix, there are a number of mice and exactly 1 cat.
Example:
$$
\begin{array}
{|r|r|}\hline
& & & ⬜ \\
\hline
⬜ & & ⬜ & ⬜ \\
\hline
⬜ & ⬜ & ⬜ & \\
\hline
& & & \\
\hline
\end{array}
$$
But in each square of t... | stackexchange_codegolf |
We've had a lot of challenges on differentiation and integration, but none on just solving related rates problems. So in this challenge, you will get a bunch of derivatives (They will be numeric, not in terms of any variables) and have to find another derivative.
The input will come in a newline separated list of equat... | 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 |
Paul is one of your Belgian acquaintances, and he would like you to create a program that outputs at least one of the following five strings:
12496=>14288=>15472=>14536=>14264
14264=>12496=>14288=>15472=>14536
14536=>14264=>12496=>14288=>15472
15472=>14536=>14264=>12496=>14288
14288=>15472=>14536=>14264=>12496
It ... | stackexchange_codegolf |
A listening party is an event where a bunch of people get together to listen to some music (like a viewing party, but for music). In the age of the internet you can do Listening Parties online with friends, where you just all hit play together.
The problem is on the internet everyone is in different time-zones so you ... | stackexchange_codegolf |
Motivation
In this challenge your task was to multiply two strings, this naturally introduces a way to take the square root of a string.
How does it work?
Given a string (for example pub) the first thing you need to do, is to determine the ASCII code for each character:
"pub" -> [112, 117, 98]
Next you map these codes... | stackexchange_codegolf |
Given a positive integer n, compute the value of the Mertens function \$M(n)\$ where:
$$M(n) = \Sigma_{k=1}^{n}\mu(k)$$
and \$\mu(k)\$ is the Möbius function where \$μ(k) = 1\$ if \$k\$ has an even number of distinct prime factors, \$-1\$ if \$k\$ has an odd number of distinct prime factors, and \$0\$ if the prime fact... | stackexchange_codegolf |
This is a more difficult version of It's a find-a-movie challenge .
Input
Your code should take a BBFC rating and a number from 1 to 5 as input. It can do this in any way you find convenient.
Output
Your code should return the name of any movie which has a) that film rating and b) that number of stars in a Guardian fi... | stackexchange_codegolf |
Some chess variants use interesting non-standard pieces. In order to concisely describe new pieces or to describe pieces without requiring everyone to memorize a bunch of non-standard names some new notation can be invented.
In this challenge we are going to look at Parlett's movement notation and convert it to nice at... | stackexchange_codegolf |
Given two integer matrices a and b, your challenge is to replace any occurences of b in a with a matrix of the same size filled with 0s. For example:
Given:
a: [ [1, 2, 3],
[4, 3, 2],
[3, 5, 4] ]
b: [ [3],
[2] ]
b occurs once in a:
[ [1, 2, 3],
[4, 3, 2],
[3, 5, 4] ]
Fill that area with zeroes:
[ [1,... | stackexchange_codegolf |
Inspired by this comment...
Thanks to users Step Hen, Wheat-Wizard, and Dennis for helping my solidify the specification of this challenge before posting it!
This is the Cops' thread. For the Robbers' thread, go here
In this challenge, you are tasked with running some code that makes it so that your language no longer... | stackexchange_codegolf |
Introduction / Background
In a recent discussion in the crypto chat I was challenged to discuss / help with the Fermat primality test and Carmichael numbers. This test is based on the premise that a^(p-1) mod p==1 will always hold for primes p, but not always for composites. Now a carmichael number is essentially the F... | stackexchange_codegolf |
You are on a plane filled with boxes, and you get a sequence of movements, say "up right right down left":
You move up, pushing all boxes in front of you away:
You move right, right and down, getting
and finally left. This time you only push one box rather than infinite boxes:
At the end, there are 4 spaces.
Given ... | stackexchange_codegolf |
The prime cluster of an integer N higher than 2 is defined as the pair formed by the highest prime strictly lower than N and the lowest prime strictly higher than N.
Note that following the definition above, if the integer is a prime itself, then its prime cluster is the pair of the primes preceding and succeeding it.
... | stackexchange_codegolf |
Challenge
You will create a function which takes a matrix filled with letters from the alphabet and determine if a 2x2 square composed of vowels exists.
If a 2x2 square of vowels is found, your function should return the top-left position (row-column) of the square.
If no 2x2 square of vowels exists, then return the ... | stackexchange_codegolf |
A simple one:
Take a positive integer n less than 1000, and output the integers from 1 to n interleaved with the integers from n to 1. You must concatenate the numbers so that they appear without any delimiters between them.
Test cases:
n = 1
11
n = 4
14233241
n = 26
1262253244235226217208199181017111612151314141315... | stackexchange_codegolf |
For an integer n that satisfies n > 0, write its value as a right-descending path based on its binary representation.
Rules
The first (most significant) set bit is always in the top-left corner.
When the next bit is set (a 1), draw a character ("filled") on the next line in the same column as the previous character dr... | stackexchange_codegolf |
Write a program that will test the primality of a specified number, and give the output as a Boolean value (True is prime). Your prime test can (but doesn't have to) be valid for the number 1.
Here's the catch: your program itself has to sum to a prime number. Convert every character (including spaces) to its Unicode/... | stackexchange_codegolf |
Introduction:
Inspired by the Puzzling-stackexchange post with the same name, which I've answered four years ago:
Can you create a perfectly valid English sentence, which makes perfect sense, but which contains the word "and" in it, five times consecutively in a row ?
"Something-or-other and and and and and something-... | stackexchange_codegolf |
A super prime is a prime whose index in the list of primes is also a prime:
3, 5, 11, 17, 31, 41, 59, 67, 83, 109, 127, 157, 179, 191, 211, 241, 277, 283, 331, 353, 367, 401, 431, 461, 509, 547, 563, 587, 599, 617, 709, 739, 773, 797, 859, 877, 919, 967, 991, ...
For this challenge, an "order 2" super prime is defined... | stackexchange_codegolf |
Since Euclid, we have known that there are infinitely many primes. The argument is by contradiction: If there are only finitely many, let's say \$p_1,p_2,...,p_n\$, then surely \$m:=p_1\cdot p_2\cdot...\cdot p_n+1\$ is not divisible by any of these primes, so its prime factorization must yield a new prime that was not ... | stackexchange_codegolf |
Create three programs, which we'll call Rock, Paper, and Scissors.
Each program must be unique, and accept input.
If a program gets any input which is not one of the programs Rock, Paper or Scissors, it must print itself.
RPS style, the programs will each print one of the following four outputs:
"win" if the running ... | stackexchange_codegolf |
The Levenshtein edit distance between two strings is the minimum possible number of insertions, deletions, or substitutions to convert one word into another word. In this case, each insertion, deletion and substitution has a cost of 1.
For example, the distance between roll and rolling is 3, because deletions cost 1, ... | stackexchange_codegolf |
As the June 2021 Language of the Month is Red, what are some general tips for golfing in Red language?
Please suggest tips that are at least somewhat specific to Red (e.g. "remove comments" isn't a valid tip here).
Please one tip per answer!
| stackexchange_codegolf |
In this challenge you'll be building a program that grows as it traverses through the ages… Until it's 2017.
Challenge
Whenever this challenge description says “program”, you can also read “function”.
Your submission, when executed, will output a program that is THE LENGTH OF YOUR SUBMISSION + 1 bytes long.
When that p... | stackexchange_codegolf |
Oh, No!
the sentences are out of balance.
Quick! balance them.
A word is defined as follows:
A sequence of letters [A-Za-z] separated by any non-letter character ([0-9] ~+- etc.)
A word is BaLanCeD if its capitalization is the same forwards as it is backwards.
Given a sentence with words, balance each word by capita... | stackexchange_codegolf |
Challenge: With any given number that has multiple digits, every digit in the number needs to repeatedly be summed together until the sum is a single digit number. To make things interesting, if there's a 0 in the number, then it must equal 26, because zero starts with the letter z, which is the 26th and final letter o... | stackexchange_codegolf |
An H tree is a fractal tree structure that starts with a line. In each iteration, T branches are added to all endpoints. In this challenge, you have to create an ASCII representation of every second H tree level.
The first level simply contains three hyphen-minus characters:
---
The next levels are constructed recursi... | stackexchange_codegolf |
Challenge :
Inspired by Alphabet Position Finder
Given an string and one of two possible mathematical operator (+ or -) as input, your task is to return the operation of each alphabet position from the string.
Example :
Input: "Hello World", "+"
=> "Hello World" = [8, 5, 12, 12, 15, 23, 15, 18, 12, 4] (converted to the... | stackexchange_codegolf |
Write the shortest possible program to remove all partial matched duplicates from a list and only retain the longest lines. Sort order does not matter.
For following inputs, the intent is to search for the string reminder followed by a number and retain the longest unique reminder + number lines.
Some rules
reminder i... | stackexchange_codegolf |
The question score on Stack Exchange is the total number of upvotes minus the total number of downvotes a question receives. However, the reputation gained/lost for every upvote/downvote is different (eg. 10/-2 on Code Golf).
Given the total reputation earned, the reputation gained by an upvote and the reputation lost ... | stackexchange_codegolf |
Introduction
Decide whether a Hexagony program composed solely of the characters .)_|\/><@ will halt using least bytes.
Challenge
Hexagony is a language developed by Martin Ender in which the source code is presented in the form of a hexagon. It has been extensively used in PPCG and there has been many impressive submi... | stackexchange_codegolf |
A rigid transformation of a square array is a mapping from square arrays of a certain size to square arrays of the same size, which rearranges the elements of the array such that the distance to each other element remains the same.
If you printed out the matrix on a sheet of paper these are the transforms you could do ... | stackexchange_codegolf |
Introduction
In a standard* (e.g. not 2020) tax year, estimated payments are due quarterly according to the schedule outlined in Publication 505.
Payment Period
Due Date
January 1 – March 31
April 15
April 1 – May 31
June 15
June 1 – August 31
September 15
September 1 – December 31
January 15
* Saturd... | stackexchange_codegolf |
The goal of this challenge is to (eventually) output every possible halting program in a language of your choice. At first this may sound impossible, but you can accomplish this with a very careful choice of execution order.
Below is an ASCII diagram to illustrate this. Let the columns represent a numbering of every ... | stackexchange_codegolf |
It is well-known that there are one-to-one correspondences between pairs of integers and the positive integers. Your task is to write code defining such a correspondence (by defining a pair of functions/programs that are inverses of each other) in your programming language of choice, plus a correctness check (see below... | stackexchange_codegolf |
The Sierpinsky Triangle is a fractal created by taking a triangle, decreasing the height and width by 1/2, creating 3 copies of the resulting triangle, and place them such each triangle touches the other two on a corner. This process is repeated over and over again with the resulting triangles to produce the Sierpinsk... | stackexchange_codegolf |
This will be a bit of a different challenge. Back in 2023, I developed a 2D esolang called Electra, and looking back at my hello world program, (which is 582 bytes by the way) I see a lot of room for golfing. There are some topics that aren't covered in the spec, e.g. in which order the currents are generated/interpret... | stackexchange_codegolf |
Ungolfed, ugly, horrible proof to help you make progress on this challenge: https://gist.github.com/huynhtrankhanh/dff7036a45073735305caedc891dedf2
A bracket sequence is a string that consists of the characters ( and ). There are two definitions of a balanced bracket sequence.
Definition 1
The empty string is balanc... | stackexchange_codegolf |
Consider the following process:
Take some non-negative integer N.
e.g. N = 571
Express it in binary with no leading zeroes. (Zero itself is the only exception, becoming 0.)
e.g. 571 = 1000111011 in binary
Break apart consecutive runs of ones and zeroes in this binary representation.
e.g. 1000111011 → 1, 000, 111, 0,... | stackexchange_codegolf |
Your challenge is to write a program to print all the primes (separated by one or more whitespace characters) less than a given integer N with an asterisk (*) next to each twin prime. A twin prime is a prime number that is either two more or two less than another prime.
(Hardcoding outputs is allowed, but it is not lik... | stackexchange_codegolf |
Given a real number, convert it to a list of lists, with the negative sign (if any) becoming an empty list, the integer part becoming a list of digits, and the fractional part (if any) becoming a list of digits. The digits must be actual numbers, not strings.
Examples
0 → [[0]]
123 → [[1,2,3]]
-123 → [[],[1,2,3]]
123.4... | stackexchange_codegolf |
Stock Time Machine
You've gained access to a dataset, tomorrowStocks, which contains the stock prices from your favorite business on the NASDAQ. This dataset is a container indexed by minutes past opening. Each index contains the price of the stock at that time.
// Assume the stock market opens at 9:30AM EDT
// tomorro... | stackexchange_codegolf |
Given a string representing a number and the base that number is in, shift each positional value upward, wrapping back to zero if the value cannot increase. You will never be provided invalid input, nor a base larger than 36.
For example, you may be provided ['5f6', '16'], which represents the number 1526 in base 16. T... | stackexchange_codegolf |
Columnar Transposition Cipher
While I have plenty of programs I have written for more advanced ciphers, I just realised I don't actually have one for one of the simplest: Columnar Transposition. The cipher, in case you don't know, works as follows:
First, you take the key, and write it as numbers. The numbers are made... | stackexchange_codegolf |
Consider this nested array
[[1,2,4],[1,2,3],[2,3]]
In each subarray in which 1 appears, a 2 appears. You might say that 1's presence is dependent on 2's presence.
The converse is not true, as 2 appears in a subarray without 1.
Additionally, 3 is dependent on 2, and 4 is dependent on 1 and 2.
Task
Given a list of lists ... | stackexchange_codegolf |
In this challenge you will be converting a mixed number to an improper fraction.
Because improper fractions use fewer numbers, your code will need to be as short as possible.
Examples
4 1/2
9/2
12 2/4
50/4
0 0/2
0/2
11 23/44
507/44
Specification
You may assume the denominator of the input will never be 0. The inpu... | stackexchange_codegolf |
An integer \$x\in[0,2^{32}-1]\$ divided by an integer \$d\in{[1,2^{31}]}\$ will produce an integral quotient \$q\$ and a remainder \$r\$, so that \$x=d\times q+r\$.
Any \$q\$, in fact, can be calculated by the following formula.
$$y=\left\lfloor\frac{mx}{2^{32}}\right\rfloor\\q=\left\lfloor\frac{y+f\lfloor(x-y)/2\rfloo... | stackexchange_codegolf |
Let's solve the same task as in this challenge but faster!
Input: a non-empty string containing letters a-z
Output: the length of a longest (contiguous) substring in which all letters are different
Time and space complexity: O(n).
The number of letters in the alphabet is 26, or O(1). Make sure you understand how your l... | stackexchange_codegolf |
Challenge
Write a complete program that prints out the time it took to execute a certain part of itself. That part must include a process whose total number of operations (and therefore execution time) is dependent on a user-substituted numeric value - this can be denoted in any way in your code (uppercase N for exampl... | stackexchange_codegolf |
Challenge
Given an image of the sky, you must output the cloud cover in oktas. The image supplied will be an image file (the type is up to you) and the output should be to STDOUT.
Oktas
In meteorology, an okta is a unit of measurement used to describe the amount of cloud cover at any given location such as a weather st... | stackexchange_codegolf |
Just a simple code golf function for fun, intentionally left open with few rules to see what creativity comes up.
Input: An integer representing the area of a rectangle.
Output: Two integers representing the side lengths of the rectangle that have the least perimeter for the area. (In any order.)
Test cases:
25 => 5, ... | stackexchange_codegolf |
Some versions of the standard Android calculator app allow you to press a key, like 'sin' and then the 'del' key to make it 'si'. Probably just a bug which they can't be bothered with removing.
The following letters/letter groupings are typable:
sin
si
s
cos
co
c
tan
ta
t
ln
l
log
lo
e
So, 'tasteless' is typable,... | stackexchange_codegolf |
I was asked this question in an interview but I was unable to figure out any solution. I don't know whether the question was right or not. I tried a lot but couldn't reach any solution. Honestly speaking, nothing came to my mind.
Rocco numbers
A positive integer \$n\$ is a Rocco number if it can be represented either a... | stackexchange_codegolf |
So this is my first challenge on this site.
The challenge is to take in an input integer \$n\$, which will be positive, and print, in ascending order (\$1\$ to \$n\$, including n), the output of \$i^{(n-i)}\$ (where \$i\$ is the current integer).
Example
Given the input 5, the program will print:
1
8
9
4
1
... | stackexchange_codegolf |
This was one of a series of challenges leading up to Brain-Flak's birthday. Find out more here.
Challenge
For this challenge your objective will be to find the very first pair of matching brackets in a fully matched string of ()[]{}<> brackets. To borrow DJMcMayhem's definition of a fully matched string:
For the pur... | stackexchange_codegolf |
Problem
A fact you may have noticed about factorials is that as \$n\$ gets larger \$n!\$ will have an increasing number of \$0\$s at the end of it's base \$10\$ representation. In fact this is true for any base.
In this challenge you will be given a base \$b > 1\$ and an integer \$n > 0\$ and you will determine the sm... | stackexchange_codegolf |
Here the first 100 numbers of an easy sequence:
0,1,0,2,1,4,3,7,6,11,10,16,15,22,21,29,28,37,36,46,45,56,55,67,66,79,78,92,91,106,105,121,120,137,136,154,153,172,171,191,190,211,210,232,231,254,253,277,276,301,300,326,325,352,351,379,378,407,406,436,435,466,465,497,496,529,528,562,561,596,595,631,630,667,666,704,703,74... | stackexchange_codegolf |
Write a program which removes any common leading spaces from the input string. For example, if the least indented line started with 3 spaces, and every other line has >= 3 leading spaces, then remove 3 spaces from the beginning of each line.
The indentation consists solely of spaces, and the string will not contain any... | stackexchange_codegolf |
A short while, ago, @daniel_ernston sent the following challenge to @StackCodeGolf on Twitter:
@StackCodeGolf Your task is to build a program that uses the API of your choice to tweet its own source code. Shortest code wins, of course.
| stackexchange_codegolf |
Write the shortest program or function that takes some text as input, and outputs either it or an empty line in a repeating pattern:
some text
some text
some text
some text
some text
some text
...
This must continue indefinitely, or until some unpreventable limitation occurs (stack size, memory, etc.). It must be n... | stackexchange_codegolf |
The challenge:
Assuming you have \$ X \$ collections, each collection \$ C_i \$ has a name \$ N_i \$ and a capacity \$ N_i \$ of elements - Determine which collection will be overflowed first while counting the occurrences of the names in a cyclic list. Also print how many cycles of the list occurred.
Example:
4 Collec... | 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 |
Your task, if you wish to accept it, is to write a program that outputs a positive integer (higher than 0). If the source code is duplicated the output must remain the same. The tricky part is that if the source code is typed three times (triplicated?) the output will be multiplied by 3.
Rules
You must build a full pr... | stackexchange_codegolf |
I have a problem at work. I need to compare two numbers that come as strings from two different databases. The numbers may come with leading zeroes and/or leading/trailing spaces. So I may have "0001 " from one database and " 1 " from the other one.
I solved the problem in C# with the following code:
Func<string, st... | stackexchange_codegolf |
In the context of quines, an intron (or payload) is a part of a quine that serves no purpose in producing output, but is still included in the data section. For example:
function quine() {
const data = "function quine() {\n const data=\"@\";\n // Arr! This be an intron!\n return data.replace(\"@\", JSON.s... | stackexchange_codegolf |
I am writing a golfing language.
Do you suggest variables, stack(s), tapes, registers, etc for storage in a code-golf language? What about implicit input?
Rough definitions:
A variable is simply a name (usually one character long in golfing languages) that a value can be assigned to, and later retrieved by that name.... | stackexchange_codegolf |
NATO phonetic alphabet is a spelling alphabet that associate to each of the 26 letters of the English alphabet one word (table below) that is easy to understand over the radio or telephone. For example, if you want to communicate the word CAT over the telephone, you do the following spelling:
CHARLIE ALFA TANGO
But wha... | stackexchange_codegolf |
(Based on this closed challenge, related)
Given an integer n > 1, draw a grid composed of the characters: "-" "+" and "|". However, since I want the grid to look nice, the horizontal component should be 2 wide.
Trailing spaces for each line are not required.
Examples:
n = 2
|
--+--
|
n = 3
| |
--+--+--
| ... | stackexchange_codegolf |
Let us consider a regular n-sided polygon where all of the sides are equal in length with n being a natural number larger than or equal to three. All of the vertices lie on the unit circle (circle of radius one centered at the origin) and one of the vertices is always at the coordinate (x,y)=(1,0). Now let's draw all p... | stackexchange_codegolf |
The Challenge
I am thirsty and need a drink, but I don't know what to order. Your task is to provide me with either a drink or options for one.
I/O
Input will be either a base or a drink name.
If given a base, your program should output one random drink from a list of drinks with that base.
If given a drink name, your ... | stackexchange_codegolf |
Your job is to create the slowest growing function you can in no more than 100 bytes.
Your program will take as input a nonnegative integer, and output a nonnegative integer. Let's call your program P.
It must meet the these two criterion:
Its source code must be less than or equal to 100 bytes.
For every K, there is ... | stackexchange_codegolf |
The riddle
In yesterday's newspaper, I found a puzzle in which a Rook should start in the lower-left corner of a 12x12 checkerboard and then, during a round trip, visit each field exactly once except for a selection which must be avoided. The puzzle came with a picture that identified the fields to be avoided as black:... | stackexchange_codegolf |
Here is Minkowski's question mark function:
It is a strictly increasing and continuous function from the reals to themselves that, among other unusual properties, maps rational numbers to dyadic rationals (those with a power-of-two denominator). Specifically, suppose the continued fraction representation of a rational... | stackexchange_codegolf |
Write the shortest program that prints the sound my alarm clock makes, and stops after an inputted number of beeps.
For reference, here is the sound my alarm makes:
beep beep beep beep beep beepbeep beepbeep beepbeep beepbeep beepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeepbeep bee... | stackexchange_codegolf |
Pipe a short stream to the following Java program run with accompanying command line options, such that it prints true.
class Code implements java.io.Serializable {
private static final long serialVersionUID = 0L;
private static long count;
@Override public int hashCode() {
++count;
return... | stackexchange_codegolf |
Objective
Write a full program that works exactly like the flow chart below.
Each output, which is an integer, shall be through stdout, followed by a line feed.
Each input shall be a line of string fed through stdin, and shall be judged to a predicate you choose for branching. The same predicate must be used for all br... | stackexchange_codegolf |
Given as input a list of positive integers, your task is to determine if every integer present has exactly two neighbors in the list. The neighbors of a integer \$x\$ are the distinct integers that appear next to an \$x\$ anywhere in the list. For example in the list:
[1,3,4,4,3,2,1]
The number 3 has 3 neighbors 1, 4... | stackexchange_codegolf |
A Geiger counter is a device that is used to detect radiation.
We will be making a Geiger counter program.
As we all know, when radiation hits a computer program it removes exactly 1 byte at random. So a Geiger counter program is a program that itself does nothing, but when any byte is removed the modified program pri... | stackexchange_codegolf |
Write a program that prints an associative array (key-value) to a table.
Requirements
Standard loopholes are forbidden
Please include a link to an online interpreter and the byte count in the answer
Use box drawing characters to draw the table.
You can write both a full program or a function.
Key or value can't cont... | stackexchange_codegolf |
The Riemann R function is as follows:
$$R (x)=\sum _{n=1}^{\infty } \frac{\mu (n) \text{li}\left(x^{1/n}\right)}{n}.$$
This uses the Möbius function as well as the logarithmic integral.
From Wikipedia, the Möbius function is defined so that for any positive integer \$n\$, \$μ(n)\$ is the sum of the primitive nth roots... | stackexchange_codegolf |
Challenge
Given a rectangular area arrange a group of rectangles such that they cover the rectangular area entirely.
Input
An integer denoting the height.
An integer denoting the width.
The dimensions of the rectangles consisting
of the following form: axb,cxd,... where a,b,c, and d are integers - any reasonable for... | 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 |
Given the output of the cop's program (o), the byte-count (n) and the number of unique bytes (c) used, come up with a corresponding piece of code that is n bytes long with c unique bytes which matches the cop's output o.
This is the robbers thread. Post solutions that you cracked here.
The COPS thread is located here.... | stackexchange_codegolf |
In C++, there exists a a <=> b three-way comparison operator that, for numerical types, does the following:
If a < b, then return a negative number.
If a = b, then return a (mathematically speaking) sign-less number.
If a > b, then return a positive number.
The Challenge
Implement the shortest full program, function,... | stackexchange_codegolf |
Notice the pattern in the below sequence:
0.1, 0.01, 0.001, 0.0001, 0.00001 and so on, until reaching 0.{one hundred zeros}1
Then, continued:
0.2, 0.02, 0.002, 0.0002, 0.00002 and so on, until reaching 0.{two hundred zeros}2
Continued:
0.3, 0.03, etc, until 0.{three hundred zeros}3
Continued:
0.4, 0.04, etc, until 0... | stackexchange_codegolf |
One reason why ISO8601 is the best date string format, is that you can simply append as much precision as you like. Given 2 integers representing seconds and nanoseconds that have passed since 1970-01-01T00:00:00, return an ISO8601 string as described below.
Output:
The standard output format without timezone looks lik... | stackexchange_codegolf |
Bitshift Variations in C Minor by Robert Miles is a Code Golf music piece written in C (with some additional bash commands). It was originally presented in a 2016 Computerphile video Code Golf & the Bitshift Variations. You can listen to clean renderings of it here (by Lucia Ceionia).
The original 2016 source code pres... | stackexchange_codegolf |
If you have a small child in your house, you may have come across foam bath letters. These can be moistened and stuck to flat surfaces such as tiles and the side of the bath to make words and messages.
The range of words and messages is somewhat limited if you only have one set though, since you only get 36 characters:... | stackexchange_codegolf |
What general tips do you have for golfing in The Shakespeare Programming Language? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to SPL (e.g. "remove comments" is not an answer).
Please post one tip per answer.
| stackexchange_codegolf |
The flag of Tennessee is specified by chapter 498 of the Public Acts of 1905.
An oblong flag or banner in length one and two thirds times its width, the large or principal field of same to be of color red, but said flag or banner ending at its free or outer end in a perpendicular bar of blue, of uniform width, running... | stackexchange_codegolf |
Al wanted to use my computer to do some simple calculations, so I lent him the use of my R terminal for a bit. He complained though, saying it wasn't set up how he liked it. I said "No problem Al, set it up how you like and I'll just revert it later." This suited Al, and I left him to it. Al isn't a big fan of online R... | stackexchange_codegolf |
A loop is a pretty simple algebraic structure. It is a tuple (G,+) where G is a set and + is a binary operator G × G → G. That is + takes two elements from G and returns a new element. The operator is also required to fulfill two properties
Cancellation: For every a and b in G there exists unique x and y in G such ... | stackexchange_codegolf |
Description
Given an object (json), write code to extract all the keys from it. This is a question that I really wanted to ask everybody for a long time ago but I did not have time to write it up. It can be helpful in some cases in your daily work.
Rule:
You can use any parse function to get the JSON object, it does n... | stackexchange_codegolf |
Miller-Rabin test
Given a base \$b\$ and an odd number \$n\$:
Write \$n\$ as \$2^{s}\times d + 1\$ where \$d\$ is odd
\$n\$ is a strong probable prime if either:
\$b^d\equiv 1 \pmod n\$
\$b^{d\cdot2^r}\equiv -1 \pmod n\$
for any non-negative \$r\$ strictly less than \$s\$.
A strong probable prime which is composite ... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.