instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Given one of the following inputs: Sweet Onion Chicken Teriyaki
Oven Roasted Chicken
Turkey Breast
Italian BMT
Tuna
Black Forest Ham
Meatball Marinara output a number from 1-7 (or 0-6) representing the day of the week that you get that deal, starting with Monday as the lowest number. Input can be all lowercase or uppe... | stackexchange_codegolf |
Related | Related
Given an ASCII art with |, _, and , check if you can draw the art in one stroke.
Description
Your task is, if the ASCII art is representing lines, then check if you can draw the whole art in one stroke, which means:
without drawing an already drawn line again
without lifting and continuing the stro... | stackexchange_codegolf |
The input message consists of ASCII characters
The encoded output message consists of blocks of 0
A block is separated from another block by a space
Two consecutive blocks are used to produce a series of same value bits (only 1s or 0s):
After the ACSII character(s) have been converted to binary, go through the string:
... | stackexchange_codegolf |
Two ambassadors at a UN conference want to speak to each other, but unfortunately each one only speaks one language- and they're not the same language. Fortunately, they have access to several translators, who each understand and speak a few languages. Your task is to determine the shortest chain of translators (since ... | stackexchange_codegolf |
Challenge
Given a left- or right-stochastic matrix where the limit as x approaches infinity of the matrix to the power of x approaches a matrix with all finite values, return the matrix to which the matrix converges. Basically, you want to keep multiplying the matrix by itself until the result no longer changes.
Test C... | stackexchange_codegolf |
Write a program that outputs Hell0 W0rld!. It must match this output exactly, including capitalization, zeroes instead of o's, exactly one space, etc. Trailing new lines are allowed.
Lowest score wins. Scoring is based on the sum of the values of each character in the language's code page - otherwise Unicode values ... | stackexchange_codegolf |
On my website, users enter their date of birth in the style xx.xx.xx - three two-digit numbers separated by dots. Unfortunately, I forgot to tell the users exactly which format to use. All I know is that one section is used for the month, one for the date, and one for the year. The year is definitely in the 20th centur... | stackexchange_codegolf |
tl;dr? See bottom for The Competition
Integer literals
While programming, the 64-bit hexadecimal literal 0x123456789abcdefL is difficult to gauge the size of. I find myself mentally grouping digits from the right by fours to see that it's 15 digits' worth.
Python PEP 515 allows you to express the above literal, insid... | 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 |
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 |
Unsurprisingly, fibonacci primes are primes that are also Fibonacci numbers. There are currently 34 known Fibonacci primes and an additional 15 probable Fibonacci primes. For the purpose of this challenge, the Fibonacci numbers are the sequence \$F_n\$ defined as \$F_1 = 1\$, \$F_2 = 1\$, and \$F_n = F_{n-1} + F_{n-2}\... | stackexchange_codegolf |
Let \$ A \$ represent the alphabet, such that \$ A_1 = \$ a and \$ A_{26} = \$ z.
Let's define that a word \$ W = w_1 w_2 ... w_n \$ (where \$ w_c \in A\$) is in standard order if and only if:
\$ w_1 = A_1 \$, and
for \$ 2 \le i \le n \$, if \$ w_i = A_x \$ then \$ w_j = A_{x-1} \$ for some \$ j < i \$ and some \$x\$.... | stackexchange_codegolf |
Inspired by a challenge from the OUCC 2022 Seniors competition.
Background
Two teams are playing "capture the flag". They take turns invading each other's base and capturing their opposing team's flag in the shortest amount of time. The attacking players each have one soft ball they can throw at the defenders. Teams ge... | stackexchange_codegolf |
Write a program or function that takes in three integers, a width w, a height h, and a step count s. You will be drawing a non-self-intersecting random walk s steps long on a 5*w by 5*h pixel image where every 5 by 5 pixel cell is either empty (pure beige) or one of these twelve simple "pipes":
The image above is enla... | stackexchange_codegolf |
Consider \$3\$ binary strings of length \$n\$ chosen independently and uniformly at random. We are interested in computing the exact expected minimum Hamming distance between any pair. The Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different.... | stackexchange_codegolf |
Part of the Code Golf Advent Calendar 2022 event. See the linked meta post for details.
As a Christmas gift, you were given a toy solar system. In this toy, all the orbits are circular and happen in the same plane. Each planet starts at a fixed location, has a fixed circumference orbit, and moves at a fixed speed (all... | stackexchange_codegolf |
Given a non-flat list of integers, output a list of lists containing the integers in each nesting level, starting with the least-nested level, with the values in their original order in the input list when read left-to-right. If two or more lists are at the same nesting level in the input list, they should be combined ... | stackexchange_codegolf |
Its been a while since you killed that hydra, you basked in the glory for years, but now people are calling you washed up, a has been. Well its time you prove them wrong, you've heard the whereabouts of annother hydra. Simply kill it and you will be awarded all the glory you deserve.
You arrive at the armory to recei... | stackexchange_codegolf |
Write a program that outputs the number 0.
That's a bit trivial, isn't it?
Let the length of your program be \$S\$. Write a program that outputs the number 0. When your program is cyclically shifted \$i < S\$ bytes left, it should output \$i\$. To cyclically shift a string \$i\$ bytes left means to move the last \$i\$ ... | stackexchange_codegolf |
Boustrophedon is a type of bi-directional text where successive lines alternate between reading left-to-right and right-to-left. Character direction was also mirrored with respect to reading direction. In reverse boustrophedon writing systems, characters were rotated 180 instead of mirrored.
Challenge
Write a program/f... | stackexchange_codegolf |
A SMILES (Simplified molecular-input line-entry system) string is a string that represents a chemical structure using ASCII characters. For example, water (\$H_2O\$) can be written in SMILES as H-O-H.
However, for simplicity, the single bonds (-) and hydrogen atoms (H) are frequently omitted. Thus, a molecules with on... | stackexchange_codegolf |
If you visit Code Golf often, you may have heard of Kolmogorov complexity. It's usually defined as the amount of bytes required to express some string in a programming language.
Here the Kolmogorov-complexity of a natural number is defined similarly: the number of bytes required to represent it in a programming languag... | stackexchange_codegolf |
You must write a program that takes an encrypted string and decrypt it according to specific rules and then print it out. Decryption will occur by performing two operations.
Sample Input Argument 1 (the encrypted string)
HGJILKBADCFE
Operation 1:
Swap the first half of the string with the second half, which should lea... | stackexchange_codegolf |
In a 9 by 9 grid some points have been marked. The task is it to
make a program that counts all distinct squares that can be made
using four marked points. Note that squares can also be placed
diagonally (any angle).
Input can be one of the following:
A character string of length 81 containing two distinct characters
... | stackexchange_codegolf |
It is often said, that all programmers should be able to write a "hello world" program in any programming language after a few glances on that language (And quicksort after a few more glances).
As the Conway's Game of Life is Turing complete (so it qualifies as a general-purpose programming language), the problem is se... | stackexchange_codegolf |
My robot has short circuited somehow and randomly run off somewhere from my lab!
Luckily, whenever he does this, his shut-down sequence initiates, giving him enough time to randomly turn and run in the direction its facing for five rounds before he switches off. His gyro and accelerometer functions are still relaying t... | stackexchange_codegolf |
On Unix-like systems, the ls command lists files. GNU's version of ls also colors them according to their properties and the environment variable LS_COLORS. The main file property that ls bases its colors on is the file's mode. In this challenge, you will determine what keys from LS_COLORS ls should look for a given mo... | stackexchange_codegolf |
Input:
A list of integers (which will never contain a zero)
Output:
A list of the same size with counts based on the following:
If the current item is negative: Look at all items before this item, and count how many times the digits occurred in those other numbers
If the current item is positive instead: Look at all i... | stackexchange_codegolf |
These are raindrops:
! | . " :
These are clouds particles:
( ) _ @ $ &
I want you to verify, when given a block of text, whether or not it is raining. It is raining if, for every raindrop, there is a cloud particle somewhere above it. There must be one cloud particle for every raindrop. Output a truthy or falsy value... | stackexchange_codegolf |
RollerCoaster Tycoon 2's maze is the inspiration for this question. Credit to Marcel Vos for thoroughly breaking the classic RCT2 AI. The pathfinding AI in this question is the AI in the latest version of OpenRCT2 at the time of writing, which was updated in response to that video.
Suppose a guest enters a \$w \times... | stackexchange_codegolf |
Given a binary number A as input with d > 1 digits, output a binary number B with d digits according to the following rules for finding the nth digit of B:
The first digit of B is zero if the first and second digits of A are equal; otherwise, it is one.
If 1 < n < d, then if the (n-1)th, nth and (n+1)th digits of A ar... | stackexchange_codegolf |
Given a positive integer N ("virality"), your program should create an ASCII-art drawing of a tree with two branches of length N extending downwards and/or rightwards from the top-left corner.
The direction taken by each branch after the first asterisk can be either rightwards or downwards, and this choice should be ma... | 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 |
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 |
Yesterday, I left my sandwich on the table. When I got up today, there was a bite in it... Was it mine? I can't remember...
Problem:
Take a representation of the sandwich and my bite pattern and tell me if it was my bite or not.
Examples:
Example 1:
My bite pattern:
..
.
Sandwich:
#####
.####
..###
Output:
truthy
Ex... | stackexchange_codegolf |
Introduction
The idea is to use the asterisk character (star) * to display an ascii-art star at a specified dimension. The dimension is an input number greater than or equal to \$1\$ that specifies the height in lines of the upper point of the star. The stars here are intended to be six pointed stars with larger sizes ... | stackexchange_codegolf |
Write a function to convert CamelCased text to snake_case: FunctionForHTMLManipulation becomes function_for_html_manipulation
The input text will be a single suitable identifier in many languages. It must start with an English letter, then be followed by any number of English letters or digits. No other characters (spa... | stackexchange_codegolf |
The challenge is simple: write a program which takes in some non-empty string \$n\$ consisting of only uppercase and lowercase ASCII letters, and outputs the code for a program (in the same language) which takes in no input and outputs \$n\$. However, the code your program generates must not contain \$n\$ as a substrin... | stackexchange_codegolf |
Input a decimal number and round it to an integer, randomly rounding up or down with a probability based on its fractional part, so the expected value of the output equals to the input value.
If input \$x\$ is an integer, the program should output it as is. If \$x\$ is not an integer, the program has a \$x-\left\lfloo... | stackexchange_codegolf |
The cool stuff
The following rosace can help calculate numbers modulo 7.
In order to do that, you must start at 0 and turn clockwise a number of steps given by the first digit. Then, for each successive digit, follow the arrow and then turn clockwise the number of steps given by that digit.
Here is how you proceed for... | stackexchange_codegolf |
Write a program, given an input n, will generate all possible n-tuples using natural numbers.
n=1
(1),(2),(3),(4),(5),(6)...
n=2
(1,1),(1,2),(2,1),(2,2),(1,3),(3,1),(2,3),(3,2),(3,3)...
n=6
(1,1,1,1,1,1) (1,1,1,1,2,1) (1,1,1,2,1,1)...
The output may be in any order that does not break any other rules.
The program... | stackexchange_codegolf |
In the Thai calendar the year 2017 corresponds to 2560. The Thai calendar is always 543 years ahead of the Gregorian calendar.
Observant coders will note that 2560 is equal to \$2^9 \times 5\$, in other words it has 10 prime factors. This will not happen again for another 896 years! We call a year tenacious if it has e... | stackexchange_codegolf |
If you've read the book Contact by Carl Sagan, this challenge may seem
familiar to you.
Given an input of a set of mathematical equations consisting of a number, an
unknown operator, another number, and a result, deduce which operators
represent addition, subtraction, multiplication, or division.
Each input equation w... | stackexchange_codegolf |
I got this challenge from Codingame and am curious about better solutions than mine:
Given a width via standard input draw a hollow square of '#' in given width and length.
Example:
5 results in
#####
# #
# #
# #
#####
I used python to solve this so i am particulary interested in other python code. But please fe... | stackexchange_codegolf |
Programming Puzzles & Code Golf has opened a taco truck! The word is out and now users from all over the Stack Exchange network are coming to try our tasty, authentic ASCII tacos. We need your help to ensure that everyone gets their orders in a timely manner. There isn't a whole lot of room inside food trucks, so you'l... | stackexchange_codegolf |
Related: Music: what's in this chord?, Notes to Tablature, Generating guitar tabs?, Translate number pairs to guitar notes
Given a guitar fingering, output the chord it represents. You can use standard input and output, or write a function that returns a string.
The input fingerings will be classifiable as one of the f... | stackexchange_codegolf |
The Challenge
Given an input string (or array) consisting of < and >, output a sequence (array or string) of integers such that:
the operators are all correct when applied in order between consecutive numbers in the output
all integers are positive (1 or greater)
the sum of the integers is as small as is mathematicall... | stackexchange_codegolf |
The Game
Recently, much of my time has been taken up by an addicting game on my phone, called Logic Dots, which inspired me to write this challenge. It's easier to explain the rules if I show you the game display, so here is a screenshot of an unsolved, and solved puzzle:
Now here, there are three main things to noti... | stackexchange_codegolf |
Overview:
Your challenge is to write a program that will play minesweeper optimally, giving the best move in any position. Moreover, you must do this on the largest board possible.
Game details: Minesweeper is a one player game, played on a rectangular board. At the beginning of the game, a specified number of mines ar... | stackexchange_codegolf |
Inspired by Digits in their lanes
Input:
An ASCII-art of width ≤ 11, consisting of spaces and #. (You can choose any two distinct characters instead.) Example:
#
###
#
#
# #
# #
# #
# ### #
# ### #
###########
# #
# #
# ### #
# ... | stackexchange_codegolf |
Background:
The current Perfect Numbers challenge is rather flawed and complicated, since it asks you to output in a complex format involving the factors of the number. This is a purely decision-problem repost of the challenge.
Challenge
Given a positive integer through any standard input format, distinguish between wh... | 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 |
This task is a classic programming task: Implement a regular expression parser. That is, write a program or function which takes a string describing a regular expression and a candidate string, and test whether the complete candidate string matches the regular expression. You may assume that the regular expression pass... | stackexchange_codegolf |
Given string S representing a dollar amount, make change for that amount of money use the least number of coins to make the change and record the amount of each coin in a list. Here are the coins available to use and their value.
Coin : Value
Dollar Coins : $1.00
Quarters: $0.25
Dimes: $0.10
Nickels: $0.05
Pennies: $0.... | stackexchange_codegolf |
This is my first code golf question, and a very simple one at that, so I apologise in advance if I may have broken any community guidelines.
The task is to print out, in ascending order, all of the prime numbers less than a million. The output format should be one number per line of output.
The aim, as with most code g... | stackexchange_codegolf |
You are to take a string representing a piece of brainfuck code and Explanations, containing only printable ASCII characters and newlines ( to ~, ASCII 10 and 32 to 126) as input and output an explanation of that code, formatted to be compliant with Stack Exchange markdown.
That is, the explanation must satisfy:
Each... | stackexchange_codegolf |
After spending a while on Stack Exchange, I can recognise most sites in the Hot Network Questions by their little icon (which is also their favicon), but certainly not all of them. Let's write a program which can! You're to write code which determines the site, given one of the (currently) 132 favicons, including Stack... | stackexchange_codegolf |
iBug recently got a long bar made of composite, yet valuable materials. The bar is so long that iBug can't easily sell it for credits, so he wants to cut it. The bar is made of such fragile and magic materials that, if a part is broken, all parts of the bar made of the same material will break, too, making it hard to c... | stackexchange_codegolf |
Given a string that is one of the directions on a 16-point compass rose
output the two directions that are immediately adjacent to the input direction, in clockwise order.
Specifically, you need to handle these (and only these) input/output pairs:
Input Output
N NNW NNE
NNE N NE
NE NNE ENE
ENE NE E
E ... | stackexchange_codegolf |
Goal:
A tree can be represented as a nested list: the list elements represent nodes, and a node is a pair of the node name and node children.
Your program takes as input a nested list of pairs, and should output a pretty tree.
Examples:
Here are four example test cases below
["stump",[]]
["trunk",[["branch",[["leaf... | stackexchange_codegolf |
Although related challenges have been asked, this one is different to warrant its own question.
Challenge
Given a positive integer, return the longest sequence of consecutive positive odd integers whose sum is the given integer. If no such sequence exists, you may report an error in whatever way makes sense for your l... | stackexchange_codegolf |
Língua do Pê, or P Language, is a language game spoken in Brazil and Portugal with Portuguese. It is also known in other languages, such as Dutch and Afrikaans. (Wikipedia)
There are some dialects in this language game. The different languages the game is played with even have their own unique dialects. Some people are... | stackexchange_codegolf |
As code-golfers, we're not used to releasing (surely). We're gonna need a few tools to help us do that.
Of course, to help marketing a new release, we need a nice and shiny Release Version. Who doesn't get excited when they hear about version 3.0.0?
Task
Your task will be to write a program/routine/... to increment a v... | stackexchange_codegolf |
Write a program that, for any \$n\$, generates a triangle made of hexagons as shown, \$2^n\$ to a side. The colors are to be determined as follows.
We may give the triangle barycentric coordinates so that every hexagon is described by a triple \$(x,y,z)\$ with \$x+y+z=2^n-1\$. (The three corners will be \$(2^n-1,0,0)\$... | stackexchange_codegolf |
Given an input string of length 2 or longer consisting solely of alphabetical characters [A-Z] or [a-z] (your choice if they're all uppercase or all lowercase), output a continuous string of characters forming a double diamond pattern.
The input string starts on the center line and extends down-and-right at a diagonal ... | stackexchange_codegolf |
You probably know Conway's Game of Life, the famous cellular automaton invented by mathematician John Conway. Life is a set of rules that, together, allow you to simulate a two-dimensional board of cells. The rules decide which cells on the board live and which ones die. With some imagination, you could say that Life ... | stackexchange_codegolf |
Given string X, convert it to Java Style string, as defined below:
Strings may only contain numbers and letters(signs are not allowed)
Strings must not start with numbers
Strings must start with Capital letter
Strings may not contain two capital letters in a raw.
As for conversion you may perform the next actions
Re... | stackexchange_codegolf |
Introduction
On the 26th of August, 2017, Floyd Mayweather, Jr. will face up to Conor McGregor in a boxing match.
Both participants will receive the phenomenal amount of 100 million dollars!
Unfortunately, we do not have the money yet, but we can already prepare the big briefcase that will contain all the banknotes.
... | stackexchange_codegolf |
Introduction
The Prime Counting Function, also known as the Pi function \$\pi(x)\$, returns the amount of primes less than or equal to x.
Challenge
Your program will take an integer x which you can assume to be positive, and output a single integer equal to the amount of primes less than or equal to x. This is a code-g... | stackexchange_codegolf |
Challenge
Given an array of positive integers and a threshold, the algorithm should output a set of consecutive-element-groupings (subarrays) such that each group/subarray has a sum greater than the threshold.
Rules
The solution should honor two additional criteria:
be of highest cardinality of the groups (i.e. highes... | stackexchange_codegolf |
Because there isn't enough xkcd on PPCG...
Challenge
The challenge is the same as above - given a menu and a total price, you need to find what the customer ordered.
The menu will be supplied as a text file in the format:
Name:Price
Name:Price
The path to the menu file and the total price should be supplied via argv ... | 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 |
Inspired by How do you write dates in Latin?
Challenge
Given a month-and-day date, output that date in abbreviated Latin, as explained below.
Input
Input is flexible, following conventions from other date and sequence challenges. You may choose to:
Take a date in mm/dd or dd/mm format or two separate month,day argumen... | stackexchange_codegolf |
We've had challenges for SIGSEGV and SIGILL so why not...
Write the shortest code that results in a Bus Error (SIGBUS) in any programming language.
Your program can't call raise() or kill(getpid(),sig) or pthread_kill(pthread_self(),sig), or any other equivalent.
| stackexchange_codegolf |
At some point, I bumped into an SO question asking how to implement Perl's trivial hash-of-hashes data structure in Java.
For those who don't know Perl, the hash value can be a scalar or another hash, or technically speaking hash reference. Arbitrary depth. Additional feature offered by Perl is autovivification - assi... | stackexchange_codegolf |
Your task is to program a mathematical function \$s\$, that takes a nonempty finite set \$A\$ of points in the 2D plane, and outputs an uncircularity score \$s(A)\$ that satisfies following properties:
Positive Definiteness: If there is a circle or a straight line that contains all points of \$A\$, then \$s(A) = 0\$. ... | stackexchange_codegolf |
A quotation is "the repetition of one expression as part of another one". In American English, a quotation is surrounded by double-quotation marks ("), as in the previous sentence. However, this rule differs when a quote appears inside another quote. In this case, the inner quote is surrounded by single-quotation marks... | stackexchange_codegolf |
Most people can't easily do modulus (or work out if a number is divisible by another number) in their heads because long division is harder than addition, subtraction and multiplication. The following method describes a way to calculate modulus in your head, as long as you can remember just a few different numbers. Thi... | stackexchange_codegolf |
As the June 2021 Language of the Month is Red, what are some general tips for golfing in Red language?
Please suggest tips that are at least somewhat specific to Red (e.g. "remove comments" isn't a valid tip here).
Please one tip per answer!
| stackexchange_codegolf |
Divide the first quadrant (including the positive x-axis, the positive y-axis, and the origin) into 1x1 grids, with each grid labelled by the coordinates of its bottom-left corner, as demonstrated below:
Note that each grid contains its boundaries and its vertices. Using mathematical symbols, the grid labelled (m,n) w... | stackexchange_codegolf |
Given a text like this:
# #### ## #
## # ## #
#### ##
Output the same text but by connecting the pixels with the characters ─│┌┐└┘├┤┬┴┼. If a pixel doesn't have any neighbours, don't change it.
So the output of the last text is:
│ ─┬── ┌─ │
└─ │ ┌┘ │
└──┘ ─┘
You can take input as a boolean array.
The inp... | stackexchange_codegolf |
Introduction
Every number can be represented as ASCII. For example, \$0\$ comes in ASCII is \$48\$, \$1\$ is \$49\$, and so on. Using this method of translating numbers to other numbers, it is possible to infinitely expand a number, by replacing all its digits with their ASCII values and doing the same for the result. ... | stackexchange_codegolf |
Details
Write a function or program that, given an array (or list), containing only integers, returns or output an array with all sub-elements reversed. That is, reverse all elements of the deepest array, then the second deepest, etc. The dimensions need not be specified, but the function or program must work for jagge... | stackexchange_codegolf |
The aim is to trim elements in from the ends of a list, depending on if they are in a second list of "falsey" results.
For example, if the first list is [-1, 1, 2, 0, -1, 3, -1, 4, -1, -1] and the second is [-1], then we would remove all leading and trailing -1s from the first input, but not any -1s in the middle: [1, ... | stackexchange_codegolf |
A knight's tour is a sequence of moves of a knight on a chessboard such that the knight visits every square only once. For those who are not aware of how knights in chess work, knights are capable of moving in an L shape (see fig. 1). (Or a ߆ shape, or even a \ shape depending on who you ask.) Essentially, in one move,... | stackexchange_codegolf |
Background
Imagine that I'm creating a really long necklace, consisting of only two characters, A and B. You must count the number of occurrences of the substring AB in the string.
However, since it's a necklace, you must also consider if the last character and the first character join to make AB. For example, in BBBA,... | stackexchange_codegolf |
What general tips do you have for golfing in Go? I'm new to Code Golfing and looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Go.
Please keep to one tip per answer.
| stackexchange_codegolf |
Introduction:
I have loads of different ciphers stored in a document I once compiled as a kid, I picked a few of the ones I thought were best suitable for challenges (not too trivial, and not too hard) and transformed them into challenges. Most of them are still in the sandbox, and I'm not sure yet whether I'll post al... | stackexchange_codegolf |
Challenge
You just entered a room. Here's how it looks (you are the X):
|\ /|
| \/ |
| X |
| |
|----|
You challenge yourself to see if you can reach where you started by following the walls. You go right until you find a wall. Then, you turn clockwise until you are facing parallel to the wall.
For example, if you... | stackexchange_codegolf |
UTF-8 is a relatively simple way to encode Unicode codepoints in a variable-width format such that it doesn't easily confuse code that isn't Unicode aware.
UTF-8 overview
Bytes in the range of 1-0x7F, inclusive, are normally valid
Bytes with the bit pattern 10XX XXXX are considered continuation bytes, with the six lea... | stackexchange_codegolf |
This question is inspired by this awesome answer.
The challenge is to write a program or function which takes in a positive integer, and outputs "Happy new year to you" or a slight variation thereof, such that the character codes of that string add up to the inputted number. The space counts towards the sum of characte... | stackexchange_codegolf |
This is a cops-and-robbers challenge the Cops' Thread can be found here
Your challenge, as robbers is to take outputs from the cops' thread and find anagrams of the output that when run as a program output the original output provided.
The winner will be the person with the most valid cracks on this question.
Rules
Yo... | stackexchange_codegolf |
This is a challenge in which two people, 1 and 2, are running for office. People deterministically vote in certain ways in the world of 1 and 2, which can allow for the candidates to figure out the results before the election.
NOTE: this is not meant to refer to any outside elections or other political events.
Two peop... | stackexchange_codegolf |
My PIN number is 1077, but that's too difficult to remember. I know from muscle memory that it's a digit, followed by a different digit, then followed by two of the same digit, which is different to the other two digits before it. As a pattern, we can say it is ABCC (where each letter represents a digit, and the same ... | stackexchange_codegolf |
Huge omega thanks to @wasif for emailing me this challenge idea in its basic form
Everyone knows that questions on StackExchange require tags - labels that allow posts to be grouped together by category. However, most of the time, I barely know which tags exist, because there's just so many of them.
Henceforth, today's... | stackexchange_codegolf |
In this challenge, You have to bring ASCII art (which are usually 2D) to 3D!
How?
like this,
X X DD
X D D
X X DD
to...
X X DD
X X DD D
X X DDDD
X XDDD
X X DD
Then How do we do that?
Given the ascii art and N, repeat this N times.
for every character (we will call this A):
let B be the character which is ex... | stackexchange_codegolf |
This challenge is in honor of mathematician John Conway who passed away April 11, 2020 due to COVID-19. He was famous for coming up with the Game of Life cellular automaton and many other mathematical contributions such as the surreal numbers and the monster group.
The advanced math of those topics is out scope for thi... | stackexchange_codegolf |
Cyclic Polyglot Challenge
This is the robbers thread. You can find the cops 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 |
Identify each letter of the English alphabet with the number denoting its position in the alphabet, that is,
a = 1, b = 2, c = 3, ..., z = 26
(no distinction between lower and upper case letters is made). Every other character is identified with 0.
The "sum" of a word is the sum of its characters, for example: the su... | stackexchange_codegolf |
Background
Quaternion is a number system that extends complex numbers. A quaternion has the following form
$$ a + bi + cj + dk $$
where \$ a,b,c,d \$ are real numbers and \$ i,j,k \$ are three fundamental quaternion units. The units have the following properties:
$$ i^2 = j^2 = k^2 = -1 $$
$$ ij = k, jk = i, ki = j $$
... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.