instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
I was walking through a pumpkin patch the other day for a birthday party, and noticed the pumpkin vines making a nifty pattern, with whirls, loops, and offshoots. We're going to simulate that here with some ASCII art.
(())
\
p--q p-----q
/ \ / \
(()) b--d (())
Vine ... | stackexchange_codegolf |
The challenge is to, given a list of points, sort in a way that, when they are connected in this order, they never intersect.
Input format (read from stdin):
X Y
1 2
3 4
5 6
...
Output should be the same as input, but sorted.
Rules:
You can start from any point.
The last point must be same as first one, making a clos... | stackexchange_codegolf |
Challenge
You are given an ASCII-art representation of characters on a plane as input by any reasonable method. This will only contain:
[a-z] representing moveable characters. Every letter will appear on the board at most once.
# representing immovable walls
. representing empty space
For example:
abcdef.gh#..
......... | stackexchange_codegolf |
The challenge here is simple, and not at all about byte-count. Your job is to output the first 50 characters of the previous quine's source code, concatenated with the first 50 characters of yours starting with the 50 characters I've placed below:
abcdefghijklmnopqrstuvwxyzACDEFGHIJKLMNOPQRSTUVWXY
So, lets take an exa... | stackexchange_codegolf |
Goal
Your task is to create a program taking no input that returns the link to your answer. You can find a link to your answer by clicking at the share button on your answer.
Rules
Standard loopholes apply except for searching for the answer online. In fact, you are expected to find the answer online.
You are allowed ... | stackexchange_codegolf |
Challenge
Given a string of any length which contains only digits from 0 to 9, replace each consecutive run of the digit 0 with its length.
Test Cases
1234500362000440 → 1234523623441
123450036200044 → 123452362344
000000000000 → 12
0123456789 → 1123456789
1234567890 → 1234567891
123456789 → 123456789
010203004050 → 1... | stackexchange_codegolf |
Gomoku or Five in a row is a board game played by two players on a \$15 \times 15\$ grid with black and white stones. Whoever is able to place \$5\$ stones in a row (horizontal, vertical or diagonal) wins the game.
Rules
In this KoTH we'll play the Swap2 rule, meaning that a game consists of two phases: In the initial ... | stackexchange_codegolf |
Background Information
Inspired by this answer on Arqade SE
Minecraft has rails which allow you to move minecarts around on them for transporting players, entities, and items. There are many types of rails, but today we're only interested in regular rails, which are also the only type that can curve.
When you place dow... | stackexchange_codegolf |
This is a rock paper scissors competition. Algorithms will face each other in 100 rounds of rock paper scissors. Except that the algorithms will also be able to read the source code of each other!
Leaderboard
1. Chaos Bot (by Aiden4) - 27 Points, 168 bytes
2. Anti-99%-of-posts (by Lyxal) - 24 Points, 489 bytes
3. Psued... | 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 |
Given a nonnegative integer \$n\$, determine whether \$n\$ can be expressed as the sum of two square numbers, that is \$\exists a,b\in\mathbb Z\$ such that \$n=a^2+b^2\$.
0 -> truthy
1 -> truthy
2 -> truthy
3 -> falsy
4 -> truthy
5 -> truthy
6 -> falsy
7 -> falsy
11 -> falsy
9997 -> truthy
999... | stackexchange_codegolf |
It is well known that a person on a grid under the influence of alcohol has an equal chance of going in any available directions. However, this common-sense statement does not hold in the realm of very small drunkards, whose behavior is very much as if they take every available path at once, and the possible paths they... | stackexchange_codegolf |
In this challenge, you are given two overlapping rectangles, and you need to calculate the rectangles created by removing one from the other.
For example, if you remove the red rectangle from the black one:
You end up with one of the following two rectangle sets:
You'll also need to handle the following:
To be more... | stackexchange_codegolf |
A string is squarefree if it contains no substring twice in a row.
It is possible to have an arbitrarily long squarefree word using a 3-letter alphabet.
Write a program which accepts a positive integer n from stdin and prints any squarefree word of length n, using characters A, B and C.
Shortest code wins.
| stackexchange_codegolf |
I've been doing quite a few code golf recently and I realised that a lot of times, I have to do something involving list.
Most of the times lists are space-separated or comma-separated values in the first argument (argv[2]), and the return value should also be a space/comma-separated string.
Are there any tips for conv... | stackexchange_codegolf |
Anyone here a die-hard Bethesda fan? Maybe you prefer Obsidian Entertainment? Well, if you're either of those things than the following picture should be relatively familiar to you.
I've taken the liberty of preparing a rather unique ASCII-Art challenge, so here's the first clue as to what I'm going to have you do:
... | stackexchange_codegolf |
Greeklish, a portmanteau of the words Greek and English, is a way of writing modern Greek using only ASCII characters. This informal way of writing was extensively used in older applications / web forums that did not support Unicode, and were not programmed to show Greek characters. Nowadays, its use is minimized due t... | stackexchange_codegolf |
Input
Your input is a single string, separated by newlines into 2n+1 lines of length 2n+1, for some integer n ≥ 0. The integer n is not part of the input; you'll have to compute it from the string. The lines are composed of the "direction characters" >^<v. If newlines pose a problem, you can replace them by vertical pi... | stackexchange_codegolf |
You are the first engineer in a hot new startup, Lexographical. Our company is making waves by digitizing and indexing all words, real or not. The core of our product... Our secret sauce... Well, that's why we hired you :)
Because we're bleeding edge, we're enforcing the latest standards. Even the latest ones aren't go... | stackexchange_codegolf |
Background
With the success of Simple Boolean Algebra Calculator, I present a more difficult problem.
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... | stackexchange_codegolf |
In this challenge you will be simulating a frog jumping from lily-pad to lily-pad in a pond. A frog's jump distance is uniquely determined by the size of the lily pad it jumps from. So for example there are lily-pads that let a frog jump 1 unit, lily-pads that let a frog jump 2 units etc. A frog can never jump more ... | stackexchange_codegolf |
Input:
Integer n which is >=0 or >=1 (f(0) is optional)
Output:
The n'th number in the sequence below, OR the sequence up to and including the n'th number.
Sequence:
(0),1,-1,-3,0,5,-1,-7,0,9,-1,-11,0,13,-1,-15,0,17,-1,-19,0,21,-1,-23,0,25,-1,-27,0,29,-1,-31,0,33,-1,-35,0,37,-1,-39,0,41,-1,-43,0,45,-1,-47,0,49,-1,-51,0... | stackexchange_codegolf |
Part of Advent of Code Golf 2021 event. See the linked meta post for details.
Related to AoC2020 Day 20, Part 1. (This day is a dreaded one for many of you, I know :P)
Obligatory final "but you're not Bubbler" explanation.
As the train carries you to the destination, you've got some spare time. You open the travel boo... | stackexchange_codegolf |
Congratulations!
You have just been hired by a Fortune 499 company specializing in oil drilling.
Your job is to write a program to determine the optimum placement of OilRUs' drill (represented by a single alphabetical character of your choice, I use a capital "O" in the examples), given a length of piping, and a two-di... | 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 |
If you've ever learned about primes in math class, you've probably have had to, at one point, determine if a number is prime. You've probably messed up while you were still learning them, for example, mistaking 39 for a prime. Well, not to worry, as 39 is a semiprime, i.e., that it is the product of two primes.
Similar... | stackexchange_codegolf |
Given no input, output this interesting alphabet pattern in either case (the case has to be consistent) via an accepted output method:
A
AB
ACBC
ADBDCD
AEBECEDE
AFBFCFDFEF
AGBGCGDGEGFG
AHBHCHDHEHFHGH
AIBICIDIEIFIGIHI
AJBJCJDJEJFJGJHJIJ
AKBKCKDKEKFKGKHKIKJK
ALBLCLDLELFLGLHLILJLKL
AMBMCMDMEMFMGMHMIMJMKMLM
ANBNCNDNENFNGN... | stackexchange_codegolf |
Haplology
Haplology is a linguistic term:
the omission of one occurrence of a sound or syllable that is repeated within a word, for example probly for probably.
For this challenge, it means specifically, replacing any sequences of two or more letters that are repeated two or more times with just one copy.
For example... | stackexchange_codegolf |
Task
Given positive integer n, output a(n) where a is the sequence defined below:
a(n) is the smallest positive integer not yet appeared so that the sum of the first n elements in the sequence is divisible by n.
Example
a(1) is 1 because it is the smallest positive integer that has not appeared in the sequence, and 1 ... | stackexchange_codegolf |
We define \$a(n)\$ as the 1-indexed position of \$n\$ in the sequence of positive integers with the same binary weight, i.e. the same number of 1's in their binary representation. This is A263017.
Given a positive integer \$n\$, your task is to determine how many positive integers \$k\$ satisfy:
$$k-a(k)=n$$
For instan... | stackexchange_codegolf |
A repost of this challenge. Meta discussion. Sandbox post. Body of the question similar to the original
Robber's challenge
This cops and robbers is now (08/03/2018) closed to further competing cop entries, as robbers may no longer be competing to crack answers, but feel free to post new answers.
The Cops challenge was... | stackexchange_codegolf |
Given two non-negative integers e.g. 27, 96 their multiplication expression would be 27 x 96 = 2592.
If now each digits is replaced with a symbol, such that
two digits are replaced with the same symbol if and only if they are equal
we could get something like AB x CD = AECA or 0Q x 17 = 0Z10 or !> x @^ = !x@!.
(follo... | stackexchange_codegolf |
Introduction
In Android Studio and other IDEs there are code completions to assist efficient code insertion (especially when the names of the classes or methods are so verbose), like the one in the image below.
There are slightly different logics used between IDEs to determine what classes, methods and variables to su... | stackexchange_codegolf |
What general tips do you have for golfing in Clean? Please post only ideas that can be applied to code golf problems in general, and are at least somewhat specific to Clean.
If you've never heard of Clean, you can find out more here.
Or, you can join the chat room.
| stackexchange_codegolf |
I have made a short script that will pull dns txt records down from a server and combine them into a single string.
DNS txt records are:
1.website.com
2.website.com
3.website.com
Each of these are iterated through using the single digit number.
The double quotes at the beginning and the end of the strings are trimmed
T... | stackexchange_codegolf |
Given a string of digits or an integer as input, you will have to indexize it.
This is how you modify the input. We will use 30043376111 as an example:
First, find the sum of the indices of each occurrence of the respective digits:
0: 1 + 2 = 3
1: 8 + 9 + 10 = 27
3: 0 + 4 + 5 = 9
4: 3
6: 7
7: 6
Then, construct a new... | stackexchange_codegolf |
Dart is an object oriented programming language borrowing from both Java and Javascript. What general tips do you have for golfing in Dart? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Dart (e.g. "remove comments" is not an answer). Please post one ti... | stackexchange_codegolf |
A zip bomb is a compressed file, designed so that unpacking it yields the biggest file possible. These are fairly well known, and there are examples of 42 KB files which expand into multiple petabytes of data.
In this challenge, the goal is reversed. Instead of providing a compressed file which is then unpacked, the go... | stackexchange_codegolf |
Given a map from arrays of integers of same size to single integers, determine if there is a set of indices such that the output is equal to the maximum of the elements at those indices for every corresponding pair.
You can take the input as a map if your language support, arrays of pairs, separated 2D array of input a... | stackexchange_codegolf |
(No, not this nor any of these)
Given a string and a list of strings, fill in the all blanks in the input string with corresponding strings.
Input/Output
The input string contains only alphabetic characters, spaces, and underscores. It is nonempty and does not start with an underscore. In other words, the input string ... | stackexchange_codegolf |
Background
We already have a challenge about throwing SIGSEGV, so why not a challenge about throwing SIGILL?
What is SIGILL?
SIGILL is the signal for an illegal instruction at the processor, which happens very rarely. The default action after receiving SIGILL is terminating the program and writing a core dump. The sign... | stackexchange_codegolf |
Ken Iverson, 1920–2020
Let's implement his favourite expression:
Given a row of Pascal's triangle, compute the next row.
This can for example be computed by taking the input padded with a zero on the left, and the input padded with a zero on the right, and then adding the two element-by-element.
Test cases... | stackexchange_codegolf |
The Golden Ratio Bureau is obsessed with this new thing they call base-phi. You see it and decide to code-golf, as is your natural instinct.
To be specific, base-phi is a number system like base 10, except it uses the number phi, or the golden ratio, as its base. A ones digit would be x*10^y, but in base phi 10 is repl... | stackexchange_codegolf |
Inspired by this video by Matt Parker
The distances between the letter keys of a QWERTY keyboard are somewhat standardised. The keys are square and both the horizontal and vertical spacing are 19.05mm (so if there were no gaps between the keys, their side lengths would be 19.05mm), and the three rows of keys are offset... | stackexchange_codegolf |
Background
Sometimes, people think you didn't work at your git project. But - you can prove yourself with git shortlog -n. Now, the problem is you are a programmer and programmers are lazy. So you want to write a program which shows the person who committed at most.
Rules
You may not do the following things:
use git s... | stackexchange_codegolf |
Background
You have again, again been given the task of calculating the number of landmines in a field. But this time, the field is foggy.
You must calculate the landmine score given a list/string of numbers, the landmine number, and the land distance (all are numbers).
The landmine number tells you where landmines are... | stackexchange_codegolf |
Final results available
Introduction
After my previous KOTH with heavy themes (fantasy war, worldwide pandemic...), I'm back with a new lighthearted game. This time, you are facing off in a "board game-like" situation. A pile of upside down coins is placed at the center of a really big table, and you are determined to ... | stackexchange_codegolf |
Write an infinite list of triangle codes, defined as code where the i-th line has i bytes for all lines, such that the i-th code generates (i-1)th code and has 1 more line than the (i-1)th code.
The score is the number of lines in the initial code. Lowest score wins.
For example, if
.
..
...
....
is outputted by
.
..
... | stackexchange_codegolf |
For all you American folk out there, remove the "s" in "maths".
Ugh, my maths teacher gave me so much algebra to do. There's just lines and lines of meaningless junk like Expand (x+1)(x+6) and Factorise x^2+2x+1.
My hands are literally dying from the inside.
So I figured out a way to hack the system - why not write a p... | stackexchange_codegolf |
This is Pascal's Braid:
1 4 15 56 209 780 2911 10864 40545 151316 564719
1 3 11 41 153 571 2131 7953 29681 110771 413403 1542841
1 4 15 56 209 780 2911 10864 40545 151316 564719
I totally made that up. Blaise Pascal didn't have a braid as... | stackexchange_codegolf |
Write the shortest program that waits for every key of a Standard 101 key US Keyboard* to be pressed and then exits writing OK!
Every time a key is pressed the program displays on a new line the remaining number of unpressed unique keys that need to be pressed until all key are pressed at least once. The program should... | 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 |
Background
Famously, the acronym GNU stands for GNU's Not Unix. 1
It's recursive because, after expanding it once, it still contains the acronym GNU, and so must be exanded again:
(GNU's Not Unix)'s Not Unix
And so on, ad infinitum. Visualizing this, we get a kind of Droste effect:
┌─────────────────────────────────... | stackexchange_codegolf |
The set of all polynomials with integer coefficients is countable.
This means that there is a sequence that contains each polynomial with integer coefficients exactly once.
Your goal is it to write a function or program that outputs such a sequence.
Example (you may use another sequence):
// list of integers [i -> Z(i)... | stackexchange_codegolf |
It's time to conclude the series of John Conway challenges of mine.
Background
A FRACTRAN program consists of an ordered list of fractions. The program starts by taking a single integer as input. Each iteration of the program, it searches the list for the first fraction such that multiplying the number by that fraction... | stackexchange_codegolf |
Task
The task is to write a script that accepts a number from 1 to 20 inclusive. It will then check if the number has a character that is found in every number that was entered before it. If the number has a character in common it will ask for another number. However if the number does not have a character in common wi... | stackexchange_codegolf |
In case you missed Encode Factor Trees, here is the definition of a Factor Tree:
The empty string is 1.
Concatenation represents multiplication.
A number n enclosed in parentheses (or any paired characters) represents the nth prime number, with 2 being the first prime number.
Note that this is done recursively:... | stackexchange_codegolf |
Given two non-negative integers e.g. 27, 96 their multiplication expression would be 27 x 96 = 2592.
If now each digits is replaced with a symbol, such that
two digits are replaced with the same symbol if and only if they are equal
we could get something like AB x CD = AECA or 0Q x 17 = 0Z10 or !> x @^ = !x@!.
(follo... | stackexchange_codegolf |
As of 27/12/20, the challenge is over as no new answers were posted on the 26th. With an astounding 55 points (and 21 answers), the winner is pppery!
A quick shout out to the top 5 scorers as well:
1st. pppery with 55 points across 21 answers
2nd. tsh with 50 points across 21 answers
3rd. SunnyMoon with 21 points acr... | stackexchange_codegolf |
Given a number \$n ≥ 2\$, a blackbox function \$f\$ that takes no arguments and returns a random integer in the range 0...n-1 inclusive, and a number \$m ≥ n\$, your challenge is to generate a random integer in the range 0...m-1 inclusive. You may not use any nondeterministic builtins or behaviour, your only source of ... | stackexchange_codegolf |
In this challenge you are to write a program or function, that takes a string as input and outputs one of two possible values. We will call one of these values truthy and one falsy. They do not need to actually be truthy or falsy. For an answer to be valid it must meet four additional criteria
When you pass your pro... | stackexchange_codegolf |
One of the lesser known programming paradigms which seems rather fitting for code golfing is Overlapping Oriented Programming (OOP) *. When writing partly identical code, many bytes can be saved by simply overlapping the identical parts and remembering in some way where the two original code lines start. Your task is t... | stackexchange_codegolf |
A room can be made up of connected rectangles, for instance an L-shaped room. Such a room can be described by a list of dimensions describing the size of each rectangle.
Assume you have two input lists. The first contains the width of rectangles stacked vertically over each other. The second contains the height of the... | stackexchange_codegolf |
Introduction
In this challenge, you are given a list of nonnegative floating point numbers drawn independently from some probability distribution.
Your task is to infer that distribution from the numbers.
To make the challenge feasible, you only have five distributions to choose from.
U, the uniform distribution on th... | stackexchange_codegolf |
Introduction
In this challenge, we will be dealing with a certain infinite undirected graph, which I call the high divisor graph.
Its nodes are the integers starting from 2.
There is an edge between two nodes a < b if a divides b and a2 ≥ b.
The subgraph formed by the range from 2 to 18 looks like this:
16-8 12 18
\|... | stackexchange_codegolf |
Every phone needs a calculator app. Because of the limited screen real estate, the developer of mine has decided to save some buttons. Instead of having two dedicated bracket buttons - one for open ( and one for close ) - there is just a single bracket button (). It looks something like this:
When the button is presse... | stackexchange_codegolf |
When playing Rock-Paper-Scissors-Lizard-Spock, your robot reflexes let you see your opponent's throw before they make it. You just need to choose a throw that beats theirs, in as few bytes as possible of course.
There's always two winning throws, and either one will work.
Input -> Possible outputs
----------------... | stackexchange_codegolf |
You're driving a car in an infinite city whose blocks are pentagons arranged in the order-4 pentagonal tiling. At each step, you proceed to the next intersection and choose whether to continue left, right, or straight. A sequence of choices that returns you to your initial state (street segment and direction) is called... | stackexchange_codegolf |
The Challenge
Your task is to create a program or function that outputs the following with no input:
a
bb
ccc
dddd
eeeee
ffffff
ggggggg
hhhhhhhh
iiiiiiiii
jjjjjjjjjj
kkkkkkkkkkk
llllllllllll
mmmmmmmmmmmmm
nnnnnnnnnnnnnn
ooooooooooooooo
pppppppppppppppp
qqqqqqqqqqqqqqqqq
rrrrrrrrrrrrrrrrrr
sssssssssssssssssss
tttttttttt... | stackexchange_codegolf |
The Xerox Alto, originally released in 1973, was the first computer to feature the now-familiar angled mouse pointer. The Alto's bitmapped pointer looked like this (redrawn from Fig. 2 here):
Your task in this code-golf challenge is to write a program/function that generates an ASCII art representation of the mouse po... | stackexchange_codegolf |
Yes, I know there is a similar question, but this one specifically concerns any possible words, even with letters left over, while the linked one restricts to a permutation of the input
Objective
Have you ever had those moments in a Scrabble game where you're staring at your letters, trying to find a good word, and y... | stackexchange_codegolf |
Introduction
Street talk can be really difficult to understand, in particular to programmers, who aren't known to be very streetwise.
It is your job to create an interpreter to help us all survive in the urban environment.
Challenge
Given an English sentence as input, create a program or a function that determines whet... | stackexchange_codegolf |
Christmas is coming up, and this year you have been charged with organizing your family's christmas get-together. You have a list of foods you want be there, but before you assign foods to people, you need to know who's coming. So...
Challenge
Given an input of relative's names separated by commas or whatever (note tha... | stackexchange_codegolf |
Interestingly, although there are challenges that work with images, there is no challenge to simply output an image. This is that challenge
Goal: output an image in the shortest possible code.
Output: Any image output is accepted. Files would be preferable, but most any non-character on the screen will function as an i... | stackexchange_codegolf |
Sandbox
Have y'all ever written an answer with unprintable ASCII characters in it and wished that there was an easy way to represent those characters in a printable way? Well, that's why the Control Pictures Unicode block was invented.
However, manually substituting these characters into one's answer is time-consumin... | stackexchange_codegolf |
Your task is to output a single number; the number of ISO weeks that a given date range intersects. To quote Wikipedia: An average year is exactly 52.1775 weeks long, but this is not about the average.
Input consists of two space-separated ISO dates:
0047-12-24 2013-06-01
The end date is never before the start date. W... | stackexchange_codegolf |
The primorial \$p_n\#\$ is the product of the first \$n\$ primes. The sequence begins \$2, 6, 30, 210, 2310\$.
A Fortunate number, \$F_n\$, is the smallest integer \$m > 1\$ such that \$p_n\# + m\$ is prime. For example \$F_7 = 19\$ as:
$$p_7\# = 2\times3\times5\times7\times11\times13\times17 = 510510$$
Adding each num... | stackexchange_codegolf |
Using a language of your choice write a program that takes a string as an input, and returns the string encrypted.
Algorithm:
You should assume that each character is always encoded in a byte and is ASCII-based. The extended ASCII codes are mapped to whatever is the default code page in use by the system.
You should en... | stackexchange_codegolf |
Your task is to create a program where if any one character is deleted, it will detect which character was deleted and then re-insert the deleted character in its own source file.
For instance, if your program is RadiationHardened and it is modified to RadiaionHardened, then your program must output that the 5th byte (... | stackexchange_codegolf |
We're going to turn ascii art versions of polygons into their equivalent GeoJSON.
The ASCII shape language
The input ASCII language only has 3 possible characters:
* signifies a vertex
- signifies a horizontal line
| signifies a vertical line
A * will never be directly adjacent to another * (but may be diagonal to on... | stackexchange_codegolf |
You probably know the game mastermind:
The player tries to guess a code of 4 slots, with 8 possible colors - no duplicates this time.
Let's call those colors A through H, so possible solutions could be ABCD or BCHD.
Each time you place a guess, the game master will respond with two information: how many slots you got r... | stackexchange_codegolf |
A complete deterministic finite automaton is a machine, with some states. Each state in the automaton has, for each character in the alphabet, a pointer to a state (not necessarily a different one). The automaton starts at some state, and then reads a string, character by character. For each character, the automaton mo... | stackexchange_codegolf |
The Challenge
Your task is to create a program that takes any given string input, and outputs the input in a squared format. Empty strings should return an empty string.
Examples
Given the input:
golf
Your program should output:
golf
o l
l o
flog
Input:
123
Output:
123
2 2
321
Input:
a
Output:
a
Input:
Hello, w... | stackexchange_codegolf |
My Precalc teacher has one of his favorite problems that he made up (or more likely stole inspired by xkcd) that involves a row of n urinals. "Checkmate" is a situation in which every urinal is already occupied OR has an occupied urinal next to them. For instance, if a person is an X, then
X-X--X
is considered checkmat... | stackexchange_codegolf |
Imagine a grid where the origin square \$(0,0)\$ is at the top left of the screen, and positive \$x\$ is rightwards whereas positive \$y\$ is downwards. Coloured squares are at various positions on the grid.
In a magical void separate from the grid are multiple snake-like strips of squares, each of a fixed length and a... | stackexchange_codegolf |
For example, given 3 sets of parenthesis, you have:
()()()
((()))
()(())
(())()
(()())
= 5 possible combinations.
Challenge
Program must:
• Take 1 number as an input
• Return one output, the number of possible combinations of parenthesis sets
Shortest number of bytes wins
| stackexchange_codegolf |
Input
The board: A 2D container (matrix, list of lists, etc.) of letters like:
["B", "C", "C", "C", "C", "B", "B", "C", "A", "A"],
["B", "A", "C", "B", "B", "A", "B", "B", "A", "A"],
["B", "C", "B", "C", "A", "A", "A", "B", "C", "B"],
["B", "B", "B", "A", "C", "B", "A", "C", "B", "A"],
["A", "A", "A", "C", "A... | stackexchange_codegolf |
Pick your favorite 6 letter common English word that has no repeated letters, such as wombat.
Write a program in an N×N grid of characters without comments such that each row and column contains all the letters of your word in lowercase in any order. The program must output a definition of your word in 36 characters or... | stackexchange_codegolf |
Task:
There are a lot of answers on this site that are arranged into ascii art, like this one. Usually the arrangement is done manually, but wouldn't a program help with that? :)
Your program will take 3 inputs:
The code, as one single line
The number of lines in the pattern (can be omitted if not necessary)
The pat... | stackexchange_codegolf |
Background
Boggle is a board game where the players have to find English words on a 4-by-4 board of random alphabets. Words can be constructed by selecting sequentially adjacent cells on the board. ("adjacent" means horizontally, vertically or diagonally adjacent.) Also, same cell can't be used more than once in a word... | stackexchange_codegolf |
The Seidel Triangle is a mathematical construction similar to Pascal's Triangle, and is known for it's connection to the Bernoulli numbers.
The first few rows are:
1
1 1
2 2 1
2 4 5 5
16 16 14 10 5
16 32 46 56 61 61
Each row is generated as follows:
If the row number is even (1-indexed):
Bring... | stackexchange_codegolf |
Problem 4 in the 2019 BMO, Round 1 describes the following setup:
There are \$2019\$ penguins waddling towards their favourite restaurant. As
the penguins arrive, they are handed tickets numbered in ascending order
from \$1\$ to \$2019\$, and told to join the queue. The first penguin starts the queue.
For each \... | stackexchange_codegolf |
At runtime, keep prompting for a line of input until the user inputs something (other than an empty newline), i.e. does not just press Enter or OK. Output or result is neither required nor prohibited.
Pseudo-code 1
myform = new form("GUI")
myform.mytxt = new editfield("")
myform.ok = new button("OK")
repeat
waitfor(m... | stackexchange_codegolf |
My user id is 106959
How to check if the number is Fmbalbuena number?
First Step: Check if the number of digits is a multiple of 3: 6 = 3 * 2
Second step: Split the digits into even thirds: 106959 -> 10 69 59
Third step: Subtract the first set of digits from the second modulo 10: 6 - 1 = 5, 9 - 0 = 9
Last step: Check t... | stackexchange_codegolf |
Your Task:
You all know what a magic square is! But what about a magic cube? A magic cube is the 3D version of a magic square, and is a set of numbers in a cube, where the sums of every straight (not diagonal) line are equal. You must write a program or function that receives an integer, and returns the number of va... | stackexchange_codegolf |
In mathematics an exclamation mark ! often means factorial and it comes after the argument.
In programming an exclamation mark ! often means negation and it comes before the argument.
For this challenge we'll only apply these operations to zero and one.
Factorial
0! = 1
1! = 1
Negation
!0 = 1
!1 = 0
Take a string of ... | stackexchange_codegolf |
Another easy challenge for you.
Your task
Write a program or function that takes the input, which contains 3 pairs of x- and y-coordinates and calculates the area of the triangle formed inside them. For those who can't remember how to calculate it, you can find it here.
Example:
1,2,4,2,3,7 # input as x1,y1,x2,y2... | stackexchange_codegolf |
The clustering coefficient of a graph (or network) is a:
measure of degree to which nodes in a graph tend to cluster together
The Wikipedia article gives a much better description of how network average clustering coefficient is calculated from local clustering coefficients than I could give.
The Challenge
Given an a... | stackexchange_codegolf |
In this challenge you and your friends are debating on which case is better, uppercase or lowercase? To find out, you write a program to do this for you.
Because esolangs scare your friends, and verbose code scares you, your code will need to be as short as possible.
Examples
PrOgRaMiNgPuZzLeS & CoDe GoLf
0.52 upperca... | stackexchange_codegolf |
Robbers' Thread
Your challenge is to find an existing challenge, and implement it in a way such that certain inputs fail. At least one input must not produce the correct output (use the other submissions on the challenge as a reference for this, but be sure to double-check). This must fail consistently, and you must kn... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.