instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
In this game, you can look inside one box at a time chosen by you. When you do that, you can see how many coins there are in that box.
The wizard has one last twist for you. At any point, you can choose to give up on this set of boxes and get him to start the whole process again (with a new random \$x\$). Of course, i... | stackexchange_codegolf |
You have been hired by the government of North Dakota to encrypt the state's communications. Write two programs, one to encrypt a message and one to decrypt that message.
The government is not really tech-savvy, so the encryption algorithm does not need to be sophisticated; just make sure the result doesn't look simila... | stackexchange_codegolf |
Consider, for a given positive integer \$k\$, the sequence \$(a, a+1, a+2, ..., a+k)\$, where \$a\$ is some positive integer. Is there ever a pair \$a, k\$ such that for each element \$a+i\$ in the sequence, either \$\gcd(a, a+i)\$ or \$\gcd(a+i, a+k)\$ are greater than 1?
This was investigated by Alan R. Woods as part... | stackexchange_codegolf |
Sometimes I see a claim like "80% of respondents agreed" and I think "what was your sample size? 5?" because, of course, with a sample size of 5 it's possible to get 80% to agree on something. If the claim is "47% of respondents agreed" then I know it must be a larger sample size.[1]
challenge
Given a positive integer ... | stackexchange_codegolf |
Shikaku is a 2D puzzle. The basic rundown of it is that a rectangular grid has some numbers in it, and you want to partition the grid into rectangular components such that each component contains exactly one number which is the number of grid squares in that component.
This challenge involves a 1D simplification of thi... | stackexchange_codegolf |
Your task is to display the letter "A" alone, without anything else, except any form of trailing newlines if you cannot avoid them, doing so in a program and/or snippet. Code that returns (instead of printing) is allowed.
Both the lowercase and uppercase versions of the letter "A" are acceptable (that is, unicode U+006... | stackexchange_codegolf |
Introduction
Ah, INTERCAL...
As much as I'd like encourage everyone to Try it Online, text output is just painful.
According to the docs it uses the "Turing Text Model".
While an... interesting concept, using it is about as much fun as shooting yourself in the foot.
And what do we do with a task like this? Automate it.... | stackexchange_codegolf |
I've been working on this iOS app recently and I encountered a (rather easily solved) problem: How do I determine if my string is comprised only of emojis?
Well, that's your job today!
Input
A string. If the presence of unicode characters is problematic for you then you may use a different reasonable format. Please st... | stackexchange_codegolf |
Your task
Given a integer input, \$ n \$ (such that \$ n > 1 \$), decide whether it can be written as the sum of (at least 2) consecutive square numbers.
Test cases
Truthy:
Input Explanation
5 1 + 4
13 4 + 9
14 1 + 4 + 9
25 9 + 16
29 4 + 9 + 16
30 1 + 4 + 9 + 16
41 16 + 25
50 9 + 16 + ... | stackexchange_codegolf |
Welcome Back to the Future's fans and enthusiastic codegolfers.
Let's begin with this simple statement : Marty arrives in 2015 in one month (On october the 21st !). Therefore I propose we use the time remaining to pay him and the saga the best homage we can.
Task
Marty left for 2015 on October the 26, 1985. Thus, you ... | stackexchange_codegolf |
Write a program that accesses Project Gutenberg's KJV Bible, either from a file called pg10.txt in the working directory or in any other way that is typical for the language, takes a Bible verse reference as input, and prints the corresponding verse, with no newlines except optionally one at the end, as output.
The sta... | stackexchange_codegolf |
The task
Your program will be given the following inputs: a number n, and an array of n positive integers. Your program only has to work when n=1000.
The program must do the following:
If the input array is a permutation of the range [1, 2, …, n], output Huh!?
Otherwise, return a three-element array [i, j, n], where i... | stackexchange_codegolf |
Given no input, your task is to generate the following:
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
... | stackexchange_codegolf |
Gaussian integer is a complex number in the form \$x+yi\$, where \$x,y\$ are integer and \$i^2=-1\$.
The task is to perform such operation for Gaussian integers \$a,b\$, that
\$a=q \cdot b+r\$ and \$|r|<|b|\$ (\$q,r\$ are Gaussian integers, \$|z|\$ is defined as \$\sqrt{a^2+b^2}\$ for \$a+bi=z\$).
Need to output only ... | stackexchange_codegolf |
In Australian Football, goals are worth 6 points and behinds are worth 1 point. Scores may include the number of goals and behinds, as well as the total score. Given the number of goals and behinds for two different teams, determine which team won the game.
Take four integers g1, b1, g2, b2 as input, and output two dis... | stackexchange_codegolf |
CLOSED to competing entries
New bots are welcome but are not part of the main competition and probably won't be officially tested.
You stand on a dusty stretch of code, watching the other programs stare at you. Will they shoot? How much ammunition do they have left? All you know is that you want to be the last one stan... | stackexchange_codegolf |
Given a black and white image with a white background and a set of black dots, paint a set of white pixels red, such that there is a path between each pair of black pixels.
Details
A path is a set of connected pixels (8-neighbourhood connectivity). Black pixels can be used as part of the paths. The goal is trying to ... | stackexchange_codegolf |
This is my friend Thomas. He is half tree, half emoticon.
| |
| :D |
| |
He is lonely. Let's make him some friends!
Given a text-based emoticon as input (e.g. ಠ_ಠ, :P, >_>, not , , or ), output the corresponding treemote.
A treemote's length is how many characters it is lon (basically most builtin length functi... | stackexchange_codegolf |
My coworker and I work on a legacy piece of software that we hate sometimes.
Whenever you run it, debug asserts come flying everywhere, and it's never a guarantee that anything will work. The motivation for this round of code golf came from my coworker saying the following about our software.
"It's like every time you ... | stackexchange_codegolf |
Satan-Primes
who are they?
they are Primes containing 666
these are Satan-Primes:[46663,266677,666599,666683,616669]
these are NOT :[462667,665669,36363631,555]
Plot
Every number bigger than 6661 has Satan-Primes behind him
The Challenge
Given an integer n>6661 find the Satan-Prime behind (or equal) and closest to itse... | stackexchange_codegolf |
The Euclidean algorithm is a widely known algorithm for calculating the greatest common divisor (GCD) of two positive integers.
The algorithm
For the purpose of this challenge, the algorithm is described as below:
Display the two input as adjacent lines of a certain character
e.g. an input of 3,4 can be represented by... | stackexchange_codegolf |
Write a program to print or return one of these strings verbatim:
abcdefghijkmnopqrstuvwxyz
ABCDEFGHIJKMNOPQRSTUVWXYZ
Notice that there is no L.
| stackexchange_codegolf |
Have you ever wondered, when doing shopping, how to pack your products into 2 bags you're carrying so that a total weight would be distributed among them as evenly as possible?
Your task is to write a function, that takes a list of positive numbers (lets say integers for simplicity) as an input. It should return two li... | stackexchange_codegolf |
There's something (well, many things ) that really annoys me. It is when dictionaries (English, not Pythonic) use the defining word itself to define the word, also called circular definitions. Example:
reticence: the quality of being reticent
-- Apple Dictionary
Circular definition: a definition that is circular
--... | stackexchange_codegolf |
An even distribution number is a number such that if you select any of it's digits at random the probability of it being any particular value (e.g. 0 or 6) is the same, \$\frac1{10}\$. A precise definition is given later on.
Here are a few examples:
\$\frac{137174210}{1111111111} =0.\overline{1234567890}\$ is an even... | stackexchange_codegolf |
Stack Exchange doesn't know how to transpose tables. Let's help.
Given a markdown table, transpose it.
Input assumptions:
There will be at least two rows (including header) and two columns
Either all cells have no leading space or all cells have exactly one leading space (you must handle both)
If the cells have a lead... | stackexchange_codegolf |
Definition
In Mathematics, Harmonic Sequence refers to a sequence where
$$a_n = \frac 1 n$$
i.e. the \$n_{th}\$ term of the sequence equals the reciprocal of \$n\$.
Introduction
In this challenge, given a positive integer \$n\$ as input, output the Partial Sum of first \$n\$ terms of the Harmonic Sequence.
Input
Yo... | stackexchange_codegolf |
Introduction
"Muhuhuhahahah!" The mad scientist laughs. "You're trapped in my own little game!"
In front of you is a deadly pit of snakes, while behind you is a bottomless chasm. There's no way out, you're stuck!
"Two steps in front of you is the snake pit, and two steps behind you is the chasm. But! Before you move, y... | stackexchange_codegolf |
Coming from this sandbox post
This is inspired from an 8th graders math test
Intro
We have a cube with following corners
A(0, 0, 0)
B(1, 0, 0)
C(1, 1, 0)
D(0, 1, 0)
E(0, 0, 1)
F(1, 0, 1)
G(1, 1, 1)
H(0, 1, 1)
This cube clearly has 8 corners, 12 edges and 6 faces. If we now cut off corner G, such that our cut plane goe... | stackexchange_codegolf |
There are 8 Australian states and territories, each with a 2 or 3 letter abbreviation:
ACT: Australian Capital Territory
NSW: New South Wales
NT: Northern Territory
QLD: Queensland
SA: South Australia
TAS: Tasmania
VIC: Victoria
WA: Western Australia
Your task is to write a function/program which takes a valid Austr... | stackexchange_codegolf |
This is my pet emoji, Billy:
-_-
Emojis don't like to be in the rain, so Billy is sad... Let's draw him an umbrella to make him feel better!
/\
/ \
/ \
-_-
This is good, he is entirely covered by his umbrella! Here is an example where only part of him is covered:
/\
/ \
/ \
-_-
In this case, s... | stackexchange_codegolf |
In this challenge, your input is an integer value. Your task is to find the sum of the range of the sum of the range of n.
Examples:
Input -> Output
1 -> 1
2 -> 6
3 -> 21
4 -> 55
5 -> 120
6 -> 231
7 -> 406
8 -> 666
9 -> 1035
10 -> 1540
This challenge should be fairly simple to co... | stackexchange_codegolf |
Given a 7-segment display with some segments switched on and some off, find a sequence of digits (0-9), such that after toggling the corresponding segments for each digit, all segments are switched off.
Example
_
_ [3] => | [1] => [OFF]
_ |
Numbers and their corresponding segments:
_ ... | stackexchange_codegolf |
Background
We've had challenges before on Fibonacci
coding and Zeckendorf
representation. These representations follow naturally from Zeckendorf's
theorem, which states
that every positive integer can be represented uniquely as the sum of one
or more distinct, non-consecutive Fibonacci numbers. For example:
$$
\begin... | stackexchange_codegolf |
Shikaku is a 2D puzzle. The basic rundown of it is that a rectangular grid has some numbers in it, and you want to partition the grid into rectangular components such that each component contains exactly one number which is the number of grid squares in that component.
This challenge involves a 1D simplification of thi... | stackexchange_codegolf |
Your challenge is simple: write as long of a pristine program as possible in the language of your choice using only unique bytes. (The full definition of a pristine program, copied from that link, is at the bottom of this question.)
That's right, no strings attached. Your code doesn't have to do anything at all, just r... | 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 |
This challenge is about Haskell point-free style polynomial functions.
Although you don't need to know Haskell language to do this challenge, Haskellers might have an advantage here.
Point-free means roughly that variables(points) are not named and the function is created from compositions of others functions.
For exam... | stackexchange_codegolf |
\$\left\{ n \atop k \right\}\$ or \$S(n, k)\$ is a way of referring to the Stirling numbers of the second kind, the number of ways to partition a set of \$n\$ items into \$k\$ non-empty subsets. For example, to partition \$\{1,2,3,4\}\$ into \$2\$ non-empty subsets, we have
$$\begin{matrix}
\{\{1\},\{2,3,4\}\} & \{\{2\... | stackexchange_codegolf |
There is an asdfmovie video about a pie flavoured pie. Someone also made an edited version with more pies, so I created this challenge.
The input is a positive integer.
The code should first output the following string:
I baked you a pie!
Oh boy, what flavour?
Then, the next line should be PIE (input number of times)... | stackexchange_codegolf |
Given a positive integer n, simplify the square root √n into the form a√b by extracting all square factors. The outputted a,b should be positive integers with n = a^2 * b with b as small as possible.
You may output a and b in either order in any reasonable format. You may not omit outputs of 1 as implicit.
The outputs... | stackexchange_codegolf |
Challenge
Write two programs that:
run in two different programming languages.
These may not be two versions of one language.
when one program is run, it outputs the second program, and vice versa.
The two programs must be different (no polyglots).
Here's the catch though:
The programs must be radiation hardened.... | stackexchange_codegolf |
Before you leave, you do not have to understand much musical notation to do this challenge.
EXPLANATION
In standard sheet music, double clefs go across the page serving as reference points to the notes, letting you know what note should be played. If you are not already familiar with the treble and bass clef, here i... | stackexchange_codegolf |
When translating DNA into proteins, the ribosomes read the sequence of DNA nucleotides 3 by 3. Each set of 3 nucleotides is called a codon, and each codon encodes for an amino acid, with some redundancies. Here's the conversion table used by most organisms (table is read left, top, right):
Humans and most other organi... | stackexchange_codegolf |
Inspired by this challenge.
Goal:
Given a pre-configured switchboard and a list of indexes, invert the switches at the given indexes.
A switchboard is made up of some number of switches (v or ^) wrapped in -'s and arranged into rows of varying length. Here is an example switchboard:
-v-^-v-
-^-v-
-v-^-v-
To invert/fli... | stackexchange_codegolf |
Given an input of a 2 dimensional array of integers, rotate the array 90 degrees clockwise.
It should work for rectangular arrays of all sizes and proportions.
The rotated array should be printed at the end of the program.
Example:
Input:
[[0,1,2,3,4,5],
[6,7,8,9,0,1],
[2,3,4,5,6,7],
[8,9,0,1,2,3]]
Output:
[[8,2... | stackexchange_codegolf |
Credit to Geobits in TNB for the idea
A post without sufficient detail recently posited an interesting game:
2 children sit in front of an array of candy. Each piece of candy is numbered 1 to x, with x being the total amount of candy present. There is exactly 1 occurrence of each number.
The goal of the game is for the... | stackexchange_codegolf |
Given a number as input, print out its collective sum
What is a collective sum?
Consider the number 13214, the input
Looping through each of the digits starting from the left, we will be able to obtain its collective sum.
1 means look at the first digit, and add it to the sum, sum = 1
3 means look at the "first 3 digit... | stackexchange_codegolf |
We are probably all used to the English alphabetical order:
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
When we compare words in English for the sake of alphabetization we first compare the first letter, whichever word has the later first letter comes later. If they are the same we check the second letter and... | stackexchange_codegolf |
Duplicate? I knew somebody must've done this before.
Programming a programming language in itself is something that has interested me since I knew what a programming language was. So I thought I'd create a Code Golf challenge for you.
Challenge
Create an interpreter for a given programming language, programmed entirel... | stackexchange_codegolf |
Introduction
Ah, INTERCAL...
As much as I'd like encourage everyone to Try it Online, text output is just painful.
According to the docs it uses the "Turing Text Model".
While an... interesting concept, using it is about as much fun as shooting yourself in the foot.
And what do we do with a task like this? Automate it.... | stackexchange_codegolf |
Introduction
Suppose I have a list of integers, say L = [-1,2,2,1,2,7,1,4].
I like having balance in my life, so I'm happy to see it has as many odd elements as even elements.
What's more, it also has an equal number of elements in all modulo classes of 3 that it has elements in:
[-1,2,2,1,2,7,1,4]
0 mod 3:
1 ... | stackexchange_codegolf |
Challenge: Read a string from user, print number of each vowel, then place all remaining chars in a line. Shortest answer wins!
Output must look like this:
Enter String: Input
Vowel Count: a: #, e: #, i: #, o: #, u: #
Remaining characters: Vowel-less Input
For example:
Enter String: LoremIpsumDolorSitAmetConsecuteurA... | stackexchange_codegolf |
Related, but this only requires positive integers and does not have to be commutative
The Cantor Pairing Function is described in this Wikipedia article. Essentially, it is an operation such that when it is applied to two values X and Y, one can obtain the original values X and Y given the result.
Your task is to desig... | stackexchange_codegolf |
Given an input array having minimum length 2 and maximum length 9 having any initial values output an array having length 2 consisting of the 1-based indexes of the array represented as either an integer or string in forward and reverse order.
The values of the array or string do not matter and are ignored. For example... | stackexchange_codegolf |
In this challenge you will write code to take a list of positive integers and output all maximal linear sublists.
A sublist is is a list which can be created by deleting values from the the input list. Sublists have more structure than just lists. They in a way "remember" which values are deleted.
Similarly we say tha... | stackexchange_codegolf |
The Challenge is to write the shortest implementation to find the Longest increasing subsequence .
Example :
Let S be the sequence 1 5 7 1 8 4 3 5 [length of S = 8 ]
We have 1 sub-sequence of length 0 [will consider it increasing]
6 sub-sequences of length 1 {1,5,7,8,4,3}[all of them are considered increasing]
(7*8)/2... | stackexchange_codegolf |
Calculate the area of a polygon.
Inspired by this shoelace algorithm video.
Task
Your job is to create a program or function that calculates the area of a polygon. Program or function is defined according the the default definition in meta.
Input
You will receive the X and Y coordinates of each vertex of the polygon. Y... | stackexchange_codegolf |
I hear somebody was very selfish on their birthday, demanding cake from everyone and there were no plans to share! 🎂
It's bound to be somebody's birthday today, so why not bake them a cake. Use your favourite programming language to make a delicious cake, with a nice "Happy Birthday" message as the output. (Might I s... | stackexchange_codegolf |
Tic-Tac-Latin!
This is a true story, so names have been altered.
My latin teacher, Mr. Latin, created his own proprietary (no joke) tic tac toe variant. Let's call it tic-tac-latin. The game is simple, it is essentially tic tac toe played on a four by four grid.
Formal rule declaration
A line is either a row, column o... | stackexchange_codegolf |
This is a good beginner challenge and a good time killer.
I only said a -natural- log because the title was too short, this has nothing to do with logarithms.
Given 2 variables:
The number of ants n.
The width of the log w.
Output a log of width w with n ants (Example shown w=3, n=6)
| |
| \O/ \O/ \O/ |
... | stackexchange_codegolf |
Taken from StackOverflow Question
Challenge
Given an encoded string in format n[s] where n is the amount of times s will be repeated, your task is to output the corresponding decoded string.
n will always be a positive number
s can not contain empty spaces
strings only contains letters from the alphabet
s length can b... | stackexchange_codegolf |
Introduction
Programmers have already solved the trolley problem (a classical problem in philosophy). In the usual trolley problem, we have a directed graph and each edge is weighted by the number of people tied to the track (edge). The objective of the usual trolley problem is to find a path through the graph that min... | stackexchange_codegolf |
For many games played on a grid, hexagons are the Clearly Superior Choice™. Unfortunately, many free game art sites only have seamless tile sets for square maps. On a past project, I used some of these, and manually converted them to hexagons.
However, I've gotten lazy in my old age. It should be easy to automate the p... | stackexchange_codegolf |
The goal is to animate a star exploding in ASCII art, starting from a single star character * to a supernovae and finally to the space void.
Rules :
You have to display only 80 characters per line on 24 lines (this is
the default terminal size on Linux)
Only these 95 printable characters from ASCII are allowed
Steps:
... | stackexchange_codegolf |
Your task is to take a 24 BPP sRGB image and output the same image upscaled 3x into red, green, and blue subpixels. The resulting image will be made entirely of pure black, red, green, and blue pixels.
Each pixel from the source image, when zoomed, produces an arrangement of 9 sub-pixels that can be either on or off (i... | stackexchange_codegolf |
Recently I had a Maths test and noticed that a certain number on the test matched an interesting pattern. The number (28384) matched a generic digit sequence that looks like this
(n)(x)(n+1)(x)(n+2)(x)(n+3) etc...
where n and x are single digit integers. The sequence can begin with either x or n and end with either x ... | stackexchange_codegolf |
Assignment is simple to explain: write the shortest code you need to determine whether an executable binary program supplied as parameter is 32 or 64 bits.
If there is a different kind of bitness, you can also do for it, but is not mandatory.
What I really don't want is telling me you support other bitnesses and after ... | stackexchange_codegolf |
Challenge
This is a simple challenge. Given two positive integers w and h create an ASCII fence with a width of w and a height of h. The fence should be constructed using the following rules:
The + character will represent a post.
The - character will be used to represent the width of the fence.
The | will be used to ... | stackexchange_codegolf |
Task
Given two positive integers (dividend and divisor), calculate the quotient and the remainder.
Normally it would be calculated as e = o*q+r where q*o<=e and 0<=r<o.
For this challenge it still e = o*q+r but q*o>=e and -o<r<=0.
For example e=20 and o=3, normally it would be 20/3 -> 20=3*6+2, since 18<=20 and 0<=2<3.... | stackexchange_codegolf |
Write a program or function that duplicates letters in a word, so that all the duplicated letters arranged from left to right in the word would form the input array.
For example:
input: chameleon, [c,a,l,n]
output: cchaamelleonn
Input
The starting word (e.g. chameleon)
An array of characters ([c,a,l,n]) or a string t... | stackexchange_codegolf |
This is a rewrite of the (currently closed) "Debunking Stroustrup's debunking of the myth “C++ is for large, complicated, programs only”" challenge.
Challenge
Write the shortest program or function that will:
Download http://www.stroustrup.com/C++.html, and
List all URLs contained in the HTML document.
A "URL" for th... | stackexchange_codegolf |
Introduction
The childhood song Eeny, meeny, miny, moe was often used to select who was "it" when playing tag. Everyone would stand in a circle and point at one person selected at random. They would sing:
Eeny, meeny, miny, moe,
Catch a tiger by the toe.
If he hollers, let him go,
Eeny, meeny, miny, moe.
As t... | stackexchange_codegolf |
In this code golf, you need to get the closest number from another one in a list.
The output may be the closest number to the input.
Example:
value: (Input) 5 --- [1,2,3] --- 3
And, the program may work with negative numbers.
Example:
value: (Input) 0 --- [-1,3,5] --- -1
value: (Input) 2 --- [1, 5, 3] --- 1 (Because... | stackexchange_codegolf |
"Baby Shark" is a children's song about a family of sharks. Having long been popular as a campfire song, it has been popularized since the mid-2000s by social media, online video and radio. - Wikipedia
Write program that takes no input, and writes the following text to the standard output or an arbitrary file:
Baby S... | stackexchange_codegolf |
I have a number like this:
n = 548915381
The output should be the sum of every second digit of that number. In this case 26:
4+9+5+8 = 26
Rules:
This is a code-golf, so the shortest code in bytes wins.
The input consists only of numbers bigger than 10 (at least 2 digits) but smaller than a 32-bit integer.
The input ... | stackexchange_codegolf |
Given a matrix of size at least 3×3 formed by positive integers, determine if it contains at least one "U" pattern, defined as
+ + + - - - + +
+ + - N - N - +
+ + - N - N - +
+ + - N N N - +
+ + + - - - + +
where
N is the same number, repeated in those seven positions
- (optional) represents any number different than... | stackexchange_codegolf |
Output the current time of day as Swatch Internet Time.
Specifically, output a three-digit (zero-padded) number of ".beats" (1000ths of a day) which represent the current time of day in the Swatch Internet Time time zone of UTC+01:00 ("Biel Meantime").
For example, if the current time in UTC is 23:47, then it is 00:47 ... | stackexchange_codegolf |
Given a BF program consisting of only the characters +-[]<>., with the property that there's an equal number of < and > between every matching pair of [].
You have to find the shortest program that can be achieved with the optimal memory layout (by rearranging the cells on the tape).
If there are multiple such programs... | stackexchange_codegolf |
Given a multi-line string as input containing characters "|", "_" and " " (space), count the number of cells it contains.
A cell is the following structure of 3 characters by 2 lines:
_
|_|
That is, an underscore on one line (the characters to its right and left don’t matter), and "|_|" right below it.
Two cells can ... | stackexchange_codegolf |
I'd like to propose a different kind of golfing challenge to this community:
(Artificial) Neural Networks are very popular machine learning models that can be designed and trained to approximate any given (usually unknown) function. They're often used to solve highly complex problems that we don't know how to solve alg... | stackexchange_codegolf |
OEIS A000009 counts the number of strict partitions of the integers. A strict partition of a nonnegative integer n is a set of positive integers (so no repetition is allowed, and order does not matter) that sum to n.
For example, 5 has three strict partitions: 5, 4,1, and 3,2.
10 has ten partitions:
10
9,1
8,2
7,3
6,4
... | stackexchange_codegolf |
Introduction
This challenge was originally the "Among Us" challenge in the "Misc" category of YASCON CTF 2020. (The link includes an answer to that challenge. Click at your own risk.)
You're given a lot of files, 1 of which is different from every other files. Your job is to find that 1 different file.
Challenge
Input... | stackexchange_codegolf |
Given two inputs, a number n and a dimension d, generate the nth d-dimensional pyramid number.
That was confusing, let me try again.
For d = 1, the numbers start 1,2,3,4,5 and is the number of points in a line n points long.
For d = 2, the numbers start 1,3,6,10,15 and is the number of points in a triangle with side le... | stackexchange_codegolf |
The famous constructed language Esperanto uses the Latin alphabet (mostly, see the linked wikipedia page for details). However, there are some characters with accents: ĉ, ĝ, ĥ, ĵ, ŝ, and ŭ. (C-circumflex, g-circumflex, h-circumflex, j-circumflex, s-circumflex, and u-breve.) Naturally, these characters are very hard to ... | stackexchange_codegolf |
You already know that the atoi function of stdlib.h converts a string to an integer.
atoi
(copied from here)
int atoi (const char * str);
Convert string to integer
Parses the C-string str interpreting its content as an integral number, which is returned as a value of type int.
Example
#include <stdio.h> /* pri... | stackexchange_codegolf |
S. Ryley proved following theorem in 1825:
Every rational number can be expressed as a sum of three rational cubes.
Challenge
Given some rational number \$r \in \mathbb Q \$ find three rational numbers \$a,b,c \in \mathbb Q\$ such that $$r= a^3+b^3+c^3.$$
Details
Your submission should be able to compute a solution f... | stackexchange_codegolf |
You can decompose a number greater than 0 as a unique sum of positive Fibonacci numbers. In this question we do this by repeatedly subtracting the largest possible positive Fibonacci number. E.g.:
1 = 1
2 = 2
3 = 3
4 = 3 + 1
12 = 8 + 3 + 1
13 = 13
100 = 89 + 8 + 3
Now, I call a Fibonacci product the same lists as abov... | stackexchange_codegolf |
This is the Robber post. The Cop post is here.
Your task is to take an integer input N and output the Nth digit in the sequence OEIS A002942.
The sequence consists of the square numbers written backwards:
1, 4, 9, 61, 52, 63, 94, 46, 18, 1, 121, 441, ...
Note that leading zeros are trimmed away (100 becomes 1, not 00... | stackexchange_codegolf |
This is a rewrite of the (currently closed) "Debunking Stroustrup's debunking of the myth “C++ is for large, complicated, programs only”" challenge.
Challenge
Write the shortest program or function that will:
Download http://www.stroustrup.com/C++.html, and
List all URLs contained in the HTML document.
A "URL" for th... | stackexchange_codegolf |
There are 95 printable ASCII characters:
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
In the Consolas font (the Stack Exchange code block default), some of the characters have mirrors around a vertical axis of symmetry:
These pairs of characters are mirrors of each o... | stackexchange_codegolf |
One of my favorite memes is the bouncing DVD logo. Yet silly but extremely satisfying, a DVD logo keeps bouncing on a screen and if you ever happened to watch this screensaver, you were most likely anxiously waiting for the logo to exactly hit the corner.
I know part of the fun is the waiting, but let's try to predict... | stackexchange_codegolf |
Exposition
Your mathematics teacher is a big fan of Vieta's formulas, and he believes that you should use them to solve quadratic equations. Given the equation
ax^2 + bx + c = 0
the product of its roots is c/a, and their sum is -b/a. When all of a, b and c are nonzero integers, assuming the roots are rational numbers,... | stackexchange_codegolf |
Definition
Given some string return an integer whose digits are the number ocurrences of a-z (case insensitive, in alphabetical order) in that string. Any character with 0 instances is skipped. Characters with 10 or more instances will define 2 or more digits of the returned integer. For example, aaaaaaaaaaaaaaaaaaaaaa... | stackexchange_codegolf |
Writing quines is hard. Why not have your computer write them for you!
Your program will take as input an interpreter (in a Turing complete language of your choosing) for a language X, and you will output a quine in language X.
Notes:
Language X is guaranteed to be Turing complete (you do not need to check this (it wo... | stackexchange_codegolf |
There are a lot™ of pokemon. One of the defining characteristics of pokemon is their type, of which every1 pokemon has up to two types, a primary type and an optional secondary type. There are mechanical implications to each type, and so it is very useful to know what type a given pokemon is during battle. But there's ... | stackexchange_codegolf |
The Triforce is a fictional artifact in The Legend of Zelda, made of three identical-looking equilateral triangles representing power, wisdom and courage. Several games in the saga include an animation when the three parts finally join together.
The purpose of this challenge is to draw a single 2D frame of such a simpl... | stackexchange_codegolf |
A number is in base-b simplified Goodstein form if it is written as
b + b + ... + b + c, 0 < c ≤ b
The simplified Goodstein sequence of a number starts with writing the number in base-1 simplified Goodstein form, then replacing all 1's with 2's and subtracting 1. Rewrite the result in base-2 simplified Goodstein for... | stackexchange_codegolf |
Stevin's Notation is a way to represent decimals in a non-fractional way.
The Flemish mathematician and engineer Simon Stevin is
remembered for his study of decimal fractions. Although he was not the
first to use decimal fractions (they are found in the work of the
tenth-century Islamic mathematician al-Uqlidisi), it ... | stackexchange_codegolf |
Definition (from Wikipedia)
A Pythagorean triple consists of three positive integers a, b, and c, such that a² + b² = c².
The typical example of a Pythagorean triple is (3,4,5): 3² + 4² = 9 + 16 = 25 which is 5²
Task:
Given an integer number c, write a program or function that returns the list of pythagorean triples wh... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.