instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Inspired by this 3Blue1Brown video
Given a square matrix \$ M \$, compute its matrix exponential \$ \exp(M) \$, which is defined, using an extension of the Maclaurin series for \$ e^x \$, as
$$ \exp(M) = \sum_{r=0}^\infty \frac {M^r} {r!} = M^0 + M^1 + \frac 1 2 M^2 + \frac 1 6 M^3 + \cdots + \frac 1 {n!} M^n + \cdots ... | 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 |
i.e each byte appears in a different ANSI shell colour.
Rules
Resetting the color of the shell after output is not required
Must be output in STDOUT or the primary colour text output of your language.
Must be done programmatically (iterating through each color and letter of the string induvidually) instead of just wri... | stackexchange_codegolf |
Challenge
Given a 2D array, find the length and direction of all the longest consecutive characters.
If there are ties, output every possible winning combination in any order, (winners can overlap with other winners)
Zero "0" is a special padding character which cannot be a winner.
Code golf rules apply, shortest code... | stackexchange_codegolf |
For the given string s, generate generate a table like below.
Input:abcd
Output:
abcd
bbcd
cccd
dddd
Input:Hello, world!
Output:
Hello, world!
eello, world!
llllo, world!
llllo, world!
ooooo, world!
,,,,,, world!
world!
wwwwwwwworld!
ooooooooorld!
rrrrrrrrrrld!
llllllllllld!
dddddddddddd!
!!!!!!!!!!!!!
Trailin... | stackexchange_codegolf |
I know there have been a lot of challenges about "the two best code-golfers in the world", but this one is a bit more unique, being Round 1 in a series of (future) challenges involving the two of them.
Your task is to write a program or function that returns two different non-whitespace ASCII strings, corresponding to... | stackexchange_codegolf |
You're tasked with writing an algorithm to efficiently estimate cost of solving an Eni-Puzzle from a scrambled state as follows:
You're given m lists of containing n elements each(representing the rows of the puzzle). The elements are numbers between 0 and n-1 inclusive (representing the colors of tiles). There are exa... | stackexchange_codegolf |
Task
Inputs \$b \leq 100\$ and \$n \geq 2\$. Consider \$n\$ binary strings, each of length \$b\$ sampled uniformly and independently. We would like to compute the expected minimum Hamming distance between any pair. If \$n = 2\$ the answer is always \$b/2\$.
Correctness
Your code should ideally be within \$\pm0.5\$ o... | stackexchange_codegolf |
In most programming languages, arithmetic is written with infix notation -- i.e. the operator is put in between the operands -- e.g. 1+2. In contrast, with Polish notation (a.k.a prefix notation), the operator comes before the operands -- e.g. +1 2. As long as the number of operands for each operator is fixed, this mea... | stackexchange_codegolf |
It's Christmas in July, so what better way to celebrate than a virtual white elephant gift exchange!
For this King of the Hill challenge, you must create a bot that plays in a White Elephant exchange simulation, trying to get the highest-valued present it can.
Game Rules
The game will be played over many rounds, each ... | stackexchange_codegolf |
Wikipedia: Zeno's Dichotomy Paradox
An infinite number of mathematicians walk into a bar. The first one orders a beer. The second one orders half a beer. The third one orders a fourth of a beer. The bartender stops them, pours two beers and says, "You're all a bunch of idiots."
Reddit
Print the following series for a... | stackexchange_codegolf |
You are to golf a program that will take a filename as input and you must output what color the file is.
The file will have any one of these extensions but your program only needs to support one. Please say which one in your answer.
.jpg
.png
.svg
.gif
.bmp
And now to the classic layout.
Input
A filename with one of ... | stackexchange_codegolf |
Befunge is a 2-dimensional programming language, with an instruction pointer (IP).
In Befunge-98, the ; character tells the IP to skip characters up until the next ; (Let us call it skipping mode when the IP is skipping characters). Here is an example:
"This part is read into the stack" ; this part is not ; @
I would ... | stackexchange_codegolf |
Challenge:
The concept is simple enough: write a full program to output its own code golf score!
Output should only be the byte count of your program and a trailing bytes.
BUT WAIT..... there is one restriction:
Your source code can not include any of the digits from your byte count
So if your score is 186 bytes, you... | stackexchange_codegolf |
Maximillian is the chief commander of the Great Greek Army and he is leading his forces into a crucial war with Spain.
If all the enemy soldiers stand in a straight line incrementally marked starting from position 1, and a particular soldier at position \$i\$ dies, the soldiers at position \$2i\$ and \$2i+1\$ die as we... | stackexchange_codegolf |
Introduction
Rules of the puzzle:
The puzzle Binary (also known as Takuzu or Subiku) is very simple to understand, and has only a few rules:
Since the name of the game is binary it's pretty obvious, but you can only fill in zeros and ones.
No more than two of the same digit can be vertically or horizontally adjacent t... | stackexchange_codegolf |
In this challenge, you will be given a square matrix A, a vector v, and a scalar λ. You will be required to determine if (λ, v) is an eigenpair corresponding to A; that is, whether or not Av = λv.
Dot Product
The dot product of two vectors is the sum of element-wise multiplication. For example, the dot product of the f... | stackexchange_codegolf |
This is a tips question for golfing in Python.
In Python golfing, it's common for a submission to be a function defined as a lambda. For example,
f=lambda x:0**x or x*f(x-1)
computes the factorial of x.
The lambda format has two big advantages:
The boilerplate of f=lambda x:... or lambda x:... is shorter than the de... | stackexchange_codegolf |
With the US election going on right now, I noticed that there is one (completely meaningless, but still) thing which Trump can still achieve and which is out of reach for Biden: Having the won states being connected.
Task: Given a list of strings of two-letter abbreviations (see below) for US states, determine whether ... | stackexchange_codegolf |
Write a program that converts a mathematical expression to words, evaluates the expression, and prints how the equation would be spoken aloud.
Input
The input must only contain numbers and the symbols +, -, *, and /. There cannot be any whitespace in the input.
The input does not say what the expression is equal to.
... | stackexchange_codegolf |
This question is a sequel to this one, working in the opposite direction.
For a reminder of terminology, the letters L, R, U, and D represent one-unit movement of a robot on the coordinate plane in the directions left, right, up, and down respectively. Given a positive even integer n, generate and print all sequences ... | stackexchange_codegolf |
In my previous bioinformatics challenge, I asked you to mutate a DNA sequence. This time, I'd like you to evaluate how likely a mutation, or a series of mutations, is.
The two types of substitutions are transitions and transversions, and due to the chemical structure of DNA bases, transitions are more likely to occur t... | stackexchange_codegolf |
Consider this spiral
###########
#
# #######
# # #
# # ### #
# # # # #
# # # # #
# # # #
# ##### #
# #
#########
Starting in the centre:
The first line (upwards) has 3 characters.
The second line has the same number of characters (3)
Next, we add two chars (5) for the next two sides.
This pattern continue... | stackexchange_codegolf |
NPM's sloc is a moderately popular tool for counting source lines of code in a file. The tool will attempt to strip out both single and multiline comments and count the remaining lines in order to get an estimate of the 'true' number of lines of code.
However, the parser used is based on regular expressions and is quit... | stackexchange_codegolf |
Task
Suppose that p pepole have to split a bill; each of them is identified by a triple (Name, n, k) made up of:
Name: the name;
n: the amount she/he has to pay;
k: the amount she/he actually paid.
The challenge here is to find out how much who owes whom.
Assumptions
Input and output can be in any convenient format.... | stackexchange_codegolf |
Given a positive number \$n\$ we call another (not same as n) positive number \$m\$ good if we insert same digits in both n and m and the resulting fractional value is same.
$$m/n = m_{\text{transformed}}/n_{\text{transformed}}$$
$$or$$
$$m*n_{\text{transformed}} = m_{\text{transformed}}*n$$
Clarifications:
No leading... | stackexchange_codegolf |
Pascal's triangle is a triangular diagram where the values of two numbers added together produce the one below them.
This is the start of it:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
You can see that the outside is all 1s, and each number is the sum of the two above it. This continues forever.
Your challenge is to chec... | stackexchange_codegolf |
Your task is to create a program or function that creates a paste on sprunge.us. Your program/function must receive the text to sprunge from your language's usual input mechanism, such as standard in; or in the case of a function, it can be a string or whatever makes the most sense to you. Your program will POST the te... | 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 |
Sandbox
Adapted from exercise 8 of 100 little Keg exercises
String manipulation is a very important part of any programming language. Consequently, that is what this challenge is about.
The Challenge
I want you to write a program that:
Takes a series of characters as input and,
Then takes another input (integer/letter... | stackexchange_codegolf |
The purpose of this challenge is to graphically depict a walk on the plane, where the direction of each step \$k\$ is determined by the primality of \$k\$ and the parity of its binary expansion. Specifically,
Initial direction is fixed, say North.
All steps have the same length.
The direction of step \$k\$ can be Nort... | stackexchange_codegolf |
Determine the length of a UTF-8 byte sequence given its first byte. The following table shows which ranges map to each possible length:
Range Length
--------- ------
0x00-0x7F 1
0xC2-0xDF 2
0xE0-0xEF 3
0xF0-0xF4 4
Notes on gaps in the table: 0x80-0xBF are continuation bytes, 0xC0-0xC1 would start an ... | stackexchange_codegolf |
Say I have a list such as [3, 0, 4, 2, 1], and I use selection sort to sort it, I could visualize it like this:
3,0,4,2,1
|-|
0,3,4,2,1
|-----|
0,1,4,2,3
|-|
0,1,2,4,3
|-|
0,1,2,3,4
This challenge is about visualizing sorting like this.
Input
Your input will be a list of positive integers, in any format yo... | stackexchange_codegolf |
Some of you may have heard of the Wargame series of computer based real time strategy game. These games pit teams of players with primarily cold war era units to see how a hot cold war would have played out. The goal of this challenge is to simulate a tank battle in these games.
Input
Two "tanks" (one red and one bl... | stackexchange_codegolf |
This is a word puzzle.
Your program should accept two words on the standard input.
Word one is the start word. Word two is the end word.
From the start word you have to reach the end word changing/add/remove one letter at a time. After each modification it must form a new valid word. Added letters are added to the begi... | stackexchange_codegolf |
How many petals around the rose
How many petals around the rose is a dice game you can play with your friends. Similar to "can I join the music box", there is a person that knows how the game works and the others have to discover the rule.
In this game, someone rolls some dice (usually two or more) and then people have... | stackexchange_codegolf |
Given a text like this:
# #### ## #
## # ## #
#### ##
Output the same text but by connecting the pixels with the characters ─│┌┐└┘├┤┬┴┼. If a pixel doesn't have any neighbours, don't change it.
So the output of the last text is:
│ ─┬── ┌─ │
└─ │ ┌┘ │
└──┘ ─┘
You can take input as a boolean array.
The inp... | stackexchange_codegolf |
Given a UTF-16 string, test its endianness.
Rules:
As long as the input is in UTF-16 without BOM, its type doesn't matter. In C++ on Windows, it can be std::wstring or std::u16string. In Haskell, it can be [Int16] or [Word16].
The endianness is tested by noncharacters. If the input contains a noncharacter, it is in wr... | stackexchange_codegolf |
Your challenge, should you choose to accept it, is simple:
Implement RFC 862, also known as the Echo Protocol:
The Echo protocol
An echo service simply sends back to the originating source any data it receives.
TCP Based Echo Service
One echo service is defined as a connection based application on TCP. A server listens... | stackexchange_codegolf |
In the poker game there are 1277 unique 'High Card' ranks. It's 1287 (13 over 5) if we include all straights.
The challenge is to write a function which returns an integer value corresponding to the rank of each 'High Card' poker combination including all straights. Possible cards are(in ascending order): '23456789TJQK... | stackexchange_codegolf |
There has recently been a big snow, and my driveway needs snow-blowing. If the snow-blower goes over some area that it has already snow-blowed, then that area will have snow blown onto it and need to be blown again. And of course, the snow-blower cannot start in the middle of the driveway, it needs to start from my gar... | stackexchange_codegolf |
Given a string x, output the characters in x sorted according to the order of appearance in your source code.
Examples
Source: ThisIs A Test
Input: Is it a Test?
Output: TissI etta?
Source: Harry - yer a wizard.
Input: I'm a what?
Output: aa wh'?Imt
Source: Mr. H. Potter, The Floor, Hut-on-the-Rock, The Sea
In... | stackexchange_codegolf |
On the TV cooking show Guy's Grocery Games, the chefs cannot begin shopping until Guy Fieri, the show's host, says "Three, two, one, go!" However, the words do not have to be all together. He often "hides" the words in things like this (based on a real example, but not quoting verbatim):
There are three of you here; a... | stackexchange_codegolf |
The challenge
This challenge is going to be a classic king of the hill game of RPS. You must write a program that takes two command line arguments, a string of all the moves that you have made, and a string of all the moves that your opponent has made. The program will then return either 'r', 'p' or 's' for rock, paper... | stackexchange_codegolf |
Program: To count the sum of all Unicode characters of a given input.
(No need to display the output. The final answer can be calculated in any base no need to convert back to hexadecimal.)
Test case : XyZ= 0058+0079+005A=012B
Condition: If the program is inputted, then its output must be an integral multiple of 1729 (... | stackexchange_codegolf |
The three rows of the qwerty keyboard are qwertyuiop, asdfghjkl and zxcvbnm. Your task is to find the longest word that can be typed using only one row of the keyboard, from a given list of words.
Sample input 1
artist
home
gas
writer
geology
marine
twerp
Output
writer
(Of the given words, only gas, writer and twerp ... | stackexchange_codegolf |
The story
"2016? Al..right," grumbled toy seller Hilbert. He opened his eyes, wiped salad dressing trickling out of his ear and ate a morning kick-start cremeschnitte. Exemplar holidays. He needs to go to work now though, and finish the year's accounting.
Christmas is a very yielding period of the year, especially for... | stackexchange_codegolf |
Related: Program my microwave oven and Generate lazy values.
My colleague is so lazy that he doesn't even bother to move his finger when programming the microwave oven. (This is actually true!)
Help him find the microwave input that gives the time closest to what he wants, but where all digits are the same. If two inpu... | stackexchange_codegolf |
In the English language, a surefire way to make a pronounceable nonsense letter combination is to make it entirely out of consonant-vowel pairs, e.g., Wu ko pa ha, or, Me fa ro, consonant first, followed by vowel.
Challenge:
Write a program or function that will, given a user-specified number of letters, create a rando... | stackexchange_codegolf |
Everyone knows that the content makes the question. But a good title helps too, and that's the first thing we see. It's time to turn that first impression into a program, and figure out what kinds of titles get more upvotes.
You are hereby challenged to write a program or function that takes the title of a PPCG questio... | stackexchange_codegolf |
The cop's thread is here
The robber's task is to find a program of size equal to or less than the cop's program, which, when given an itself as input, produces the same output as the cop's program.
Additionally, even if a cop's answer is provisionally marked Safe and has been revealed, you can still crack it by finding... | stackexchange_codegolf |
To normalize a vector is to scale it to a length of 1 (a unit vector), whilst keeping the direction consistent.
For example, if we wanted to normalize a vector with 3 components, u, we would first find its length:
|u| = sqrt(ux2 + uy2 + uz2)
...and then scale each component by this value to get a length 1 vector.
û ... | stackexchange_codegolf |
Challenge
Given a user's ID, determine how many times they have hit the repcap.
Specs
On a given day, let's a user has hit the repcap if they had reputation that wasn't gained due to the repcap. Essentially, on any given day, if the user's net reputation change as calculated without any cap was different from their act... | stackexchange_codegolf |
This is going to be relatively quick...
Challenge
Given a lower-case word as input, calculate the Pearson's Correlation Coefficient between the letter position of the word (nth letter within the word, x), and the letter position within the alphabet (nth letter of the alphabet, y).
Background
Pearson's Correlation Coeff... | stackexchange_codegolf |
Write a function or program that accepts one character (or a string of length 1) as input, and outputs the number of times that character occurs inside the code.
This program must be a Proper Quine, only in the sense that it cannot, for example, read itself as a file, etc.
Input can be any character, printable or not... | stackexchange_codegolf |
For example, given 3 sets of parenthesis, you have:
()()()
((()))
()(())
(())()
(()())
= 5 possible combinations.
Challenge
Program must:
• Take 1 number as an input
• Return one output, the number of possible combinations of parenthesis sets
Shortest number of bytes wins
| stackexchange_codegolf |
Every phone needs a calculator app. Because of the limited screen real estate, the developer of mine has decided to save some buttons. Instead of having two dedicated bracket buttons - one for open ( and one for close ) - there is just a single bracket button (). It looks something like this:
When the button is presse... | stackexchange_codegolf |
Write a program that precisely clones GNU cat version 8.32, which is
installed on my computer.
In any case, if called with the same arguments, same stdin, and same files,
your program's output to both stdout and stderr must by byte-for-byte identical
to that of GNU cat, and the exit code must be the same. This applies ... | stackexchange_codegolf |
Challenge
Given a positive integer n, you must calculate the nth digit of \$e\$, where \$e\$ is Euler's number (2.71828...).
The format of the output can be a number or a string (e.g., 3 or '3')
Example
# e = 2.71828...
nthDigit(3) => 8
nthDigit(1) => 7
nthDigit(4) => 2
Shortest code wins.
| stackexchange_codegolf |
Introduction
Often, people refer to dates as the "second Friday in August, 2018" or the "fourth Sunday in March, 2012". But it's hard to tell what date that is! Your task to is to write a program that receives a year, a month, a day of the week, and an integer, and output that date.
Challenge
For input, you will get a... | stackexchange_codegolf |
Your task is to create a program which takes a black-and-white outlined image (example images are below) and fills it in with colour. It is up to you how you section off each region and which colour to fill it with (you could even use an RNG).
For example:
As you can see I am clearly an artist of a superior calibre wh... | stackexchange_codegolf |
Input: from STDIN number of vertices in Graph \$2 \leq N \leq 100\$.
Rules: [Code size] = max ([code length without spaces, tabs and newlines], [total code length divided by 4])
Math formulation: In the graph of N vertices, between each pair of vertices can be 3 road states:
there is no road
there is a road from A to ... | stackexchange_codegolf |
Once upon a time I wanted to order custom tokens for a board game. They say they can do it, and then they present me their price list. I was confused because they charge per inch of head movement, and I have no idea how much will my tokens cost.
INPUT: a 2d grid:
|,-,\,/ are straight cuts. Each has a length of 1.
┌,┐,... | stackexchange_codegolf |
The world has been invaded by aliens. They are everywhere killing people and taking over the world. You are hiding with your friend.
They have one weakness - the high pitched sounds.
You can't go yell at them, because you'd get caught before, so you remember the state had a conveniently made machine that emits a high p... | stackexchange_codegolf |
Introduction
This is a web scraping Code Golf challenge that attempts to take stock Name and price columns from the 'Most Active' list on this New York Times URL.
Why is this challenge interesting?
Challenge:
Scrape these figures from this NYT page and turn it into a data frame using the smallest number of bytes possib... | stackexchange_codegolf |
Given three non-negative integers y, m, and d (of which at least one must be positive) and a valid date with a positive year (in any reasonable format that includes the year, month, and day, and no additional information), output the date that is y years, m months, and d days after the original date.
The Gregorian cale... | stackexchange_codegolf |
Task
You must write a program in Language A that will output the source code for a program in Language B which will then output the source code for a program in Language C and so on and so forth. The final program must output the x root y where x and y are the inputs e.g. in Python:
print(int(input()) ** (1/int(input()... | stackexchange_codegolf |
Your program should print the following:
**Language, XXX bytes**
```
CODE
```
or its equivalent. XXX should be substituted by the actual number of bytes your program takes, and CODE should be substituted by the source code of your program. Language should be substituted by the actual language your program is in.
Your... | stackexchange_codegolf |
Inspired by I reverse the source code, ...
Your task, if you wish to accept it, is to reverse text and mirror select characters. Yes, yes, I know. Very surprising.
Input
A string, stdin, an array of characters, or any other source of text. All characters of the input are guaranteed to be in the printable ASCII range (3... | stackexchange_codegolf |
Sokobunny 1
You love buns!
You love them so much, that you chased one down a bunburrow. The burrows are like mazes, and YOU WANT TO CATCH THE FLUFFBALLS!!!! However, the buns are smart! You can't catch the bun by by chasing after it, as you wait out of politeness for the buns.
Taken from the game Paquerette Down the Bu... | stackexchange_codegolf |
If \$R\$ runners were to run a race, in how many orders could they finish such that exactly \$T\$ runners tie?
Challenge
Given a positive integer \$R\$ and a non-negative integer \$0\leq T\leq {R}\$ produce the number of possible finishing orders of a race with \$R\$ runners of which \$T\$ tied.
Note, however, that run... | stackexchange_codegolf |
Emmet is a text-editor and IDE plugin for writing HTML code using much fewer keypresses. You might think of it like a code-golfing HTML preprocessor. Its syntax is based on CSS selectors.
Your challenge is to code-golf an implementation of Emmet. Given some Emmet code, output the resulting HTML.
Note that for the purpo... | stackexchange_codegolf |
Write a program that is a polyglot in three languages that plays rock–paper–scissors.
The input for any version of the program is always one of the strings rock or paper or scissors.
In the first language the program must output the rock–paper–scissors choice that beats the input:
Input Output
rock paper
paper... | stackexchange_codegolf |
In races in which racers go around at least one turn of a curved track, the starting positions for each racer are staggered, so that each racer travels the same distance around the track (otherwise, the racer in the innermost lane would have a huge advantage).
Given the lengths of the major and minor axes (or semi-majo... | stackexchange_codegolf |
In this quine variant, your program must output its source code transposed across the diagonal from the top left to the bottom right. For example:
your program
on
four lines
outputs
yof
ono
u u
r r
p l
r i
o n
g e
r s
a
m
The whitespace in the output is not arbitrary. Spaces appear in two situations... | stackexchange_codegolf |
Where am I now?
Given a string d, containing only the letters NSWE, determine the coordinates I've traveled (from left to right, consuming greedily) and the final coordinate where I reside.
The rules for reading coordinates from left-to-right:
If the next character is N or S:
If the character after the N or S is anot... | stackexchange_codegolf |
Challenge
Create a console program to display each byte of a file.
Winning
Since this is code-golf, fewest bytes wins.
Rules
Program must be a console application, meaning that it will be ran from some sort of command-line interpreter;
Every byte must be uppercase hexadecimal, separated by a space, and it must be 2 ... | stackexchange_codegolf |
What?
Many programming languages, both practical and esoteric, have functions, methods, etc to convert a given string to a decimal number. This is how the process might work:
For each character in the given string.
Take the character's ASCII value and subtract it by 48.
Multiply the output value by 10. (The output at... | stackexchange_codegolf |
We are going to bring down an imaginary building with a series of explosions. Our building is a 5x5 matrix of integers ranging 1-9, each representing a single brick.
The challenge is to set of a series of explosions to bring down our building as much as we can, why not! Each brick that is connected (horizontally, verti... | stackexchange_codegolf |
Dart is an object oriented programming language borrowing from both Java and Javascript. What general tips do you have for golfing in Dart? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Dart (e.g. "remove comments" is not an answer). Please post one ti... | stackexchange_codegolf |
Challenge
Robin likes having his variables declaration in the shape of an arrow. Here's how he does it:
Input any number of strings
Order them by ascending length
Output them ordered by the middle to roughly form a negative arrowhead, like this (whichever order golfs the best):
5 or 4
3 2
1 1
2 3
4 ... | stackexchange_codegolf |
Given two integers, compute the two numbers that come from the blending the bits of the binary numbers of equal length(same number of digits, a number with less digits has zeros added), one after the other, like such:
2 1
10 01
1 0
1001
0 1
0110
some examples:
Input
Binary
Conversion
Output
... | stackexchange_codegolf |
Introduction
Some time ago, I need to write function which split string in some specific way. At the first look, task looks trivial, but it was not so easy - especially when I want to decrease code size.
Challenge
As example we have following input string (it can be arbitrary)
Lorem ipsum dolor sit amet consectetur ad... | stackexchange_codegolf |
The challenge: Write a script to print the alphabet, but you can't use any ASCII strings in your program. Unicode escape characters are allowed (if thats what you call them).
External libraries are allowed, as long as a link to the documentation is provided, and an online example if possible.
As this is code-golf, the ... | stackexchange_codegolf |
Everyone knows the Fibonacci sequence:
You take a square, attach an equal square to it, then repeatedly attach a square whose side length is equal to the largest side length of the resulting rectangle.
The result is a beautiful spiral of squares whose sequence of numbers is the Fibonacci sequence:
But, what if we didn... | stackexchange_codegolf |
Inclusion-Exclusion lets you calculate the sizes of some unions and intersections between sets knowing some of the other values. I won't explain it exactly, but your challenge is to visualize inclusion-exclusion on a Venn Diagram.
Because I'm nice, you'll be using rectangles, not circles.
You will be given a list of re... | stackexchange_codegolf |
The Golden Ratio Bureau is obsessed with this new thing they call base-phi. You see it and decide to code-golf, as is your natural instinct.
To be specific, base-phi is a number system like base 10, except it uses the number phi, or the golden ratio, as its base. A ones digit would be x*10^y, but in base phi 10 is repl... | stackexchange_codegolf |
A checkerboard program is a program where each individual character's ordinal value alternates from even to odd, excluding the line terminator (which can be any standard line-endings).
A triangular program is a program where each line has one additional character than the preceding line, with the first line having one ... | stackexchange_codegolf |
Write a program which displays the current system time as an analog clock, using ASCII graphics. The clock must show at least the hour and minute pointers, and must have enough resolution of at least 5 minutes.
The display can be as small and as ugly as you wish, but the shown time should be easily recognizable.
The p... | stackexchange_codegolf |
Welcome to the grinder.
Your task is to make big rocks into small rocks by grinding them.
Take an input of a big rock of size n > 3 and grind it.
Continue to grind the rocks by dumping them into the grinder until the size of all the rocks are 2.
rocks are always grinded into equal even halves. If the result of a grin... | stackexchange_codegolf |
I challenge you to write a code to make an (extended) ASCII-art logic gate diagram for the sum of products form of an equation.
Use the following notation to represent gates:
AND
INPUT───|&&
|&&───OUTPUT
INPUT───|&&
OR
INPUT───|OR
|OR───OUTPUT
INPUT───|OR
Gates with more... | stackexchange_codegolf |
Introduction
Each Unicode codepoint can be represented as a sequence of up to 4 bytes. Because of this, it is possible to interpret some 2, 3, or 4-byte characters as multiple 1-byte characters. (See here for a UTF-8 to bytes converter).
Challenge
Given a UTF-8 character, output it split into a sequence of 1-byte chara... | stackexchange_codegolf |
Average out two lists
Challenge
Given two lists of positive integers, determine whether it is possible to rearrange the elements into two new lists such that the new lists have the same arithmetic mean (average).
Input
The input can be taken through STDIN or as function arguments. Input can be taken as a list, or if yo... | stackexchange_codegolf |
Code Golf
Totally real backstory: I'm a contractor working on a website www.Sky.Net and one of our tasks it to create some self-aware program or something, I don't know I wasn't really listening to the boss. Anyways in an effort to make our code more self-aware we need IT to be able to know what code is on each line-nu... | stackexchange_codegolf |
The cumulative sum of a vector is calculated by simply taking the sum of all previous elements. For instance:
vec = [1 1 1 -1 -1 -1 -1 -1 1 1 1 1 -1]
cum_vec = [1 2 3 2 1 0 -1 -2 -1 0 1 2 1]
Now, impose an upper and a lower limit, meaning that you stop increasing the cumulative sum if it's at the up... | stackexchange_codegolf |
After seeing some impossibly short solutions in this SE, I began to wonder what code someone could come up with to build a pseudo-random number generator. Now given that I am new to programming, I have absolutely no idea what such generator should look like, or what language to write them in. But that did not stop me f... | stackexchange_codegolf |
Given year, month and optionally weekday of 1st, output the calendar of the month. The first week should remain nonempty.
For empty cell, fill it with the date where it's supposed to be, in last or next month, and add # to indicate gray. If last few days can't fit in 5 lines, then they share last line with 5th week, us... | stackexchange_codegolf |
The edit distance between two strings is the minimum number of single character insertions, deletions and substitutions needed to transform one string into the other.
This task is simply to write code that determines if two strings have edit distance at most 3 from each other. The twist is that your code must run in l... | stackexchange_codegolf |
Problem
John bought 5 apples. You are given the weights of every group of four apples, and must then find the weights of the apples themselves.
For example, if all apples without the first one weigh 798 g, without the second - 794 g, without the third - 813 g, without the fourth - 806 g, and without the fifth - 789 g, ... | stackexchange_codegolf |
Note: This is inspired by this question by @Willbeing where task was to count the number of perfect plates of a certain length, but it's slightly different.
We call a perfect licence plate that plate whose text satisfies the following conditions:
It consists of characters, which can either be uppercase letters([A-Z])... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.