instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
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 |
Write a program that takes a United States aircraft registration number and returns a 24-bit ICAO hex code corresponding to that registration and vice-versa.
An aircraft registration number always begins with an N and is followed by 1 to 5 characters: 1 to 5 digits and then 0 to 2 uppercase letters. That is, one of the... | stackexchange_codegolf |
Guidelines
Scenario
John has an important number, and he doesn't want others to see it.
He decided to encrypt the number, using the following steps:
His number is always a non-decreasing sequence (ie. "1123")
He converted each digit into English words. (ie. "123" -> "ONETWOTHREE")
And then, rearrange the letters random... | stackexchange_codegolf |
In this challenge, you'll print out the SBCS of Jelly, a popular golfing language. Its code page looks like this:
_0
_1
_2
_3
_4
_5
_6
_7
_8
_9
_A
_B
_C
_D
_E
_F
0_
¡
¢
£
¤
¥
¦
©
¬
®
µ
½
¿
€
Æ
Ç
Ð
1_
Ñ
×
Ø
Œ
Þ
ß
æ
ç
ð
ı
ȷ
ñ
÷
ø
œ
þ
2_
!
"
#
$
%
&
'
(
)
*
+
,
-
.
/
3_
0
1
2
3
4
5
6
7
8
9
:
;
<
=
>
?
4... | stackexchange_codegolf |
The Māori language has quite simple pronouns. It uses a single word for he/she/they/etc (ia), and the words for "you" and "me" are koe and au respectively.
There are also words for groups of exactly two people:
tāua - You and me (we, au and koe)
māua - Me and them (we, au and ia)
rāua - Them (third person plural - two... | stackexchange_codegolf |
Introduction:
I think most people will know how darts work. But since some might not, here are the rules of playing Darts in a nutshell:
Amount of players: 2
Starting points: 501
Goal: Get your points to 0 first
Darts per player: 3
Available numbers on the board: 1 through 20, and Bulls-eye
Here is the layout of a Da... | stackexchange_codegolf |
Let \$n=42\$ (Input)
Then divisors are : 1, 2, 3, 6, 7, 14, 21, 42
Squaring each divisor : 1, 4, 9, 36, 49, 196, 441, 1764
Taking sum (adding) : 2500
Since \$50\times 50=2500\$ therefore we return a truthy value. If it is not a perfect square, return a falsy value.
Examples :
42 ---> true
1 ---> true
246 ---> true
1... | stackexchange_codegolf |
This will turn into a series involving other aspects of calculus, including using the "derivative" of a string to find "stationary points" etc, as well as "integration" of sentences
Introduction
If y'all have ever studied calculus, you'll most likely know that differentiation is limited to differentiable functions.
No... | stackexchange_codegolf |
Introduction
There have been a few examples of the smallest possible OCI container that does "X". However these examples never correctly handle termination signals.
Challenge
Produce the smallest possible container that correctly handles PID 1 signal responsibilities.
The container does not need to manage child process... | stackexchange_codegolf |
Input
A string s of printable ASCII characters, newlines, and spaces (0x20 ( ) to 0x7E (~)), and a non-negative integer n.
Challenge
To write a program that outputs either another program, or s depending on n. If n = 1, Then your code should output code which outputs s. If n = 2, Your code should output code which outp... | stackexchange_codegolf |
Using one programming language write 5 single-line programs, each of which outputs a different line of the first verse to Harry Nilsson's 1972 song "Coconut" when run individually:
Brother bought a coconut, he bought it for a dime
His sister had another one, she paid it for a lime
She put the lime in the coconut, she ... | stackexchange_codegolf |
When you look at the last decimal digit of each power of a non-negative integer a repeating pattern forms. For example, 3:
3^1 = 3
3^2 = 9
3^3 = 27
3^4 = 81
3^5 = 243
3^6 = 729
3^7 = 2187
3^8 = 6561
3^9 = 19683
The last digits go 3971 which repeats indefinitely. In fact any number we choose that en... | stackexchange_codegolf |
Write a program that will test the primality of a specified number, and give the output as a Boolean value (True is prime). Your prime test can (but doesn't have to) be valid for the number 1.
Here's the catch: your program itself has to sum to a prime number. Convert every character (including spaces) to its Unicode/... | stackexchange_codegolf |
Imagine a very simple language. It has just 2 syntax features: () indicates a block scope, and any word consisting only of 1 or more lower case ASCII letters, which indicates a identifier. There are no keywords.
In this language, the value of identifiers is not important except when they appear multiple times. Thus for... | stackexchange_codegolf |
Write a program which will eventually, given enough time, print all possible permutations of ASCII characters (both printable and non-printable) less than or equal to its length, except itself. The text of the program must not appear anywhere in its output.
For example, if your program is abc, then part of your output ... | stackexchange_codegolf |
In this question Tom learned that, in general, there are many motivations to choose to include case sensitivity in his programming language, because the possible combinations for a variable name are much more than what's possible with a case insensitive programming language for a name of the same length.
But, as a more... | stackexchange_codegolf |
Inspired by Find the largest fragile prime
A recurring prime (or whatever you choose to call it) is a prime that, when removing leading digits, always remain prime regardless of how many digits are removed.
for example
6317 is a recurring prime because...
317 is a recurring prime because...
17 is a recurring prime beca... | stackexchange_codegolf |
If you wanted to compute a very large long problem, that on a machine that you could buy today for an inflation adjusted price, will take some amount of years/decades. The issue is, if you only have that budget, and so can only purchase one machine. So if you purchase the machine now, it may actually take longer to com... | stackexchange_codegolf |
A 1-up quine is a program which is very similar to a quine. The one major difference is that instead of printing itself once, when n copies of the program are concatenated, the result prints the original program n+1 times.
Example
If your program is Abc123:
Abc123 -> Abc123Abc123
Abc123Abc123 -> Abc123Abc123Abc123
... | stackexchange_codegolf |
Introduction
A polyglot is a program that is valid in multiple languages at once. An iterative quine is a program that outputs another program that outputs another program that outputs the source of the original program. Note that the number of chained programs does not have to be 3; it could be 2, 4, or 97384.
Challen... | stackexchange_codegolf |
This is the robbers thread of this cops and robbers challenge. The cops thread is here.
Related, but hashes numbers instead of strings and uses a different scoring system.
Definitions
A hash collision is when two different strings produce the same hash.
Summary
In this challenge, the cops will make a hash function, wit... | stackexchange_codegolf |
Background
The nuclear industry has term, SCRAM, used to describe a quick shutdown of the reactor. There's a fun myth that it stands for "Safety Control Rod Ax Man," the role which served to shut down the Chicago Pile if it got too hot by literally cutting a rope with an ax (although this was debunked).
The US Nuclear... | stackexchange_codegolf |
Cheddar is a high-level, functional + object-oriented programming language created by our user Downgoat designed to make programming easier, faster, and more intuitive.
What general tips do you have for golfing in Cheddar? I'm looking for ideas which can be applied to code-golf problems and which are also at least som... | stackexchange_codegolf |
Let's make a little stupid program that simulates the meme "Mr. incredible becoming uncanny", but in this case, our little ASCII friend is going to react to our code length.
Objective:
Create a program that takes anything (preferably a program) as input and outputs this:
Pov:
<face> you score X on codegolf
Where X ... | stackexchange_codegolf |
A simplistic version of English numeral calculator
Task
Write a program that takes a string as input and outputs the result of the expression.
Rules
The input string will be worded and not numeral.
There will be no parentheses.
Order of calculation will be divide,multiply,subtract then add.
For same operations, the cal... | stackexchange_codegolf |
In the alternating Fibonacci sequence, you first start with 1 and 1 as usual.
However, instead of always adding the last two values to get the next number, you alternate starting with adding, and every other time you subtract instead.
The sequence starts like this:
1
1
2 # 1 + 1
-1 # 1 - 2
1 # 2 + -1
-2 # -1 ... | stackexchange_codegolf |
You and your friend want to send each other secret messages. However, because you are conspiracy theorists and think that the government has a quantum computer that can crack any standard encryption. Therefore, you are inventing one of your own. The first step of this is as follows: taking an input string, you check... | stackexchange_codegolf |
Inspired by Copied from this question at Stack Overflow.
Given a matrix A, create a matrix B such that the columns of A are arranged in a block-diagonal fashion. For example, given
1 2 3
4 5 6
the output would be
1 0 0
4 0 0
0 2 0
0 5 0
0 0 3
0 0 6
Rules
Input and output may be in the form of 2D arrays, nested arrays... | stackexchange_codegolf |
I'm new to this site, so I don't know whether this challenge already appeared:
Write a piece of source code, so that after running the code, it prints out exactly (i.e. not longer, not shorter) the source code itself.
The code can be in any programming language, but preferably in commonly used ones, such as the C famil... | stackexchange_codegolf |
Introduction
Time is a really simple concept. Seconds pass, one after the other, all the same. But humans love making it hard. This Stackoverflow question has gathered many answers and even though they are surprisingly long and complex, most of them will still fail for certain inputs. Can you format a number of seconds... | stackexchange_codegolf |
Robbers thread
Cops
Understanding slicing
Remember, slices are zero-indexed. Take this slice: [2:]. If the string is "abcde", the result is "cde" because the slice basically means "get all elements with an index greater than 2." Let's try [1:3]. If there is an end slice, the end slice is not included. (excluded) Theref... | stackexchange_codegolf |
Background
It's well known in mathematics that integers can be put into a one-to-one correspondence with pairs of integers.
There are many possible ways of doing this, and in this challenge, you'll implement one of them and its inverse operation.
The task
Your input is a positive integer n > 0.
It is known that there e... | stackexchange_codegolf |
Background
The monkeys need help organizing their defense and have asked you, Benjamin the code monkey, to create a program that will list all tower upgrade options. Each tower has three unique upgrade "paths", each having a tier represented by a number between 0 and 5 inclusive, 0 meaning no upgrade. Up to two paths m... | stackexchange_codegolf |
Background
(Based on a true, heart-wrenching story)
In my time, I've played around with Lisp and similar languages often. I've written with them, ran them, interpreted them, designed them, and made machines write with them for me... And if there is one thing that bothers me, it's seeing Lisp that does not comply with m... | stackexchange_codegolf |
Given a \$n\$-dimensional vector \$v\$ with real entries, find a closest permutation \$p\$ of \$(1,2,...,n)\$ with respect to the \$l_1\$-distance.
Details
If it is more convenient, you can use permutations of \$(0,1,...,n-1)\$ instead. If there are multiple closest permutations, you can output any one or alternativel... | stackexchange_codegolf |
Introduction
Imagine you are on a two dimensional cartesian plane and want to determine your position on it. You know 3 points on that plane and your distance to each of them. While it is always possible to calculate your position from that, doing that in your head is pretty hard. So you decide to write a program for t... | stackexchange_codegolf |
A common optimization to save space in binaries is to merge string literals where one literal is the suffix of another. For instance, a binary with the string literals
a: foobar
b: bar
c: barbaz
d: foobarbaz
e: baz
might contain the following string literal pool (# representing the \0-terminator):
foobar#foobarbaz#
w... | stackexchange_codegolf |
Task
Given two positive integers a, b and a Unicode mathematical inequality symbol c, determine if a c b is true.
You many take the character or its Unicode codepoint for the input c. You may output your language's truthy/falsy values, or two distinct values for true and false respectively.
Standard code-golf rules app... | stackexchange_codegolf |
Introduction
In geometry, the Peano curve is the first example of a space-filling curve to be discovered, by Giuseppe Peano in 1890. Peano's curve is a surjective, continuous function from the unit interval onto the unit square, however it is not injective. Peano was motivated by an earlier result of Georg Cantor that ... | 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 |
Write a quine, that when run, creates itself in the current directory, in a source file named itself. We will be using Windows in this, so the file name (and therefore quine) must have the following limitations:
None of these characters \ / : ? * < > |
Fewer than 211 255 characters
Limitations and assumptions
Your c... | stackexchange_codegolf |
Shifty-eyes ASCII guys like to shift ASCII Ii's:
>_> <_< >_< <_>
Given a string of shifty-guys, spaced apart or separate lines, shift the Ii's side to side, left the wall and right the skies:
Ii
The shortest shifter wins the prize.
Say What?
Write a program or function that takes in a string of an arbitrary list of t... | stackexchange_codegolf |
I am trying to find the shortest code in python 3, to solve this problem:
You are driving a little too fast, and a police officer stops you.
Write code to take two integer inputs, first one corresponds to speed, seconds one is either 1 or 0, corresponding to True and False respectively to indicate whether it is birthd... | stackexchange_codegolf |
A number is a Mersenne Prime if it is both prime and can be written in the form 2m-1, where m is a positive integer.
For example:
7 is a Mersenne Prime because it is 23-1
11 is not a Mersenne Prime because it cannot be written as 2m-1
15 is not a Mersenne Prime because it is not prime
The first few Mersenne primes:... | stackexchange_codegolf |
Code Golf Challenge
Given a string of 10 characters:
'abcdefghij'
I want to format it in this pattern and print it in the console in a minimum number of characters:
(abc) def-ghij
My solution:
print(f"({s[0:3]}) {s[3:6]}-{s[6::]}")
| stackexchange_codegolf |
It's election time, and your job is to beat your competitor in a head-on rivalry! You are both trying to win over a city of 256 people in a 16x16 grid. Right now, the city hasn't been divided into voting regions yet, but that's where your gerrymandering skills come in! You can also campaign in arbitrary areas of the ci... | stackexchange_codegolf |
The title says it all; Given a number in the binary (base-2) number system, output the same number expressed in unary (base-1).
You should take the binary number as a string (optionally with a separator), list, or equivalent structure of digits, using any number or digit you like for the digits. The unary output can us... | stackexchange_codegolf |
A binary eye is an odd set of digits, with all of its digits except the center one set to 1 or 0, and the center one set to the opposite of the others. Thus, there are two binary eyes for a given odd number of digits:
x
eyes
1
1,0
3
101,010
5
11011,00100
7
1110111,0001000
9
111101111,000010000
Make ... | stackexchange_codegolf |
With the given text below, there are some words in the text that repeats several times in the text. Use any programming language to write a short code that compresses the text to display it. Or in other words, use the smallest number of bytes to display the text.
The Text is:
Peter Piper picked a peck of pickled peppe... | stackexchange_codegolf |
So, I wrote myself a one-liner which printed out a snake on the console. It's a bit of fun, and I wondered how I might condense my code...
Here's a (short) example output:
+
+
+
+
+
+
+
... | stackexchange_codegolf |
Given two strings of digits, determine which string, if any, has the earliest digit which is lower than the other string's digit at the same index.
Do note that this differs from alphabetization, as shown in the following examples:
Examples
Given inputs 12345000 and 1233999999, the second string would have the earliest... | stackexchange_codegolf |
Goal
As the title suggests, write a radix sort function (either MSB or LSB is fine) that accepts two parameters:
an array of values of any type (you can assume that they are all of the same type / class, etc.)
a function (or function pointer, depending on your language) that takes a single parameter of the same type a... | 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 |
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 |
You are given a polynomial function, in the following format:
\$x = (c_0 * y^0) + (c_1 * y^1) + (c_2 * y^2) + ... + (c_n * y^n)\$
where \$c_n\$ stands for the coefficient of the \$n^{th}\$ power of \$y\$
You have to plot the equation on a \$10 * 10\$ ASCII matrix. The value must be floored to an integer before plotting... | stackexchange_codegolf |
I just discovered this site and this is my first question, I hope I'm doing it correctly.
The challenge is the following, you must write a code that prints all the prime numbers of \$n\$ digits. Since this problem is computationally complicated, I think that one way to simplify it is to give a number \$m\$ that will be... | stackexchange_codegolf |
Given a string and a substring and a positive integer n.
Remove the n occurences of a substring from the end of the originally given string. If the substring is not present in the string or the number of times the substring appears is less than n, then the output is the original string. No space should be present in pl... | stackexchange_codegolf |
Recently, I've found a rant from 2004 about Internet Explorer's color parsing. Turns out, MS made sure that just about anything will be parsed as a color somehow and I think it makes for a neat challenge.
Well, how does IE parse colors?
Let's give it an input with a length of...
...less than 4 chars:
Replace chars no... | stackexchange_codegolf |
Task
This one is simple. We want to compress a URL, but don't trust URL shorteners.
Write a program that prints to stdout (or a 0-argument function that returns) the following, working URL:
http://a.b.c.d.e.f.g.h.i.j.k.l.m.n.oo.pp.qqq.rrrr.ssssss.tttttttt.uuuuuuuuuuu.vvvvvvvvvvvvvvv.wwwwwwwwwwwwwwwwwwwwww.xxxxxxxxxxxx... | stackexchange_codegolf |
Challenge
Create a program that outputs a square grid showing visible and non-visible points \$(x, y)\$ from the origin based on their greatest common divisor (GCD).
A point \$(x, y)\$ is considered visible from the origin \$(0, 0)\$ if the \$\gcd(x, y) = 1\$. Otherwise, it's non-visible.
Input
An integer \$n\$, repre... | stackexchange_codegolf |
Print or return the following string:
zottffssentettffssenttttttttttttttttttttffffffffffffffffffffsssssssssssssssssssseeeeeeeeeennnnnnnnnno
This is the first letter of each of the numbers zero, one, two, all the way up to one hundred.
Standard I/O rules apply, but the output must be exactly as shown above, optionally ... | stackexchange_codegolf |
(yes, "generating generating" in the title is correct :) )
Context
In middle (?) school we are taught about sequences and, in particular, we are taught about linear sequences where the nth term is generated with an expression of the form an + b, where a and b are some coefficients. In this challenge, we will deal with ... | stackexchange_codegolf |
Drawing the Sierpinski triangle has been done to death. There's other interesting things we can do with it though. If we squint hard enough at the triangle, we can view upside-down triangles as nodes of a fractal graph. Let's find our way around that graph!
First, let's assign a number to each node. The largest upside-... | stackexchange_codegolf |
Adapted from this FiveThirtyEight riddle.
Background
Examine the following infinite sequence:
3 3 3 2 3 3 3 2 3 3 3 2 3 3 2 3 3 3 2 ...
Let's say the sequence is 1-indexed. The ith number in the sequence determines how many 3s there are before the ith 2 and following any previous 2s. So since the sequence starts with ... | stackexchange_codegolf |
In honor of national pi day, create a program that, when given an integer, n, as input, will create a circular "pie" constructed of these smaller pies:
Your program should output the image in a closed polygonal shape, and the number of outputted images should be equal to the value of the nth digit of pi.
Below are som... | stackexchange_codegolf |
Most everyone here is familiar with Pascal's Triangle. It's formed by successive rows, where each element is the sum of its two upper-left and upper-right neighbors. Here are the first 5 rows (borrowed from Generate Pascal's triangle):
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
We're going to take Pascal's Triangle and p... | stackexchange_codegolf |
Your task, if you wish to accept it, is to write a program that outputs a positive integer (higher than 0). If the source code is duplicated the output must remain the same. The tricky part is that if the source code is typed three times (triplicated?) the output will be multiplied by 3.
Rules
You must build a full pr... | stackexchange_codegolf |
The challenge:
Given four coordinates, each in x y form, your job is to find out whether or not the given coordinates form a rectangle, and output a truthy/falsey.
Rules:
For the sake of simplicity, squares, lines (two identical pairs of coordinates) or dots (all four of the coordinates are the same) are all counted a... | stackexchange_codegolf |
This is a Code Golf challenge.
Flood is a game in which the player is presented with a game board such as this:
On each turn, you choose a colour (on the link above, by clicking a square containing that colour), and the cell in the top-left corner is filled with that colour - this colour will absorb all adjacent cells... | stackexchange_codegolf |
Input
A string s of printable ASCII characters, newlines, and spaces (0x20 ( ) to 0x7E (~)), and a non-negative integer n.
Challenge
To write a program that outputs either another program, or s depending on n. If n = 1, Then your code should output code which outputs s. If n = 2, Your code should output code which outp... | stackexchange_codegolf |
A ragged matrix, is a matrix that has a different number of elements in each row. Your challenge is to write a program in any favorable language to find the indices of all occurrences of target in the ragged matrix.
Input:
A list of ragged lists (can be empty) of positive integers and a target range e.g. 26-56. The tar... | stackexchange_codegolf |
Title stolen inspired by Greg Hewgill's answer to What's the difference between JavaScript and Java?
Introduction
Java and JavaScript are commonly used languages among programmers, and are currently the most popular tags on Stack Overflow. Yet aside from similar names, the two have almost nothing in common.
In honor of... | stackexchange_codegolf |
Challenge
Given a sequence of non-negative integers, create a function that output a descendant pyramid where the children are the sum of both parent numbers.
The result is outputted as an string using tab \t.
Note: trailing tabs on each line are not required
1\t\t2\t\t3\n\t3\t\t5\t\n\t\t8\t\t results in
1 2 ... | stackexchange_codegolf |
Challenge:
Given the input array l with a list of strings, only keep the elements in the sequence that have a letter that's repeated at least 3 times. Like 'lessons' has 3 s letters, so it should be kept in the sequence. But, 'lesson' has only two s letters, so it should be removed.
Notes:
l will always be a sequence,... | stackexchange_codegolf |
Challenge
Joe the rapper is struggling with rhyming words in his lyrics. He needs your help.
For this situation, we will use rhymes where the last syllable in a word is the same as the other word (spelled the same).
When Joe inputs a word, the program will read a list of words from a file and output those that rhyme wi... | stackexchange_codegolf |
The challenge here is to find the longest uninterruped arc around a unit circle with a random amount of points distributed in random positions around it.
Here is a diagram to assist my explanation:
The red line indicates the largest arc between any two points that is not interrupted by any other points. The challenge ... | stackexchange_codegolf |
Who will rule the realm?
You are given a family tree which contains: name, sex, date of birth, date of death and a list of heirs, for each family member. You may use any convenient (nested) list format to represent the tree. The following examples will use JSON. Determine who will rule the realm and in which order.
The... | stackexchange_codegolf |
In base-10, all perfect squares end in \$0\$, \$1\$, \$4\$, \$5\$, \$6\$, or \$9\$.
In base-16, all perfect squares end in \$0\$, \$1\$, \$4\$, or \$9\$.
Nilknarf describes why this is and how to work this out very well in this answer, but I'll also give a brief description here:
When squaring a base-10 number, \$N\$, ... | stackexchange_codegolf |
Pretty simple challenge here. Who can make the fastest algorithm (lowest time complexity) to determine whether or not the circle is "boxed in" given the following setup?
Input: Your program receives a pair of numbers (a,b) that denotes the position of a circle on a grid like this with arbitrary dimensions:
Where a-1 i... | stackexchange_codegolf |
You are given two strings, each consisting of the English word for a number between 1 and 13:
one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen
Your program or function must find out whether it's possible to spell at least one other word from the same list without using any of the let... | stackexchange_codegolf |
What general tips do you have for golfing in Starry? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Starry (e.g. "remove comments" is not an answer).
Please post one tip per answer.
| stackexchange_codegolf |
As part of his answer to Make an Error Quine!, @Falko proposed the following algorithm:
How to create your own solution in 2 minutes?
Open a new file in an IDE of your choice.
Bang your head onto the keyboard in front of you.
Compile.
Replace the code with the compiler error message.
Repeat steps 3 and 4 until the co... | stackexchange_codegolf |
Challenge:
In the programming language of your choice, shut down the machine that your code was executed on.
Rules
No shutting down by resource exhaustion (e.g.: forkbomb to force shutdown)
You are allowed to write code that only works in a specific environment/OS, if you wish.
Standard loopholes are forbidden
This ... | stackexchange_codegolf |
Here is a relatively simple two dimensional array challenge.
Imagine a battlefield of 625 foot soldiers. You command the odd troops, but unfortunately the strength of the even troops overwhelms you. Thankfully, your soldiers have a secret power: If the power of each odd troop and the fellow odd allies surrounding them ... | stackexchange_codegolf |
Note to Moderators and editors:
This post's title is for effect and should not be changed. The misspelling is intentional and part of the challenge.
Backstory
The (stereo)typical bad SO question asks something along the lines of "plz send teh codez!" In other words, it asks someone to do the work for the asker and ... | stackexchange_codegolf |
Languages, such as C++, have introduced a new comparison operator: <=>.
This operator returns -1, 0, or 1† when comparing two items together:
−1 means the left-hand side is smaller,
0 when both values are equal,
+1 means the right-hand side is smaller.
Here is what I have been coming up with in x86-64:
556: 48 8b... | stackexchange_codegolf |
Challenge
Write a program that compresses and decompresses ASCII text losslessly. It should be specialized to work well with palindromes, including case-insensitive and punctuation-insensitive palindromes. The best compression with the smallest source wins.
Scoring
total_bytes_saved / sqrt(program_size) - Highest score... | stackexchange_codegolf |
Given two positive integers, \$A\$ and \$B\$, illustrate their least common multiple by outputting two lines of dashes (-) with length \$\text{lcm}\$\$(A, B)\$ after replacing every \$A\$th dash in the first line and every \$B\$th dash in the second line with vertical bars (|).
In this way, the end of each line will be... | stackexchange_codegolf |
Introduction
Your goal is to find the least number of ones you need to add or multiply together to get the input value, this is A005245.
Input
One positive integer N.
Output
The smallest number of ones that must be added/multiplied to get N.
Sample Input
7
Sample Output
6
Explanation
(1 + 1 + 1) * (1 + 1) + 1 = 7
... | stackexchange_codegolf |
Othello/Reversi is a board game in which players take turn placing pieces of a color (dark or light) on the 8x8 board. The possible moves are positions where there are one or more pieces of the opponent's color in a straight (horizontal, vertical, or diagonal) line between that position and a piece of the player's colo... | stackexchange_codegolf |
You will need to evaluate the definite integral (bounded by \$a\$ and \$b\$) of a certain polynomial function that takes the form of:
$$\int_a^b \left( k_n x^n + k_{n-1} x^{n-1} + \cdots + k_2x^2 + k_1x + k_0 \: \right) dx$$
Normally, this can be done using the fundamental theorem of calculus and power rules. For examp... | stackexchange_codegolf |
Introduction
Let's observe the following string:
AABBCCDDEFFGG
You can see that every letter has been duplicated, except for the letter E. That means that the letter E has been de-duplicated. So, the only thing we need to do here is to reverse that process, which gives us the following un-de-duplicated string:
AABBCCD... | stackexchange_codegolf |
Introduction
This challenge was inspired by a seemingly simple task requested at work that couldn't easily be done in Microsoft Teams. At least not from what we could find!
Task
Your task, if you choose to accept it, is to output the last week day of any month in any year.
Input
You can input the desired month/year in ... | stackexchange_codegolf |
Background
As you maybe know Ramanujan made this magic square by \$4x4\$ Matrix:
This works like all magic squares.
But the special thing in this square is that his birthdate is hidden in the first row, the 22\$^{nd}\$ Dec 1887.
Challenge
Can you make one for your birthdate?
Input
The User will give Input in this form... | stackexchange_codegolf |
Hexagonal tessellations, or tilings of the plane, are three-colorable -- meaning that using only three colors, such as Red, Blue, and Green, every hexagon can be colored without any two hexagons that share a border sharing a color. A partial example showing such a pattern.
Given a partial hexagonal tiling in ASCII (via... | stackexchange_codegolf |
This challenge is simple: Take a path to an png image file as input and overwrite that file with a copy of itself rotated 90 degrees clockwise. You may assume that the file has dimensions of 128x128 pixels. You may not use image metadata modifications (like Exif) to rotate the image; the pixels themselves must be trans... | stackexchange_codegolf |
Cops' challenge
This cops-and-robbers challenge challenges the Cop to write a non-empty program that, when run, produces some non-empty output in language A, and, when reversed, produces some non-empty output in language B. The program may produce any output to STDERR when run in either language, but may not take input... | stackexchange_codegolf |
Your task is to write some code that outputs an OEIS sequence, and contains the name of the sequence in the code (A______). Easy enough right? Well here's the catch, your code must also output a second separate sequence when the name of the sequence in the code is changed to the name of the second sequence.
Input Out... | stackexchange_codegolf |
Let \$A\$ be a square matrix that is at least \$2 \times 2\$ where each element is an integer. \$A^2 = A \times A\$ will then have the same dimensions as \$A\$, and will have integer elements. For example, let
$$A = \left[ \begin{matrix}
-3 & 2 \\
0 & -1
\end{matrix} \right]$$
Therefore,
$$\begin{align}
A^2 & = \left... | stackexchange_codegolf |
In set theory, the natural numbers \$\mathbb{N} = \{0, 1, 2, 3, ...\}\$ are usually encoded as pure sets, that is sets which only contain the empty set or other sets that are pure. However, not all pure sets represent natural numbers. This challenge is about deciding whether a given pure set represents an encoding of n... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.