instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Gimbap(김밥) is Korean food, somewhat looks like sushi roll. Here is Korean emoticon represent Gimbap : @)))))))))) Your quest is make ASCII Gimbap cutter. Rule Input is string made with only @ and ). Output cuts every valid Gimbap with ), and then add @ between them. So for example @)) to @) @). Valid Gimbap starts wi...
stackexchange_codegolf
A first order separable ordinary differential equation is (arguably) the easiest type of differential equation to solve, and takes the form of $$N(y)\frac{dy}{dx} = M(x) \\ y(x_0) = y_0$$ For two given functions \$N(y)\$ and \$M(x)\$ and an initial condition \$y(x_0) = y_0\$. Your task is to take \$N(y)\$, \$M(x)\$, \...
stackexchange_codegolf
Introduction: I have loads of different ciphers stored in a document I once compiled as a kid, I picked a few of the ones I thought were best suitable for challenges (not too trivial, and not too hard) and transformed them into challenges. Most of them are still in the sandbox, and I'm not sure yet whether I'll post al...
stackexchange_codegolf
Imagine you are given an array/string containing \$5\$ letters of the English alphabet, with each letter having any value from A to Z (inclusive). Every day, each letter will perform a job, which can affect itself or other letters in the array. The letter's job is determined by the letter itself. Most letters are, due ...
stackexchange_codegolf
A Shift matrix is a binary matrix with one superdiagonal or subdiagonal formed by only ones, everything else is a zero. A superdiagonal/subdiagonal is a diagonal parallel to the main diagonal, which is not the main diagonal, i.e. all entries \$a_{ij}\$ where \$i=j+k\$ and \$k \neq 0\$. The main diagonal is defined to b...
stackexchange_codegolf
Write a program that when given a string \$S\$, it generates a program of the same language as itself. The generated program, when given a continuous substring of \$S\$, should predict the next character in an occurence of the subtring in \$S\$. You are guaranteed that this substring occurs exactly once in \$S\$ and do...
stackexchange_codegolf
Background Hello golfers! I would like to learn all the programming languages! But I kinda have a short attention span... and copying all the Hello World examples gets boring... but I like fire! ^w^ Challenge So here is the plan! I want you all to write the smallest code that will compile, print Goodbye Cruel World!, ...
stackexchange_codegolf
The well known cat command simply copies its stdin directly to stdout unchanged. But there are plenty of other commandline tools that exist... What other commands can be used to duplicate the functionality of the venerable cat? Rules You are not allowed to use any shell features, including pipes, file redirection, var...
stackexchange_codegolf
Introduction We all know prefixes and suffixes. But there are other types of affixes that exist too. Such as circumfixes, a type of affix that has two parts, one of which is a prefix and another of which is a suffix. Figuring out whether some string is a prefix or a suffix of some other string is easy, but what about f...
stackexchange_codegolf
It's become somewhat of a tradition in PPCG that some users temporarily change their names by an anagram (a new name formed by reordering the letters of the old). Sometimes it gets difficult to find out who is who. I could use a program or function to tell if two phrases are anagrams of each other. The challenge The pr...
stackexchange_codegolf
In Conway's Game of Life, there is an infinite square grid of cells, each of which is alive or dead. The pattern changes each "generation". A dead cell with exactly 3 live neighbors (orthogonal or diagonal) becomes a live cell. A live cell only lives to the next generation if it has 2 or 3 live neighbors. These simple ...
stackexchange_codegolf
Introduction Our goal is to efficiently find the maximum of a large amount of (redundant) data. We define the outer product of vectors \$A\$ and \$B\$ as a matrix containing the products of all entries of \$A\$ with each entry of \$B\$. (see outer Product) $$ A\otimes B := A\cdot B^T = \left(\begin{array}{rrr} A(1)\cdo...
stackexchange_codegolf
Anyone got tips for golfing in Thue. One tip per answer, and no tips aplicable to all languages (like remove comments)
stackexchange_codegolf
I've been playing around with a robot on the coordinate plane. This robot is able to tell me if it goes left, right, up, or down by reporting back a string consisting of the letters L, R, U, and D, such as DLURRDLURDLLLRRLRLDURRU. Each character represents a movement of one unit. However, it seems that the robot is goi...
stackexchange_codegolf
A problem I sometimes encounter is that when writing comments using LaTeX, the comment is too long. Today you will solve this, by writing code which, given a LaTeX math expression, will produce the shortest equivalent expression. To define equivalent expressions, we will need to specify a (simplified) parser for LaTeX:...
stackexchange_codegolf
Quote notation is a way of expressing rational numbers based on the concept of \$p\$-adic numbers, written in the form \$x'y\$. The quote indicates that the number to it's left (\$x\$) is "repeated" infinitely to the left, then prefixed to the number on the right (\$y\$). For example \$3' = \: ...3333\$ and \$764'31 = ...
stackexchange_codegolf
In @Adám's Dyalog APL Extended, the ⍢ (under) operator means conjugation: apply one function, then a second function, then the inverse of the first. It's fun to think of real-life actions in terms of conjugation: A problem is transformed by g into another domain where it more readily solved by f , and then transfor...
stackexchange_codegolf
Introduction In the strategy game Starcraft 2, there are three "races" to choose from: Terran, Zerg, and Protoss. In this challenge we will be focusing on the Protoss and the iconic phrase "You must construct additional pylons!" This message is stated when you run out of supply to build your army. So, to help out the S...
stackexchange_codegolf
I found it quite hard to achieve a range of numbers as rows in MySQL. For example the range 1-5 is achieved by: SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 will result in: 1 2 3 4 5 for 0-99 I can cross join two 0-9 tables: CREATE TABLE nums as SELECT 0 as num UNION SELECT 1 UNION SELECT ...
stackexchange_codegolf
When Alice was touch typing on her QWERTY keyboard (Figure 1), she accidentally shifted both of her hands rightwards by one key, so q became w, w became e, etc. (p became [). Spaces were not affected because the space bar was quite big. Your task is to help her fix her message using the shortest number of bytes, i.e. u...
stackexchange_codegolf
Pseudo-Quantum Bogosort Quantum Bogosort is as follows: Quantumly randomise the list, such that there is no way of knowing what order the list is in until it is observed. This will divide the universe into O(n!) universes; however, the division has no cost, as it happens constantly anyway. If the list is not sorted, ...
stackexchange_codegolf
I don't like curry. Help me reverse the effects of this evil question - Make me some curry - by uncurrying functions. Task Given a blackbox curried function, output its uncurried equivalent. The curried function will take a single argument and output either another curried function or a value of another type. The uncu...
stackexchange_codegolf
Given \$a\$ and \$b\$, both odd \$n+1\$-bit integers, compute \$a/b\$ to a precision of \$n+1\$ bits in the 2-adic integers. That is, compute \$c\$ such that \$a = bc\, (\mathop{\rm mod} 2^{n+1})\$. \$n\$ should be your language's native integer size, or if native integers are bigints, take it as a parameter. If your l...
stackexchange_codegolf
Challenge Write a function which takes one parameter: an integer t. Your function has to stop your program for t seconds before continuing, similar to time.sleep(t) in Python and WAIT t in BBC BASIC. You must not use any built in waiting functions or any built in functions for executing code after a certain time, and y...
stackexchange_codegolf
2fuck is a simple 2D variation on brainfuck. Like traditional brainfuck, there is an 1D memory tape that extends 30000 bytes to the right from its beginning, consisting of values between 0 and 255. Arithmetic should wrap around, adding 1 to 255 sets the cell to 0, and moving right from memory cell 29999 should move the...
stackexchange_codegolf
Let's say you have a positive integer N. First, build a regular polygon, that has N vertices, with the distance between neighbouring vertices being 1. Then connect lines from every vertex, to every other vertex. Lastly, calculate the length of all lines summed up together. Example Given the input N = 6, build a hexagon...
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
I, uh....honestly can't believe we don't have this one yet. Challenge Write two functions or programs that: Convert from decimal to percentage Convert from percentage to decimal You may also write a single program that does both of the above. Format Percentages must be taken and returned with a percent sign. (In many...
stackexchange_codegolf
This problem (see below) has been given as a High School Programming League code golf challenge. The shortest codes submitted during the contest were: 177 bytes in Ruby, 212 bytes in Python 2.5, 265 bytes in C. Can anyone make it shorter? Other programming languages are also allowed. Problem formulation: Given 8 integ...
stackexchange_codegolf
Let's solve the same task as in this challenge but faster! Input: a non-empty string containing letters a-z Output: the length of a longest (contiguous) substring in which all letters are different Time and space complexity: O(n). The number of letters in the alphabet is 26, or O(1). Make sure you understand how your l...
stackexchange_codegolf
Make a function, method, program or routine that will accept two interger parameters (say x and y) and the total of the two values multiplied. Except straight multiplication is not allowed so you must not simply do something like: int multiply (int x, int y) { return x*y; } Also you must not use a for () loop, lik...
stackexchange_codegolf
Introduction For the ones who never heard of this game before. You are playing a ball which needs to survive as long as possible. This is done by moving to the left or right, going to the holes. Since the map moves upwards, you need to go downwards to survive longer. If you search for images, you probably know which ga...
stackexchange_codegolf
For this challenge, you are to output the result of the sum of some numbers. What are these numbers? Well, you are given input, (a, b), which are integers (positive, negative, or zero) , a != b, and a < b , and each integer within a and b (including them) will have exponents according to the Fibonacci numbers. That's c...
stackexchange_codegolf
Introduction The Prime Counting Function, also known as the Pi function \$\pi(x)\$, returns the amount of primes less than or equal to x. Challenge Your program will take an integer x which you can assume to be positive, and output a single integer equal to the amount of primes less than or equal to x. This is a code-g...
stackexchange_codegolf
Introduction Yes, it's as simple as that. Download any file from the internet! Rules You must use your language's API. You must output the file you downloaded to STDOUT, the console, a file, etc. Input should be empty, or the URL you wish to download, but the url must count to byte count.. Good luck!
stackexchange_codegolf
The TAK function is defined as follows for integers \$x\$, \$y\$, \$z\$: $$ t(x, y, z) = \begin{cases} y, & \text{if $x \le y$} \\ t(t(x-1,y,z), t(y-1,z,x), t(z-1,x,y)), & \text{otherwise} \end{cases} $$ It can be proved that it always terminates and evaluates to the simple function below: $$ t(x, y, z) = \begin{cases}...
stackexchange_codegolf
I was pondering today about how many characters it would take in each language to throw an exception, and noticed there wasn't any existing collection of answers, so: The task Throw an exception in the least amount of characters. If your language does not have exceptions, then a panic is valid. A panic constitutes as a...
stackexchange_codegolf
So, My friend has come up with this interestng question, that is, given two numbers x and y deciding whether their difference: x-yis 0 or less without using any conditionals. The code should return 0 if they are 0 or less, or the result of the subtraction otherwise. My attempt (In Pseudo-Java): try { Math.log(x-y); } c...
stackexchange_codegolf
Given a matrix like this: 1 1 3 -2 3 -4 1 -1 1 1 1 0 0 -1 0 0 By taking a 2×2 "sliding sum", where the sum of every 2×2 region of the matrix is one element of the resulting matrix, we get: 1 1 1 1 -1 1 1 1 1 We can do this for sliding windows of any size. For example, a 1×3 sliding sum of the same input ...
stackexchange_codegolf
This is a very simple challenge. Task Whenever your code is run, your code should output the next sunset date and time in GMT for all capital cities on Earth. You should get the list of capitals from the below table. The dates and times should be outputted sorted by the name of the capital. You don’t need to output t...
stackexchange_codegolf
The title is pretty self-explanatory, isn't it? Your task is to output the alphabet (the string "abcdefghijklmnopqrstuvwxyz") to STDOUT, using each and every letter of the alphabet in your program once and only once. Oh, and for a bit of extra fun? The letters "g", "o", "l" and "f" must be in order (just for the code t...
stackexchange_codegolf
Background It's well known in mathematics that integers can be put into a one-to-one correspondence with pairs of integers. There are many possible ways of doing this, and in this challenge, you'll implement one of them and its inverse operation. The task Your input is a positive integer n > 0. It is known that there e...
stackexchange_codegolf
Inspired by Is this Flow Free puzzle trivial? by @Bubbler. Lengthy chunks of this challenge are borrowed from there. This may be one step of a solution for the linked challenge, depending on chosen strategy. Challenge Given an array of digits 1-9 and a padding character of your choice, output the border of the shape ma...
stackexchange_codegolf
Task Given a positive integer number and a threshold, split into every possible way without generating any numbers above the threshold. Examples Input: 15008 Threshold: 400 Valid Output: [[1, 5, 0, 0, 8], [15, 0, 0, 8] [1, 50, 0, 8], [150, 0, 8]] Invalid outputs: [[1, 5, 0, 0, 8], [15, 0, 0, 8], [150, 0, 8], [1, 500...
stackexchange_codegolf
Input A binary string \$s\$ of length \$n\$ and a positive integer \$k \leq n\$. Output The number of binary strings with Levenshtein distance exactly \$k\$ from the string \$s\$. Example outputs Each example gives the largest possible output for the given \$(n, k)\$ pair. k=1, s=1010, output=14 k=2, s=1010, outupt=55...
stackexchange_codegolf
Given the input of n and value. The code is supposed to nest the single element list with value repeated n times. The final output should be a multilevel nested list with single repeated values in all sublists. This is code-golf, so the shortest code in bytes wins! Test cases: n = 1, value = 'a': ['a'] n = 2, value = '...
stackexchange_codegolf
During the 49 days between Passover and Pentecost, Jewish liturgy provides four numerical problems that I've here phrased as code golf problems. Input/Arguments These four, in any order, and by any means: A text \$L\$ consisting of exactly 7 sentences. The first and last sentences have 7 words each, the middle one ha...
stackexchange_codegolf
An alternating permutation is a permutation of the first \$ n \$ integers \$ \{ 1 ... n \} \$, such that adjacent pairs of values in the permutation alternate between increasing and decreasing (or vice versa). Equivalently, it is a permutation where there are no "runs" of continuously increasing or decreasing values wi...
stackexchange_codegolf
This is the cops' thread. The robbers' thread is here. Your challenge is to write a program or function that, with a certain input, prints the exact string Hello, World! and a newline. Capitalization, spacing and punctuation must be exact. Input may be taken via standard input, a file, or command-line/function argument...
stackexchange_codegolf
There is an asdfmovie video about a pie flavoured pie. Someone also made an edited version with more pies, so I created this challenge. The input is a positive integer. The code should first output the following string: I baked you a pie! Oh boy, what flavour? Then, the next line should be PIE (input number of times)...
stackexchange_codegolf
Introduction Programmers have already solved the trolley problem (a classical problem in philosophy). In the usual trolley problem, we have a directed graph and each edge is weighted by the number of people tied to the track (edge). The objective of the usual trolley problem is to find a path through the graph that min...
stackexchange_codegolf
Problem Given a positive integer n where n < 100 Output a diamond pattern as follows: Input n=1 /\/\ \/\/ Input n=2: /\ /\ //\\/\/\//\\ \\//\/\/\\// \/ \/ Input n=3: /\ /\ //\\ /\ /\ //\\ ///\\\//\\/\/\//\\///\\\ \\\///\\//\/\/\\//\\\/// \\// \/ \/ \\// \/ ...
stackexchange_codegolf
One reason why ISO8601 is the best date string format, is that you can simply append as much precision as you like. Given 2 integers representing seconds and nanoseconds that have passed since 1970-01-01T00:00:00, return an ISO8601 string as described below. Output: The standard output format without timezone looks lik...
stackexchange_codegolf
Given a string s and a positive integer N, gradually duplicate each character more and more until N duplicates, and then staying at N duplicates until N characters away from the end, then step down again. For example, given abalone and 3: a we start with 1 copy bb then 2 copies aaa then 3 copies, which is our sec...
stackexchange_codegolf
It's strange this question hasn't been asked yet, so here it is: Calculate the length of a string given through STDIN Rules As said, your string will be given through STDIN, not via command line arguments Print the length of the string to STDOUT Only ASCII chars will be given, and all printable ASCII chars count! This...
stackexchange_codegolf
Your Goal: Given an odd integer input n greater than 1, generate a random English word of length n. An English word is one in which the odd (1-based) indices are consonants and the even (1-based) indices are vowels, the vowels being aeiou. Random For the purposes of this challenge, you are to sample from the vowels and...
stackexchange_codegolf
I assume everyone here is familiar with the Caesar Cipher that shifts letters to a certain index. https://en.wikipedia.org/wiki/Caesar_cipher for those who still needs introduction. But, we can all agree that plain Caesar is unfun and way too easy. So here's a version that also shifts characters around. This version fi...
stackexchange_codegolf
Inspired by certain puzzles on Flow Free: Warps. Background We all know that L-triominos can't tile the 3x3 board, and P-pentominos can't tile the 5x5 board. But the situation changes if we allow the board to wrap around in both dimensions: L-triominos can tile 3x3 toroidal grid The 3rd tile wraps around through all fo...
stackexchange_codegolf
Several years back, Hot Wheels made a simple flash game called "Formula Fuelers Racers"*. To play the game, you select three ingredients from a fridge to put into your car, which is then raced against the computer's randomly-generated car. It turns out the mechanics of this game are pretty simple. First off, the act...
stackexchange_codegolf
On a recent episode of QI, the first 5 multiples of 142857 were described as anagrams of the original number. Of course, anyone with more than a passing knowledge of that number will know that those numbers are actually cyclic, not just anagrams. But that got me thinking. Please write a program or function that outputs...
stackexchange_codegolf
Related You are a manager at a large number factory. You want to show everyone your business is doing well, by showing randomly chosen samples. Unfortunately, your business is not doing that well. But luckily, you have a bit of ingenuity... Write a program or function that when given an array of unique, positive numbe...
stackexchange_codegolf
Once upon a time I wanted to order custom tokens for a board game. They say they can do it, and then they present me their price list. I was confused because they charge per inch of head movement, and I have no idea how much will my tokens cost. INPUT: a 2d grid: |,-,\,/ are straight cuts. Each has a length of 1. ┌,┐,...
stackexchange_codegolf
Challenge Write a complete program that prints out the time it took to execute a certain part of itself. That part must include a process whose total number of operations (and therefore execution time) is dependent on a user-substituted numeric value - this can be denoted in any way in your code (uppercase N for exampl...
stackexchange_codegolf
The following is an unfolded milk carton: +-----+-\|/-+-----+-\|/-+-+ | | / \ | | / \ | | +-----+/---\+-----+/---\+-+ | | | | | | | | | | | | | | | | | | +-----+-----+-----+-----+-+ \ / \ / \ / \ / \_/ \_/ \_/ \_/ This is a code-golf kolmo...
stackexchange_codegolf
Sometimes lexicographical sorting of strings may cut it, but when browsing the filesystem, you really need better sorting criteria than just ASCII indices all the time. For this challenge, given a list of strings representing filenames and folders in a directory, do a filesystem sort, explained below: Split every stri...
stackexchange_codegolf
As many of you will know, almost every programming language has a standard casing system; unfortunately, we have not been able to agree on a singular system to use and now must frequently switch between camelCase, snake_case, PascalCase and kebab-case. Now I know what you're thinking... wouldn't it be nice if we had a ...
stackexchange_codegolf
Task Given a positive integer n less than 2^30 specified as input in any way you choose, your code should output a random integer between 0 and n, inclusive. The number you generate should be chosen uniformly at random. That is each value from 0 to n must occur with equal probability (see Rules and Caveats). Rules an...
stackexchange_codegolf
In the future when Time Travel (abbreviated as TT) will be common, coin tossing will become a serious mind-sport. To prepare for the future we create a competition for programs where time traveling will be really happening from the viewpoints of the entries. The competition is a round-robin style King of the Hill consi...
stackexchange_codegolf
An linear discrete convolution is an operation that turns two vectors of numbers into a third vector of numbers by multiplying elements inside-out. Formally, for two vectors a and b with elements 0 to n - 1, the discrete linear convolution of a and b can be computed with this loop: for i = 0 to 2*n - 2 c[i] = 0; ...
stackexchange_codegolf
What general tips do you have for golfing in Uiua? I'm looking for ideas that can be applied to code golf problems in general that are specific to Uiua. (e.g. "remove comments" would not be an answer.) Please post one tip per answer.
stackexchange_codegolf
I have so many secrets and nowhere to keep them! The goal is simple: write a program that lets you save a string and have it be protected by a password. The program will take an alias, password and (optional) secret as parameters. If this is the first time the program is called with a given alias, then it will store/re...
stackexchange_codegolf
Introduction OEIS sequence A127421 is the sequence of numbers whose decimal expansion is a concatenation of 2 consecutive increasing non-negative numbers. Put simply, every number in the sequence is formed by putting together n with n+1 for some non-negative, integer value of n. The first several terms are: 1, 12, 23,...
stackexchange_codegolf
Given a string and integer n, split the string at n character, and print as follows: Ex) laptop 3 should print lap top laptop 2 should print la pt op (see how it splits the string at every 2nd char) Special cases: laptop 0 should print laptop (since we split at every 0th char, thus none) laptop 9 should print laptop (...
stackexchange_codegolf
Game of Game of Life Conway's Game of Life is a 0-player game. But that's okay! We can make it a multi-player game. This game is played on the smallest square grid that will accommodate a 6x6 square for each player (12x12 for 2-4 players, 18x18 for 5-9 players, etc). This grid is actually a torus, so it wraps in bot...
stackexchange_codegolf
Inspired by this game Challenge: Given an ASCII art string representing a number, output that number. Example: Input: &&&& ##### .====.. .&&& $$$$$. %% %% % % . +. . @@@ . @@ . = . = . ???? +++. && &&. % % = = $$$ . @@@@@ # # . ===. .$$$$$ ...
stackexchange_codegolf
JavaScript has no direct support for keyword arguments, but it supports argument object destructuring. It is standard to use a destructed final argument for keyword arguments. Here is an example: function f(x, { a = 7, b = 2}){ return [x, a, b]; } You would then call this function like: f(9, {}); // ==> [9, 7, 2] ...
stackexchange_codegolf
Problem Statement: You will receive a substring of a palindromic string. You must return the index of the substring which marks the point of reflection of the original string. You are only provided the substring, which is not necessarily a palindrome because it is not necessarily centered about the middle of the origin...
stackexchange_codegolf
Related but very different. A boustrophedon is a text where every other line of writing is flipped or reversed, with reversed letters. In this challenge, we will just reverse every other line, but leave the actual characters used intact. You may chose which lines to reverse, as long as it is every other one. You may ta...
stackexchange_codegolf
Without using any built-in factoring/polynomial functions, factor a polynomial completely into irreducibles over the integers or a finite field. Input Your program/function will receive some prime (or zero) number n as input. The field/ring is the finite field of that order (ie Z/nZ), or just Z if n is 0. Your program ...
stackexchange_codegolf
Task Write a program/function that when given three 2d points in cartesian coordinates as input outputs a truthy value if they are collinear otherwise a falsey value Three points are said to be collinear if there exists a straight line that passes through all the points You may assume that the coordinates of the three ...
stackexchange_codegolf
Given a list of N lists, each containing M positive integers, and a separate list of M positive integers (target values), return a list of N scalars (integers with a value of 0 or more) that correspond to each list in the lists of lists, such that when each value in a list is multiplied by it's scalar, and the values a...
stackexchange_codegolf
What general tips do you have for golfing in ///? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to /// (e.g. "remove unnecessary whitespace" is not an answer). Tips for itflabtijtslwi and Lines are on-topic and valid here as well. Please post one tip per ...
stackexchange_codegolf
We have a challenge to calculate the hyperfactorial and one to count the trailing zeros of the factorial, so it seems logical to put them together and count the trailing zeros in the hyperfactorial. As a recap, the hyperfactorial of a number, H(n) is simply Πiⁱ, that is, 1¹·2²·3³·4⁴·5⁵·…·nⁿ. It can be defined recursiv...
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
Sequel to Verify Tents and Trees solution. Background Tents and Trees (try here) is a puzzle played on a square (or rectangular) grid, where the objective is to place tents horizontally or vertically adjacent to each of the trees, so that no two tents touch each other in 8 directions (horizontally, vertically, and diag...
stackexchange_codegolf
Given any unsigned 16 bit integer, convert its decimal form (i.e., base-10) number into a 4x4 ASCII grid of its bits, with the most-significant bit (MSB) at the top left, least-significant bit (LSB) at bottom right, read across and then down (like English text). Examples Input: 4242 +---+---+---+---+ | | | | # | ...
stackexchange_codegolf
This is a rewrite of the (currently closed) "Debunking Stroustrup's debunking of the myth “C++ is for large, complicated, programs only”" challenge. Challenge Write the shortest program or function that will: Download http://www.stroustrup.com/C++.html, and List all URLs contained in the HTML document. A "URL" for th...
stackexchange_codegolf
Find the Intersection of 2 Sets in Unioned Interval Notation Given two sets of real numbers described as the union of intervals, output a description of the intersection of these two sets as a union of the same type of interval. The input sets will always consist of unions of intervals such that each interval begins a...
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
Background Often, when storing a number in binary with some maximum, we simply round the maximum to the next power of two then allocate the number of bits nececairy to store the whole range. Lets call the result of this method \$S(x, m)\$ where x is the number and m is the maximum. While not bad, the naive has a few bi...
stackexchange_codegolf
Basing on this SO question. Challenge is rather simple: given a date period in the format YYYYMM output it in the format MMMYY. Rules: The input will be a number or a string exactly 6 characters long, consisting only of digits. Last two digits will be between 01 and 12. Output must be in the form MMMYY, where MMM repr...
stackexchange_codegolf
Katlani is a constructed language being designed in chat. In this challenge, your goal is to print the largest dictionary of katlani nouns possible in 400 bytes or less. Task In 400 bytes or less, your program should print a list of katlani nouns. You can choose to output them as a list/array in your language, or as a ...
stackexchange_codegolf
Inverse function of this challenge To (properly) multiply an string by an integer, you split the string into characters, repeat each character a number of times equal to the integer, and then stick the characters back together. If the integer is negative, we use its absolute value in the first step, and then reverse t...
stackexchange_codegolf
Create a program (any language) which, given positive integer m, outputs a valid C expression that: Uses a single variable x assumed of 32-bit unsigned type (i.e. uint32_t) Would evaluate to range [0, m) for any of the 2³² possible x, reaching any of the m possible outcomes either 2³² / m or 2³² / m + 1 times (where /...
stackexchange_codegolf
Mafia (also known as Werewolf) is a party game that plays roughly like this: The game begins on day 0. After every day n comes a night n. After every night n comes a day n+1. i.e. D0, N0, D1, N1, D2, N2... At the dawn of day 0, a host secretly chooses players to fill certain roles:   Some number of players become th...
stackexchange_codegolf
Polystrips are a subset of polyominoes conforming to the following rules: each piece consist of 1 or more cells no cell can have more than two neighbours the cells should not enclose a hole Free polyominoes are distinct when none is a rigid transformation (translation, rotation, reflection or glide reflection) of ano...
stackexchange_codegolf
Your task is to make a program that measures how fast you can type the letters of the English alphabet. The program shall only accept lowercase letters a to z in alphabetical order. Each letter is echoed as typed on the same line (without new line or any other separators between letters). If you type an invalid char...
stackexchange_codegolf
Introduction Putting all positive numbers in its regular order (1, 2, 3, ...) is a bit boring, isn't it? So here is a series of challenges around permutations (reshuffelings) of all positive numbers. The first challenge in this series is to output a(n) for a given n as input, where a(n) is A064413, also known as the EK...
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
Description The Gameboy stores tiles as 2 bit-per-pixel 8x8 images, thus 16 bytes. Every two bytes is a complete row with all of the Low-bits of each pixel in the first byte, and all of the High-bits of each pixel in the second. Input Input will be exactly 16 bytes, received through Standard IO in one of the following...
stackexchange_codegolf