instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
There are radiation hardened quines, palindromic quines, but has anyone tried both?! I think not! Rules So the challenge here is to make a quine that if any symbol is deleted it prints its original source code, and the quine needs to be the same read forward and backwards(before radiation damage)! All code will be scor...
stackexchange_codegolf
The challenge Write a function that returns the nth element of an array even if its out of bound. function safeGet(index, arr) { const safeIndex = ??? return arr[safeIndex] } const arr = ["a", "b", "c"]; safeGet(0, arr) // "a" safeGet(1, arr) // "b" safeGet(2, arr) // "c" safeGet(3, arr) // "a" go back to the be...
stackexchange_codegolf
You are given a very special gun with a full magazine. Let n be the initial number of bullets in the magazine and i the number of bullets left. That gun is really unreliable, hence each time you shoot, you have a i/n chance to successfully shoot. The fewer bullets you have left, the more tries it requires to shoot. The...
stackexchange_codegolf
Take the string abcdfghjk. To overwrite it, starting from f, with the string wxyz, you would continue along the original, replacing each character with the one from the replacement string. The result would be abcdwxyzk. Now, consider a string which would be too long to fit, like lmnopqrs. Starting at f you would get ab...
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
This question wants you to golf batch programms. In Batch you can use set x=averylongbatchcommand %x% arg1 which expands to set x=averylongbatchcommand averylongbatchcommand arg1 Your task is it to expand these statements. As you can also use set for arithmetic purposes like this: set x = 0 set /a x= %x%+1 you sho...
stackexchange_codegolf
The goal is to create a generator generator [...] generator generator comprehension. The generator must be created via generator comprehension. The following expression must be valid for any number of nestings: next(next(next(next(next(generator))))). The winner is whoever achieves this with the fewest number of byte...
stackexchange_codegolf
Who doesn't love a good fractal? The Sierpinski Carpet is a classic example of a fractal. To complete this task, you will be required to generate a carpet of type \$n\$ and print the resulting image to the stdout (see example below for formatting) \$n\$, representing the level carpet. Steps can be found on this Wikiped...
stackexchange_codegolf
Your task is to accept as input two "ASCII Art"s, and align each piece of art next to each other horizontally. For example, say you have two strings, "abc\ndef" and "123\n456". You need to align them horizontally to produce the string "abc123\ndef456". I'm calling this "aligning horizontally" because while the inputs, ...
stackexchange_codegolf
This is the Cop post. The Robber post is here. Your task is to take an integer input N and output the Nth digit in the sequence OEIS A002942. The sequence consists of the square numbers written backwards: 1, 4, 9, 61, 52, 63, 94, 46, 18, 1, 121, 441, ... Note that leading zeros are trimmed away (100 becomes 1, not 00...
stackexchange_codegolf
If \$R\$ runners were to run a race, in how many orders could they finish such that exactly \$T\$ runners tie? Challenge Given a positive integer \$R\$ and a non-negative integer \$0\leq T\leq {R}\$ produce the number of possible finishing orders of a race with \$R\$ runners of which \$T\$ tied. Note, however, that run...
stackexchange_codegolf
Challenge In this challenge, we will use a language that is very similar to Brainfuck but slightly different. This variant of BF does not have any input and output commands; instead, it simply takes a tape as input and modifies it until it halts. The final state of the tape is considered the output of the program. The...
stackexchange_codegolf
This is the robbers' challenge. The cops' one is here. In Fewest (distinct) characters for Turing Completeness, the goal is to find the minimum number of characters which make a language Turing Complete...in other words, allow it to do any computation possible with any other language. In this challenge, we'll be doing ...
stackexchange_codegolf
Sandbox Given a boolean matrix representing my grass field, sheep length \$n\$ and wool thickness \$k\$, you will have to count my sheep. A sheep is a single independent unbroken line of sheep length \$n\$ and thickness \$k\$. #|##|# | # #| | #|# are all valid sheep for \$n=2,k=1.\$ ##|###|## | ## ##|###| ## | ## ...
stackexchange_codegolf
For example, how many adjacent swaps are at least needed to convert some string such as BVVKCV to one without any instances of VK? Input-length of the string will be within the range 1 <= length <= 200. VK will be hardcoded across all test cases. Input string examples: Input: VKVKVVVKVOVKVQKKKVVK Output: 8 Input: VV...
stackexchange_codegolf
Your task: given a nonzero positive number i, calculate pi using the Nilakantha series unto i terms. The Nilakantha series is as follows: $$\text 3 + \frac{4}{2 \times 3 \times 4} - \frac{4}{4 \times 5\times 6}+\frac{4}{6 \times 7 \times 8} - ...$$ 3 is the first term, 4/2*3*4 is the second, -4/4*5*6 is the third, and...
stackexchange_codegolf
Background When I was younger, I was taught a method of drawing a weird "S" shape, that I (along with my classmates) found fascinating. Today, I rediscovered it, and due to its formulaic approach to drawing it, thought it could lead to an interesting challenge :P Drawing the "S" The S can be drawn by following these si...
stackexchange_codegolf
Let's just see how this goes If you've ever listened to the radio program "I'm sorry, I haven't a clue", then you've probably heard of the game called "Mornington Crescent". For those who haven't, it's a game where players name random stations on the London Underground network. The first person to name "Mornington Cres...
stackexchange_codegolf
We often get restricted-source questions here on PPCG that favour submitting solutions using only a subset of characters (sufficiently so that there's a tag printable-ascii that identifies a particular subset of those challenges). Wouldn't it be nice if we could automatically cut languages down to a subset of their nor...
stackexchange_codegolf
We all know true and false, but what do speakers around the globe say? +----------------------+------------+------------+ | Language | True | False | +----------------------+------------+------------+ | Arabic | sahih | zaif | | Armenian | irakan | kelc ...
stackexchange_codegolf
The main purpose of the RGB (Red Green Blue) color model is for the sensing, representation and display of images in electronic systems, such as televisions and computers HSL (Hue Saturation Lightness) is an alternative color model, designed in the 1970s by computer graphics researchers to more closely align with the ...
stackexchange_codegolf
Dice Cricket is a game I was introduced to as a child and have used as a way to pass time for years since. I couldn't find a Wikipedia page so I'll explain the rules below. Dice Cricket Rules Premise Dice Cricket is a game similar to scoring a game of cricket as you watch it but rather than watching and recording the r...
stackexchange_codegolf
Challenge: Given a list of integer, sort descending by their single largest digit(s). The order for numbers with the same largest digit are then sorted by second largest digit, etc. We ignore duplicated digits in numbers. And if all digits in a number are the same, the order of those numbers in the list can be in any w...
stackexchange_codegolf
The barfoos, a hypothetical alien species, go about charity in an interesting way. Every morning, barfoo Specialists come up with an ordered list of causes to donate to, and for each cause they recommend what quantity of resources should be donated. That wasn't the weird part. Here's the weird part: A random civilian b...
stackexchange_codegolf
As preparation for the nth Exodus, Noah decides to write a program that will decide If he will let animals on his ark. However, Noah wants to go back to grass roots. Thus he decides that the program should be as small and as simple as possible. GOAL: Recreate the Contrabulous Choosematron, in a way that follows evange...
stackexchange_codegolf
As a follow up to my previous challenge Count to 20 with Words!, we will once again be using the word list from that challenge to perform another task. This time, you will be exclusively using: https://github.com/Magic Octopus Urn/wordListsByLength/blob/master/10.txt To choose 26 different words, each starting with a u...
stackexchange_codegolf
Consider the Atbash transformation: A|B|C|D|E|F|G|H|I|J|K|L|M Z|Y|X|W|V|U|T|S|R|Q|P|O|N Where A ⇔ Z and L ⇔ O, e.g. There is an interesting property that some words share. When some strings are translated to their atbash-equivalent, said translation is the original word reversed. I call these Atbash Self Palindromes. ...
stackexchange_codegolf
Your Task Given a list of words, check if they form a valid word grid. They form a valid grid if there are N words with N letters and they spell the same words vertically as they do horizontally. The words can be given in any order. [FILE, ICED, LEAD, EDDY] = True and [FILE, LEAD, EDDY, ICED] = True. Print True if it i...
stackexchange_codegolf
Task Produce this 24kB ASCII art output: ________ \ \ ________ \____ \ ...
stackexchange_codegolf
I know there have been a lot of challenges about "the two best code-golfers in the world", but this one is a bit more unique, being Round 1 in a series of (future) challenges involving the two of them. Your task is to write a program or function that returns two different non-whitespace ASCII strings, corresponding to...
stackexchange_codegolf
Program: To count the sum of all Unicode characters of a given input. (No need to display the output. The final answer can be calculated in any base no need to convert back to hexadecimal.) Test case : XyZ= 0058+0079+005A=012B Condition: If the program is inputted, then its output must be an integral multiple of 1729 (...
stackexchange_codegolf
I've invented an SQL-like language. Let's call it SelectQL. You can't INSERT anything, you can only SELECT, and I don't have the time for an interpreter. How about you help? The Challenge Write a full program or a function that takes in a database of tables and a valid SelectQL SELECT string, interprets the string, and...
stackexchange_codegolf
Introduction Every letter in the English alphabet can be represented as an ASCII code. For example, a is 97, and S is 83. As we all know, the formula for averaging two numbers \$x\$ and \$y\$ is \$\frac{x+y}{2}\$. I'm pretty sure you can see where this is going. Your challenge is to average two letters. Challenge Yo...
stackexchange_codegolf
The goal of this challenge is to fill a niche that is mostly lacking on this site. In my observations there most parsing verification challenges fall into two categories: Super easy parsing. This parsing can usually be done with a regex, and regex based answers usually do well. Super complex parsing. These are cha...
stackexchange_codegolf
On December 4, 2017, the Google Doodle was a graphical programming game featuring a bunny. The later levels were nicely non-trivial and they seemed like a great candidate for an atomic-golf challenge. Details Game There are four available moves: hop forward, turn left, turn right, and loop. Each of these moves is one ...
stackexchange_codegolf
Write a function or program that, when given a list of names, outputs or returns a list where duplicates of given names have a unique shortened version of their surname. Input: A list of names, where a name is defined by a given name and a last name separated by a space. Names are non-empty strings containing only upp...
stackexchange_codegolf
Generator functions This gives the context for why this challenge came to life. Feel free to ignore. Generator functions are a nice way of encoding the solution to a problem of combinatorics. You just write some polynomials, multiply them and then your solution is the coefficient of one of the terms. For example, how m...
stackexchange_codegolf
An H tree is a fractal tree structure that starts with a line. In each iteration, T branches are added to all endpoints. In this challenge, you have to create an ASCII representation of every second H tree level. The first level simply contains three hyphen-minus characters: --- The next levels are constructed recursi...
stackexchange_codegolf
NOTICE - This challenge is now closed. Any new answers will be ignored and the accepted answer will not change Challenge Write a valid program which, when just two characters in the program are changed, removed or added, completely changes the output. The changed output must have a Levenshtein Distance of 15 or more ...
stackexchange_codegolf
The Fibonacci polynomials are a polynomial sequence defined as: \$F_0(x) = 0\$ \$F_1(x) = 1\$ \$F_n(x) = x F_{n-1}(x) + F_{n-2}(x)\$ The first few Fibonacci polynomials are: \$F_0(x) = 0\$ \$F_1(x) = 1\$ \$F_2(x) = x\$ \$F_3(x) = x^2 + 1\$ \$F_4(x) = x^3 + 2x\$ \$F_5(x) = x^4 + 3x^2 + 1\$ When you evaluate the Fibo...
stackexchange_codegolf
The challenge, should you accept it, is to determine how much you win in the Bingo Golf Flax Lottery. Based on but not equal to the BingoFlax lottery The input is two lists of numbers (positive non-zero integers). The first list always contains 24 potentially non-unique numbers that make up your board, a 5 x 5 grid of ...
stackexchange_codegolf
Be sure to see the other challenge, Reverse ASCII character map! The ASCII charset (American Standard Code for Information Interchange) is the most widely-used character encoding standard. ASCII codes represent text in computers, telecommunications equipment, and other devices. Challenge Your challenge is to print a ...
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
You sell gold coins. Each gold coin you sell is supposed to be 1 ounce. However, you find out that one of your coin suppliers is cheating you. By alloying the gold material with something else, their coins weigh only 0.9 ounces. With a help of a pointer scale (one that shows the exact weight of a quantity of matter set...
stackexchange_codegolf
The Cabbage, Wolf, Goat riddle with a twist! Backstory: There’s an intergalactic river than needs to be crossed! Being a space-ferryman you’ve offered some aliens on your small space ferry that can only carry two entities: you and a passenger. However, you know that because politics, some of these aliens will instantly...
stackexchange_codegolf
Oh, <PROGRAM NAME HERE>, tell me how many character '<CHARACTER HERE>'/s are there in your body. I do not think it a dupe to this. That question asks for printing a list directly but this one requires some input that will cause problem. Your work is to write a quine-like program/function that takes an input of one cha...
stackexchange_codegolf
Do you have any code-golf tips for writing in SOGL, a golfing language created by dzaima? Your tips should be at least somewhat specific to SOGL. Please post one tip per answer.
stackexchange_codegolf
Jason has a big JSON but it's unreadable, so he needs to prettify it. Formatting Spec The JSON has 4 different types: Numbers; Just 0-9 Strings; Double quoted " strings escaped with \ Arrays; Delimited by [], with items separated by ,, items can be any of these types Objects; Delimited by {}, format is key: value wher...
stackexchange_codegolf
Background The number of values for a given type is called the cardinality of that type, and that of type T is written as |T|. Haskell and a few other languages have a certain set of enum types, each of which has a small finite number of values (the exact names vary, so this challenge uses some arbitrarily chosen names...
stackexchange_codegolf
(Meaning: Convert English to Bleet) We have praised goats as god for years now. But if we can't translate English to 'Bleet', the Goat God's language, we cannot communicate with them. So, to communicate with them, we have researched the activities of goats, and retrieved this pattern, which is the core of the language....
stackexchange_codegolf
Given a string as input, print a new string with each letter pushed to the right by its respective alphabet index. We all know that A is a slow and Z is a fast letter. This means that Z gets shifted to the right by 25 spaces, A doesn't get shifted at all and B gets shifted by 1 space. Your program only has to handle up...
stackexchange_codegolf
We are to define the idea of a fixed list as follows: A fixed list is a list of fixed lists. This definition is recursive so it's useful to look at some examples. The empty list [] is a fixed list. And list of empty lists is a fixed list. e.g. [[],[],[]] Any list of the above two is also a fixed list. e.g. [[],[],[[...
stackexchange_codegolf
The challenge is to detect missing integer sequences of files or directories. You have a directory filled with files/directories that are named as integers. The files/directories are generated from multiple threads yet the job did not complete - there are therefore gaps in the sequence. The input is two integers a sta...
stackexchange_codegolf
I think we've all done this as a kid: some websites require a minimum age of 18, so we just subtract a few years from the year of birth and voilà, we 'are' 18+. In addition, for most rides at amusement parks the minimum height to enter is 1.40 meters (here in The Netherlands it as at least). Of course this can be cheat...
stackexchange_codegolf
Challenge A simple challenge: given two or more strings, output all of the substrings that are in each string. Rules Input is always a comma separated list of strings Strings should be outputted from longest to shortest length without duplicates Strings should preserve whitespace Examples Input: aaa,aa Output: aa a ...
stackexchange_codegolf
Given a String and an Array as input, your task is to output the text the input String will print when typed on a typical Mobile Keypad. In a Mobile Keypad, a letter is typed by pressing a button n times, where n is the position of where the letter is at on the button's label. So, 22 should output b. Rules The Helpe...
stackexchange_codegolf
Rearrange a given list such that all the odd numbers appear before all the even numbers. Besides for this requirement, the output list may be in any order. The input will only contain integers, but they may be negative and there may be duplicates, and they may appear in any order. Shortest solution wins. Test cases [1,...
stackexchange_codegolf
The absolute value of a number \$x\$ is normally written as \$|x|\$. The left and right side of the absolute value uses the same symbol, so it is not immediately obvious how to parse nested absolute values e.g. \$||1-2|+|3-|4-5|||\$ Your goal is to parse such an expression containing nested absolute values: The express...
stackexchange_codegolf
Your task is to write a program or function which takes a pure brainflak program as input (assume it contains only balanced ()[]{}<>), and output a visually mirrored copy of it. If you reversed a brainflak program as a string, say ({}()) (add one to an input), you would get ))(}{(, which is not valid. Instead, you shou...
stackexchange_codegolf
The Game You will be playing an (almost) standard game of Connect-4. Unfortunately, it is a correspondence game and someone has placed black tape on every second row starting from the bottom, so that you cannot see any of your opponent's moves within these rows. Any moves within already-full columns will count as passi...
stackexchange_codegolf
You'll get a human-readable question matching one of the following syntaxes, and are expected to print/return the corresponding result. Finding similarities between the human-readable inputs and matching them with minimum size code is explicitly part of the task, so I won't give a formal definition. "Will October begi...
stackexchange_codegolf
I honestly don't know what the point of this sort of calculation would be, but it should make fun golfing. Shortest code wins. Input (in no particular order) An array of integers, a (All elements will be integers less than the length of the array.) An index therein, i An iteration count, n Processing Store a number ...
stackexchange_codegolf
It's not too important anymore, but occasionally somebody needs to know. Here is a simple golf: Taking no user input, tell me if the computer on which the code is run is on a 64-bit operating system, or a 32-bit operating system! If the code is run on a 32-bit operating system, print "32", if the code is run on a 64 bi...
stackexchange_codegolf
You a sequence of numbers like this one given to you as a string: "1 2 3 4 8 11 19 33 59 154 196 260" Create a program (any language) that calculates the smallest outcome you can't get by adding two of those numbers together. The numbers given must be integers, and are always positive. You can only use each number once...
stackexchange_codegolf
Given the Dowker notation of a knot and its crossing signs, calculate its bracket polynomial. Although there are more technical definitions, for this challenge it is enough to think of a knot as something made physically by attaching the two ends of a string together. Since knots exist in three dimensions, when we draw...
stackexchange_codegolf
Six is a number perfect in itself, and not because God created all things in six days; rather, the converse is true. God created all things in six days because the number six is perfect. I am fascinated by numbers. As were Sophie Germain and Marin Mersenne. To be more specific, these two were fascinated by primes: a ...
stackexchange_codegolf
Given a nonnegative integer, return whether it is a three digit number ending in one, in any consistent integer base. In other words, the number needs to be represented in base-N, N being an integer greater than zero. Rules This is code-golf, so shortest answer wins. Since unary behaves weirdly, the behavior with inpu...
stackexchange_codegolf
A radiation-hardened program is a program where, if any character of the code is removed, the program will still function the same. For this question, we'll be writing a program that detects when it is irradiated. Write a program or function that, when any single byte is removed, the resulting program will output that ...
stackexchange_codegolf
The challenge: Given four coordinates, each in x y form, your job is to find out whether or not the given coordinates form a rectangle, and output a truthy/falsey. Rules: For the sake of simplicity, squares, lines (two identical pairs of coordinates) or dots (all four of the coordinates are the same) are all counted a...
stackexchange_codegolf
Dotcomma is a simple esolang I made a while ago that only uses four operators: [.,]. In this challenge, you'll determine if a dotcomma program consisting only of [.] halts. Without ,, there is no input, output, or queue, making this challenge possible. Blocks: Any code wrapped in [] is a block. All blocks and operators...
stackexchange_codegolf
I'm new to this stackexchange, but I must say I am very impressed by the knowledge of some here, and the original codegolf answers for some questions. I'm not even sure if the following is possible, since my programming language knowledge is very limited, but it sounds like a pretty interesting challenge: Goal: Output ...
stackexchange_codegolf
You are given a square matrix of width \$\ge2\$, containing square numbers \$\ge1\$. Your task is to make all square numbers 'explode' until all of them have disappeared. You must print or return the final matrix. More specifically: Look for the highest square \$x^2\$ in the matrix. Look for its smallest adjacent neig...
stackexchange_codegolf
Any two separate nodes in a binary tree have a common ancestor, which is the root of a binary tree. The lowest common ancestor(LCA) is thus defined as the node that is furthest from the root and that is the ancestor of the two nodes. The following are binary trees and the lowest common ancestors of the some of their n...
stackexchange_codegolf
ed is the standard text editor on Unix systems. Your goal is to write an ed clone. Task Write a program that reads an input stream and for every received end of line character, print ? followed by a end of line character. The communication has to interactive. Means the program needs to output as soon as possible and h...
stackexchange_codegolf
The task Given any array of integers, e.g.: [-1,476,578,27,0,1,-1,1,2] and an index of that array (this example uses 0 based indexing, though you can use 1 based indexing as well.): index = 5 v [-1,476,578,27,0,1,-1,1,2] Then return the nearest number greater than the element at that index. ...
stackexchange_codegolf
Here the first 100 numbers of an easy sequence: 0,1,0,2,1,4,3,7,6,11,10,16,15,22,21,29,28,37,36,46,45,56,55,67,66,79,78,92,91,106,105,121,120,137,136,154,153,172,171,191,190,211,210,232,231,254,253,277,276,301,300,326,325,352,351,379,378,407,406,436,435,466,465,497,496,529,528,562,561,596,595,631,630,667,666,704,703,74...
stackexchange_codegolf
Write a program that takes as its input a string consisting of printable characters (ASCII 20-7E) and an integer n in [2,16] and performs the following modification to the string. Each character in the string is converted to its ASCII code (the examples given are in hexadecimal, though base 10 is also acceptable). The...
stackexchange_codegolf
I like the concept of 0815, except the interpreter on the creator's website returns an Error 404. So I decided to ask you all to help! The Basics 0815 is based around three (3) registers and a queue. The registers are named X, Y, and Z, with X being write-only, Z being read-only, and Y being a "helper" register that ca...
stackexchange_codegolf
Chat room: https://chat.stackexchange.com/rooms/106513/easter-bunny-challenge Git repo: https://github.com/AJFaraday/easter_bunny_hunt The garden is a 2-dimensional grid with 49 rows and 49 columns. The Easter Bunny™️ is in the center of the garden, minding his own business, holding on to 100 Easter eggs. He'll hop awa...
stackexchange_codegolf
Let's introduce a simplified variant of the well known Spider Solitaire. From Wikipedia: The main purpose of the game is to remove all cards from the table, assembling them in the tableau before removing them. Initially, 54 cards are dealt to the tableau in ten piles, face down except for the top cards. The tableau pi...
stackexchange_codegolf
Introduction I have a lot of ASCII rocks. They are built with dashes, pipes, Vs, carets, angle brackets, slashes and spaces. Example: /--\ | | | | \--/ I want to erode them, like this: /\ / \ \ / \/ All of the corners have become rounder. A more complicated example: /----\ | \------\ | | | ...
stackexchange_codegolf
Given a set of letter grades, output the GPA (grade point average) of those grades, rounded to one decimal place. Valid grades and their corresponding value are the following: A = 4 grade points A- = 3.7 grade points B+ = 3.3 grade points B = 3 grade points B- = 2.7 grade points C+ = 2.3 grade points C = 2 grade points...
stackexchange_codegolf
Given an integer array of at least two elements, output the Matrix-Vector (defined below) of the array. To compute the Matrix-Vector, first rotate through the size-n input array to create a matrix of size n x n, with the first element of the array following the main diagonal. This forms the matrix portion. For the vect...
stackexchange_codegolf
Your friend Jack is a picky eater. He only likes certain foods, and he only likes to eat a certain amount of them each day. Despite this, Jack has very strict calorie and macronutrient goals that he strives to meet with his diet. To complicate things further, Jack's cravings change day by day, and he will only eat the ...
stackexchange_codegolf
I'm trying to solve a CSS challenge. It contains a rotated leaf shape (looks like an eye). Score for the challenge depends on amount of characters of the code. Here's my way to make a leaf shape: div { width: 200px; height: 200px; border-radius: 99% 0; rotate: 45deg; background: #d9d9d9; } <div></div> He...
stackexchange_codegolf
Pure data is a graphical programming language designed for audio processing. This makes it unsuitable for most general programming but especially unsuitable for code-golf. It would then be nice to have a tips question so that people can get a first foot up in this language. What tips are there for golfing in Pure Data...
stackexchange_codegolf
Note: There are some rude words in this question. There's an implicit puzzle posed in this classic Monty Python sketch (you can also ready the script online). Various phrases are described as being 'woody' or 'tinny', and one is described as being 'PVC'. Given a phrase, respond with its type according to the following...
stackexchange_codegolf
A balanced string is a string of parentheses () so that every parenthesis is can be matched with another one. More rigorously they are the strings spanned by this grammar: S → (S)S | ε We can turn a string "inside out" by: Switching all occurrences of ( and ) with each other Moving characters from the front of the s...
stackexchange_codegolf
Some people count sheep to get to sleep. Others count goats. Write a program or function that takes in a positive integer N and outputs N-1 awake goats followed by one sleeping goat, as if someone was counting N goats and at the very last one they fell asleep. Awake goats look like this: \ ___/o> -(___)" '' ''...
stackexchange_codegolf
I use "sentence" here loosely to mean "any sequence of words separated by spaces" and "words" to mean "sequences of alphanumeric (hexatrigesimal) characters unseparated by spaces". Conversion is from base-36 (0123456789abcdefg...) or (0123456789ABCDEFG...) Conversion to base-16 (0123456789abcdef) or (0123456789ABCDEF)...
stackexchange_codegolf
In the video game Minecraft, you can obtain beacons and put them on pyramid-like structures to give you special effects, such as speed or jump boost. Your task is to, given an effect, construct the beacon pyramid required for it. There are multiple sizes of beacon pyramids, required for different effects. The largest h...
stackexchange_codegolf
Many languages allow strings to be "added" with +. However this is really concatenation, a true addition would follow the group axioms: It is closed (the addition of any two strings is always a string) It is associative ( \$\forall a b . (a + b) + c = a + (b + c)\$) There is an identity (\$\exists e . \forall a . a...
stackexchange_codegolf
Write a function or program that accepts one character (or a string of length 1) as input, and outputs the number of times that character occurs inside the code. This program must be a Proper Quine, only in the sense that it cannot, for example, read itself as a file, etc. Input can be any character, printable or not...
stackexchange_codegolf
In math a magic square is an N×N grid of numbers from 1 to N2 such that every row, column, and diagonal sums to the same total. For example here's a 3×3 magic square: In this challenge we'll extend the idea to magic code squares where, instead of numbers, each grid cell is any non-newline character. They can be be rep...
stackexchange_codegolf
This is the cop's thread. The robber's thread is here. Write a code that takes an input n and creates a n-by-n "snake matrix". A snake matrix is a matrix that follows this pattern: 3-by-3: 1 2 3 6 5 4 7 8 9 and 4-by-4: 1 2 3 4 8 7 6 5 9 10 11 12 16 15 14 13 The exact output format is optiona...
stackexchange_codegolf
look! It's an ASCII maze! Soo coolzors, amazeballs and stuff. +-+-----+---+ | | | | | | ++ | | | | ++ +-+ | | | | +-------+ | | | | | +---------+-+ But, but, but... it's a pain to work out which direction all the parts of the maze are going. I just want to draw the layout and the maze make it...
stackexchange_codegolf
Description of the problem Imagine a quarter of an infinite chessboard, as in a square grid, extending up and right, so that you can see the lower left corner. Place a 0 in there. Now for every other cell in position (x,y), you place the smallest non-negative integer that hasn't showed up in the column x or the row y. ...
stackexchange_codegolf
In this task you are given an odd number of white balls and the same number of black balls. The task is to count all the ways of putting the balls into bins so that in each bin there is an odd number of each color. For example, say we have 3 white balls. The different ways are: (wwwbbb) (wb)(wb)(wb) for the two differ...
stackexchange_codegolf
We don't have a challenge for conversion between Cartesian and polar coordinates, so ... The challenge Write two programs (or functions) in the same language: one that converts from polar to Cartesian coordinates, and the other from Cartesian to polar coodrinates. The score is the sum of the two program lengths in by...
stackexchange_codegolf
Write a program which takes two arrays of positive integers as input. One of them (your choice which) will have one item missing compared to the other. Your program must figure out what is missing. Rules You can choose which array has one missing: You can take ordinary then missing or vice versa. Arrays may contain dup...
stackexchange_codegolf