instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
We've been twice challenged to make 'error quines' (see Make an error quine! and Make a slow error quine maker!), so why don't we try the opposite? Instructions Write a "program" that, when run, produces an error. Copy the error message into a new program, and run it. Repeat Step 2 until the program runs without produ...
stackexchange_codegolf
What general tips do you have for golfing in Grass? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Grass (e.g. "remove no-op characters" is not an answer). Please post one tip per answer.
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
Your job is to output the html of the current version (at the time of this writing) of the Wikipedia page for Kolmogorov complexity: https://en.wikipedia.org/w/index.php?title=Kolmogorov_complexity&oldid=781950121&action=raw (backup) This is code-golf, so the shortest code wins.
stackexchange_codegolf
Chebyshev Polynomials are a family of orthogonal polynomials that pop up in all kinds of places in math, and they have a lot of quite interesting properties. One characterization of them is that they are the unique polynomials that satisfy \$T_n(\cos(x)) = \cos(nx)\$. Challenge Given an nonnegative integer \$n\$, you s...
stackexchange_codegolf
Write a named function or program that computes the quaternion product of two quaternions. Use as few bytes as possible. Quaternions Quaternions are an extension of the real numbers that further extends the complex numbers. Rather than a single imaginary unit i, quaternions use three imaginary units i,j,k that satisfy ...
stackexchange_codegolf
In Russia we have something like a tradition: we like to look for lucky tickets. Here's what a regular ticket looks like: As you can see, the ticket has a six-digit number. A six-digit number is considered lucky if the sum of the first three digits is equal to the sum of the last three. The number on the photo is not...
stackexchange_codegolf
Given string s of even length as input, randomly capitalize exactly half of the letters. You can assume the input will always be a non-zero, even length You can assume the input will consist of only lowercase letters ([a-z]) Exactly half of the letters should be capitalized in the output Every permutation that has exa...
stackexchange_codegolf
The Corpus are a fictional faction from the popular video game Warframe who have a somewhat interesting language. Whilst other factions in the game such as the Grineer have some logic behind their language, the Corpus is simply a lossy substitution of the English language. All Corpus words are the same as their English...
stackexchange_codegolf
The goal is simple, print out each day of the twelve days of Christmas, the text should match this exactly On the first day of Christmas my true love gave to me A partridge in a pear tree On the second day of Christmas my true love gave to me Two turtle doves, and A partridge in a pear tree On the third day of Christ...
stackexchange_codegolf
Task A pure mirror checkmate is a checkmate position, where the mated king is surrounded by 8 empty squares which are attacked or guarded by the winning side exactly once. You will be given a valid chess position where Black is in mate. Your task is to find if that mate is a pure mirror checkmate. Examples (click for l...
stackexchange_codegolf
This challenge has two threads. This is the cops' thread. The robbers' thread is located here. Your challenge is to choose an OEIS sequence and write two full programs in two different languages that produces that nth item in the sequence when given an n via STDIN, or an other forms of standard input, where n is any p...
stackexchange_codegolf
Introduction to Numerical Mathematics This is the "Hello, World!" of PDEs (Partial Differential Equations). The Laplace or Diffusion Equation appears often in Physics, for example Heat Equation, Deforming, Fluid Dynamics, etc... As real life is 3D but we want to say "Hello, World!" and not sing "99 bottles of beer,..."...
stackexchange_codegolf
Consider a grid from \$(0,0)\$ in the bottom-left corner to \$(m,n)\$ in the top-right corner. You begin at \$(0,0)\$, and can only move in one of these three ways: Directly north \$(+0, +1)\$, Directly east \$(+1, +0)\$, or Directly north-east \$(+1, +1)\$ How many different paths are there from your start at \$(0,0...
stackexchange_codegolf
Task Given an integer, n, where 3 <= n < 2^32, calculate the area of a regular n-gon, with an apothem of 1, using the formula A = n * tan(π / n). The apothem of a regular polygon is a line segment from the center to the midpoint of one of its sides. Output the area of this regular polygon as a floating point value sh...
stackexchange_codegolf
The game of xiangqi, also known as Chinese chess, is a chess-like game popular in China, Vietnam, Taiwan, and other East Asian countries. The colours of the two sides in xiangqi are red and black. There are 16 black pieces in xiangqi: the 1 general (G), 2 advisor (A), 2 elephant (E), 2 horse (H), 2 chariot (R), 2 canno...
stackexchange_codegolf
This is inspired by the excellent Visualize Visual Eyes challenge. It is posted with permission from and credit to @Jordan We are going to create an ASCII art approximation of the Xeyes challenge but without worrying about the actual mouse movements. Just the positions. EDIT I thought about whether this could be seen a...
stackexchange_codegolf
A polyglot is a program that can be run in 2 or more different programming languages. What general tips do you have for making polyglots, or choosing languages that are easy to write polyglots for a specific task? Please post the tips that could be applied in most situations. I.e. they shouldn't work only in polyglots ...
stackexchange_codegolf
Your task is simple: Write a program that can be run in two languages. It should be a normal quine (prints its own source code) in language 1, and should be an error quine (generates an error message identical to its own source code) in language 2. This is code-golf, so the shortest valid submission (in bytes) wins. Ru...
stackexchange_codegolf
In this game, you can look inside one box at a time chosen by you. When you do that, you can see how many coins there are in that box. The wizard has one last twist for you. At any point, you can choose to give up on this set of boxes and get him to start the whole process again (with a new random \$x\$). Of course, i...
stackexchange_codegolf
Challenge: Your task is to write as many programs / functions / snippets as you can, where each one outputs / prints / returns an integer. The first program must output the integer 1, the second one 2 and so on. You can not reuse any characters between the programs. So, if the first program is: x==x, then you may not u...
stackexchange_codegolf
This task is simple: Write a program or function that outputs the list of all musical notes (using English note names) from A♭ to G♯. All notes without a name consisting of a single letter (i.e. black notes on a musical keyboard) should have their name printed twice, once as the sharp of a note, once as the flat of one...
stackexchange_codegolf
Prior to the decimalisation of Sterling in February 1971, a pound (£ - from Roman libra) comprised 20 shillings (s - solidus), each of 12 pennies (d - denarius). Additionally, until 1960, each penny could be divided into four farthings (some parts of the Commonwealth also had fractions of farthings, but we'll ignore t...
stackexchange_codegolf
Slope fields or direction fields, are a graphical representation of the solutions to a first-order differential equation of a scalar function. A slope field shows the slope of a differential equation at certain vertical and horizontal intervals on the cartesian plane, and can be used to determine the approximate tangen...
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
Given a positive integer, determine if it can be represented as a concatenation of two square numbers. Concatenated numbers may not begin with 0 (except for 0). Any leading zeros in input should be ignored. Examples 11 -> true // because 1 and 1 are squares 90 -> true // because 9 and 0 are squares 1001 -> true // ...
stackexchange_codegolf
The task In this challenge, your task is to write three programs that form a kind of mutual quine-like system. Let's call the programs A, B and C. If one of the programs is given the source of another program as input, it shall output the source of the third program. For example, if A is given B as input, it outputs C....
stackexchange_codegolf
You have been hired as a research assistant, and asked to create a small program that will build rat mazes. The rat box is always 62x22 and has an entrance (a) and exit (A) for the rat, like this (input 1): #######a###################################################### # ...
stackexchange_codegolf
Given an \$n \times n\$ matrix of integers, The task is to find the optimal dividing line that maximizes the sum of the integers on the same side as the top left corner. The dividing line should be connected and made up of only vertical and horizontal lines. For an example with a non-optimal dividing line: [[ 3, 0,...
stackexchange_codegolf
We have some new sheriffs moderators in town, Mego and DJMcMayhem. We need a challenge to properly honour them for their new positions, so there we go. Here's something that has caught my attention when hovering over their profiles – their user IDs are \$31716\$ and \$45941\$. If you perform digit-wise subtraction, y...
stackexchange_codegolf
The goal is to simplify sentences containing multiple negatives. Like with multiplying negative numbers, two negative words annihilate each other until at most one is left (doesn't matter which one). While some words disappear without a trace, other leave behind a positive part The affected words are: no not couldn't ...
stackexchange_codegolf
Given n numbers in an array (you can't assume they are integers), I would like to compute the product of all subsets of size n-1. You can do this by multiplying all the numbers together and then dividing by each one in turn, as long as none of the numbers is zero. However, how quickly can you do this with no division...
stackexchange_codegolf
Challenge Given the high resolution molecular mass of an organic molecule, output the molecule's molecular formula. Explanation The input will be a single number to three decimal places of precision, the relative molecular mass of the molecule. Here, the molecular mass is defined as the sum of the masses of the atoms i...
stackexchange_codegolf
My previous challenge, Print invisible text was quite popular, likely due to how trivial it is. However those more observant of you may have noticed that you're not really printing invisible text, because it's impossible to read what was inputted given only the output. So I figured how about a real invisible text chall...
stackexchange_codegolf
In APL, you can write tacit functions, called trains. How they work is irrelevant for this challenge. Here are the different ways they can be grouped, using ⍴ as the function: ⍴ -> ⍴ ⍴⍴ -> ⍴⍴ ⍴⍴⍴ -> ⍴⍴⍴ ⍴⍴⍴⍴ -> ⍴(⍴⍴⍴) ⍴⍴⍴⍴⍴ -> ⍴⍴(⍴⍴⍴) ⍴⍴⍴⍴⍴⍴ -> ⍴(⍴⍴(⍴⍴⍴)) ... The order remains the same. The procedure is...
stackexchange_codegolf
Imagine a countable infinite amount of empty rooms. When an infinite amount of guests come, they occupy the 1st, 3rd, 5th...(all odd) empty rooms. Therefore there's always an infinite amount of empty rooms, and occupied guests needn't move when new guests come. - - - - - - - - - - - - - - - - - 1 - 1 - 1 - 1 - 1 - 1 - ...
stackexchange_codegolf
Challenge Given a list of unique colour names as input, sort them in the order that they first appear in Joseph's Amazing Technicolour Dreamcoat. Example Input: green, blue, red, brown Output: red, green, brown, blue The full list of colours, in order, is: 1. red 2. yellow 3. green 4. brown 5. scarlet 6. black...
stackexchange_codegolf
Background An Eisenstein integer is a complex number of the form \$ z = a + b\omega \$ where \$a, b\$ are integers and \$\omega\$ is the third root of unity \$\frac{1-\sqrt3i}{2}\$. The Eisenstein integers can be viewed as the triangular lattice points, as shown in the image below (from Wikipedia): Following the trian...
stackexchange_codegolf
This is the robbers' thread, the cops' thread is here A polyglot is a program, that without modification, can run in multiple languages. Robbers' Challenge First, find a vulnerable cop's answer, then try to find languages that the submission works in, if you found any that weren't listed by the cop, then you just cra...
stackexchange_codegolf
(Despite 60+ questions tagged chess, we don't have a simple n-queens challenge.) In chess, the N-Queens Puzzle is described as follows: Given an n x n chessboard and n queens, arrange the queens onto the chessboard so that no two queens are threatening each other. Below is an example solution for n = 8, borrowed from W...
stackexchange_codegolf
Your challenge: The code must print "Hello, World!" and nothing else. Your restrictions: Your program must satisfy these requirements: The program must be a pangram. It must use every character in printable ASCII, or, if you chose a particularly strange language, characters which are stored as one byte. You are allow...
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
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
Given an integer \$N>3\$, you have to find the minimum number of bits that need to be inverted in \$N\$ to turn it into a square number. You are only allowed to invert bits below the most significant one. Examples \$N=4\$ already is a square number (\$2^2\$), so the expected output is \$0\$. \$N=24\$ can be turned int...
stackexchange_codegolf
Recently, I've seen Hare Krishna people with their mantra on the emblem and I've found it may be quite interesting to code golf. The challenge Write the Hare Krishna mantra, i.e.: Hare Krishna Hare Krishna Krishna Krishna Hare Hare Hare Rama Hare Rama Rama Rama Hare Hare Winning criteria This is code-golf, so shortest...
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
You are given a set of positive integers. You must arrange them into pairs such that: Each pair contains 2 numbers, one of which is a multiple of another. For example, 8 is a multiple of 4, and 9 is a multiple of 9. If the same number occurs many times in the initial set, it can be used that many times in the pairs; a...
stackexchange_codegolf
Basic rules (different from mine) Story It is the year 4579, humans now have 2 hands with 1001 fingers each. Chopsticks has become based off of points. And @Dennis has more rep then @Martin... Hand drawn red circles are now downvoted... Jon Skeet has hit 2 trillion rep on every SE site... Yeah scary I know Chopsticks i...
stackexchange_codegolf
Introduction Street talk can be really difficult to understand, in particular to programmers, who aren't known to be very streetwise. It is your job to create an interpreter to help us all survive in the urban environment. Challenge Given an English sentence as input, create a program or a function that determines whet...
stackexchange_codegolf
Introduction Ah, INTERCAL... As much as I'd like encourage everyone to Try it Online, text output is just painful. According to the docs it uses the "Turing Text Model". While an... interesting concept, using it is about as much fun as shooting yourself in the foot. And what do we do with a task like this? Automate it....
stackexchange_codegolf
Because ARM is the July 2021 LoTM, I figured I'd create the tips thread. ARM is probably the most successful architecture for the digital world. From mobile phones to supercomputers, ARM is everywhere! Consequently, let's have a thread where we can help each other shorten our ARM code. One tip per answer, and no stupid...
stackexchange_codegolf
My brothers and I like to play Cribbage. Now, the scoring rules for Cribbage are somewhat complicated, and I often worry that I'm not counting my score correctly. Therefore, your job is to write a program that will correctly score my hand. Scoring There are two ways to score points in Cribbage: during pegging, and wh...
stackexchange_codegolf
The aim of this challenge is to find an impossibly short implementation of the following function p, in the langage of your choosing. Here is C code implementing it (see this TIO link that also prints its outputs) and a wikipedia page containing it. unsigned char pi[] = { 252,238,221,17,207,110,49,22,251,196,250,2...
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
Given a positive integer n, output the smallest base b >= 2 where the representation of n in base b with no leading zeroes does not contain a 0. You may assume that b <= 256 for all inputs. Test Cases 1 -> 2 (1) 2 -> 3 (2) 3 -> 2 (11) 4 -> 3 (11) 5 -> 3 (12) 6 -> 4 (12) 7 -> 2 (111) 10 -> 4 (22) 17 -> 3 (122) 20 -> 6 (...
stackexchange_codegolf
Given two positive integers \$n\$ and \$b\$, such that \$n > 2\$ and \$n > b > 1\$, count the trailing zeros when converting \$n\$ to base \$b\$. Your program should be able to handle any value of \$b\$ within your integer maximum. The digits of \$n = 18\$, \$b = 3\$ are \$[2,0,0]\$, so the correct output is \$2\$. T...
stackexchange_codegolf
In the original Shantae game, there are transformation dances that you have to input in time using the D-Pad, A, and B. If you complete a predefined sequence while dancing, you will transform into the corresponding form (or teleport or heal). Your task is to output the corresponding effect when given an input. The catc...
stackexchange_codegolf
Fastest code is a scoring method on this site where the goal is to write code that is as fast as possible. From the tag wiki: The winner of a fastest-code challenge is determined by the runtime performance of the submissions. For fairness, all submissions should be benchmarked on the same machine, which usually means ...
stackexchange_codegolf
Write a program or function which, given an input string and a standard deviation σ, outputs that string along the normal distribution curve with mean 0 and standard deviation σ. Normal distribution curve The y coordinate of each character c is: where σ is given as input, and where x is the x axis coordinate of c. Th...
stackexchange_codegolf
Consider, for a given positive integer \$k\$, the sequence \$(a, a+1, a+2, ..., a+k)\$, where \$a\$ is some positive integer. Is there ever a pair \$a, k\$ such that for each element \$a+i\$ in the sequence, either \$\gcd(a, a+i)\$ or \$\gcd(a+i, a+k)\$ are greater than 1? This was investigated by Alan R. Woods as part...
stackexchange_codegolf
Output an infinite sequence of positive integers, such that, for each element in the sequence, all positive integers that have not yet been output have a positive probability of being chosen, and no value is repeated. For example, if the first integer is 3, then 3 may not be output again, but all other positive integer...
stackexchange_codegolf
The problem You just got a new job, hurray! You expect to be given various interesting tasks, and be able to learn a lot in the next few months. Good news, your boss gave you your first work this morning. You are now in charge of... Writting adresses on envelopes. Yay. Fortunatelly, you are not required to write everyt...
stackexchange_codegolf
This challenge is a tribute to the winner of Best Picture at the Oscars 2017, La La Land Moonlight! Write a function/program that takes a string containing only letters [A-Za-z], the four symbols that are common in every day sentences .,'? and spaces, and outputs the string in the style of La La Land. To be more spec...
stackexchange_codegolf
Rules: Your program must print "hello world" when executed Your program must be interpretable or compilable into 2 or more languages Your program must require no input or arguments Languages with identical syntax are too easy, and will be shunned. We all know you can write echo hello world in Bash and Batch, so let's ...
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
TL;DR: Solve this particular challenge, a robot simulation, by stepping on all of the white pads, and avoiding the gray pads. You can step on a white pad any number of times, as long as you step on each white pad at least once. Solutions in languages like Befunge with a 2D instruction pointer would also be accepted, bu...
stackexchange_codegolf
Given a positive integer \$n\$, your task is to find out the number of partitions \$a_1+a_2+\dots+a_k=n\$ where each \$a_j\$ has exactly \$j\$ bits set. For instance, there are \$6\$ such partitions for \$n=14\$: $$\begin{align}&14 = 1_2+110_2+111_2&(1+6+7)\\ &14 = 10_2+101_2+111_2&(2+5+7)\\ &14 = 10_2+1100_2&(2+12)\\ ...
stackexchange_codegolf
Background You awake to find yourself lost in a one dimensional labyrinth! A mystical genie (or something) appears and explains that the exit lies in front of you, but that between you and the exit is a series of challenges. As you wander forward you realize that all of the so-called challenges are merely locked doors....
stackexchange_codegolf
Introduction Unlike English, German is considered to have quite a phonemic writing system. That means that the correspondence between spelling and pronunciation is close. Given any word you aren't familiar with, you would still know how to pronounce it because of the spelling system. This means a computer should be abl...
stackexchange_codegolf
Yet another Jimmy challenge by his original father. See these other lovely challenges. As you all know, recently we've been seeing challenges related to Jimmy on platforms. Now, Jimmy is an acrobat as I mentioned before, and he's got other tricks up his sleeve. One of these tricks is hanging by ropes. Here's an exampl...
stackexchange_codegolf
The task is a rather simple quine challenge with a twist, you must output your source code in the shape of a pyramid. The shape of a pyramid is defined below: 1 234 56789 ABCDEFG HIJKLMNOP QRSTUVWXYZa bcdefghijklmn ......etc...... The main limitation of this challenge is that your quine mus...
stackexchange_codegolf
Let us take a break from the brain-wrecking questions and answer some of the simpler ones You have recently read something extremely funny, and want to express your laughter to the world! But how can you? Task You have to display the string: Lololololololololololololololololololololololololololololololololololololololo...
stackexchange_codegolf
Challenge Premise I've got multiple pretty numbers all in a row. Each is a decimal digit. 0s are weakly attracted to 0s, 1s are attracted to 1s a little more strongly and so on until 9. I don't know why — it must be something I ate. As a result, a sort of two-way sideways sedimentation occurs until the higher values ar...
stackexchange_codegolf
Steven Gerrard was born on 30th of May 1980. He is now 37 years old. Happy birthday, Steven! To celebrate his anniversary, your goal is to remind him the number of goals he has scored each year in premiere league for Liverpool. He doesn't want to remember the goals scored before or after playing for Liverpool. It is l...
stackexchange_codegolf
Given a fraction in the format m/n (where m and n are coprime integers), output the corresponding Unicode fraction. Your program/function will not be expected to take in any input that does not correspond to a Unicode character. Arrays, e.g. [2, 3] as opposed to 2/3, are accepted. m / n as opposed to m/n is also fine. ...
stackexchange_codegolf
It's a common problem to navigate in a 2D matrix. We've seen it many times and will see again. So let's help future us and develop the shortest solutions to generate all eight possible steps in a 2D matrix. Challenge Your code must output the following 8 pairs of -1,0,1 in any order: (0,1) (0,-1) (1,0) (-1,0) (1,1) (1,...
stackexchange_codegolf
Output the area \$A\$ of a triangle given its side lengths \$a, b, c\$ as inputs. This can be computed using Heron's formula: $$ A=\sqrt{s(s-a)(s-b)(s-c)}\textrm{, where } s=\frac{a+b+c}{2}.$$ This can be written in various ways, such as $$ A= \frac{1}{4}\sqrt{(a+b+c)(-a+b+c)(a-b+c)(a+b-c)}$$ $$ A= \frac{1}{4}\sqrt{(a^...
stackexchange_codegolf
This is the robbers' challenge. To post a cop, go here. In this challenge, cops will invent a (likely simple) programming language, and write an interpreter, transpiler, or compiler that allows you to run it. Robbers will write a program in this language that manages to inject arbitrary code into the interpreter, trans...
stackexchange_codegolf
Background You are a rich executive of a software empire. Your time is worth a lot of money. As such, you must always travel in the most efficient route possible. However, as an executive, you spend a lot of time participating in important phone calls. It is paramount that you never drop calls, so you must never travel...
stackexchange_codegolf
You find yourself in a strange place. A frighteningly dark maze, lit only by dim candles resting in the occasional hallway. Numerous paths lie only in impassable darkness, foreboding and-- ...Hm? What? Pick up a candle and carry it with you? No, no, that would be extremely rude. The Task Given a maze as input, output t...
stackexchange_codegolf
Your function must accept two strings and return new string where are UTF-16 code of all symbols is the sum of UTF-16 codes of inputs symbols If the resulting sum is greater than 65535 (maximum UTF-16 codepoint), take the sum modulo 65536 If there are more symbols in one string then sum with zero, codes of symbols wh...
stackexchange_codegolf
Sorry folks, but what I've got for you today is a golf but just limited by JS (or, to be strict, for a day of posting - an ES6 - the most modern set of it - if its ES7 - feel free to EDIT! use MOST MODERN features). So if you afford that restriction - let's proceed! Assume we have JSON root data structure r and some gl...
stackexchange_codegolf
Sometimes, when I'm idly trying to factor whatever number pops up in front of me¹, after a while I realize it's easier than I thought. Take 2156 for example: it eventually occurs to me that both 21 and 56 are multiples of 7, and so certainly 2156 = 21 x 100 + 56 is also a multiple of 7. Your task is to write some code ...
stackexchange_codegolf
Write a program or a function that accepts the list of outputs from a logic function and outputs the LaTeX code for its truth table. The inputs should be labeled as lowercase letters a-z, and the output should be labelled as F. The length of list of inputs will always be shorter than 2^25, which means that number of in...
stackexchange_codegolf
Description You, an armchair cryptanalyst, have noticed that the first letters of each word in your neighbor's mail (yes, you read it -- how else would you know if he's plotting something?) look very suspicious put together. To make sure that his mail is safe to send to its destination, you need to first decode these m...
stackexchange_codegolf
(The text asks how many boxes there are in the picture) Now you are required to generate such a problem and its answer. Input an integer n (optionally) random source of two values, in case you don't want to use the default random. Output can be a 3D array A[n][n][n] of booleans, where A[i][j][k] => (i==0 || A[i-1][...
stackexchange_codegolf
Write a program that is a sonnet, and when run prints out a sonnet. By "sonnet" I mean: 14 lines Each line, when read aloud, has 10 syllables Symbols can be ignored, or pronounced in whatever reasonable way you want. Popularity contest, most upvotes wins.
stackexchange_codegolf
This is essentially the same thing as this question, except harder. You are again to write a program that gets from the lower-left corner of a rectangle to the upper-right corner. However, this time diagonal moves are allowed. The program will accept an ordered pair (width, height), and use these as the dimensions for ...
stackexchange_codegolf
Given an input of a list of words and their abbreviations, output the pattern by which the abbreviations can be formed. Let us take the example input of potato ptao puzzle pzze as an example (that is, the abbreviation for potato is ptao, and the abbreviation for puzzle is pzze). Consider all possible ways to obtain pt...
stackexchange_codegolf
At 1998, Brian Kernighan, while working on the book "The Practice of Programming", wanted to demonstrate realisation of regular expression engine. But struggled to find small engine, that cod could fit in the book. So Brian Kernighan asked Rob Pike to write one for him, and Rob did it gracefully. Here is original sourc...
stackexchange_codegolf
A family of sets is called laminar if for any two sets \$A\$ and \$B\$ in the family one of the following is true: \$ A \subseteq B \$ \$ A \supseteq B \$ \$ A \cap B = \emptyset \$ Or less mathematical: A laminar set is a list of lists that satisfies the following condition: If two elements of the top level list hav...
stackexchange_codegolf
We're going rootin' tootin' cow-poke shootin! This is a simple contest, first program to draw their pistol wins. How it works: I require 2 things from you, an executable, and a command to be run from a bash terminal. The executable needs to do one thing: wait until it receives 'draw!' from STDIN, and then print 'bang!...
stackexchange_codegolf
The task is simple. Write an interpreter for the language *. Here's a bigger link to the wiki. There are only three valid * programs: * Prints "Hello World"  *  Prints a random number between 0 and 2,147,483,647 *+* Runs forever. The third case must be an infinite loop according to the specifications in this question...
stackexchange_codegolf
Curve stitching is the process of "stitching" together multiple straight lines in order to create a curve, like so: For an explanation of curve stitching, visit this website. We will be drawing our curve in the top left of the screen, as shown in the image above. Given an integer n (via STDIN or a function parameter),...
stackexchange_codegolf
0xUsernames There's so many people using a messaging service that they're running out of space to store all the usernames! To fix this, they are going to start storing usernames as hexadecimal, where possible. If a username consists of only the characters 0123456789ABCDEF (case insensitive), it can be converted to a ...
stackexchange_codegolf
Input Two dates, each comprising of a month (Dec or Jan) and a day (01-31). These will be given as 4 integers (12 01 01 01, for example), in any reasonable format you choose (leading zeroes, no leading zeroes, list, individual inputs, list of lists, etc.). The first date is supposed to represent today's date. Output I...
stackexchange_codegolf
Take as input an integer in any reasonable format. Then, output all the proper sub-strings of the base-10 digits of that integer that are powers of two, in any reasonable format. Test cases 10230 -> [1, 2] 13248 -> [32, 1, 2, 4, 8] 333 -> [] 331 -> [1] 32 -> [2] # As 32 is not a proper sub-string, since it is the whole...
stackexchange_codegolf
This challenge is a sequel to Letter Boxed Validator. The New York Times has a daily online game called Letter Boxed (the link is behind a paywall; the game is also described here), presented on a square as follows: You are given 4 groups of 3 letters (each group corresponds to one side on the picture); no letter appe...
stackexchange_codegolf
This challenge is inspired by this app. The test cases are borrowed from that app. This is a fastest-code challenge, where the objective is to solve the largest test cases in the least amount of time. There are provided some smaller test cases, so that people might test their algorithms faster. You'll be given a squa...
stackexchange_codegolf
Challenge This is a simple challenge. Given two positive integers w and h create an ASCII fence with a width of w and a height of h. The fence should be constructed using the following rules: The + character will represent a post. The - character will be used to represent the width of the fence. The | will be used to ...
stackexchange_codegolf