instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
There are n people on a 2D plane. Using distances between them we're going to find their positions. To get a unique answer you must make four assumptions:
There are at least 3 people.
The first person is at position (0, 0).
The second person is at position (x, 0) for some x > 0.
The third person is at position (x, y) ... | stackexchange_codegolf |
The Code
Your program should take an input of n > 2 and output the largest prime less than or equal to n. You can choose how the number is input (standard input, read from a file, etc). For example:
Input Output
3 3
9 7
28 23
486 479
Simple enough. And if a program passes all of the test cases it's g... | stackexchange_codegolf |
Take a square matrix containing positive integers as input, and calculate the "rotated sum" of the matrix.
Rotated sum:
Take the sum of the original matrix and the same matrix rotated 90, 180 and 270 degrees.
Suppose the matrix is:
2 5 8
3 12 8
6 6 10
then the rotated sum will be:
2 5 8 8 ... | stackexchange_codegolf |
Surprisingly, I don't think we have a code-golf question for determining if a number is semiprime.
A semiprime is a natural number that is the product of two (not necessarily distinct) prime numbers.
Simple enough, but a remarkably important concept.
Given a positive integer, determine if it is a semiprime. Your ou... | stackexchange_codegolf |
Telephones in the United States (and perhaps some other places) have letters associated with some of the numbers.
2 = A, B, C
3 = D, E, F
4 = G, H, I
5 = J, K, L
6 = M, N, O
7 = P, Q, R, S
8 = T, U, V
9 = W, X, Y, Z
No letters are associated with the number 0 or 1.
Your challenge: Given any phone number in seven-digit... | stackexchange_codegolf |
Challenge
Design a compression algorithm specialized for compressing ASCII mazes. You will need to create both a compression algorithm and a decompression algorithm. Your score will be based on the size of your compressed mazes.
Mazes
These mazes are made primarily of the characters (floors), +, -, |, and # (walls), a... | stackexchange_codegolf |
(Based on this closed challenge, related)
Given an integer n > 1, draw a grid composed of the characters: "-" "+" and "|". However, since I want the grid to look nice, the horizontal component should be 2 wide.
Trailing spaces for each line are not required.
Examples:
n = 2
|
--+--
|
n = 3
| |
--+--+--
| ... | stackexchange_codegolf |
Write a program or function that, given a string, will strip it of zalgo, if any exists.
Zalgo
For this post, zalgo is defined as any character from the following Unicode ranges:
Combining Diacritical Marks (0300–036F)
Combining Diacritical Marks Extended (1AB0–1AFF)
Combining Diacritical Marks Supplement (1DC0–1DFF)
... | stackexchange_codegolf |
Input
An array that can contain arrays or positive, consecutive, ascending integers. The arrays can have any number of arrays inside of them, and so on and so forth. No arrays will be empty.
Output
This array simplificated
How to simplificate an array
We will use the array, [1, [2, 3], [[4]], [[[5, 6], 7, [[[8]]]], 9]]... | stackexchange_codegolf |
A directed graph G is given with Vertices V and Edges E, representing train stations and unidirectional train routes respectively.
Trains of different train numbers move in between pairs of Vertices in a single direction.
Vertices of G are connected with one another through trains with allotted train numbers.
A hop is ... | stackexchange_codegolf |
Adapted from Tips for restricted source in Python
Just like code-golf, restricted-source pushes one to exploit quirks and hidden features of the Powershell language. Now, We already have a place to collect all these tips for code-golf, those for restricted-source remain transmitted by word of mouth or hidden deep wit... | stackexchange_codegolf |
Objective/Restrictions:
May only be answered with programming language that has function syntax (or procedure, method, lambda, macro, statement grouping and labelling) .
Create a function with at least 2 argument/parameter, that generates an array containing 7 random strings, each string contains 3 characters, string... | stackexchange_codegolf |
Description
You have a list of integers and start counting from the first term to the next and continue from that to the next and so on..
How many times have you counted?
For example given [ 2, 5, 3, 8 ]
you start at 2 and count to 5 -> 3 4 5 (3 times)
then from 5.. 4 3 (2 times)
and finally 4 5 6 7 8 (5 times)
You co... | stackexchange_codegolf |
Task
You will be given a string in the input consisting only of the characters from a to z, i.e. the input will match the regex /^[a-z]*$/.
Your output should be a complete program in the same language, whose source code contains the input, and is a proper quine.
Example
Your program would receive the input abc and out... | stackexchange_codegolf |
I find NullPointerException to be interesting since there are no explicit pointers in Java. Here is a program that throws such an exception.
class c {
public static void main(String[]s) {
throw new NullPointerException();
}
}
What is the shortest Java program that throws NullPointerException?
| stackexchange_codegolf |
Your goal is to output an ASCII art pie chart. This is code-golf, so the shortest program (counting the bytes of the source code, not the characters) wins.
No external softwares or APIs are allowed. Only the native ones of each language.
The starting angle and the direction (clockwise/anticlockwise) of the circle are n... | stackexchange_codegolf |
In this challenge, you should write a program or function which takes no input and prints or returns a string with the same number of bytes as the program itself. There are a few rules:
You may only output bytes in the printable ASCII range (0x20 to 0x7E, inclusive), or newlines (0x0A or 0x0D).
Your code must not be a... | stackexchange_codegolf |
So simple: Provide some code that outputs foo and with the reversed source outputs bar. But before you come up with something like this boring python 2:
print "foo"#"rab" tnirp
you should know the score: You multiply the number of bytes with (1 + dead bytes), where dead bytes are bytes that can be changed to most othe... | stackexchange_codegolf |
I have a colleague at work that works from home every Tuesday and Thursday. At around 8:00 AM he sends us a message with the following text:
Hello today I'm working from home
In order to relieve him from the burden of doing this every day he stays at home, we would like to automate this task for him.
The challenge
Wr... | stackexchange_codegolf |
We all know and love the corpulent DDL expressions one can write in PostgreSQL with wording like DEFERRABLE INITIALLY DEFERRED, ALTER FOREIGN DATA WRAPPER, or even DROP TEXT SEARCH CONFIGURATION. But how far can one go? Here comes the definitive challenge for the longest DDL expression, with constraints of course. Mwah... | stackexchange_codegolf |
The picture:
Sick of the same old grid where the answer is simply a square pyramidal number?
Accept the challenge and write a program that given a positive integer \$n\$ counts how many squares are in the \$n^{\text{th}}\$ iteration of the Harter-Heighway dragon!
The sequence of squares of size 1 is A003230
Your cod... | stackexchange_codegolf |
Given an expression like 4 / 2 + 3, determine whether the expression has the same value in Python 2 and Python 3. Recall that in Python 2 division rounds down (so that 5 / 2 -> 2), whereas in Python 3 division returns a float (so that 5 / 2 -> 2.5).
For simplicity's sake, we will only consider expressions of the form:
... | stackexchange_codegolf |
3D-modeling software mainly uses UV Mapping to map textures onto a 3D object. The valid values for both U and V are usually located in an inclusive [0..1] range.
Challenge
You bought a new 3D-modeling software which is super-easy to use. However there is one issue with it: it adds or subtracts a random integer number f... | stackexchange_codegolf |
Adapted from the UIL - Computer Science Programming free response question "Carla" for 2018 District.
Introduction
In UNIX-like operating systems, each file, directory, or link is "owned" by a "user", who is a member of a "group", and has certain "permissions" represented by a ten-character string such as "drwxrwxrwx".... | stackexchange_codegolf |
The difference list of a list of integers is the list differences of consecutive members.
For example the difference list of
1, 3, 2 ,4
is
2, -1, 2
Your task is to take as input a difference list and output what the difference list would look like if the original list were sorted.
For example the difference list
2, 1... | 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 |
Task
A date can be compactly represented in a 6-character string in the format ddmmyy where the first two characters (dd) represent a day, the 3rd and 4th characters (mm) represent a month and the last two characters (yy) represent a 20XX year. Given a string with 6 characters in [0-9] determine if it represents a vali... | stackexchange_codegolf |
Given a string and the characters used to encode it, you need to compress the string by only using as many bits as each character needs. You will return the character codes for each character needed to create a compressed string.
For example, given the string "the fox" and the encoder characters " abcdefghijklmnopqrstu... | stackexchange_codegolf |
Help! My device malfunctions and whenever I try to repeat a String, I get a messy results. Instead of repeating the same string N times, it fills an NxN square with each of its characters, and stacks the squares up.
For example, given the String "Test" and the number 2, instead of "TestTest", I get:
TT
TT
ee
ee
ss
ss
t... | stackexchange_codegolf |
Specifically, Conway's PRIMEGAME.
This is an algorithm devised by John H. Conway to generate primes using a sequence of 14 rational numbers:
A B C D E F G H I J K L M N
17 78 19 23 29 77 95 77 1 11 13 15 15 55
-- -- -- -- -- -- -- -- -- -- -- -- -- --
91 85 51 38... | stackexchange_codegolf |
So your task is to take a 3x3 block where -'s mean blank spaces, and *'s mean filled spaces, for example:
-**
-*-
*-*
and rearrange the block so that the *'s form an X, like this:
*-*
-*-
*-*
Input:
3x3 squares like above, they can be 3 lines, an array, or however you want.
Output: The shortest amount of moves to rea... | stackexchange_codegolf |
Giving n(any amount) of points (x,y). What's the minimum amount of circles required to cross every point given?
Task
Your program will get n (you can have n as part of input or use EOF instead) points (x,y).
The points might at same place => (x1,y1) = (x2,y2) can happen
x and y will be integer of range -10000~10000, wh... | stackexchange_codegolf |
This question is similar to Do the circles overlap?, except your program should return True if the circumference of one circle intersects the other, and false if they do not. If they touch, this is considered an intersection. Note that concentric circles only intersect when both radii are equal
Input is two x, y coordi... | stackexchange_codegolf |
Background
As far as we can tell from trying everything (besides cheating with ZWSPs), you can't type
`\
in Stack Exchange chat. However, you can type
\`
by doing
`\\``.
So, if you want to tell someone in chat how to type backslash-backtick, you'd need to type out
`\`\\`\``
to format
`\\``
into a codeblock.
Challenge
Y... | stackexchange_codegolf |
Background
When you run tail -f file in bash, the file is outputted and then any subsequent appends.
However, when you remove something that has already been displayed, tail outputs:
tail: nameoffile: file truncated
Your Challenge
When given an input f, append tail: [value of f]: file truncated (with trailing & leadin... | stackexchange_codegolf |
You should code a piece of code that looks like it outputs the language name but actually outputs the name reversed.
E.g. a Python program should look like it outputs Python but should actually output nohtyP.
The winner is the answer with the most upvotes in a week!
| stackexchange_codegolf |
Final results
1st place goes to Follow!
Honourable mentions to The diff predictor (2nd), and Simple Killer, Low Blow and High to Low (joint 3rd).
Other winners:
(score competition) 1st - Simple Killer
Honourable mentions: The diff predictor and Naiive.
(wins competition) 1st - Crab
Honourable mentions: Follow and High ... | stackexchange_codegolf |
There are many ways to generate random words. You can take random syllables from a set, you can use n-tuples, probably neural networks (what can't they do?), alternating between consonants and vowels, etc. The method this challenge is based off of is by far the worst. It uses a Markov chain to generate random words. If... | stackexchange_codegolf |
Challenge
Given a grid size, obstacles' positions, player position and target position your task is to find a path for the player to get to the target and avoid the obstacles at the same time (if necessary).
Input
N: Grid size N x N
P: Player's position [playerposx, playerposy]
T: Target's position [targetposx, targ... | stackexchange_codegolf |
This contest is over.
Due to the nature of cops-and-robbers challenges, the cops challenge becomes a lot easier when the interest in the associated robbers challenge has diminished. Therefore, while you can still post hash functions, your answer will not get accepted or form part of the leaderboard.
This challenge is... | stackexchange_codegolf |
The day this post was published was Christmas Eve. Tomorrow will be Christmas. Yesterday was Christmas Eve Eve. In two days it will be
Christmas Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Ev... | stackexchange_codegolf |
Background
A backronym is an acronym that was formed from an existing word. For example, spam is actually named after the canned meat product as used in the Monty Python sketch, but can be interpreted as "stupid pointless annoying mail".
Challenge
Given a string a, and a word t, capitalise the correct letters of the w... | 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 |
The picture:
Sick of the same old grid where the answer is simply a square pyramidal number?
Accept the challenge and write a program that given a positive integer \$n\$ counts how many squares are in the \$n^{\text{th}}\$ iteration of the Harter-Heighway dragon!
The sequence of squares of size 1 is A003230
Your cod... | stackexchange_codegolf |
The Challenge:
For an input of one letter X (upper or lower case from A to Z) and one digit N (0-9) print the corresponding letter X made of N * X.
The letter has to be from this list:
AAA BBBB CCCC DDDD EEEEE FFFFF GGG H H
A A B B C D D E F ... | stackexchange_codegolf |
This page is not for Visual Basic Tips
Visual Basic .NET (VB.NET) is an multi-paradigm dialect of basic that was developed and released by Microsoft in 2002 as a replacement for Visual Basic. The current version of VB.Net as of Feb 2018 is Visual Basic .NET 15.0.
Unlike Visual Basic (VB), Visual Basic .NET (VB.NET) is ... | stackexchange_codegolf |
Now that other users have helped Trump build the wall, its time for you to climb it.
This is an ascii art challenge where you need to output a climbing wall with randomly placed holds.
A climbing wall is made up of panels each of which has between 3 and 10 holds and is 5 panels high. Each panel is 4 characters high and... | stackexchange_codegolf |
Challenge
Write a program or function that takes in 4 non-negative integers, A, B, C, and D, that represent two fractions, A/B and C/D, where B and D are non-zero and A <= B and C <= D.
Output an ASCII art depiction of the fractions made of |x- characters on two lines as follows:
The lines will always be the same, min... | stackexchange_codegolf |
Introduction
So John finally has his holidays! And what better could he do than watching some movies. He indeed has a lot of movies to watch, but he is unable to decide which one to watch first. He has a list of movies, each in the format: <Movie name> (<Year>). So he makes a simple set of rules to decide his order of ... | stackexchange_codegolf |
You need to print A-Z like this:
1. A
2. B
3. C
4. D
5. E
6. F
7. G
8. H
9. I
10. J
11. K
12. L
13. M
14. N
15. O
16. P
17. Q
18. R
19. S
20. T
21. U
22. V
23. W
24. X
25. Y
26. Z
But your source code cannot use 1,2,4,6.
Trailing newlines in output allowed,, but leading ones not allowed.
Standard loopholes apply, shor... | stackexchange_codegolf |
You are to write a very small program within 100 characters. Your program must distinguish between masculine and feminine french nouns. The output should be un if it is masculine and une if it is feminine. Often, there are certain statistical rules you can follow (e.g. if it ends in an "e" it is more likely feminine th... | stackexchange_codegolf |
Introduction
How to prove that 1 = 2:
1 = 2
2 = 4 (*2)
-1 = 1 (-3)
1 = 1 (^2)
You can just multiply both sides by 0, but that's cheating. This is just bending the rules a little bit.
Your challenge:
Write a program/function that, when given two integers, outputs a "proof" that the two are equal.
Rules
Your program's... | stackexchange_codegolf |
Your job is to implement bitwise addition.
To ensure that this is done, you will compute and print the result of addition without carry (or bitwise XOR). Then, you will compute the carry of the addition (bitwise AND) and multiply it by two (bitwise left shift). If the carry is nonzero, then you add the carry and the pr... | stackexchange_codegolf |
The task is to convert a string representing a number in decimal (base 10) representation to duodecimal (base 12). The input is thus a string, the output should be printed.
The input number can be positive and negative, can be integer or rational. The decimal and duodecimal representations will have a finite number of ... | stackexchange_codegolf |
A string is called a "prime string" if it can't be written as a concatenation of more than one of the same string.
Your task is to write a program that, given a sequence of letters of length N (5 < N < 100), determines if it is prime or not.
Examples
Input: AABBAA
Output: not prime, false, 0, etc.
Input: FDFJKEHKLJHD... | stackexchange_codegolf |
Write a program that has at least one byte that, when run, does absolutely nothing.
I thought this would be done by now, but I can't find any other challenges like this.
How to tell if it does nothing:
No variables are declared
Nothing is returned
Input does nothing
You could run a program after it and it would run no... | stackexchange_codegolf |
As we learned from the IBM PC AT, YouTube (see video), Wikipedia (see article), and Sesame Street:
The letter H is the most merciless letter of the alphabet!
(Even when actually composed from two elements in Code Page 437. In fact, it's even MORE merciless that way.)
Like the Aliens in, uhm...er... Aliens, Beasts rele... | stackexchange_codegolf |
Jimmy has had a busy last week with all these platforms and ropes, and poor Jimmy doesn't even have legs or feet to stand on!
Your job is to take a string containing multiple Jimmys and give them legs and shoes!
Get input in the form of a Jimmy String
Jimmy String => /o\ /o\ /o\
containing only /o\ and
give each ... | stackexchange_codegolf |
Requirements:
Take a single word as input with only lowercase alphabetical characters (a-z)
Output a string where every other character is repeated, with the first repeated character being the second character in the string
Example:
Input: abcde
Output: abbcdde
Winning Criteria:
Standard code golf. Shortest number of... | stackexchange_codegolf |
In sporting competitions, it often happens that winners are presented on podiums, with the first-place person on the highest in the middle, the second-place person on the middle height to the left, and the third-place person on the lowest and to the right. We're going to recreate that here with some special tweaks.
The... | stackexchange_codegolf |
Introduction
cowsay is a Unix command made by Tony Monroe, written in Perl. It outputs a picture of a cow saying given text. For example:
________________________
< Typical cowsay output! >
------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
... | stackexchange_codegolf |
Input: an array of length \$n\$ containing integers in the range \$0\$ to \$2n\$.
For each integer \$x\$ in the array, compute the number of integers that occur before \$x\$ that are no larger than \$x\$.
As an example, if the array is
[3, 0, 1, 4, 3, 6]
the output should be equivalent to:
3: 0
0: 0
1: 1
4: 3
3: 3
6: ... | 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 |
Given an array of letters in the range 'a' to 'o', compute how to construct the array by successively inserting the letters in alphabetical order. You will always start the insertion with a base array of all the 'o's that are in the array to be reconstructed.
Examples
Let the input array be:
['o', 'b', 'o', 'b', 'a']
... | stackexchange_codegolf |
Given an infinite arithmetically-progressive¹ sequence, compute the minimum length of a prefix with a product divisible by 2^8.
Sample cases & reference implementation
Here is a reference implementation that I wrote in Io.
1, 1 -> 10
2, 4 -> 8
3, 5 -> 10
2, 6 -> 5
7, 5 -> 6
4, 1 -> 9
10, 9 -> 7
256, 9 -> 1... | stackexchange_codegolf |
Hermite polynomials refer to two sequences of polynomials:
The "probabilist's Hermite polynomials", given by
$${He}_n(x) = (-1)^n e ^ \frac {x^2} 2 \frac {d^n} {dx^n} e ^ {-\frac {x^2} 2}$$
where \$\frac {d^n} {dx^n} f(x)\$ refers to the \$n\$th derivative of \$f(x)\$
The "physicist's Hermite polynomials", given by
$... | stackexchange_codegolf |
This challenge is about implementing Shm-reduplication, originating in Yiddish, where one takes a word, duplicates it, and replaces the first syllable in the second word with "Shm" in order to indicate that one does not care. Some examples include:
"Isn't the baby cute?", "Eh, baby shmaby"
"Come buy from my store, we ... | stackexchange_codegolf |
Given 3 positive integers a, b, and n (whose maximum values are the maximum representable integer value in your language), output a truthy value if a ≡ b (mod n), and falsey otherwise. For those unfamiliar with congruency relations, a ≡ b (mod n) is true iff a mod n = b mod n (or, equivalently, (a - b) mod n = 0).
Rest... | stackexchange_codegolf |
TAS Golf
In the style of a tool-assisted speedrun with a code-golf twist, the goal of this challenge is to complete World 1-1 of the original Super Mario Bros game for the NES in your chosen programming language in as few bytes as possible, using only the in-game controller inputs in the format I'll describe below. Yo... | stackexchange_codegolf |
Consider:
c=(a,b)=>(+a||0)+(+b||0)
Yes, it is not good to solve it like that. But I want to shorten it even more. If a is a string and b is a string, then return 0. If one is a number, return it (floats and intergers). And if both inputs are numbers, then return the sum (if either string can be cast to a number, treat... | stackexchange_codegolf |
Let's play Russian Roulette!
Normally, this would be a race to write the shortest MOD 6 program, but that's not very realistic, as the chance of winning decreases with each click. Here are the rules:
Emulate a real six-shooter:
A single bullet is placed into one of the six chambers, and the barrel is spun once, onl... | stackexchange_codegolf |
Calculate the maximum number of circles of radius r that can fit in a rectangle with width x and height y. Write a function that take r, x and y as input and returns the number of circles that fit in the rectangle.
| stackexchange_codegolf |
Write a program that outputs its source code in reverse when run, and outputs its source forwards when I reverse the source. If your program is "abcd", when run with no arguments it should output "dcba", and when I run the program "dcba" it should output "abcd."
This is a quine challenge, so both your forwards and reve... | stackexchange_codegolf |
Background
The sequence in the title is A245788 "n times the number of 1's in the binary expansion of n" ("times" here means multiplication), which starts like this:
1, 2, 6, 4, 10, 12, 21, 8, 18, 20,
33, 24, 39, 42, 60, 16, 34, 36, 57, 40,
63, 66, 92, 48, 75, 78, 108, 84, 116, 120,
155, 3... | stackexchange_codegolf |
Note: The survey for community favorite will be released soon
In this KoTH, the aim is to be the last bot alive. Coins will be placed in random areas, and your bot must get the coins first. If a bot runs into another bot, the bot with more coins wins, and the other bot dies. More details below.
Coin types
There will ... | stackexchange_codegolf |
What all languages have a construct similar to python's eval, so you can write code during runtime and run it?
A list would be helpful for certain programming challenges - ones where it is obvious an eval is either necessary or highly efficient.
| stackexchange_codegolf |
From Wikipedia, Gabriel's Horn is a particular geometric figure that has infinite surface area but finite volume. I discovered this definition in this Vsauce's video (starting at 0:22) where I took the inspiration for this problem.
You begin with a cake (a cuboid) of dimension \$x \times y \times z\$. In your first sli... | stackexchange_codegolf |
Background
The number 1729 is the Hardy-Ramanujan number. An amazing property of it was discovered by S. Ramanujan (who is widely regarded as the greatest Indian mathematician1), when G.H. Hardy paid a visit to him in a hospital. In Hardy's own words:
I remember once going to see him when he was ill at Putney. I had r... | stackexchange_codegolf |
I'm new to this code-golfing thing and I'm very interested in CJam.
Is there a way to get all the current stack as an array? I think I can do it with something like [1$ 2$...n$] but I would have to get the stack's length and use some kind of iterator (or use a fixed length stack... useless). But is there a way to achie... | stackexchange_codegolf |
Introduction
Busy Beavers are programs (specifically Turing Machine programs) that aim to output the most ones as possible, while having the least states as possible and halting.
Challenge
Your challenge is to make a busy beaver, which outputs as many ones as possible, but also outputs a second busy beaver. That secon... | stackexchange_codegolf |
In chat, we are often fast-typers and don't really look at the order of letters before posting a message. Since we are lazy, we need a program that automatically swaps the last two letters in our words, but since we don't want to respond too late, the code must be short.
Your task, if you wish to accept it, is to write... | stackexchange_codegolf |
The challenge
The plastic number is a number related to the golden ratio, with many interesting mathematical properties. As such, there are many approaches that can be used to calculate the number.
In order to precisely specify the number for the purposes of this challenge, we'll use the following definition (although ... | stackexchange_codegolf |
Cops thread
Robbers
Robbers, your job is to find the slices of the corresponding cop's code.
Scoring
The robber with the most cracks wins.
Example
Take this code:
iimmppoorrtt ssyymmppyy;;pprriinntt((ssyymmppyy..iisspprriimmee((iinnppuutt(())))))
The slice here is [::2], so the robber's post could look like this:
Crac... | stackexchange_codegolf |
Can you think of a regular expression that does not match itself?
| stackexchange_codegolf |
Consider a list of subject, grade pairs. E.g.
[("Latin", "A"), ("French", "A*"), ("Math", "B"), ("Latin", "A*")]
The task is to return the same list but with each subject given at most once. Where a subject occurred more than once originally, the returned list should have the highest grade for that subject.
Using th... | stackexchange_codegolf |
If you remember back to your schooling years, you might remember learning about Truth Tables. They seemed boring, but they are basis for logic and (some would argue) all computing...
Problem
Your mission, should you choose to accept it is to write a program, function, or widget of code that can output a truth table gi... | stackexchange_codegolf |
Determining whether a Turing machine halts is well known to be undecidable, but that's not necessarily true for simpler machines.
A Foo machine is a machine with a finite tape, where each cell on the tape has an integer or the halt symbol h, e.g.
2 h 1 -1
The instruction pointer starts by pointing to the first cell:
2 ... | stackexchange_codegolf |
Challenge:
Given two integers \$a\$ and \$b\$, with lengths \$A=length(a), B=length(b)\$, output an ASCII-art of the \$a^{th}\$ root of \$b\$, including the answer rounded to \$A\$ amount of decimal places.
The size of the ASCII-art root also depends on \$A\$ and \$B\$.
Example:
\$a=123\$, \$b=1234\$
____
123 /123... | stackexchange_codegolf |
A rigid transformation of a square array is a mapping from square arrays of a certain size to square arrays of the same size, which rearranges the elements of the array such that the distance to each other element remains the same.
If you printed out the matrix on a sheet of paper these are the transforms you could do ... | stackexchange_codegolf |
Given a string that contains only lowercase letters, encode that string with the alphabet cipher.
To encode with the alphabet cipher (I will be using the example hello):
First, convert each letter in the string to a number depending on its position in the alphabet (a = 1, b = 2, etc.) Example: 8 5 12 12 15
Pad each nu... | stackexchange_codegolf |
This is the cops' thread. The robbers' thread goes here.
Write a program or function consisting only of printable ASCII characters (that excludes tab and newline) that outputs at least 5 printable ASCII characters in ascending order (from space to tilde / 32 to 126). Characters can be outputted several times, as long a... | stackexchange_codegolf |
Inspired by the problem with the same name on Puzzling SE by our very own Dmitry Kamenetsky.
You are to find the largest number that only uses every digit pair once, in a given base. For example, in ternary we have 2212011002.
Challenge: Given a base from 2-10, output the largest number in that base with no repeating d... | stackexchange_codegolf |
Introduction
Arrays are usually used with for-loops or iterators. One different task might be the use as a cheap way to rotate through a set of items, so after reaching the last index, the next item would be the first item of the array. This is useful for cases like menus and physical controls.
Challenge
Given the size... | stackexchange_codegolf |
Given integers 0<x<10106 and 0<n<106, work out x(1/n) under 15 seconds(TIO or your computer), 1GB memory. You can assume the result is integer smaller than 50000.
Shortest code in bytes in each language win.
Sample:
x n result
121 2 11
123 1 123
1024 10 2
A larger sample can be seen here
| stackexchange_codegolf |
Wordle is a daily online word game that has received considerable attention recently.
The Game
The object is to guess a secret word in the fewest attempts. Consider the following instance of the game:
The secret word is rebus, and the player's first guess was arise. The letters r, s, and e are displayed in yellow to i... | stackexchange_codegolf |
Wordle is a daily online word game that has received considerable attention recently.
The Game
The object is to guess a secret word in the fewest attempts. Consider the following instance of the game:
The secret word is rebus, and the player's first guess was arise. The letters r, s, and e are displayed in yellow to i... | stackexchange_codegolf |
Task:
Create a program that will take an acronym as input, for example dftba, and generate some possible phrases that the acronym could stand for. You can use wordlist as word input. Inspired by https://www.youtube.com/watch?v=oPUxnpIWt6E
Example:
input: dftba
output: don't forget to be awesome
Rules:
Your program ca... | stackexchange_codegolf |
The Question
A Sophie Germain prime is a prime \$p\$ such that \$2p+1\$ is prime as well. For example, 11 is a Sophie Germain prime because 23 is prime as well. Write the shortest program to calculate Sophie Germain primes in ascending order
Rules
The Sophie Germain primes must be generated by your program, not from a... | stackexchange_codegolf |
Based on the interpretation user @ThePirateBay made from the first version of my own challenge
Output diagonal positions of me squared
now I challenge you to make ASCII art that draws diagonal lines based on a square character matrix based on a given number n.
Input
A number n.
Output
A square matrix of size n^2 which... | stackexchange_codegolf |
Your task: given an integer n, generate an embedded hexagon pattern following the below rules, to the nth depth.
An embedded hexagon has the basic shape of this: (n=0)
__
/ \
\__/
Embedded Hexagons n=1 and n=2:
____
/ \ \
/\__/ \
\ /
\____/
________
/ \ \ \
/\__/ \ \
/\ ... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.