instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
In this challenge, you will play the noisy iterated prisoner's dilemma.
The Prisoner's dilemma is a scenario in game theory where there are two players, each with two options: cooperate, or defect. Each player does better for themself if they defect than if they cooperate, but both players would prefer the outcome wher... | stackexchange_codegolf |
Your challenge is to print x digits of pi where x is your code length.
Examples:
Source code (length) -> output
foo! (4) 3.141
foobar (6) 3.14159
kinda long (10) 3.141592653
+++++ (5) 3.1415
123456789 (9) 3.14159265
You can use floor(π/10 * 10code_length) / 1... | stackexchange_codegolf |
Given a string, like potatocarrot, break it into the smallest number of substrings possible. These substrings can consist either be a single character, or one of a list of words passed as input. For example, if [carrot, potato] was the input, the optimal way to break the string up would be [potato][carrot]. If the list... | stackexchange_codegolf |
This is the robber's thread. The cop's thread is here.
A snake matrix is a square matrix that follows this pattern:
3-by-3:
1 2 3
6 5 4
7 8 9
and 4-by-4:
1 2 3 4
8 7 6 5
9 10 11 12
16 15 14 13
Your task is to write a code that takes an input n and creates such a matrix, in the same language as a cop pos... | stackexchange_codegolf |
Forget BIDMAS! Write a program that takes an equation and an operator precedence order, and prints the result.
Example input format:
1.2+3.4*5.6/7.8-9.0 */+-
Rules & guidelines:
The only operators that are defined are addition (+), subtraction (-), multiplication (*), and division (/). No parentheses, no exponentiati... | stackexchange_codegolf |
I was looking for this page to help me enhance my first answer with SQLite, but I couldnt find one. So here we are!
What general tips do you have for golfing in SQLite? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to SQLite. Please post one tip per answe... | stackexchange_codegolf |
Write a program that accepts HTTP requests on any port of your choice above 1024, and responds to requests on any URL of your choice with its own source code. It must work with, at least, Firefox and Chrome. The code should be delivered as text/plain (removed requirement because none of the answers but one met it) with... | stackexchange_codegolf |
Task
Make a complete program or a function which calculates sum of all temperatures which, when written in Celsius and Fahrenheit scale, are anagram of each other.
Description
For example, 275 degree Celsius = 527 degree Fahrenheit, and 527 is anagram of 275. Non-integer temperatures (either in degree Celsius or degr... | stackexchange_codegolf |
I think the Collatz Conjecture is already well-known. But what if we invert the rules?
Start with an integer n >= 1.
Repeat the following steps:
If n is even, multiply it by 3 and add 1.
If n is odd, subtract 1 and divide it by 2.
Stop when it reaches 0
Print the iterated numbers.
Test cases:
1 => 1, 0
2 ... | stackexchange_codegolf |
You have been hired by the American embassy in the UK to act as a translator. Being a programmer, you decide to write a program to do a bit of the work for you.
You've found out that often just doing the following things can satisfy Word's spellcheck, which has been set to "English (United States)", somewhat, so you do... | stackexchange_codegolf |
If we assign each letter a respective integer, starting from 1, then a is 1, b is 2, c is 3, and so on. After z, the letters loop back around, but with a in front (aa, ab, ac). It then goes to ba, bb, bc... After this is completed, as you may have figured, another letter is added (aaa, aab, aac). "Prime letters" would... | stackexchange_codegolf |
Your task is to generate a nonsense word that is reasonably pronounceable with the specified number of 'syllables'. Each time the program is run possibly results in a different nonsense word.
Pronounceability
A pronounceable word is made up of syllables, which are in turn made up of a vowel group that is possibly sandw... | stackexchange_codegolf |
Thunno 2 is a stack-based golfing language with around 400 commands (achieved through overloads) created by me, The Thonnu.
It seems like a good idea to share some tips for golfing in Thunno 2.
Please, one tip per answer, and no tips like “remove comments and whitespace”.
Links:
Tutorial
List of commands
Attempt This... | stackexchange_codegolf |
This challenge is as follows.
(Uhoh no! Now everyone is going to use reciprocal division. Now all the answers are going to look the same and lose originality, ugh!)
Given two integers multiply them, ... but you can't use the multiplication symbols "*" and "x". As you probably know multiplication is just an extension... | stackexchange_codegolf |
This one is inspired by Calvin's Hobbies recent multiplication table challenge.
Write a function or program that takes an integer N as input and prints or returns a N-by-N unique multiplication spiral. The code must (in theory) work for N between 0 and 1000 (outputting this can be hard though). The output should be equ... | stackexchange_codegolf |
Inspired by this game
Challenge:
Given an ASCII art string representing a number, output that number.
Example:
Input:
&&&& ##### .====.. .&&&
$$$$$. %% %% % % . +. .
@@@ . @@ . = . = . ????
+++. && &&. % % = =
$$$ . @@@@@ # # . ===.
.$$$$$ ... | stackexchange_codegolf |
A shape is chiral if no amount of rotation can make it look like it's mirror image. In this puzzle we will be writing chiral computer programs.
For this puzzle we will think of a program as a rectangular matrix of characters. As such all solutions to this challenge must be rectangular (that is all lines must be of th... | stackexchange_codegolf |
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
Inspired by https://xkcd.com/835
In the midst of his mid-life crisis, Santa has impulsively purchased a Sports Sleigh™ for present delivery this year. The only problem is that this sleigh has a specially designed Infinite Present Trunk... | stackexchange_codegolf |
Write a program or function that given positive n and m calculates the number of valid distinct domino tilings you can fit in a n by m rectangle. This is sequence A099390 in the Online Encyclopedia of Integer Sequences. You may take input in as function argument(s), CLA or on stdin, in any reasonable format. You must r... | stackexchange_codegolf |
Output the numbers 1-16 (or any other set of 16 distinct items). Then, repeatedly, output a random value chosen uniformly from the last 16 items outputted.
After the same item is printed 16 times in a row, halt.
If a number appears multiple times in the last 16 values, it should have proportionally more chance to be ch... | stackexchange_codegolf |
I have a bunch of boards I need to stack in as small a space as possible. Unfortunately, the boards fall over if I stack them more than 10 high. I need a program to tell me how to stack the boards to take as little horizontal space as possible, without stacking boards more than ten high, or having boards hanging out ... | stackexchange_codegolf |
Challenge
Your program needs to take an input of a string, where the string has only letters, no special characters, no numbers, and no accents (they look all weird).
Then, your program should output a superscript version.
Example
Input: hello world
Output: ʰᵉᶫᶫᵒ ʷᵒʳᶫᵈ
Test Cases
hello - ʰᵉᶫᶫᵒ
code - ᶜᵒᵈᵉ
golf - ᵍᵒᶫᶠ
a... | stackexchange_codegolf |
Given a sequence of integers or to be more specific a permutation of 0..N
transform this sequence as following:
output[x] = reverse(input[input[x]])
repeat
For example: [2,1,0] becomes [0,1,2] and reversed is [2,1,0]. [0,2,1] becomes [0,1,2] and reversed [2,1,0].
Example 1
In: 0 1 2
S#1: 2 1 0
S#2: 2 1 0
Output:... | stackexchange_codegolf |
Your task is to write a non-empty program / function of byte count L, which, when repeated M times, checks whether a given positive integer N is equal to L × M.
You should, in theory, support an arbitrary number of repetitions (an arbitrary positive integer value of M), but it's fine if, due to language limitations, it... | stackexchange_codegolf |
Write a program or a function in your favorite programming language that will take as input a number n (integer or non-integer) between 0 and 100 inclusive, and output the corresponding grade as outlined below:
If 0 < n <= 40, then output E.
If 40 < n <= 55, then output D.
If 55 < n <= 65, then output C.
If 65 < n <= ... | stackexchange_codegolf |
Goal
Sort a list of items ensuring that each item is listed after its specified dependencies.
Input
An array of arrays of integers, where each integer specifies the 0-based or 1-based index of another item that this item must come after. The input may be an array or string or anything else human readable.
For example,... | stackexchange_codegolf |
Since today marks the occasion of the 26th leap second ever to occur, your challenge will be to output the date and time of every leap second in GMT or UTC that has occurred so far, as well as the one to occur today.
Input
There is no input.
Output
1972-06-30 23:59:60
1972-12-31 23:59:60
1973-12-31 23:59:60
1974-12-31 ... | stackexchange_codegolf |
Background
You have again been given the task of calculating the number of landmines in a field. However, we have now travelled into the flatlands.
You must calculate the landmine score given a list/string of numbers (which will be 2D) and the landmine number.
The landmine number tells you where landmines are.
For each... | stackexchange_codegolf |
I have previously posted a challenge, smallest number of steps for a knight in chess.
Now I would like to go a step further by adding the possibility to choose your piece.
If you place a piece on any square of a chessboard, what is the smallest number of steps to reach every possible position?
Rules
It is an 8 by 8 bo... | stackexchange_codegolf |
The challenge is to detect missing integer sequences of files or directories. You have a directory filled with files/directories that are named as integers.
The files/directories are generated from multiple threads yet the job did not complete - there are therefore gaps in the sequence.
The input is two integers a sta... | stackexchange_codegolf |
This is a KOTH challenge for the dollar bill auction game in game theory. In it, a dollar is being sold to the highest bidder. Bids go up in increments of 5¢, and the loser also pays their bid. The idea is that both players escalate the bidding war far beyond the value of a dollar in order to cut their losses.
Let's ho... | stackexchange_codegolf |
If you have ever had any exposure to Japanese or East Asian culture you will have surely encountered the Amidakuji game:
As Wikipedia explains, it is a type of lottery drawn on paper and used to randomly select a permutation of N items.
For example, it may be used to randomly assign a starting sequence to N people, o... | stackexchange_codegolf |
We're getting markdown tables! I assume this is what they look like:
data
data data data
---------------------
| |
| |
| |
| |
Your task is to make a program or function to generate one of these tables. You'll be given input (string, list of ... | stackexchange_codegolf |
Intro
There are 3 nails in the wall. You've got a piece of string that is fixed to the picture frame with both ends. To hang the picture, you entangled the string with the nails. But before letting the picture go: Can you predict whether the image is going to fall, just by looking at how the string is wrapped around th... | stackexchange_codegolf |
You have 2 numbers, both stored separate as numeric data type.
First number is always 6 digits long.
Second number can vary between 1 and 4 digits. If it's less than 4 digits, it needs to be padded with numeric value 0.
End result always needs to be 10 digits number.
Order has to be respected. n1|n2
Example #1:
n1 = 11... | stackexchange_codegolf |
The objective of this challenge is to take an array of positive integers, and enumerate its indices, grouping like elements.
An enumeration without any duplicates is done by just outputting an array of pairs (value, index), for example, [3, 4, 13, 9, 2] => [[3,1],[4,2],[13,3],[9,4],[2,5]].
However, if a given element a... | stackexchange_codegolf |
Implement a function or program which raises x to the power of y. Inputs are 16-bit signed integers. That is, both are in the range [-32768, 32767]. The output should be in the same range. I chose this range because it should make it possible to do exhaustive testing to ensure all edge-cases are covered.
If the output ... | stackexchange_codegolf |
Your input will consist of an 18×18 image in any reasonable format, containing a horizontally and vertically centered 14px Roboto Mono character. This can be any of 94 printable ASCII characters (not including the space). But: you only need to be able to recognize some 80 character subset of your choice.
Output should ... | stackexchange_codegolf |
This is the cops' thread. The robbers' thread is here.
Your challenge is to make a program that runs forever without halting1, unless it gets a particular input or inputs2. If it receives that input, it must terminate in a finite amount of time3. This is code-golf, so the shortest answer that has not been cracked by a ... | stackexchange_codegolf |
Befunge Chess is an esolang mini-game I invented that is centered around the Befunge esolang. The general gist of the game is to make the instruction pointer land on a specific target cell while avoiding the opponent's target cell.
Today's challenge isn't to play the game, but to simply execute arbitrary boards.
The Ru... | stackexchange_codegolf |
I came across this picture the other day: (Credit to Josep M Batlle I Ferrer)
Your job is to generate this picture. This graph is generated by repeatedly applying newton's method to the graph of:
$$f(x)=\cosh(x)-1$$
In other words, repeatedly apply the following function to every point till the rectangular distance is... | stackexchange_codegolf |
Because of this, families from all over the world are building Christmas trees.
But this normal tree can get boring after a while, so let's make an ASCII tree!
Leafs are represented by # and must be arranged as shown in the example output. We have 5 balls (O) and 5 candy canes (J), which we place randomly around the tr... | stackexchange_codegolf |
Leaderboard
154 Calculator
144 Taxman
138 Statistician
137 Solver
137 RandoAggroLawyer
136 Gambler
134 Turncoat
119 Lawyer
119 BloodyMurder
113 Bandit
79 Challenger
74 Mask
64 Random
An archive of the latest match, including the log and all output files, is available.
Calculator, by Brilli... | stackexchange_codegolf |
Let us take a break from the brain-wrecking questions and answer some of the simpler ones
You have recently read something extremely funny, and want to express your laughter to the world! But how can you?
Task
You have to display the string:
Lololololololololololololololololololololololololololololololololololololololo... | stackexchange_codegolf |
Given two polynomials f,g of arbitrary degree over the integers, your program/function should evaluate the first polynomial in the second polynomial. f(g(x)) (a.k.a. the composition (fog)(x) of the two polynomials)
Details
Builtins are allowed. You can assume any reasonable formatting as input/output, but the input and... | stackexchange_codegolf |
Alice is an intern in a company that uses Brainfuck as a primary language for both client-side and server-side development. Alice just has written her first code and she's a bit nervous as she's getting ready for her first code review.
Alice wants to make her code properly formatted and look nice, but she has no time t... | stackexchange_codegolf |
You are given an array/list/vector of pairs of integers representing cartesian coordinates \$(x, y)\$ of points on a 2D Euclidean plane; all coordinates are between \$−10^4\$ and \$10^4\$, duplicates are allowed. Find the area of the convex hull of those points, rounded to the nearest integer; an exact midpoint should ... | stackexchange_codegolf |
Given a list of the integers from \$1\$ to some \$n\$, give the minimum number of adjacent swaps required to put the list in ascending order.
You will receive a list as input and should output a non-negative integer. You may if you wish choose to expect a list of the integers from \$0\$ to \$n\$ instead.
This is code-... | stackexchange_codegolf |
Your task is to create a program or function which randomly errors. Specifically, there must be a nonzero probability of erroring, but also a nonzero probability of running without error.
An error is anything that causes a program to terminate abnormally, such as dividing by zero or using an uninitialized variable. Thi... | stackexchange_codegolf |
Given a matrix, output a representation of the matrix where the top left element is on top, the anti-diagonal is the central row and the bottom right element is at the bottom.
For example, consider the following matrix:
1 2 3
4 5 6
7 8 9
The diamond version of this matrix is:
1
4 2
7 5 3
8 6
9
Inputs and output... | stackexchange_codegolf |
A number is a Chen prime if it satisfies two conditions:
It is prime itself
Itself plus two is either a prime or a semi-prime.
A prime is a number where it has exactly two divisors and those divisors consist of itself and one.
A semi-prime is a number which is the product of two primes. (Note that 12 = 2*2*3 is not s... | stackexchange_codegolf |
Your challenge is to find the file extension of a provided filename:
hi.txt -> txt or .txt
carrot.meme -> meme or .meme
lol (undefined behavior)
what..is..this..file -> file or .file
.bashrc -> bashrc or .bashrc
T00M@n3KaPZ.h0wC[]h -> h0wC[]h or .h0wC[]h
agent.000 -> 000 or .000
You must get the text from the last . ... | stackexchange_codegolf |
Given a string consisting of ()[]{}, print the paired brackets in the same order as they appear in the string.
Any opening bracket ([{ can be paired with any closing bracket )]}.
For example:
({()[}]]
returns:
(], {], (), [}
Rules
A string consisting of ()[]{} should be received as the input
The bracket-pairs should ... | stackexchange_codegolf |
WPA2, the actual encryption standard that secures all modern wifi networks, has been cracked... This challenge has nothing to do with the way that the WPA2 was cracked, however is is about computing the 64-digit hexadecimal key that corresponds to a given WPA-PSK pass-phrase.
A wireless network with WPA-PSK encryption ... | stackexchange_codegolf |
"Talk" is a baroquified accumulator-based language that is created in response to Dennis's quote on talk.tryitonline.net.
Waiting for someone to create an esolang called talk.
. The "Talk" language has 4 commands:
00 If the accumulator is 0, set the accumulator to 0.
01 If the accumulator is 0, set the accumulator t... | stackexchange_codegolf |
Mr. William Shakespeare wrote plays. A lot of plays. In this tarball containing every single one of his works, each one of his plays is one long file.
It needs to be split into Scenes for a stage production. Because actors are impatient, your code needs to be as short as possible.
Task:
Your task is to write a program ... | stackexchange_codegolf |
Given an integer \$ n \ge 2 \$, you need to calculate \$ \lfloor n \log_2(n) \rfloor \$, assuming all integers in your language are unbounded.
However, you may not ignore floating-point errors - for example, in python lambda n:int(n*math.log2(n)) is an invalid solution, because for example for n=10**15, int(n*math.log2... | stackexchange_codegolf |
Challenge
You are given two distinct bit strings of the same length. (For example, 000 and 111.) Your goal is to find a path from one to the other such that:
At each step, you change only one bit (you can go from 000 to any of 001, 010, 100).
You cannot visit the same bit string twice.
The path is as long as possible,... | stackexchange_codegolf |
Dialogue by a 3Der.
I was hired by Sr. 4Der to learn the 4D universe and I was willing to get to know more about it. But since I am a 3Der, I wouldn't see him, nor would I know how the real shapes look like. All I can do is illustrate.
Sr. 4Der is pretty much invisible to us. We can't see him, but we can hear his voi... | stackexchange_codegolf |
the goal
Build an optimizing Brainfuck implementation. Whether it is a compiler, an interpreter, a JIT compiler, or whatever else is up to you.
scoring
A reference implementation (bfi) will be given. Each implementation will run the same program (mb.b) also given at the end.
Your score is
time spent to run `mb.b` trans... | stackexchange_codegolf |
I got into code-golfing recently and tried to write the smallest tautogram checker.
A tautogram is a sentence in which all words start with the same letter, for example: Flowers flourish from France.
Given a sentence as input, determine whether it is a tautogram.
Test Cases
Flowers flourish from France
True
This i... | stackexchange_codegolf |
Given a string s and an array/list l, determine whether or not s can be made with parts from l.
For example, if the string is "Hello, world!" and the list is [' world!', 'Hello,'], then the program/function should return a truthy value, because you can arrange the list to form the string. The following list would also ... | stackexchange_codegolf |
For more MtG-goodness: Magic: The Gathering Combat with Abilities
Premise:
In Magic: the Gathering, you cast spells by paying their mana cost by tapping lands for the required amount. These lands can produce one of the five colors which are:
White (W)
Blue (U)
Black (B)
Red (R)
Green (G)
The cost is made up of two... | stackexchange_codegolf |
Definition
Let's call an (infinite) integer sequence universal if it contains every finite integer sequence as a contiguous subsequence.
In other words, the integer sequence (a1, a2, …) is universal if and only if, for each finite integer sequence (b1, …, bn), there is an offset k such that (ak+1, …, ak+n) = (b1, …, bn... | stackexchange_codegolf |
Let me tell you about a simple number system. (which I made up just for this challenge)
This system contains the functions (), [], {}, and <>.
1. ()
When () is given no arguments, it evaluates to 0.
When () is given one or more arguments, it evaluates to the sum of the arguments.
2. []
When [] is given no arguments, it... | stackexchange_codegolf |
The lack of a social life drove a poor nerd into inventing another superfluous esolang called !+~%. For no good reason it initializes the accumulator with 6 and knows the following commands:
! (out(Accu); Accu = 6) prints the accumulator value as decimal string to stdout (without newline) and resets the accumulator to... | stackexchange_codegolf |
Part of Advent of Code Golf 2021 event. See the linked meta post for details.
The story continues from AoC2016 Day 2, Part 2.
You finally figure out the bathroom code (on the weird diamond-shaped keypad) and open the bathroom door. And then you see another door behind it, with yet another keypad design:
For those who... | stackexchange_codegolf |
Bingo
Bingo is a numbers game where players match randomly drawn numbers to the numbers on their cards. Each bingo card is a square grid with 25 spaces, and the columns of the grid are labeled with letters such as "B", "I", "N", "G", "O". The letters help to identify the number range in each column, for example, the "B... | stackexchange_codegolf |
Knockout is a basketball game where players take turns shooting. It is played as a sequence of two-player contests, each of which has the possibility of "knocking out" one of those players.
Suppose the players are A B C D and their chances of shooting and making a basket are 0.1 0.2 0.3 0.4 respectively, independently ... | stackexchange_codegolf |
We're going rootin' tootin' cow-poke shootin!
This is a simple contest, first program to draw their pistol wins.
How it works:
I require 2 things from you, an executable, and a command to be run
from a bash terminal.
The executable needs to do one thing: wait
until it receives 'draw!' from STDIN, and then print 'bang!... | stackexchange_codegolf |
Fast and Golfiest Cops Thread
Welcome to the first season of Fast and Golfiest, a cops-and-robbers challenge! I designed this challenge to encourage competitive coding for efficiency (fastest algorithm) to become more popular on the site.
The rules are simple. The cops must choose a problem from LeetCode, the prestigio... | stackexchange_codegolf |
A Fragile Quine
A fragile quine is a quine that satisfies the property of having each substring made by removing a single character, when evaluated, produces an error.
For example. If your program asdf is a quine, then for it to be fragile, the following programs must error:
sdf
adf
asf
asd
Your program (and all of it... | stackexchange_codegolf |
Description
Your task is to take a string as input, and convert the first letter of each word to uppercase, and the rest to lowercase.
Test Cases
Input => Output
ISN'T THIS A REALLY COOL TEST CASE??? => Isn't This A Really Cool Test Case???
tHis iS A rEALLY WeiRd SeNTEncE => This Is A Really Weird Sentence
I Like This ... | stackexchange_codegolf |
Write three different programs such that when any one program is provided as input to one of the other two, you get the source of the remaining program as output. More explicitly, given programs \$A\$, \$B\$, and \$C\$, where \$f(g)\$ denotes the output obtained from inputting the text of program \$g\$ into program \$f... | stackexchange_codegolf |
A Harshad number is a number that is divisible by the sum of its digits. This is obviously dependent on what base the integer is written in. Base 10 Harshad numbers are sequence A005349 in the OEIS.
Your Task:
Write a program or function that determines whether a given integer is a Harshad number in a given base. ... | stackexchange_codegolf |
As the majority of nations using the Euro have the , as the decimal separator, you must use it also.
The task is to output all the values of the Euro coins and notes in ascending order. You must also put the trailing ,00 on the integer values.
0,01 0,02 0,05 0,10 0,20 0,50 1,00 2,00 5,00 10,00 20,00 50,00 100,00 200,0... | stackexchange_codegolf |
Eyeballing the binary values printed as ovals and sticks is not so easy...
To help with that, you must write a function (or a program) that prints numbers in custom binary representation.
So I want to take a number, say 3 (00000011) and output the bits in user-defined format, for example with space separated pairs:
0... | stackexchange_codegolf |
Given a Gaussian integer \$a+bi\$ where \$a\$,\$b\$ are integers and \$i = \exp\left(\pi i/2\right)\$ is the imaginary unit, return the closest (w.r.t to the Euclidean distance) Eisenstein integer \$k+l\omega\$ where \$k\$,\$l\$ are integers and \$\omega = \exp(2\pi i/3) = (-1+i\sqrt{3})/2\$.
Background
It is probably ... | stackexchange_codegolf |
Jimmy has had a busy last week with all these platforms and ropes, and poor Jimmy doesn't even have legs or feet to stand on!
Your job is to take a string containing multiple Jimmys and give them legs and shoes!
Get input in the form of a Jimmy String
Jimmy String => /o\ /o\ /o\
containing only /o\ and
give each ... | stackexchange_codegolf |
Given a string like [[[],[[]]],[]], made of only commas and square brackets, your challenge is to determine whether it represents a list.
A list is either:
[], the empty list
At least one list, joined with commas and wrapped in square brackets.
You may use any three characters instead of [,].
You may output as:
Any ... | stackexchange_codegolf |
No, not this. And not this either. This question is nothing like those
Write the shortest code to print/return the following output:
/\ /\ /\
/ \ / \ / \
/ /\ \ / /\ \ / /\ \
/ / \ \/ / \ \/ / \ \
\ \ / /\ \ / /\ \ / /
\ \/ / \ \/ / \ \/ /
\ / /\ \ / /\ \ /
\/ / \ \/ / \ \/... | stackexchange_codegolf |
The title of Numberphile's newest video, 13532385396179, is a fixed point of the following function \$f\$ on the positive integers:
Let \$n\$ be a positive integer. Write the prime factorization in the usual way, e.g. \$60 = 2^2 \cdot 3 \cdot 5\$, in which the primes are written in increasing order, and exponents of 1... | stackexchange_codegolf |
Given an input of a color in #rrggbb hex format, output its RGB complement in
the same format.
The RGB complement R2G2B2 of any color
R1G1B1 is defined as the color with
R2 value 255 - R1, B2 value 255 -
B1, and G2 value 255 - G1.
Hex digits may be either in uppercase (#FFAA20) or lowercase (#ffaa20). The
case of the i... | stackexchange_codegolf |
Inspired by the fact that a few related challenges to this could be answered by Vyxal in 0 Bytes using a special flag combination.
Given only one input integer \$n\$, calculate \$f(n,n)\$ where
$$ f(x,y)=
\begin{cases}
x & \text{if } y=0 \\
f(\left(\sum_{k=1}^xk\right),\text{ }y-1) & \text{otherwise}
\end{cases}
$$
If ... | stackexchange_codegolf |
Not entirely sure if this one or a similar challenge has already been posted, but here it goes anyway.
Write a program that takes a string as input and writes its trucated/summarized output form such that a specific sep (separator) is placed in the middle, removing the necessary characters of the original string so tha... | stackexchange_codegolf |
Input
A non-empty array of positive integers.
Task
Convert each integer to either binary, octal, decimal or hexadecimal in such a way that each digit (0 to F) is used at most once.
Output
The list of bases that were used to solve the puzzle.
Detailed example
The expected output for [ 16, 17 ] is [ octal, decimal ].
Her... | 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 |
When given a a list of values and a positive integer n, your code should output the cartesian product of the list with itself n times.
For example, in pseudocode your function could be similar to:
for x1 in list:
for x2 in list:
for x3 in list:
...
for xn in list:
pri... | stackexchange_codegolf |
Some numbers, such as \$14241\$, are palindromes in base 10: if you write the digits in reverse order, you get the same number.
Some numbers are the sum of 2 palindromes; for example, \$110=88+22\$, or \$2380=939+1441\$.
For other numbers, 2 palindromes are not enough; for example, 21 cannot be written as the sum of 2 ... | stackexchange_codegolf |
Your challenge: The code must print "Hello, World!" and nothing else.
Your restrictions: Your program must satisfy these requirements:
The program must be a pangram.
It must use every character in printable ASCII, or, if you chose a particularly strange language, characters which are stored as one byte.
You are allow... | stackexchange_codegolf |
Schlosberg Numbers
In issue 5 of Mathematical Reflections, Dorin Andrica proposed the problem of characterising the positive integers n such that is an even integer. Eight people submitted correct solutions showing that these are the integers n for which is even. The published solution was by Joel Schlosberg, so I c... | stackexchange_codegolf |
Objective
Given a dimension of an SI unit, convert the Lorentz-Heaviside version of a Planck unit \$1\$ into SI metric.
What is a Planck unit?
Planck units are a set of units of measurement. It defines five fundamental constants of the universe as dimensionless \$1\$.
What is a dimension?
There are five types of fundam... | stackexchange_codegolf |
Given two positive integers a and b, output two positive integers c and d such that:
c divides a
d divides b
c and d are co-prime
the least common multiple of c and d equals the least common multiple of a and b.
If there are more than one possible answers, you can output only one or all of them.
Test cases:
a b c ... | stackexchange_codegolf |
The Wilson score interval is a confidence interval of the probability of success, based on the proportion of successes in a set of Bernoulli trials (a Bernoulli trial is a trial in which exactly two outcomes are possible: success or failure). The interval is given by the following formula:
The two values given by the ... | stackexchange_codegolf |
Your program must accept as input six numbers, which describe a triangle - for example, the inputs 80, 23, 45, 1, 76, -2 describe a triangle with vertices (80, 23), (45, 1), and (76, -2). The input must be given as six plain real numbers or as a list of six real numbers, in the order given in the example. Your task is ... | stackexchange_codegolf |
Given the following Python "reference implementation" of non-terminating FizzBuzz:
i=1
while True:
if i%15 == 0:
print("FizzBuzz")
elif i%3 == 0:
print("Fizz")
elif i%5 == 0:
print("Buzz")
else:
print(i)
i += 1
We can represent its output as an infinite array of char... | stackexchange_codegolf |
Define the (unnormalised) Willmore energy of a surface as the integral of squared mean curvature over it:
$$W=\int_SH^2\,dA$$
For surfaces topologically equivalent to a sphere \$W\ge4\pi\$, and \$W=4\pi\$ iff it is actually a sphere. Thus the energy quantifies how spherical a surface is.
In September 2020 I asked on Ma... | stackexchange_codegolf |
The aim of this post is to gather all the tips that can often be applied to radiation-hardening challenges.
Please only post answers which can apply to a large number of languages, and one tip per answer.
| stackexchange_codegolf |
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 problem is a challenge that has to do with DOM manipulation at scale and overcoming some issues that may be inherent in dealing with the DOM.
This challenge is interesting because limitations push us to think through things differently and lean on the strengths of languages different than what we usu... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.