instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
See also: Rotatagons
Challenge
Given a string as input, output its wordagon.
Wordagons
A wordagon is a way of representing a string in a hexagon. Now, let's create a wordagon from the string hexa:
Firstly, you start with the first character in the string a place it in the centre:
h
Then, you take the next character in... | stackexchange_codegolf |
Characters
Let’s call these Unicode characters English IPA consonants:
bdfhjklmnprstvwzðŋɡʃʒθ
And let’s call these Unicode characters English IPA vowels:
aeiouæɑɔəɛɜɪʊʌː
(Yes, ː is just the long vowel mark, but treat it as a vowel for the purpose of this challenge.)
Finally, these are primary and secondary stress ma... | stackexchange_codegolf |
A nonogram is a Japanese puzzle game in which the goal is to draw a black-and-white picture according to a list of contiguous regions, like so:
Define the nonographic magnitude of a row or column to be the number of contiguous black regions in that row or column. For example, the top row has a nonographic magnitude of... | stackexchange_codegolf |
Challenge
Determine how many integer lattice points there are in an ellipse
$$\frac{x^2}{a^2} + \frac{y^2}{b^2} \leq 1$$
centered at the origin with width \$2a\$ and height \$2b\$ where integers \$a, b > 0\$
.
Input
The Semi-major \$a\$ and Semi-minor \$b\$ axes.
Output
Number of interior and boundary points.
Example
E... | stackexchange_codegolf |
The goal of this challenge is to implement a digital low-pass filter.
You are free to implement any type of digital filter you want, however whatever results produced must pass the validation script below.
Here's a general description of what the validation script expects:
When an FFT is taken of the filtered signal, ... | stackexchange_codegolf |
Let's make a little stupid program that simulates the meme "Mr. incredible becoming uncanny", but in this case, our little ASCII friend is going to react to our code length.
Objective:
Create a program that takes anything (preferably a program) as input and outputs this:
Pov:
<face> you score X on codegolf
Where X ... | stackexchange_codegolf |
Input
None
Output
52 cards. No duplicates. Cards are represented as their unicode characters, e.g. .
The Unicode codepoints follow the following format:
The first three digits are 1F0.
The next digit is A, B, C, or D for spades, hearts, diamonds, and clubs respectively.
The next digit is 1 through C and E for the vari... | stackexchange_codegolf |
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
While other Elves are busy carrying air blowers, Fen comes and shouts, "I've got a spell for this job!"
To recap, a chimney is modeled as a rectangular grid. The number in each cell represents the amount of smoke in the region. The lef... | stackexchange_codegolf |
Your goal is to write "Hello, World!" (minus the quotes). This is a popularity-contest, so most up votes wins. Code length will be used to break ties.
Anything goes, as long as it is within the following rules:
All characters must be either letters or numbers, so you may only use characters in the string "abcdefghijk... | 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 |
A program is "conveniently palindromic" if
it is equal to the string derived when its reverse has all its parentheses (()), brackets ([]), and braces ({}) flipped. No other characters are special and require flipping. (<> are sometimes paired but often not so they are left out.)
copied from this challenge.
Write a co... | stackexchange_codegolf |
Challenge closed, the shortest answer has been acccepted.
A military projection is a projection where all lengths and the angles in the X-Z plane remain unattuned.
Your task is to print a cube in military projection using /, |, \, -, and any whitespaces you want, given any integer greater than zero as it's side length.... | 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 |
Given a list of positive integers determine if there is an element that is either greater than its two neighbors or less than its two neighbors (a "bump"). To be clear a bump can never be the first or last item of the list because they only have one neighbor.
Your program should output one of two consistent values eac... | stackexchange_codegolf |
The Fabius function is an example of a function that is infinitely differentiable everywhere, yet nowhere analytic.
One way to define the function is in terms of an infinite number of random variables. Specifically, given a sequence of independent random variables \$\{U_n\}\$, where each \$U_n\$ is uniform on the inter... | stackexchange_codegolf |
Giving n(any amount) of points (x,y). What's the minimum amount of circles required to cross every point given?
Task
Your program will get n (you can have n as part of input or use EOF instead) points (x,y).
The points might at same place => (x1,y1) = (x2,y2) can happen
x and y will be integer of range -10000~10000, wh... | stackexchange_codegolf |
The purpose of this task is to write a program or function to find the most common substring within a given string, of the specified length.
Inputs
A string, s, of any length and characters that are valid as inputs for your language.
A number, n, indicating the length of substring to find. Guaranteed to be equal to or... | stackexchange_codegolf |
According to RollingStone, below are the 26 greatest singers of all time:
Aretha Franklin Al Green
Ray Charles Robert Plant
Elvis Presley Mick Jagger
Sam Cooke Tina Turner
John Lennon Freddie Mercury
Marvin Gaye Bob Marley
Bob Dylan Smoke... | stackexchange_codegolf |
Write the shortest program or function that takes some text as input, and outputs either it or an empty line in a repeating pattern:
some text
some text
some text
some text
some text
some text
...
This must continue indefinitely, or until some unpreventable limitation occurs (stack size, memory, etc.). It must be n... | stackexchange_codegolf |
Inspired by this question, your goal today is to encode an URL in brainfuck.
My browser has been hacked! The location bar has been turned into a brainfuck interpreter. I need a program that turns an URL into a brainfuck program. My computer is also very slow, so if the brainfuck program is small it's better.
Oh and I o... | stackexchange_codegolf |
The domain server requires that all employees have a strong, random password conforming to the following rules:
Exactly 15 characters long.
Keyboard-typeable characters only (as shown in code-type below). Teaching the sales to use ALT+NUMPAD codes is not permitted.
At least 1 lower case letter: abcdefghijklmnopqrstuv... | stackexchange_codegolf |
There is an array of integer values to be sorted.During the sorting process, the places of two numbers can be interchanged. Each interchange has a cost, which is the sum of the two numbers involved.
You must write a program that determines the minimal cost to sort the sequence of numbers.
| stackexchange_codegolf |
My family has an e-commerce business. On our own site, we force people to choose their state from a dropdown menu when they enter their address, but through some other channels we use, customers can enter anything they want into the box.
My mom loves the invoice templates I made for her, which are automagically generat... | stackexchange_codegolf |
This challenge is a sequel to Letter Boxed Validator.
The New York Times has a daily online game called Letter Boxed (the link is behind a paywall; the game is also described here), presented on a square as follows:
You are given 4 groups of 3 letters (each group corresponds to one side on the picture); no letter appe... | stackexchange_codegolf |
this challenge was based on a sandboxed post by @dmckee
Old fashioned cell phones were and are used heavily as texting platforms, unfortunately the keyboard has only 12 + a few buttons, and is therefor ill-suited to naive text entry.
Common solutions make use of the traditional telephone coding (generally with a modest... | stackexchange_codegolf |
Cyclic Equivalence
Let L be a list of pairs of letters, for example [(a,b), (a,c)]. We call L a list of commutators. Two words are cyclically equivalent over L, if one can be transformed into the other using the following operations:
Cyclic shift: pop a letter from the beginning, and push it to the end.
Commutator swa... | stackexchange_codegolf |
This is the robbers' thread for 'Almost Illegal Strings'.
See the cop's thread for information on participating. A section from the post is included here for convenience.
The Robbers' Challenge
Find an uncracked answer. Write a program in the language specified that contains as a contiguous substring the almost illega... | stackexchange_codegolf |
Your task here will be to write a very dumb AI capable of fetching all treasures on a map.
Map
The map is defined as follow: (artist-mode™-powered)
Basic case:
+-+-+-+-+-+-+-+-+-+-+-+-+-+
|P| | | | | | | | | | | | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+
| | | | | | | | | | | | | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+
| | |T| | | | | | | ... | stackexchange_codegolf |
There's a little-known secret in Banjo-Kazooie that you can interleave the three Cheato codes on the Treasure Trove Cove Sandcastle floor and it will still recognize all of them. So you could, for instance, enter BLUREEGOLDDFFEEGEAATHTHEEGSRSRS, activating BLUEEGGS, REDFEATHERS, and GOLDFEATHERS all at once.
Challenge
... | stackexchange_codegolf |
Knight is the Language of the Month for August 2022, and I noticed that it didn't have a tips page, so here it is!
I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Knight (e.g. "remove comments" is not an answer).
Please post only one tip per answer.
| stackexchange_codegolf |
Given an integer n >= 2, output the largest exponent in its prime factorization. This is OEIS sequence A051903.
Example
Let n = 144. Its prime factorization is 2^4 * 3^2. The largest exponent is 4.
Test Cases
2 -> 1
3 -> 1
4 -> 2
5 -> 1
6 -> 1
7 -> 1
8 -> 3
9 -> 2
10 -> 1
11 -> 1
12 -> 2
144 -> 4
200 -> 3
500 -> 3
1024... | stackexchange_codegolf |
Results are now out here!
Congratulations offset prediction for winning the challenge!
Don't worry if you missed out, the controller code as well as all the bots that competed are all in the Github repo, so you can always test your bot against those that competed in the challenge yourself.
(Hover for more info)
This c... | stackexchange_codegolf |
This is the cops' post. The robbers' is here.
You make a program and a regex.
For most inputs, one of the following happens:
the regex doesn't match, and the program returns a falsey value
the regex doesn't match, and the program returns a truthy value
the regex matches, and the program returns a truthy value
But for... | stackexchange_codegolf |
The 16-color CGA palette (also known as the HTML colors) is a set of 16 colors used by early graphics adapters. The goal of this challenge is to output all 16 of them, in hex format (RRGGBB), in ascending order by hex value, separated by newlines. Thus, the output should be exactly this:
000000
000080
0000FF
008000
008... | stackexchange_codegolf |
A donut distribution (for lack of a better term) is a random distribution of points in a 2-dimensional plane, forming a donut-like shape. The distribution is defined by two parameters: the radius r and spread s, in which the distance to the origin follows a normal (Gaussian) distribution around r, with a standard devia... | stackexchange_codegolf |
Description
In this challenge, you need to write a function that takes in a list of strings and returns the smallest string based on their ASCII value. You should assume that the input list contains only lowercase alphabetical strings.
Test Cases
["a", "b", "c"] => "a"
["hello", "world", "code"] => "code"
["aaa", "aa",... | stackexchange_codegolf |
I have been going to puzzling.se, and people over there write stuff in rot13 a lot, sot this gave me an idea:
Write a program that takes 2 inputs, a string and integer:
the message to encode or decode
how far to shift
You can input in a function call, and output in any legal way
twist:
it must work with any printable... | stackexchange_codegolf |
A few month back, I made a language called ;# (Semicolon Hash) and it started a little bit of a craze (it even got its own tag, as you can see). But, as with everything, the craze died down, and questions related to it stopped being posted.
However, a few people were annoyed at the lack of capability of ;# and this lea... | stackexchange_codegolf |
This challenge's concept is pretty simple. All you have to do is write a program that will compile as both valid C and valid C++! Well, there are some catches. The program must behave differently when compiled in each language. The program must have different output for each language in order to be considered "behaving... | stackexchange_codegolf |
Given a list (array) of names, your challenge is to join the items using some glue and abbreviate the longest items first until the joined string fits a maximum length. And output that string. Since the glue is part of the final string, the length of the glue is included too
Abbreviation is done using the … character
... | stackexchange_codegolf |
Lets create a system of numbers where the biggest digit in the nth place value (counting from right to left) of a number length m is always equal to m - n + 1. To give an example the largest 5 digit number expressible in this system is written 12345. Apart from the number of digits available to be used in a particular ... | stackexchange_codegolf |
I'm currently scanning a bunch of handwritten documents and converting them to .txt files. Since I have a terrible handwriting the .jpg->.txt converter converts some of my umlauts to the "normal" letter encased by '
Task
Write a program or a function that:
Is given a string
you can choose any I/O codepage as long as
... | stackexchange_codegolf |
Challenge
Given a colour raster image* with the same width and height, output the image transformed under Arnold's cat map. (*details see below)
Definition
Given the size of the image N we assume that the coordinates of a pixel are given as numbers between 0 and N-1.
Arnold's cat map is then defined as follows:
A pixe... | stackexchange_codegolf |
If we assign each letter a respective integer, starting from 1, then a is 1, b is 2, c is 3, and so on. After z, the letters loop back around, but with a in front (aa, ab, ac). It then goes to ba, bb, bc... After this is completed, as you may have figured, another letter is added (aaa, aab, aac). "Prime letters" would... | stackexchange_codegolf |
Challenge
In this challenge you will construct trees, in the form of ASCII Art using recursion. Basically you will generate the ASCII version of the Fractal Tree
Input
Number of iterations 0 < N <= 5
Output
The Nth iteration of the Fractal Tree. It must be a matrix of 63 rows and 100 columns. (i.e. 6300 printable ch... | stackexchange_codegolf |
The challenge.
Make a program that produces a random series of 8 notes in the scale of E minor, and then harmonizes them.
Details.
Notes must be represented in output as a 1-2 char string, which designates the note and if it is sharped or not, followed by a number, which designates the octave. Examples would be C3, D#... | stackexchange_codegolf |
This challenge is simple: Take a path to an png image file as input and overwrite that file with a copy of itself rotated 90 degrees clockwise. You may assume that the file has dimensions of 128x128 pixels. You may not use image metadata modifications (like Exif) to rotate the image; the pixels themselves must be trans... | stackexchange_codegolf |
Blokus is a board game in which players take turns placing pieces on a \$ n \times n \$ square grid. In this version of the game, there will be just one person playing. The person is given \$ 21 \$ unique polyominoes, ranging from \$ 1 \$ to \$ 5 \$ tiles each. They then proceed to place down a subset of the pieces ont... | stackexchange_codegolf |
Challenge
Given a user's name (not ID, we have that challenge already), output their current reputation and their ID.
Input
Input will be a single string which is the user's username. You may assume that this user exists.
Output
Output will be two integers to either STDOUT or STDERR which will be the user's reputation ... | stackexchange_codegolf |
Given an input string and a wrapping string, find the location of the first input string char in the wrapping string and replace it with the wrapping string char 1 step to the right of that, find the second char in the wrapping string and replace it with the char 2 steps to the right, find the third and replace it with... | stackexchange_codegolf |
Given an m by n chocolate bar, m,n positive, output the number of ways to break the bar into mn 1 by 1 pieces where each break occurs on a gridline.
Order is important. Pieces are also distinguishable, so the two pieces on either end of a 1 by 3 chocolate bar are not equivalent.
For instance, for a 2 by 2 block we have... | stackexchange_codegolf |
You work at a bakery, and every day you make pastries. You make 100 of each of several different types. However customers are less predictable. Some days they order all of one kind of pastry and you run out, some days they order hardly any and you have some left over. So your boss has made up a chart which tells you ho... | stackexchange_codegolf |
Introduction:
Inspired by the Puzzling-stackexchange post with the same name, which I've answered four years ago:
Can you create a perfectly valid English sentence, which makes perfect sense, but which contains the word "and" in it, five times consecutively in a row ?
"Something-or-other and and and and and something-... | stackexchange_codegolf |
Challenge Description:
An anagram is a word or phrase formed by rearranging the letters of another word or phrase. For example, "listen" and "silent" are anagrams. In this challenge, your task is to write a program or function that takes a list of strings as input and returns the unique anagrams.
Write a program or fun... | stackexchange_codegolf |
This proposal had few attention for 8 months (though an answer was posted in the sandbox at that time), so I decided to post it anyway.
Introduction
Napier's bones is a calculation tool, which helps speeding up the calculation of multiplication, division and digit-by-digit square root extraction by turning n-digit-by... | stackexchange_codegolf |
Roll cakes are delicious sweets made with a layer of sponge cake, a layer of cream (or icecream), rolled as a spiral, see Wikipedia.
Your task is to get a non-empty phrase string from standard input, strip the spaces out, and roll it as a roll cake starting from the center in right to left in a counterclockwise directi... | stackexchange_codegolf |
Given a positive integer n, randomly output n non negative integers that sum to one hundred. n will be at most 200. The output should be present as a list of integers (not sorted).
Your random sample should be uniformly sampled from all lists of n non negative integers that sum to one hundred.
Your code should run in a... | 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 |
Task
Your task is to write as short as possible program preferably in Brainf**k which determines the last digit of given number after it's conversion from decimal to binary system.
Input
An integer in decimal system consisting of up to 200 digits. There is a newline character (ASCII 10) after the given number
Output
On... | stackexchange_codegolf |
Background
In X11 (a windowing system used by a lot of Unix-like OS), what you would call the clipboard behave a bit differently than on other OSes like MacOS or Windows. While the "traditional" clipboard using ctrl+v/ctrl+c works, there is also another clipboard, called PRIMARY selection, that behave as following:
wh... | stackexchange_codegolf |
This is my attempt to pair code-shuffleboard with code-golf.
You need to write a full program or function that sums all codepoints of the input string. If there is no input, you can output any number, including 0.
Rules
The input will always be in printable ASCII.
The sum of the codepoints of your source must be exact... | stackexchange_codegolf |
Inspired by this challenge, as well as a problem I've been working on
Problem:
Given a non-empty set of points in 3D space, find the diameter of the smallest sphere that encloses them all. The problem is trivial if the number of points is three or fewer so, for the sake of this challenge, the number of points shall be ... | stackexchange_codegolf |
Play the Fruit Box Game
Intro
Fruit Box is a game consisting of a 10x17 grid of numbers, each between 1 and 9, where the goal is to clear as many numbers as possible in a two-minute time window. In order to clear numbers, one selects a rectangle aligned with the grid, and if the numbers inside of it sum to 10, they are... | stackexchange_codegolf |
Your code may not contain the letter "e", but must count the number of "e"s in the inputted string and output that as a number. Bonus points if you use a language that is not a codegolf language and a language that actually uses the letter e (unlike brainfuck) --- not a required criteria.
| stackexchange_codegolf |
Inspired by this comment...
Thanks to users Step Hen, Wheat-Wizard, and Dennis for helping my solidify the specification of this challenge before posting it!
This is the Cops' thread. For the Robbers' thread, go here
In this challenge, you are tasked with running some code that makes it so that your language no longer... | stackexchange_codegolf |
Warm up: Regex, Paper, Scissors
This is the challenge I originally wanted to post, before realising that some very short solution exist. Nevertheless, it can be an interesting problem to think about in preparation for the actual challenge below.
Write three regexes R, P and S such that they match each other in a cyclic... | stackexchange_codegolf |
Introduction
Consider two strings A and B of the same length L, and an integer K ≥ 0.
For the purposes of this challenge, we say that the strings are K-compatible, if there exists a string C of length K such that A is a contiguous substring of the concatenation BCB.
Note that A is a substring of BAB, so A and B are alw... | stackexchange_codegolf |
The golf challenge is to encode and compress the following image inside a source file.
To do this you need to write 3 functions: red, green, and blue which accept x/y coordinates of the image and return the corresponding R/G/B pixel value between 0-255.
Here is the C/C++ test code:
#include <stdio.h>
#include "your_fi... | stackexchange_codegolf |
A few days ago I made a puzzle about moving people on an airplane. Now I am interested in the general version of this puzzle and the shortest code golf for it.
I will briefly summarise the puzzle here. A small airplane went through some heavy turbulence and all its N passengers ended up sitting in reverse order, ie., p... | stackexchange_codegolf |
Challenge
Write a program or function that given a string, returns a valid Brainfuck program that when compiled and executed as Brainfuck, returns that string..
Assume all inputs are encoded as ASCII.
Assume the outputted BF program will execute in an environment with an infinite tape.
Assume the pointer starts at c... | stackexchange_codegolf |
First question here, don't yell at me if this is a duplicate or a bad challenge.
Introduction
I thought of this challenge myself, and it seems to be a good basic puzzle for beginner code-golfers. It also might help me decide which code-golfing language to learn.
Challenge
Given an array of integers that are less than o... | stackexchange_codegolf |
The infinity symbol is also called a lemniscate. Your program must draw a lemniscate with text via standard out (formatted with newline feeds) or graphically.
The infinity symbol (by my standards) must be continuous (that is, every non-whitespace character must be touching two other non-whitespace characters diagonally... | stackexchange_codegolf |
Write a program that takes a single line string that you can assume will only contain the characters /\_‾. (That's forward and backward slash, underline and overline. You can use ~ in place of overline if you need since overline is not convenient ASCII.)
For example, one possible input is:
__/‾‾\/\_/‾
Your program nee... | stackexchange_codegolf |
Challenge
I'm under attack by the larcenous Midnight Crew and I need to summon the Catenative Doomsday Dice Cascader in order to defend myself. Since I'm low on space, I need the code to be as short as possible.
The algorithm for the Catenative Doomsday Dice Cascader is as follows:
First, the six sided die in the Prime... | stackexchange_codegolf |
Imagine this short function to clamp a number between 0 and 255:
c = n => n > 0 ? n < 255 ? n : 255 : 0
Is this the shortest possible version of a clamp function with JavaScript (without ES.Next features)?
P.S: Not sure if it's relevant but, the 0 and 255 are not random, the idea is to clamp a number as an 8-bit unsig... | stackexchange_codegolf |
This is similar to the alignment used in word.
Task
3 inputs: A 1 line string, a positive integer k, and direction (left or middle or right)
Your job is to insert new lines(\n) and spaces in the string such that every line has k characters in it and aligned to the direction given.
Rules
The words must not be split(unle... | stackexchange_codegolf |
Introduction
In mathematics, the hyperoperation sequence is an infinite sequence of arithmetic operations (called hyperoperations) that starts with the unary operation of successor (n = 0), then continues with the binary operations of addition (n = 1), multiplication (n = 2), and exponentiation (n = 3), after which th... | stackexchange_codegolf |
Definitions:
A palindrome is a string which reads the same backward or forward (not counting spaces or special characters), such as "madam" or "Sorel Eros".
A date is said to be a palindrome when its dd-mm-yyyy format is a palindrome (or any other local representation).
Two strings are said to be anagrams when the co... | stackexchange_codegolf |
Description
Let a permutation of the integers {1, 2, ..., n} be called minimally interpolable if no set of k+2 points (together with their indices) fall on a polynomial of degree k.
That is,
No two points fall on a horizontal line (0-degree polynomial)
No three points fall on a line (1-degree polynomial)
No four poi... | stackexchange_codegolf |
It's time to make a more advanced program (rather than something simple, like printing some shape). You need a package manager for something, I guess.
First of all, if something wasn't defined, you are allowed to do anything, including destroying the computer (but please, don't, unless this will save your characters). ... | stackexchange_codegolf |
The challenge
Given two strings, each of length up to 30, consisting of printable ASCII characters (codes \$[32, 126]\$), put them onto a balance scale in the fewest bytes of code! This consists of the following steps:
Calculate and compare the weights of the strings
Choose the appropriately tilted ASCII-art scale
Pla... | stackexchange_codegolf |
So, there's a famous children's rhyme...
This is the house that Jack built.
This is the malt
That lay in the house that Jack built.
This is the rat
That ate the malt
That lay in the house that Jack built.
This is the cat
That killed the rat
That ate the malt
That lay in the house that Jack built.
This is the do... | stackexchange_codegolf |
Minesweeper is a puzzle game where mines are hidden around a board of nondescript tiles with the goal of identifying the location of all mines. Clicking on a mine loses the game, but clicking on any other tile will reveal a number from 0-8 which signifies how many mines directly surround it.
Given a number, you must di... | stackexchange_codegolf |
Here's one generalized version of the famous Eight Queen's Puzzle:
Given an n × n chess board, and an integer m (≤ n). Find all possible ways to put nm Queens such that
there are m Queens at each row
there are m Queens at each column
(note that we do not impose any restriction on the diagonals).
As you might see, ... | stackexchange_codegolf |
Task:
You must create an interpreter that can parse snippets of a programming language. The language does not need to be complex, but it must include the following syntactical elements:
Ability to assign and read variables (could be as simple as a-z being premade variables)
If statements (elseif and else are not requi... | stackexchange_codegolf |
We've all been told at some point in our lives that dividing by 0 is impossible. And for the most part, that statement is true. But what if there was a way to perform the forbidden operation? Welcome to my newest creation: b-numbers.
b-numbers are a little bit like imaginary numbers: the main pronumeral involved repre... | stackexchange_codegolf |
Write a program or function that
checks if a variable name is valid and
output 1 or True if it is valid,
0.5 if it is valid but starts with an underscore (_),
and 0 or False if it is not valid.
Rules
A variable name in most languages is valid if it begins with an underscore or letter (a – z, A – Z, _) and the rest o... | stackexchange_codegolf |
Write a function (not a full program), so that if the function is called with a single global variable (or your language's closest equivalent) as its argument, it outputs (i.e. prints or returns) the name of that variable. If the argument is not a variable, output a falsey value instead. (You don't have to handle the c... | stackexchange_codegolf |
Your task: given an input string, determine whether the binary representation of that string does not have 4 1s or 0s in a row, anywhere. Furthermore, your code itself should not contain any such runs of four in a row.
Test Cases
String Binary Result
U3 01010101 00110011 Truthy
48 ... | stackexchange_codegolf |
RPS 25 is a version of Rock Paper Scissors which has 25 hand symbols instead of just 3. Each symbol defeats 12 symbols, and is defeated by 12 others.
Here's a link to a chart showing which symbols defeat which.
The challenge here is simple: your program should take in two strings representing the symbols thrown by each... | stackexchange_codegolf |
In mathematics, the factorial, shortened "fact" of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example, 5! is 1 * 2 * 3 * 4 * 5 = 120
The factorial of 0 is 1, according to the convention for an empty product.
These are the regular facts we are used to. ... | stackexchange_codegolf |
Word changer is a game where you are trying to turn one word into another via single-character edits, with each step being its own word. For this challenge, edits may be replacements, insertions, or deletions. For example, WINNER → LOSER can be done with this route (there may be others):
WINNER
DINNER
DINER
DINE
LINE
L... | stackexchange_codegolf |
Write the shortest program that prints the sound my alarm clock makes, and stops after an inputted number of beeps.
For reference, here is the sound my alarm makes:
beep beep beep beep beep beepbeep beepbeep beepbeep beepbeep beepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeepbeep bee... | stackexchange_codegolf |
Background
You are sitting in chemistry class and your friend keep sending you these strange letters. It is your job to decrypt the messages into words.
This is the inverse of this challenge.
The Challenge
Input: A list or a string of integers from 1 to 118.
Output: The words for each chemical element if possible. Ot... | stackexchange_codegolf |
For each character in your program, the program with that character removed must produce a number smaller than the program with the next character removed. Your base program isn't required to do anything, and may be invalid.
An example submission could be abcd, where bcd outputs 1, acd outputs 4, abd outputs 5, and abc... | stackexchange_codegolf |
Given a non-empty string consisting of only lower and upper case alphabetical characters and spaces ([a-zA-Z ]), reduce it to a snippet of the alphabet, starting with the first character.
To reduce a string, begin with the first alphabetical character, then remove every character after it that is not the next letter of... | stackexchange_codegolf |
Task
Given a string composed of ASCII printable characters, return how many strings could fit the given pattern with character literals and regex-like ranges.
Pattern string
The pattern string follows this grammar (the | means an option and the * means 0 or more occurrences of whatever was immediately to the left):
pat... | stackexchange_codegolf |
Modern hardware can perform multiplication very fast in a constant latency of 3~4 cycles. But some tiny chips for embedded environments sometimes lack hardware multiplication, which has to be emulated by a series of instructions.
Goal
You are given a primitive CPU with a set of basic operations. Your job is to implemen... | stackexchange_codegolf |
your challenge is to draw this ASCII art:
| | |- - - - | | - - -
| | | | | | |
|- - -| |- - - | | | |
| | | | | | |
| | |- - - - |- - - |- - - - - -
remember this is code golf meaning you have to answer in the leas... | stackexchange_codegolf |
For the given string s, generate generate a table like below.
Input:abcd
Output:
abcd
bbcd
cccd
dddd
Input:Hello, world!
Output:
Hello, world!
eello, world!
llllo, world!
llllo, world!
ooooo, world!
,,,,,, world!
world!
wwwwwwwworld!
ooooooooorld!
rrrrrrrrrrld!
llllllllllld!
dddddddddddd!
!!!!!!!!!!!!!
Trailin... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.