instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Input: A valid 6 HEX digit color code wihout a # prefix Valid: 000000 FF00FF ABC123 Your job is to find to which one of these: Red: FF0000 Green: 00FF00 Blue: 0000FF White: FFFFFF Black: 000000 the input color is the closest too, in this case you try to only match it to black or white when the RGB is the same v...
stackexchange_codegolf
Input The input is a single positive integer n Output The output isn with its most significant bit set to 0. Test Cases 1 -> 0 2 -> 0 10 -> 2 16 -> 0 100 -> 36 267 -> 11 350 -> 94 500 -> 244 For example: 350 in binary is 101011110. Setting its most significant bit (i.e. the leftmost 1 bit) to 0 turns it into 001011110...
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
I was watching the world snooker championship and it got me wondering.. Snooker scoring In the game of snooker there are certain rules that you must adhere too: When there are red balls on the table, during your turn you must first pot a red ball After potting each red ball, you must pot a colored (not red) ball (the ...
stackexchange_codegolf
Satan-Primes who are they? they are Primes containing 666 these are Satan-Primes:[46663,266677,666599,666683,616669] these are NOT :[462667,665669,36363631,555] Plot Every number bigger than 6661 has Satan-Primes behind him The Challenge Given an integer n>6661 find the Satan-Prime behind (or equal) and closest to itse...
stackexchange_codegolf
Sandbox Adapted from exercise 4 of 100 little Keg exercises The ability to repeat chunks of code within a program is an important part of any programming language. Also just as important is the ability to make decisions based on different values. The Challenge I want you to write a program that: Starts at the number ...
stackexchange_codegolf
Given an input string, write a program that outputs the total number of lines and curves it has. The Challenge Take input from STDIN, or any other input method. Output to STDOUT, or any other output method, the total number of lines and curves contained in the string, in that order, based on the below table in the cod...
stackexchange_codegolf
Write some code that acts as a cat program. That is, to input a string and output it as is. But the normal reversion of your code must output the normal reversion of the input string. And the visual reversion of your code must output the visual reversion of the input string. The normal reversion is the reversed charact...
stackexchange_codegolf
Input Integers a1, a2, a3, b1, b2, b3 each in the range 1 to 20. Output True if a1^(a2^a3) > b1^(b2^b3) and False otherwise. ^ is exponentiation in this question. Rules This is code-golf. Your code must terminate correctly within 10 seconds for any valid input on a standard desktop PC. You can output anything Truthy ...
stackexchange_codegolf
Your task Given a integer input, \$ n \$ (such that \$ n > 1 \$), decide whether it can be written as the sum of (at least 2) consecutive square numbers. Test cases Truthy: Input Explanation 5 1 + 4 13 4 + 9 14 1 + 4 + 9 25 9 + 16 29 4 + 9 + 16 30 1 + 4 + 9 + 16 41 16 + 25 50 9 + 16 + ...
stackexchange_codegolf
Given a natural number \$n\$, return the \$n\$-th cuban prime. Cuban Primes A cuban prime is a prime number of the form $$p = \frac{x^3-y^3}{x-y}$$ where \$y>0\$ and \$x = 1+y\$ or \$x = 2+y\$ Details You may use 0 or 1 based indexing, whatever suits you best. You can return the \$n\$-th prime given the index \$n\$ or...
stackexchange_codegolf
Write a program using only printable ASCII characters that takes no input. For reference, here are the 95 printable ASCII characters in order: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ When your program is run it should print 0 (plus an optional trailing newline) t...
stackexchange_codegolf
A palindrome is a string which is the same when read forwards and backwards. For example "racecar" is a palindrome, but "Racecar" is not. A substring is a contiguous set of characters in a larger string. Your task is to write a program or method which takes a string or character array as input and outputs the length of...
stackexchange_codegolf
(Essentially the inverse of Find the needle in the haystack) Given two tuples, (w, h) and (x, y), generate a haystack composed of a single random printable ASCII character of w width and h height with a needle made of a different random printable ASCII character at (x, y) when measured from the upper-left. For example,...
stackexchange_codegolf
To celebrate the island's next Founder's Day, colored filters (fuchsia, chartreuse, and aquamarine*) have been installed in every lighthouse. All lighthouses begin operation with their fuchsia filter, and they are all on the same color cycle: FCA, FCA, ... Each lighthouse changes its color filter after every ON blink,...
stackexchange_codegolf
A near-repdigit number is a positive integer where all the digits are the same, except one. For example 101 and 227 are near-repdigits. A near-repdigit prime is a near-repdigit that is also prime. For example: 101, 113, 131, 151, 181, 191, 199, 211, 223, 227, 229, 233, 277, 311, 313, 331, 337, 353, 373, 383, 433, 443, ...
stackexchange_codegolf
According to TIO there are two types of programming languages: Practical (seen in many corporate environments as a development standard). Recreational (if seen in a corporate environment, you're probably fired). Your Task Mix together one language from each of these realms to achieve the simple goal of calculating th...
stackexchange_codegolf
Challenge: Given an integer \$n\$, guaranteed to be \$\geq2\$ and a power of 2, we are going to draw multiply boards either side-by-side or below one another, where the first has dimensions of \$n\$ by \$n\$; the second \$\frac{n}{2}\$ by \$\frac{n}{2}\$; the third \$\frac{n}{4}\$ by \$\frac{n}{4}\$; etc.; until the fi...
stackexchange_codegolf
You should write a program or function which receives a list of distinct integers as input and outputs or returns the number of occurrences of the input numbers in the following upside-down number pyramid. Starting from the original list in every step we create a new one with the maximal values of every pair of adjacen...
stackexchange_codegolf
Your task is to print out this exact text: - || -|- |--- |-|-- -|-|-- -|----- |-|----- |---|-|-- -|-----|-- ---|-|----- |---|-|----- |---|-----|-- -----|---|-|-- -|-|---|------- ------|---|----- |-|---------|-|-- ---|-----|---|---- -|-----|-|--------- |-|---|-|----------- |-----------|---|-|-- -|-----|-|---------|-- --...
stackexchange_codegolf
You should write a program or function which outputs or returns as much of Chapter I of The Little Prince as it can. Your program or function has to be an M-by-N block of code containing only printable ascii characters (codepoint from 32 to 126) and newlines at the end of each row. You can only use at most 26 character...
stackexchange_codegolf
Given two integers as input in an array, draw a rectangle, using the first integer as width and second as height. Or, if your language supports it, the two integers can be given as separate inputs. Assume the width and height will never be less than 3, and they will always be given. Example Outputs: [3, 3] |-| | | |-| ...
stackexchange_codegolf
Your Task: You all know what a magic square is! But what about a magic cube? A magic cube is the 3D version of a magic square, and is a set of numbers in a cube, where the sums of every straight (not diagonal) line are equal. You must write a program or function that receives an integer, and returns the number of va...
stackexchange_codegolf
Here's one for fans of Cabin Pressure. There is an episode in which the characters devise a new version of Fizz Buzz, which is simplified to contain absolutely no mathematics. It has these rules: If someone says "fizz", you say "buzz". If someone says "buzz", you sing "'ave a banana" If someone says your name, you say...
stackexchange_codegolf
I tested the waters on this sort of question with python, but now I get to the real question I want to ask. restricted-source challenges are uniquely rewarding in Haskell because of Haskell's strict rule set. Type coercion which is the bread and butter for other languages in these sort of challenges is arguably non-ex...
stackexchange_codegolf
Introduction My gnome friends are writing a programming language and have asked for my help. Due to their size, the gnomes can only handle small superscript numbers instead of big numbers. However, the language they're writing the interpreter in only accepts big numbers! Your Challenge Given an input of a superscript n...
stackexchange_codegolf
Prompt: You are given two sets of XY coordinates along with two angles (all are floats): X1 Y1 A1 X2 Y2 A2. The angles are relative to world coordinates: 0 being straight up or north and going clockwise. Your program or function has to return a set of two floats of the XY coordinates the two angles cross at. Example: ...
stackexchange_codegolf
You are to print this exact text: ABABABABABABABABABABABABAB BCBCBCBCBCBCBCBCBCBCBCBCBC CDCDCDCDCDCDCDCDCDCDCDCDCD DEDEDEDEDEDEDEDEDEDEDEDEDE EFEFEFEFEFEFEFEFEFEFEFEFEF FGFGFGFGFGFGFGFGFGFGFGFGFG GHGHGHGHGHGHGHGHGHGHGHGHGH HIHIHIHIHIHIHIHIHIHIHIHIHI IJIJIJIJIJIJIJIJIJIJIJIJIJ JKJKJKJKJKJKJKJKJKJKJKJKJK KLKLKLKLKLKLKLKL...
stackexchange_codegolf
This is the logo for LAPACK, a widely used software library for numerical linear algebra. Your task is to print the logo (color and matrix brackets not required) as this exact string. Trailing newline is allowed. L A P A C K L -A P -A C -K L A P A -C -K L -A P -A -C K L A -P -A C K L -A -P A C -K
stackexchange_codegolf
Challenge Given a string such as Hello World!, break it down into its character values: 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33. Then calculate the difference between each consecutive pair of characters: 29, 7, 0, 3, -79, 55, 24, 3, -6, -8, -67. Finally, sum them and print the final result: -39. Rules ...
stackexchange_codegolf
Challenge Given an integer, n, as input where 0 <= n <= 2^10, output the nth even perfect number. Perfect Numbers A perfect number is a number, x where the sum of its factors (excluding itself) equals x. For example, 6: 6: 1, 2, 3, 6 And, of course, 1 + 2 + 3 = 6, so 6 is perfect. If a perfect number, x, is even, x mo...
stackexchange_codegolf
In the wake of the many (two?) FizzBuzz-related challenges posted recently on PPCG, I've been tempted to come up with my own. Behold... Fizz Buzz Lightyear Write a program or function that takes an integer n and prints out FizzBuzz for any number divisible by 15, Fizz for any number divisible by 3, and Buzz for any num...
stackexchange_codegolf
Background In 1960, the 11th General Conference on Weights and Measures defined the Système International d'Unités (SI) Units which scientists still use today. The metre and the kilogram became standard units in that conference. These were based on powers of 10 (10, 100, 1000, etc.). For example: there are 100 centime...
stackexchange_codegolf
Choose any five characters your language supports. There are 5! = 5×4×3×2×1 = 120 ways these can be arranged into a 5-character string that contains each character once; 120 permutations. Choose your characters such that, when each of the 120 strings is run in your language, the 120 outputs produced will be as many uni...
stackexchange_codegolf
Room Number Locator I have come across an interesting problem solving technique at my job when given the wrong room number from a colleague for a meeting. Every now and then, while on the way to a meeting, a member on my team will send me the wrong room number, typically because they are in a rush at their desk and fat...
stackexchange_codegolf
Let's say we have some arbitrary number: For example 25. We also have some "tokens" (poker chips, money, something similar) with different values. Values of tokens are 2; 3; 4; 5. "Tokens" are limitless You need to achieve number 25 using exactly n tokens (for example, 8) and to output all possible ways of doing so. F...
stackexchange_codegolf
I think the Collatz Conjecture is already well-known. But what if we invert the rules? Start with an integer n >= 1. Repeat the following steps: If n is even, multiply it by 3 and add 1. If n is odd, subtract 1 and divide it by 2. Stop when it reaches 0 Print the iterated numbers. Test cases: 1 => 1, 0 2 ...
stackexchange_codegolf
Intro Reverse and add is as simple as it sounds, take n and add it to its digits in reverse order. (e.g. 234 + 432 = 666). If you apply this process repeatedly some numbers will eventually hit a prime number, and some will never reach a prime. Example I currently have 11431 rep. 11431 is not prime 11431 + 13411 = 2484...
stackexchange_codegolf
In some languages, strings are started and ended with a quote mark ('). And quote itself is escaped by writing it twice sequentially. For example, empty string is written as '', and I'm is written as 'I''m'. This question is about find out all non-overlapping strings from left to right in such format from the given inp...
stackexchange_codegolf
Given a non-empty list/vector of positive integers, write a function to check the following conditions in as few bytes as possible. Take the first integer (the key, or k1) and check that the next k1 values have no duplicate values, excluding instances of k1. Take the last integer (the second key, or k2) and check tha...
stackexchange_codegolf
Summer Klerance, a senior in college, is what her teachers refer to as GBL*. Students in her probability class have been assigned individual problems to work on and turn in as part of their final grade. Summer, as usual, procrastinated much too long, and, having finally looked at her problem, realizes it is considerabl...
stackexchange_codegolf
You have been assigned the task of installing new locks to the company's building. However, the locks you use are quite unusual: they require some combination of keys to open. Now, you want to figure out which locks are the most secure, so you can prioritize the most important locations. The keys you use are numbered b...
stackexchange_codegolf
Task Given two positive integers \$m,n\$, imagine a chessboard of size \$m \times n\$. A chess queen is on the upper-left corner. In how many ways can it reach the lower-right corner, by moving only right, down, or diagonally right-down (possibly moving many steps at once, because it's a queen)? The resulting 2D sequen...
stackexchange_codegolf
Inspired by this challenge (thanks @cairdcoinheringaahing for the title!), your task is to take two printable ASCII strings and multiply them element-wise with the following rules. How does it work? Given two strings (for example split and isbn) you will first, truncate the longer one such that they have equal length a...
stackexchange_codegolf
As part of its compression algorithm, the JPEG standard unrolls a matrix into a vector along antidiagonals of alternating direction: Your task is to take the unrolled vector along with the matrix dimensions and reconstruct the corresponding matrix. As an example: [1, 2, 5, 9, 6, 3, 4, 7, 1, 2, 8, 3], 4, 3 should yiel...
stackexchange_codegolf
This challenge is from a game, Keep Talking And Nobody Explodes. This is like one of those toys you played with as a kid where you have to match the pattern that appears, except this one is a knockoff that was probably purchased at a dollar store. – From the manual Objective The Simon Says module consists of 4 colored ...
stackexchange_codegolf
Notwen wants to study the kinematics of bodies thrown from big heights in a uniform gravitational field but unfortunately he doesn't have the technical possibility to go to sufficiently high places and observe the objects while falling. But who doesn't want to see advances in science so... Let's help Notwen build a gra...
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
It's been a while since I posted here, so here we go another day another challenge. Challenge : Given a number(n) split it into it's prime factors. Input : A positive non-zero integer greater than 2. Output : Decompose the number into it's prime factors and return the number of occurances of each prime in it. Ouput...
stackexchange_codegolf
Here is an ASCII-art of a 4-way intersection: | | | | | | | | | | | | | -----+-----+----- | | - - -| |- - - | | -----+-----+----- | | | | | | | | | | | | | (Note how the horizontal roads are 3 rows tall, while...
stackexchange_codegolf
Specifically, this references JavaScript, a programming language that happens to be one you can run on StackExchange/StackOverflow. However, you may use any programming language to do this challenge. This is not actual JS golfing, but merely a "code-golfable" challenge. Actual complete parsing of JS is not needed. An e...
stackexchange_codegolf
Challenge : \$\pi\$ is supposed to be infinite. That means every number is contained inside the decimal part of \$\pi\$. Your task will be to take a positive integer on input and return the position of this number in \$\pi\$ digits on output. For example, if the input is 59, we'll return 4 Here is why : we will look fo...
stackexchange_codegolf
Write a program that takes in a number N from 1 to 9 inclusive. In its native form your program should output N+N. E.g. output 2 if N is 1, 4 if N is 2, 6 if N is 3, and so on. When every character in your program is duplicated in place, then it should be a program that takes in N (still from 1 to 9) and outputs N×N. E...
stackexchange_codegolf
We don't have a single challenge about drawing a real 3 dimensional cube, so here it goes: Challenge Your task is to draw a rotated, cube with perspective. It can be in a separate window or as an image. Input Your input is 3 separate numbers between 0 and 359.99... These represent the rotation around the x, y and z axi...
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
This is kept fairly original: Write a program that creates a standard blackjack game: input "h" means hit or draw another card input "s" means stand, or take what you have already Rules: cards values are as follows: 2-9 = face value of card 10, J, Q, K = 10 aces = 11 unless player busts, then it's only a 1 if 2 or m...
stackexchange_codegolf
Task description In number theory, the Carmichael function λ takes a positive integer n and returns the least positive integer k so that the k-th power of each integer coprime to n equals 1 modulo n. Given a positive integer n, your solution must compute λ(n). The shortest code in bytes wins. Your program should theore...
stackexchange_codegolf
Background In the game stick ranger, there is an item which grants the character the ability to get critical hits. Each time a projectile hits an enemy, it has some probability to be a critical hit (crit). For most weapons this is calculated independently each time, but for one class (the angel) things work differently...
stackexchange_codegolf
Let A be an m by n rectangular matrix of positive integers, where m and n are also positive integers. We are interested in RoD ('Right-or-Down') paths from the upper-left cell of A to the lower right cell; in an RoD path, each successive cell of the path is either one cell to the Right of or one cell Down from the prev...
stackexchange_codegolf
Your task is to generate a nonsense word that is reasonably pronounceable with the specified number of 'syllables'. Each time the program is run possibly results in a different nonsense word. Pronounceability A pronounceable word is made up of syllables, which are in turn made up of a vowel group that is possibly sandw...
stackexchange_codegolf
There is a parade marching through a city! There are 3 main groups of marchers: the (B)and, Poster (C)arriers, and (F)lag Holders. Also, every (P)oliceman in the whole city is on duty. Flag holders (F) can march anywhere in the parade, but two flag holders cannot march next to each other, unless three or more flag hold...
stackexchange_codegolf
Robbers thread Cops Understanding slicing Remember, slices are zero-indexed. Take this slice: [2:]. If the string is "abcde", the result is "cde" because the slice basically means "get all elements with an index greater than 2." Let's try [1:3]. If there is an end slice, the end slice is not included. (excluded) Theref...
stackexchange_codegolf
Introduction: Since it's almost Halloween, I was just thinking of some random Halloween-themed challenges. Eventually I was reading through Frankenstein's wikipedia page, and came across the following text: The creature Part of Frankenstein's rejection of his creation is the fact that he does not give it a name, which...
stackexchange_codegolf
Background This challenge is based on a personal project I did, UnitDC. This challenge is a super-miniaturized version of UnitDC. Challenge Please write a simple unit-aware calculator that evaluates a sequence of positive integers, units and operators in RPN (postfix) notation, while checking whether the units are comp...
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
This challenge is based on a video in which Andrew Huang discusses unusual time signatures... https://www.youtube.com/watch?v=JQk-1IXRfew In it, he advises that you can understand time signatures by dividing them into 3's and 2's. So you count to a small number a few times, instead of counting to a large number. Here's...
stackexchange_codegolf
Given 2 integer inputs representing the size of the field, x and y, output a path through the field. Example output for 5, 4: # # # ### ### # The whole field is 5 by 4, and there is a path made of hashmarks crossing the field. The path should always start in the top left corner, and go to the bottom right. T...
stackexchange_codegolf
Task Given two lists of characters, output their Cartesian product, i.e. the list of pairings of each letter from the first list with each letter from the second list. Example "123456" and "abcd" give: [["1","a"],["1","b"],["1","c"],["1","d"],["2","a"],["2","b"],["2","c"],["2","d"],["3","a"],["3","b"],["3","c"],["3","d...
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
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
What general tips do you have for golfing in Mini-Flak? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Mini-Flak (e.g. "remove comments" is not an answer). Please post one tip per answer. Mini-Flak is just Brain-flak without [], <...> or <> so tips for ...
stackexchange_codegolf
A space cleaner is a special character which removes all spaces between it and the first non space character to its left and it is represented by a '!' character. If it reaches the beginning of the string it stops. Given a string output the string in any reasonable format after the cleaning process. Trailing spaces at ...
stackexchange_codegolf
Snakes look like this: >>>v @ ^ v ^ >>>^ v ^ v ^<<<<<<<<< The snake can cross over itself as in this case: @ ^ >^>v ^<< For a crossover to be valid, the characters on either side must be moving the same direction. The case of @ >^v ^< can be considered unclear and invalid. The output is a st...
stackexchange_codegolf
Challenge Your challenge is simple, calculate the depth of each matching brackets in the given input e.g. (()()(()))->[[1,1,[1]]], and output it in the form of a list/array/string representation Explanation: For every bracket in the input, you have to count how many nested brackets there are for that part of the input ...
stackexchange_codegolf
How can we depict a turned shape simply and nicely using ascii characters in 3D space? I suggest this method : Instead of a circle we use a square rotated by 45° for the cutting section so that we only need '/' and '\' characters to draw it. /\ / \ \ / \/ And we use '_' character for the profiles: upper, lower ...
stackexchange_codegolf
Write a program that takes in (via stdin or command line) a string with the recursive form PREFIX[SUFFIXES] where PREFIX may be any string of lowercase letters (a-z), including the empty string, and SUFFIXES may be any sequence of strings with the recursive form PREFIX[SUFFIXES] concatenated together, including the e...
stackexchange_codegolf
Input: Two strings (NOTE: the order of input is important). Output: Both words/sentences start on lines with one empty line in between them. They 'walk' horizontally 'next to each other'. But when they have the same character at the same position, they cross each other, and then continue walking 'next to each other'. C...
stackexchange_codegolf
Based on this: Make me a square! You need to output this: #### # # # ### # # # # #### Where "#" is replaced with the input. If you input "A", you should get AAAA A A A AAA A A A A AAAA If you input "&", you should get &&&& & & & &&& & & & & &&&& Leaderboard Here is a Stack Snippet to generate both a reg...
stackexchange_codegolf
From Wikipedia, Gabriel's Horn is a particular geometric figure that has infinite surface area but finite volume. I discovered this definition in this Vsauce's video (starting at 0:22) where I took the inspiration for this problem. You begin with a cake (a cuboid) of dimension \$x \times y \times z\$. In your first sli...
stackexchange_codegolf
Piet is an interesting programming language for a number of reasons. Today we will focus on one reason: the roll command. The roll command was originally from PostScript and is a powerful way to manipulate the stack. The roll command pops the top two elements of the stack and uses them as parameters. We'll call the fir...
stackexchange_codegolf
The solar year is 365 days, 5 hours, 48 minutes, 45 seconds, and 138 milliseconds, according to this video. With the current Gregorian calendar, the rules for leap years are as follows: if year is divisible by 400, LEAP YEAR else if year is divisible by 100, COMMON YEAR else if year is divisible by 4, LEAP YEAR ...
stackexchange_codegolf
The Challenge Write a program or function that takes no input and outputs a 3-dimensional vector of length \$1\$ in a theoretically uniform random direction. This is equivalent to a random point on the sphere described by $$x^2+y^2+z^2=1$$ resulting in a distribution like such Output Three floats from a theoretically ...
stackexchange_codegolf
Task - The title pretty much sums it up: raise an integer x to power x, where 0<x. Restrictions: Use of exponentiation, exp(), ln(), and any other powers-related language built-ins, like pow(), x^x, x**x is forbidden. You can assume that the given integer fits the limits of the programming language of your choice. Te...
stackexchange_codegolf
Recently there have been a couple of ASCII pet snake challenges (e.g. here) 0 0 0 0 0 000 00 0 00 000 0 0 000 0 0 0 00 0 000 This challenge is to take a randomly generated horizontal pet snake (height of five line...
stackexchange_codegolf
or: Build a vertical quine Inspired by Take a stand against long lines. Your task is to build a vertical quine with as short a line length as possible. Scoring Shortest line length (excluding newlines) wins, with code-golf criteria as a tie-breaker. Line length is determined as the longest line in your program excludin...
stackexchange_codegolf
Challenge Choose any number of languages. Call this set L. Write a program so that running it in any language in L produces an interpreter for a different language in L. Each language in L must have exactly one interpreter for it. This is to prevent, for example, Nothing or Text being part of L and all interpreters be...
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
Consider two sorted arrays of integers \$X\$ and \$Y\$ of size \$m\$ and \$n\$ respectively with \$m < n\$. For example \$ X = (1,4)\$, \$Y = (2,10,11)\$. We say that a matching is some way of pairing each element of \$X\$ with an element of \$Y\$ in such a way that no two elements of \$X\$ are paired with the same el...
stackexchange_codegolf
Inspired and looted from this dice challenge by Arnauld Input You are given a 5x1 or 1x5 (your choice) dice matrix which consist of binary 3x3 sub-matrices. Goal Given a valid dice matrix, you are to score it using the rules of 6,5,4 which are as follows: If the roll contains 6,5,4, add the other two dice together and...
stackexchange_codegolf
Part of Advent of Code Golf 2021 event. See the linked meta post for details. Related to AoC2020 Day 11, Part 2. You enter the waiting area for a ferry, and you see a bunch of people sitting at a bunch of seats. The seats form a grid like this (. is a floor, L is an empty seat and # is an occupied seat): LL.#L #.L.L L...
stackexchange_codegolf
Mountain range number A number is a mountain range number if the inequalities satisfied by their consecutive digits alternate. In a way, looking at the number's digits should exhibit a /\/\/\... or a \/\/\/... pattern. More formally, if our number n has \$k\$ digits $$n = d_1d_2d_3\cdots d_k$$ then n is a mountain rang...
stackexchange_codegolf
Summary A new string manipulation language has been made, using only the characters $+#-!*|@>! Your task is to implement an interpreter for it in as few bytes as possible. Input A string, which is a single line of this language. This can be taken in any reasonable way (stdin, function parameter, command line argument e...
stackexchange_codegolf
Based on a list of numbers and their equivalent letters, take a string input, replace the characters of that string with the equivalent number/letter and output the result. List 1 = a 2 = b 3 = c 4 = d 5 = e 6 = f 7 = g 8 = h 9 = i 0 = j Input thisisastring1124 Output t89s9s1str9n7aabd Rules Numbers are equiva...
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
The famous game of Qwirkle has simple but intricate rules (See part 2 of this question for a summary of the rules!) The Challenge You are somehow (text input, function parameter, whatever) given a board of a Qwirkle game, like a snapshot from any current timeframe within a game. This board can be anything from complet...
stackexchange_codegolf
A certain well-known cable company has a somewhat clumsy 'Search for Program' feature that works through the remote. It takes muchly much button pushing; so, being an admirer of economy of motion, I thought I'd seek out a programmer's help to minimize the number of finger movements I have to make. The Craptastic Search...
stackexchange_codegolf
Here's an advanced version of the Count the Liberties challenge. The definitions of the terms liberty and group are the same as the previous challenge, so have a look at the previous one for details, but briefly put, A group is a group of stones that are connected horizontally or vertically. Liberty is the number of e...
stackexchange_codegolf
Some chess variants use interesting non-standard pieces. In order to concisely describe new pieces or to describe pieces without requiring everyone to memorize a bunch of non-standard names some new notation can be invented. In this challenge we are going to look at Parlett's movement notation and convert it to nice at...
stackexchange_codegolf
This is an adaption of Core War, a programming KOTH dating back to the 20th century. To be more specific, it is using an incredibly simplified instruction set primarily based off of the original proposal. Background In Core War, there are two programs battling for control over the computer. The goal of each program is...
stackexchange_codegolf
Your program should print the following: **Language, XXX bytes** ``` CODE ``` or its equivalent. XXX should be substituted by the actual number of bytes your program takes, and CODE should be substituted by the source code of your program. Language should be substituted by the actual language your program is in. Your...
stackexchange_codegolf