instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
The edit distance between two strings is the minimum number of single character insertions, deletions and substitutions needed to transform one string into the other.
This task is simply to write code that determines if two strings have edit distance at most 3 from each other. The twist is that your code must run in l... | stackexchange_codegolf |
Today, @HyperNeutrino succeeded merging his two accounts, and finally got the reputation he lost back. Now, it's time to celebrate! Your task is to output this exact text:
/\
/ \
/ \
/ \
/ \
/ \
/ ... | stackexchange_codegolf |
Background
The Collatz Conjecture is quite well-known. Take any natural number. Triple and increment if odd; cut in half if even. Repeat, and it will reach 1 eventually. This famous conjecture, however, is only that, for it is yet unproven.
Little-known to the world, that was not Lothar Collatz's first attempt at fame.... | stackexchange_codegolf |
The purpose of this challenge is to produce an ASCII version of the cover of this great album by the rock band Pink Floyd.
The brick junctions are made of characters _ and |. Bricks have width 7 and height 2 characters, excluding junctions. So the basic unit, including the junctions, is:
_________
| |
| |
_... | stackexchange_codegolf |
Background
So, nowadays the popular Prisoner's Dilemma variant is the Prisoner's Trilemma, where there are three options. I can easily see that being increased, so I figured
Why settle for three options, when we can have INFINITE options?
Therefore, I created the Floating Point Prisoner's ?Lemma.
Equations:
Each roun... | stackexchange_codegolf |
Objective
Given a permutation of 4 distinct items, classify the permutation by the normal subgroup(s) it belongs.
Input/Output Format
You gotta choose the followings as the hyperparameters for your submission:
The 4 distinct items.
The permutation serving as the identity permutation.
The input format is to accept a... | stackexchange_codegolf |
Consider a horizontal line with vertical lines centered on the x-axis and placed at gaps of \$\sqrt{2}/2\$. For a positive integer \$n \geq 3\$, the first half of the lines have lengths \$0, \sqrt{2}, 2\sqrt{2}, 3\sqrt{2}, \dots, (n-1)\sqrt{2}\$ and then the second half have lengths \$(n-2)\sqrt{2}, (n-3)\sqrt{2}, \do... | stackexchange_codegolf |
Please note that this question is different from this question. This one asks for graphical output, while the other one asks for ascii art.
Objective
Help! Timmy's graphing calculator broke! His calculator cannot graph anymore. However, he has found a way to add new programs and functions to his calculator. Your job is... | 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 |
Task
Given a non-negative integer \$n\$, evaluate the factorial \$n!\$.
The factorial is defined as follows:
$$
n!=\begin{cases}1 & n=0\\n\times(n-1)!&n>0\end{cases}
$$
Rules
All default I/O methods are allowed.
Standard loopholes are forbidden.
Built-ins are allowed.
There is no time or memory limit.
Giving imprecise... | stackexchange_codegolf |
The task
Given any array of integers, e.g.:
[-1,476,578,27,0,1,-1,1,2]
and an index of that array (this example uses 0 based indexing, though you can use 1 based indexing as well.):
index = 5
v
[-1,476,578,27,0,1,-1,1,2]
Then return the nearest number greater than the element at that index. ... | stackexchange_codegolf |
In Chinese, numbers are written as follows:
1 一 2 二 3 三 4 四 5 五 6 六 7 七 8 八 9 九 10 十
For numbers above 10, it is expressed as the number of tens and the number of ones. If there is only one ten, you do not need to explicitly say one, and if there are no ones, you don't need to put anything after:
11 十一
24 二十四
83 八十三
90... | stackexchange_codegolf |
Challenge
Take an input string \$s\$, and split it into words \$w_1, w_2, ..., w_n\$. If the amount of words is odd, then return \$s\$. Otherwise, for each word: Take the second last letter, and swap it with the first letter keeping capitalization positions. So GolF becomes LogF.
Now check if the amount of words is a m... | stackexchange_codegolf |
For a given list of number \$[x_1, x_2, x_3, ..., x_n]\$ find the last digit of \$x_1 ^{x_2 ^ {x_3 ^ {\dots ^ {x_n}}}}\$
Example:
[3, 4, 2] == 1
[4, 3, 2] == 4
[4, 3, 1] == 4
[5, 3, 2] == 5
Because \$3 ^ {(4 ^ 2)} = 3 ^ {16} = 43046721\$.
Because \$4 ^ {(3 ^ 2)} = 4 ^ {9} = 262144\$.
Because \$4 ^ {(3 ^ 1)} = 4 ^ {... | stackexchange_codegolf |
Your program should compute the number of moves it takes a chess knight to reach each square of the chess board. The input will be two space-separated integers representing coordinates of the starting square (horizontal then vertical coordinate, 0-7 inclusive each). Your program should output a number grid containing... | stackexchange_codegolf |
We already have challenges dealing with simulating vanilla Conway's Game of Life, Wireworld and rule 110, but so far none corresponding to a (specific) non-totalistic rule. So here is one.
In June 2000 David Bell described the Just Friends rule, which uses the same square grid and two states as regular Life but has the... | stackexchange_codegolf |
Write a program that, given any 'n' number of strings of 'm' length, returns 'm' number of 'n'-length strings, with this condition:
Every new string should contains the letters at the same index of the others strings
For example, the first output string must contain the first letter of all the input strings, the second... | stackexchange_codegolf |
Background
Boolean Algebra concerns representing values with letters and simplifying expressions. The following is a chart for the standard notation used:
Above is what actual boolean algebra looks like. For the purposes of this code golf, this is not the syntax that will be used.
Your Task
Given a string with three c... | stackexchange_codegolf |
I often have to take character data and categorize it numerically at work. A common thing I do is to take character type variables and convert them to numeric type characters, keeping same categories according to the level of work I'm doing. (The longer the substring, the more in depth and specific, shorter substrings ... | stackexchange_codegolf |
This is a relatively simple question. I'm trying to golf a Snake game I've written, and I'm trying to work out if there's a way to golf the following conditional assignments which control x and y coordinates of the snake ensuring a wrap around of the play area:
if (P<0) {
P = T-1;
}
if (P>T-1) {
P = 0;
}
if (Q<0) {... | stackexchange_codegolf |
...or "snakes but not too long".
Inspired by this challenge and this comment.
Task
Write a program or a function that takes no input and outputs its own source code formatted as a snake according
to the rules below:
If your code has any whitespace, it will not be output; it will just be skipped.
There will be one char... | stackexchange_codegolf |
This challenge is a prize for ais523 for winning the "Rookie of the Year" category in "Best of PPCG 2016". Congratulations!
BackFlip is an esoteric programming language made by user ais523, who has created well over 30 other interesting esolangs.
BackFlip is a 2D language like Befunge or ><> where the instruction poin... | stackexchange_codegolf |
If you have ever looked at an objdump of a C++ program, you have likely seen something like this:
_ZN3foo3bar3bazI6sampleEE3quxvi3foo
This is a C++ mangled symbol, which encodes the namespaces, classes, and function/template arguments, using the Itanium ABI.
Specifically, it is for the following function:
void foo::ba... | stackexchange_codegolf |
You've gotten out of Earth's gravity well - good for you! However, you're feeling a bit uncomfortable in zero-gravity, and you want to replicate 1 \$g\$ of force in a centrifuge. Use the equation for force in a centrifuge:
$$\text{RCF} = \frac{r_\text{m} \, \left(\frac{2 \pi N_\text{RPM}}{60}\right)^2}{g}$$
Where
\$\t... | stackexchange_codegolf |
A bunch of cars are lined up at a 4-way stop sign waiting to proceed. Everyone is confused about who gets to go next, who is going which way, etc. Clearly suboptimal.
Your job is to schedule the traffic at the stop sign in an optimal fashion.
You receive as input 4 strings of turn requests, one for each of the four c... | stackexchange_codegolf |
A lexicographically increasing number is an integer whose digits are in strictly increasing order. Print all lexicographically increasing numbers under 10000.
Here are lines of the expected output:
0
1
2
3
4
5
6
7
8
9
12
13
14
15
16
17
18
19
23
24
25
26
27
28
29
34
35
36
37
38
39
45
46
47
48
49
56
57
58
59
67
68
69
78... | stackexchange_codegolf |
I recently had to add a small basic calculator to a project. I wrote a quick dirty one, but it seemed small enough to check with you people out here ;)
Just out of curiosity & an appetite to get surprised for some real hacky solutions, try and beat this one :
CODE (JS/JQUERY):
function scalcy() {
var b="", p=parse... | stackexchange_codegolf |
When I was a kid, there was a "really cool" shortcut to count to 100:
1, 2, miss a few, 99, 100
Output the exact string above, in the fewest characters possible, without using these characters: 0, 1, 2, 9
| stackexchange_codegolf |
An Séimhiú agus an tUrú
In Irish Gaelic (Gaeilge) there are a number of ways that the start of a word can be changed. The most common of these are lenition (an séimhiú) and eclipsis (an t-urú)
Lenition involves adding the letter h as the second letter. For example, the word "bean" (woman) would be lenited to "bhean".
E... | stackexchange_codegolf |
Preamble
Integers are always either even or odd. Even integers are divisible by two, odd integers are not.
When you add two integers you can infer whether the result will be even or odd based on whether the summands were even or odd:
Even + Even = Even
Even + Odd = Odd
Odd + Even = Odd
Odd + Odd = Even
Likewise, when... | stackexchange_codegolf |
Ultrafactorials
The ultrafactorials are a sequence of numbers which can be generated using the following function:
$$a(n) = n! ^ {n!}$$
The resulting values rise extremely quickly.
Side note: This is entry A046882 in the OEIS. Also related are the hyperfactorials, a still quite huge, but a bit smaller sequence: A002109... | stackexchange_codegolf |
For the purpose of this question a meandering curve is one that follows the general direction from left to right, but makes repeatedly n+1 turns at 90 degrees to the left and then n+1 turns to the right (for n>0).
In fact the meander itself will have n segments.
The turns are denoted with +.
The width of the meanders (... | stackexchange_codegolf |
Thanks to MD XF's recent challenge, we can now read passwords in many different languages! The problem is, now we need to port our applications to mobile devices, and they do password entry a little differently.
Challenge
Read a string from the keyboard.
Each time a characterk is entered, display it for a short time i... | stackexchange_codegolf |
Originally posted (and deleted) by @Tlink, which was most likely inspired from this StackOverflow question.
Since it was a shame it got deleted, because it seemed like a good challenge in general, I figured I'd repost it with proper formatting and rules. (I've tried contacting @Tlink and get his/her permission to post ... | stackexchange_codegolf |
Year of 2010, an Icelandic Vulcano, concisely named Eyjafjallajökull erupted, resulting in my long-planned flight being canceled.
In case this ever happens again, I would really like to know in advance, so please help me build a simple visual alert system !
Input
Take the Icelandic Meteorological Office volcanic activ... | stackexchange_codegolf |
Pancake sorting is the colloquial term for the mathematical problem of
sorting a disordered stack of pancakes in order of size when a spatula
can be inserted at any point in the stack and used to flip all
pancakes above it. A pancake number P(n) is the minimum number of
flips required for n pancakes. 1
In 1979, a you... | stackexchange_codegolf |
Given a list of positive integers such as [69, 420], your challenge is to generate the sequence of numbers that can be formed by concatenating numbers from the above set, in ascending numerical order.
For example, with [69, 420] the sequence begins:
69
420
6969
42069
69420
420420
Note that elements of the sequence sho... | stackexchange_codegolf |
SPECIFICATION
Given m variables, create every combination up to order n. For example,
The output of mapping two variables (a and b) to order 1 would be:
a
b
a b
The output of mapping two variables (a and b) to order 2 would be:
a
a2
b
b2
a b
a2 b
a b2
a2 b2
The output of mapping two variables (a and b) to order 3 ... | stackexchange_codegolf |
The task in this challenge is to put elements of an array into time bins. The input will be a non-decreasing array of positive integers representing the time of events, and an integer which represents the size of each bin. Let us start with an example. We call the input array A and the output array O.
`A = [1,1,1,2,7,... | stackexchange_codegolf |
What are some tips for golfing in Turing Machine But Way Worse, a language made by MilkyWay90 and ASCII-only?
Tips should be Turing Machine But Way Worse-specific and not be trivial (For examples that you shouldn't post, removing unnecessary whitespace or using shorter state names).
EDIT: Added documentation to TMBWW
| stackexchange_codegolf |
Given a list of positive integers, partition the list into two sublists such that the absolute value of the difference of the sums over the two sublists is minimal.
The output of the program should be the (non-negative) difference of these sums.
Examples:
[1,2,3] -> 0 # [1,2], [3]
[2,3,5,7,11] -> 0 # [2,5,7], ... | stackexchange_codegolf |
(This is not a duplicate of Follow the path, as this challenge have invalid path detection and use ><^v in the output.)
Task
So your task is to take in the description of the path and draw it out in a "Befunge(or a lot of other 2D esolangs)-like" format, and detect if it is invalid. Note that if the path is invalid, yo... | stackexchange_codegolf |
You're at integer coordinates \$(x,y)\$ facing one of North, South, East, or West. Your goal is to walk home to \$(0,0)\$. At each step, you may do one of:
Walk one step in the current facing direction, that is to whichever of \$(x+1,y)\$, \$(x-1,y)\$, \$(x,y-1)\$, or \$(x,y+1)\$ you're facing.
Rotate 90 degrees left,... | stackexchange_codegolf |
There is a rectangular 2D array containing viruses denoted by 'v', antidote1 denoted by 'a', and antidote2 denoted by 'b' (there are no values other than 'v', 'a' and 'b').
Antidote1 can kill neighboring viruses in horizontal and vertical directions only, but antidote2 can kill neighboring(if any) viruses in horizontal... | stackexchange_codegolf |
Jelly has compressed string literals, using the “...» delimiters. The way these work is by interpreting the ... as a base-250 integer, \$n\$, then repeatedly divmod-ing this integer until it reaches \$0 \newcommand{\d}[2]{ \left( \left\lfloor \frac {#1} {#2} \right\rfloor, #1 \text{ mod } #2 \right) }\$, building up th... | stackexchange_codegolf |
You sit at home, rubbing your hands in a most evil fashion. This time, I'll be able to set the community A-SPIN! I'll merely claim that I have proven this problem (which is of no doubt improvable) inside this book here… You open to the first relevant page. You scrawl those words…
You are, of course, the evil Fermat! Ha... | stackexchange_codegolf |
The powers that be want to be able to quickly convert any number they have into their own number base using any format they would like.
Input
Your program must accept 3 parameters.
Number: The string number to be converted
InputFormat: the base string the number is currently in
OutputFormat: the base string that the ... | stackexchange_codegolf |
Introduction: Deep Thought calculated The answer to life the universe and everything in a period of 7.5 million years, the solution was 42.
Write a program in any programming language that takes approx 75 seconds to calculate, starting from whatever you want, and output the number 42.
N.B. The number 42 must be calcula... | stackexchange_codegolf |
Task is pretty simple. Your program should take a number N from 1 to 20 and draw the following ASCII art.
When N=1:
_____
| | |
| | |
| | |
| | |
| | |
| | |
| | |
|_|_|
\ /
\-/
v
When N=2:
_______
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| ... | stackexchange_codegolf |
A set is sum-free if no two (not necessarily distinct) elements when added together are part of the set itself.
For example, {1, 5, 7} is sum-free, because all members are odd, and two odd numbers when added together are always even. On the other hand, {2, 4, 9, 13} is not sum-free, as either 2 + 2 = 4 or 4 + 9 = 13 ad... | stackexchange_codegolf |
This is the robbers' post. The cops' is here.
Your challenge is to take a cop's post and find an input that the regex matches but the program returns a falsey value.
Once you have cracked a cop's post, comment in a link to your crack. (If you don't have enough rep to comment, please say so, and someone will do it for y... | stackexchange_codegolf |
This challenge has been divided into parts.
Your goal is to convert a sentence into a form of 'short-hand'
For Part 1 these are the rules
Take in 1 word
Remove all vowels(a,e,i,o,u), except the ones at the beginning and the end
If a letter is repeated more than once consecutively, reduce it to only one (e.g. Hello -> ... | stackexchange_codegolf |
This is kept fairly original:
Write a program that creates a standard blackjack game:
input "h" means hit or draw another card
input "s" means stand, or take what you have already
Rules:
cards values are as follows:
2-9 = face value of card
10, J, Q, K = 10
aces = 11 unless player busts, then it's only a 1
if 2 or m... | stackexchange_codegolf |
Create A "Hello, World!" program but without any vowels. Winner is the program with the least bytes.
Rules:
No vowels are allowed in the code.
Must print to STDOUT
Must be a full program.
Submissions are measured in Bytes
Any language goes as long as there aren't any vowels
Edit:
Y is only a vowel if there aren't any... | stackexchange_codegolf |
SPECIFICATION
Given m variables, create every combination up to order n. For example,
The output of mapping two variables (a and b) to order 1 would be:
a
b
a b
The output of mapping two variables (a and b) to order 2 would be:
a
a2
b
b2
a b
a2 b
a b2
a2 b2
The output of mapping two variables (a and b) to order 3 ... | stackexchange_codegolf |
"Set" is a card game played with a deck of 81 cards, twelve of which are pictured below:
Each card has four attributes, each of which may assume three values:
Number: the number of symbols, either 1, 2, or 3
Shape: the shape of the symbol, either squiggle, diamond or oval
Colour: either purple, red or green
Shading: ... | stackexchange_codegolf |
Cyclic Polyglot Challenge
This is the cops thread. You can find the robbers thread here.
Cyclic Polyglot
A N-element cyclic polyglot is a complete program that can be run in N different languages. In each language, when the program is run with no input (possibly subject to this exception), it should print the name of a... | stackexchange_codegolf |
Imagine you have two boxes B(x) and B(y), each containing an unknown bit - 0 or 1, and a machine F that can X-ray them and produce a third box for B(x^y) (xor). F can also compute B(x*y) (and). In fact, those are just special cases of the the single operation the machine can perform - inner product each, denoted with F... | stackexchange_codegolf |
Inspiration:
Heavily inspired by Smallest chess board compression I decided to make a similar but distinctly different competition.
tl;dr
Take the file Chess_Games.txt and compress it as much as you can so that you can expand it to the original file.
Objective:
Write an algorithm to encode and decode an entire chess da... | stackexchange_codegolf |
A stem and leaf plot displays a bunch of numerical values in groups, which are determined by all but the last digit. For example, suppose we have this set of data:
0, 2, 12, 13, 13, 15, 16, 20, 29, 43, 49, 101
We could produce this stem and leaf plot:
0|02
1|23356
2|09
3|
4|39
5|
6|
7|
8|
9|
10|1
The first row's stem... | 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 |
This challenge is inspired by a talk about Schläfli symbols, etc that I gave in a Geometry seminar. While I was putting together this challenge, I saw that Donald Knuth himself was interested in (some subset of) this problem. In October 2016, he commented on a related OEIS sequence:
If [the OEIS author] is wrong about... | stackexchange_codegolf |
Connecting Dots
We define a type of question on the test, connecting the dots
Question parameters
There are two parameters. Suppose they are 5 and 4. The second one must be less than or equal to the first one.
Thus, the question will look like this:
*
*
*
*
*
*
*
*
*
Possible answer... | stackexchange_codegolf |
The results are in, the contest is over.
The winner is arshajii's EvilBot with 14 wins ahead of Neo-Bot with 13 wins and CentreBot and LastStand with 11 wins each.
Scores from the final run
Results:
java Rifter: 9 match wins (45 total bout wins)
java EvadeBot: 10 match wins (44 total bo... | stackexchange_codegolf |
Part of Advent of Code Golf 2021 event. See the linked meta post for details.
Related to AoC2020 Day 3.
On the way to vacation, you're traveling through a forest on an airplane. For some biological and geological reasons, the trees in this forest grow only at the exact integer coordinates on a grid, and the entire for... | stackexchange_codegolf |
Given a string consisting of only upper and lower case letters, output an if it begins with a vowel, and a if not. For the purposes of this challenge, we'll ignore normal grammar rules, and use a very basic rule instead: if the input begins with a vowel (any of AEIOUaeiou), then output an. Otherwise, output a.
Your pro... | stackexchange_codegolf |
The following problem is a common interview question, thus dull answers are discouraged. Go short or creative, best if both:
Create the following pattern
###########
## ##
# # # #
# # # #
# # # #
# # #
# # # #
# # # #
# # # #
## ##
###########
In case you cry "dupe",
I see y... | stackexchange_codegolf |
Task
You are playing Hangman, and your opponent uses a simple but effective strategy: Each turn, from the remaining letters, they guess the letter that appears most frequently across all possible words. When multiple letters appear with the same maximum frequency, your opponent selects randomly among them.
That is, yo... | stackexchange_codegolf |
Spirals are cool , so are numbers, and number spirals are even cooler. But what if I want a specific number, in a specific place using xy coordinates...
Challenge
Using an infinite spiral moving down first, curling in a counterclockwise manner
ex:
6 5 4
7 0 3
8 1 2
9 10 11
Take negative and positive inputs(... | stackexchange_codegolf |
The gravitational binding energy of a planet is the amount of energy required to separate every tiny piece of it so that no piece will orbit or collide with another piece. For a uniform sphere, Wikipedia gives this formula:
$$E = \frac{3GM^2}{5R}$$
Where G is the gravitational constant (6.672e-11 m3•kg-1•s-2), M is mas... | stackexchange_codegolf |
Introduction and Credit
We all know and love our awesome rules to test whether a number is divisble by 11 or 3, which is just some clever sum over the digits of the number. Now this challenge takes this to a new level, by requiring you to compute the sum of the digits and then checking whether the result is a perfect i... | stackexchange_codegolf |
Challenge:
Given an ASCII art of a (possibly leaky) bowl consisting of a random distinct non-whitespace and non-~ character, fill it completely with ~ characters. If the bowl is leaky, fill the bottom row below the bowl and a stream of liquid emerging from that, with the intended amount of ~ if the bowl would not have ... | stackexchange_codegolf |
This is the robbers' challenge. To post a cop, go here.
In this challenge, cops will invent a (likely simple) programming language, and write an interpreter, transpiler, or compiler that allows you to run it. Robbers will write a program in this language that manages to inject arbitrary code into the interpreter, trans... | stackexchange_codegolf |
Input a datetime, format the datetime in YYYY-MM-DD HH:mm:ss format using 30-hour clock time.
The 30-hour clock time works as:
After 6 a.m., it is same as 24-hour clock time
Before 6 a.m., it use date for previous day, and plus Hours by 24.
For more examples, you may checkout the testcases.
Rules
To simplify the que... | stackexchange_codegolf |
For the purpose of this question a meandering curve is one that follows the general direction from left to right, but makes repeatedly n+1 turns at 90 degrees to the left and then n+1 turns to the right (for n>0).
In fact the meander itself will have n segments.
The turns are denoted with +.
The width of the meanders (... | stackexchange_codegolf |
Challenge
Premise
Bob lost1 Alice's precious grand piano. Big mistake. Alice has now stolen Bob's low-orbit ion cannon.
Alice refuses to just make up with Bob, so let's help her give him a light tap on the roof. Suppose that from the top Bob's house looks like a lattice polygon, where all points have integer coordinate... | stackexchange_codegolf |
Task
Given an array of non-negative integers a, determine the minimum number of rightward jumps required to jump "outside" the array, starting at position 0, or return zero/null if it is not possible to do so.
A jump from index i is defined to be an increase in array index by at most a[i].
A jump outside is a jump wher... | stackexchange_codegolf |
Given an image, either as input (possibly in RGB triplets) or with the filename as input (you may assume the image has a specific filename, possibly without an extension), output an image representing a single color channel of the image.
You will also take another input, representing which channel to output. The input ... | stackexchange_codegolf |
This is the companion question to Jumblers vs Rebuilders: Coding with Tetris Bricks where Rebuilders can post their solutions.
As argued in Where should we put robbers? it allows more formatting freedom for robbers and lets them gain rep.
Only answer this question if you have cracked a yet uncracked answer to Jumblers ... | stackexchange_codegolf |
I would like to convert ASCII art to something that takes less bytes. I have string like this:
my $string = ' ██ ████ █';
And I would convert this to something like this:
print "█" x 1."█" x 1."█" x 1"█" x 1"█" x 1;
So I would write this in one line and convert to using x operator. How can achieve ... | stackexchange_codegolf |
Given an integer, output an upside-down tent.
The input determines both the size of the tent (absolute value) and whether the entrance is on the left side (negative numbers) or the right side (positive numbers).
If input = -1:
____
\/_/
If input = -2:
________
\ / /
\/___/
If input = -3:
____________
\ / /... | stackexchange_codegolf |
Today's challenge is to draw a binary tree as beautiful ascii-art like this example:
/\
/ \
/ \
/ \
/ \
/ \
... | stackexchange_codegolf |
Problem source: https://oj.vnoi.info/problem/backtrack_j
We have these two shapes:
#.
##
and
.#
##
Let's call the first shape the L and the second shape the flipped L.
On a 4x4 board, there are 16 cells. Each cell can be either free or occupied. In all the illustrations, # represents an occupied cell and . represents... | stackexchange_codegolf |
Take a list of 2-digit hexadecimal numbers as input, and output the binary value, replacing each 1 with an 'X', and each 0 with a space.
For example
Input = FF, 81, 47, 99.
FF = 11111111 in binary, so print XXXXXXXX
81 = 10000001 in binary, so print X X
47 = 01000111 in binary, so print X XXX
99 = 10011001 in ... | stackexchange_codegolf |
Prompt:
You are given two sets of XY coordinates along with two angles (all are floats): X1 Y1 A1 X2 Y2 A2. The angles are relative to world coordinates: 0 being straight up or north and going clockwise.
Your program or function has to return a set of two floats of the XY coordinates the two angles cross at.
Example:
... | stackexchange_codegolf |
Definition: a prime power is a natural number that can be expressed in the form pn where p is a prime and n is a natural number.
Task: Given a prime power pn > 1, return the prime p.
Testcases:
input output
9 3
16 2
343 7
2687 2687
59049 3
Scoring: This is code-golf. Shortest answer in bytes wins.
| stackexchange_codegolf |
Based on Chunky vs. Smooth Strings.
Squiggles /\_/\/\__/\/\/\/\_/\_/\ are fun to make on a keyboard when you are really bored. But not all squiggles are created equal. Some squiggles are smooth, like \___/, and some are chunky, like /\/\/\/\. Others are just downright broken, like ////_\\\
Inside every squiggle of N... | 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 |
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 |
Introduction:
Beckett Grading Service (aka BGS), is a company which encapusulates and grades Trading Card Game (TCG) cards (i.e. sport cards, Magic The Gathering, Pokémon, Yu-Gi-Oh, etc. etc.). The TCG cards that come in for grading will be checked on four categories (which we will later refer to as subgrades): centeri... | stackexchange_codegolf |
Martin Ender's 2D programming language Alice has two different modes depending on what orientation the IP has: orthogonal (Cardinal mode) or diagonal (Ordinal mode). Commands in Alice change their meaning depending on which mode the program is in when they're executed. One especially interesting implementation of this ... | stackexchange_codegolf |
Background
Slowsort is an in-place, stable sorting algorithm that has worse-than-polynomial time complexity. The pseudocode for Slowsort looks like this:
procedure slowsort(A[], i, j) // Sort array range A[i ... j] in-place.
if i ≥ j then
return
m := floor( (i+j)/2 )
slowsort(A, i, m) ... | stackexchange_codegolf |
An IDE developer has hired you to write a program that generates (by printing to stdout) n lines of randomly generated code. They will use your program to create sample code for use in marketing their newest compiler.
Rules:
Your randomly generated output code:
must not be the same each execution (for the same n param... | stackexchange_codegolf |
Introduction
Suppose we have a network of railroads.
Each junction in the network is controlled by a switch, which determines whether an incoming train turns left or right.
The switches are configured so that each time a train passes, the switch changes direction: if it was pointing left, it now points right, and vice ... | stackexchange_codegolf |
Introduction
Often, people refer to dates as the "second Friday in August, 2018" or the "fourth Sunday in March, 2012". But it's hard to tell what date that is! Your task to is to write a program that receives a year, a month, a day of the week, and an integer, and output that date.
Challenge
For input, you will get a... | stackexchange_codegolf |
You get a string which contains an integer between 1000 and 99999999 as input. The input string might contain leading zeroes but cannot be longer than 8 characters.
Your goal is to output all dates between 6th of December 1919 and 5th of December 2019 which fit the input in these formats:
day - month - year (dmy)
mont... | 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 |
Explanation
In this task you'll be given a set of N points (x1,y1),…,(xN,yN) with distinct xi values and your task is to interpolate a polynomial through these points. If you know what Lagrange interpolation is you can skip this section.
The goal of a polynomial interpolation is to construct the (unique) polynomial p(x... | stackexchange_codegolf |
Plot contrivance
You wake up to find that something has gone horribly wrong! Your time machine has malfunctioned and you are lost sometime between June 2022 and October 1991.
You check the computer that you keep on the desk to see what time it is, but alas the positron interference from your quantum undetangler has fr... | stackexchange_codegolf |
Find the maximum possible number of disjoint sets of characters, that are Turing complete subsets of your language.
Rules:
You can assume your Turing complete subset is contained in/called from a main-function if that is required by your language
The subsets must not share any characters (in the native encoding of th... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.