instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Given a string that contains only lowercase letters, encode that string with the alphabet cipher. To encode with the alphabet cipher (I will be using the example hello): First, convert each letter in the string to a number depending on its position in the alphabet (a = 1, b = 2, etc.) Example: 8 5 12 12 15 Pad each nu...
stackexchange_codegolf
Objective Given a permutation of 4 distinct items, classify the permutation by the normal subgroup(s) it belongs. Input/Output Format You gotta choose the followings as the hyperparameters for your submission: The 4 distinct items. The permutation serving as the identity permutation. The input format is to accept a...
stackexchange_codegolf
This question is based on a question I asked in Spanish language. Yes, I asked for an algorithm in Spanish Language. :) In Spain, current license plates have this pattern: 1234 XYZ where XYZ are three consonants taken from the full set of Spanish consonants (except the 'Ñ', I think). Sometimes, when traveling with ...
stackexchange_codegolf
Challenge This coding challenge is to figure out how many rounds the cat can live. In a \$4\times4\$ matrix, there are a number of mice and exactly 1 cat. Example: $$ \begin{array} {|r|r|}\hline & & & ⬜ \\ \hline ⬜ & & ⬜ & ⬜ \\ \hline ⬜ & ⬜ & ⬜ & \\ \hline & & & \\ \hline \end{array} $$ But in each square of t...
stackexchange_codegolf
The Len(language,encoding) family of languages is a variety of Lenguage derivatives. To encode a program into a Len language, you replace every character with its representation in a certain encoding, then turn that into a giant integer. Your challenge is to write a function or program that encodes your language into a...
stackexchange_codegolf
Your challenge, should you choose to accept it, is to write a program in a language of your choice that, when given a string (limited to printable ASCII) as input, outputs a new program in the same language that outputs that string without using any characters from that string in the code. But this task is impossible a...
stackexchange_codegolf
Your Programs: You'll write two programs (both in the same language). The storage program takes a string from STDIN and stores it somewhere persistent (see below) and then exits without error. The retrieval program takes no input, retrieves the string that was stored, and prints it to STDOUT. Objective test of Persiste...
stackexchange_codegolf
The Game You will be playing an (almost) standard game of Connect-4. Unfortunately, it is a correspondence game and someone has placed black tape on every second row starting from the bottom, so that you cannot see any of your opponent's moves within these rows. Any moves within already-full columns will count as passi...
stackexchange_codegolf
Objective Given a dimension of an SI unit, convert the Lorentz-Heaviside version of a Planck unit \$1\$ into SI metric. What is a Planck unit? Planck units are a set of units of measurement. It defines five fundamental constants of the universe as dimensionless \$1\$. What is a dimension? There are five types of fundam...
stackexchange_codegolf
The challenge is to, given a list of points, sort in a way that, when they are connected in this order, they never intersect. Input format (read from stdin): X Y 1 2 3 4 5 6 ... Output should be the same as input, but sorted. Rules: You can start from any point. The last point must be same as first one, making a clos...
stackexchange_codegolf
Conway's Game of Life is a well known cellular automaton "played" on an infinite grid, filled with cells that are either alive or dead. Once given an initial state, the board evolves according to rules indefinitely. Those rules are: Any live cell with 2 or 3 living neighbours (the 8 cells immediately around it) lives ...
stackexchange_codegolf
The Inspiration The Challenge I'm tired of seeing the same old-same old clock in my top-right-hand corner of my screen. It's time for a new clock. While the clock clock sated my lack of interesting clock for a little while, it simply will do no longer. Your job: make a better, more interesting clock. The Rules Make a c...
stackexchange_codegolf
Given a letter of the English alphabet, your task is to build a semi-diagonal alphabet to the input. How to build a Semi-Diagonal alphabet? Brief Description: First, you take the position of the letter in the alphabet, P (P is 1-indexed here). Then, you print each letter until the input (inclusive) on a line, precede...
stackexchange_codegolf
I like golfing in tinylisp: (d M(q((x)(i x(i(disp x)0(M x))0 But I also like posting explanations with nicely formatted code: (d M (q ((x) (i x (i (disp x) 0 (M x)) 0)))) Can you help me generate the ungolfed code for my explanations? The task Given a line of tinylisp code, return or output the same cod...
stackexchange_codegolf
Let's define a pristine program as a program that does not have any errors itself but will error if you modify it by removing any contiguous substring of \$N\$ characters, where \$1 \le N < \text{program length}\$. For example, the three character Python 2 program `8` is a pristine program (thanks, Sp) because all the...
stackexchange_codegolf
Backstory Not really real, sshh! It all started one day when a coworker brought in a homemade loaf of bread for my boss's birthday. My boss really liked this loaf of bread, and he wanted another. Unfortunately, my coworker has quit, so my boss needs me to give him another loaf. The problem is, I have no idea how to mak...
stackexchange_codegolf
Given a directory (such as C:/), given from stdin or read from a file, produce a directory tree, with each file/folder indented based on its depth. Example If I have a C:/ drive which only contains two folders foo and bar, and bar is empty while foo contains baz.txt, then running with input C:/ produces: C:/ bar/ ...
stackexchange_codegolf
Input The code should take an integer \$n\$ between 1 and 1000. Output The code should output positive integers with \$n\$ bits. Accompanying each integer should be its full factorization. Each integer should be a uniformly random \$n\$ bit number. Score The score for your code will be the number of integers it outputs...
stackexchange_codegolf
Challenge Given an element name, output its electron configuration. Input Your input will be the full name of each element (the range being from Hydrogen, 1, to Calcium, 20) with some exceptions - you should be able to account for the following inputs: Natrium - This is sodium Kalium - This is potassium Note that inpu...
stackexchange_codegolf
Given a string of ASCII art like such (This isn't ASCII art but it will do for the example): abc d e fgh Jumble it as if it was being displayed on a screen with one character per line, like so: a b c d e f g h Print the result, wait one second, ±0.5 seconds before clearing the terminal and the print the same thing, ...
stackexchange_codegolf
Your task is to write a program or a function that prints an ASCII triangle. They look like this: |\ | \ | \ ---- Your program will take a single numeric input n, with the constraints 0 <= n <= 1000. The above triangle had a value of n=3. The ASCII triangle will have n backslashes (\) and vertical bars (|), n+1 line...
stackexchange_codegolf
Your challenge is to write a program that is a quine, meaning it prints out its own source code. For at least one individual character, when it is removed from the program's source, a single different character is removed from the output. By different, I mean that the character removed from the code is distinct from th...
stackexchange_codegolf
Flavortext So...this is awkward. It seems I accidentally turned into a monkey last night after eating one too many banana sundaes. This has made many things inconvenient, especially typing. You see, monkeys only need the following characters: uppercase letters (A-Z), space, comma (,), exclamation mark (!), and question...
stackexchange_codegolf
The world has been invaded by aliens. They are everywhere killing people and taking over the world. You are hiding with your friend. They have one weakness - the high pitched sounds. You can't go yell at them, because you'd get caught before, so you remember the state had a conveniently made machine that emits a high p...
stackexchange_codegolf
Part of the Code Golf Advent Calendar 2022 event. See the linked meta post for details. As a Christmas gift, you were given a toy solar system. In this toy, all the orbits are circular and happen in the same plane. Each planet starts at a fixed location, has a fixed circumference orbit, and moves at a fixed speed (all...
stackexchange_codegolf
The task Given a positive integer c, output two integers a and b where a * b = c and each a and b is closest to sqrt(c) while still being integers. Test cases Input: 136 Output: 17 8 Input: 144 Output: 12 12 Input: 72 Output: 9 8 Input: 41 Output: 41 1 Input: 189 Output: 21 9 Rules a, b and c are all positive int...
stackexchange_codegolf
The Penrose triangle, also known as the Penrose tribar, or the impossible tribar, is an impossible object. The goal in this challenge is to display a Penrose triangle in the fewest bytes possible. Source: Wikipedia Rules: You must display the Penrose Triangle digitally after generating it. They must look the same as ...
stackexchange_codegolf
Two points pand q in a topological space can be separated if there are open sets U and V such that: p is an element of U and q is an element of V U and V do not have any elements in common Your task is given a topology (a set of open sets) and two points p and q (p!=q) to output sets U and V satisfying the above cond...
stackexchange_codegolf
Guide the Alphabet Given an array of directions, where the directions are defined as follows: NW N NE W . E SW S SE Or as indexes (you may use these indices for directions instead of the strings above): 0 1 2 3 . 4 5 6 7 You may choose either format, supporting both is not required by the challenge. Generate ...
stackexchange_codegolf
Question Write a program to accept one string on the console only and print back its letters arranged in alphabetical order. The string must only have the following characters: 0123456789abcdefghijklmnopqrstuvwxyz Rules The ascending alphabetical order is defined in the given string. All repeated characters must be ...
stackexchange_codegolf
Note This is the decryption challenge. The encryption challenge can be found here. Challenge The challenge is to decrypt a given string, using the rules as specified below. The string will only contain lowercase alphabets, digits, and/or blank spaces. If you want to know how the input string has been encrypted, refer t...
stackexchange_codegolf
A Fermi-Dirac Prime is a prime power of the form \$p^{2^k}\$, where \$p\$ is prime and \$k \geq 0\$, or in other words, a prime to the power of an integer power of two. They are listed as integer sequence A050376. While a normal prime factorization generally does not contain a set of distinct primes (for example \$24=2...
stackexchange_codegolf
Input A string of printable ASCII characters, for example: This is an example string. Output For every consonant (BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz) that is not followed by a vowel (AEIOUaeiou) add the last vowel before it, in lowercase. Consonants before the first vowel are left as-is: Thisi isi ana examapal...
stackexchange_codegolf
Please help me automate my discrete mathematics homework. Given a valid propositional formula, check if it is an instance of one of Łukasiewicz's axioms. Here's how it works. A term can be defined inductively as follows: Single lower-case letters of the Latin alphabet (a, b, c, etcetera) are terms. Given a term ϕ, ¬ϕ ...
stackexchange_codegolf
Dedicated to Martin Gardner, taken from his book Background In the old days, the Slavs had a divination method for finding out whether a girl would get married. The girl would clutch six straws in her hand so that the ends would poke out the top and bottom of her fist. Then her friend would join together the ends of pa...
stackexchange_codegolf
Starting with 1, output the sequence of integers which cannot be represented as the sum of powers of earlier terms. Each previous term can be used at most once, and the exponents must be non-negative integers. This sequence starts: 1, 2, 6, 12, 25, 85, 194, 590, 1695, 4879, 19077, 83994, 167988 For example, after 1 an...
stackexchange_codegolf
Input An array that can contain arrays or positive, consecutive, ascending integers. The arrays can have any number of arrays inside of them, and so on and so forth. No arrays will be empty. Output This array simplificated How to simplificate an array We will use the array, [1, [2, 3], [[4]], [[[5, 6], 7, [[[8]]]], 9]]...
stackexchange_codegolf
Introduction We all know and love our Fibonacci sequence and have seen a myriad of challenge on it here already. However, we're still lacking a very simple case which this answer is going to provide: Reversed fibonacci! So given F_n your job is to find n. Specification Input Your input will be a non-negative integer, w...
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
We are doing a PCG challenge at work, and I'm submitting answers in C#. This is a modification of the "M'Kay" challenge. My solution has been deemed correct by the requirements, I'm just trying to shrink it further if possible. A filler word is an apparently meaningless word, phrase, or sound that marks a pause or h...
stackexchange_codegolf
An example will easily explain this to you. Suppose an array [1,2,3,4,5] Step 1 1 2 3 4 5 ----+---- Step 2 5/ 4/ 1 2 3 / ----+/ Step 3 5| 4| 1 2 3| ----+| Step 4 5\ 4\ 1 2 3\ ----+-\ Step 5 Take the sum of face-to-face elements 6 6 3 You just successfully folded an array 1 time. 2 times f...
stackexchange_codegolf
This is the cops' challenge. To post a robber, 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
Write a code to display "I Love You". Without using any built-in tools or functions like echo, System.out.println, printf, ... You are not allowed to directly call any function throughout the program execution, but the system environment or the compiler-generated code might do. This way, you can put your code in a mai...
stackexchange_codegolf
The following data contains the (approximate) population of each UTC timezone in the world (source): UTC;Population (in thousands) -11;57 -10;1853 -9.5;8 -9;639 -8;66121 -7;41542 -6;272974 -5;332101 -4.5;31923 -4;77707 -3.5;499 -3;248013 -2;4855 -1;3285 0;285534 +1;857443 +2;609921 +3;496279 +3.5;81889 +4;129089 +4.5;3...
stackexchange_codegolf
NOTE: Some terminology used in this challenge is fake. For two integers n and k both greater than or equal to 2 with n > k, n is semidivisible by k if and only if n/k = r/10 for some integer r. However, n may not be divisible by k. Put more simply, the base 10 representation of n/k has exactly one digit after the decim...
stackexchange_codegolf
Background The traveling salesman problem (TSP) asks for the shortest circuit that visits a given collection of cities. For the purposes of this question, the cities will be points in the plane and the distances between them will be the usual Euclidean distances (rounded to the nearest integer). The circuit must be "...
stackexchange_codegolf
The Problem: Count the number of holes in a connected polygon. Connectivity of the polygon is guaranteed by the condition that every triangle in the input triangulation shares at least 1 side with another triangle and that there is only one such connected set of triangles. Input is a list L of n points in the plane and...
stackexchange_codegolf
You want to write your English essay. However, all characters on your keyboard broke other than the arrow keys and the enter key. You want to find out how to place the characters so you can write your essay with the least movement. Formally, you have to assign to each character of !"$%&'()+,-./0123456789:;<=?[]`abcdef...
stackexchange_codegolf
(via chat) The OEIS entry A123321 lists the sequence of numbers that are the product of seven distinct primes. For brevity, we'll call this a 7DP number. The first few numbers and their corresponding divisors are below: 510510 = 2 * 3 * 5 * 7 * 11 * 13 * 17 570570 = 2 * 3 * 5 * 7 * 11 * 13 * 19 690690 = 2 * 3 * 5 * 7 *...
stackexchange_codegolf
Time sheets In a work place you often have to complete time sheets. This task is write code to help this. Input Two times in a slightly non- standard 12 hour clock signifying the start and end of the day separated by a space. A third number represents the number of minutes taken for lunch. For example 9:14 5:12 30 Th...
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
This challenge requires integration with C, so you can stop reading if you're not interested. Matrix multiplication is a simple operation, but the performance depends a lot on how efficiently the code is written. Let's compute m = x * y. The following code is the implementation of the textbook algorithm. for (int i = 0...
stackexchange_codegolf
You are a package handler for Big CompanyTM and your job is to load boxes into a truck. These are special, stretchy trucks: their length can be adjusted at will. But stretching trucks are expensive, so keep the truck lengths as short as possible! The Challenge Write a full program or function that, when given the truck...
stackexchange_codegolf
Challenge: Given two integers \$a\$ and \$b\$, with lengths \$A=length(a), B=length(b)\$, output an ASCII-art of the \$a^{th}\$ root of \$b\$, including the answer rounded to \$A\$ amount of decimal places. The size of the ASCII-art root also depends on \$A\$ and \$B\$. Example: \$a=123\$, \$b=1234\$ ____ 123 /123...
stackexchange_codegolf
Disclaimer: This challenge inspired by me spending the morning debugging recursive functions, which have been frying my brain a little. Here's an example of recursion, from a letter, we keep going to the previous letter of the alphabet, printing out each one as we go, until we hit the letter a, then we print that and s...
stackexchange_codegolf
Objective Write a program that outputs some printable ASCII characters. The trick is that if the program is reversed byte-by-byte, it must output the same thing in the reverse order, byte-by-byte, too. Rules No standard loopholes. The program must not be a palindrome, nor can it be 1 byte in length (or empty). No rest...
stackexchange_codegolf
John has made an array of numbers which are important to him. Unfortunately, John lost the array. Luckily, he knows some details about the array. You will receive each of these sets of details (which are lists of 3 integers). Each detail is the sum of a section of the list. Each has the numbers a, the starting index...
stackexchange_codegolf
I need to call my friends but the buttons of my cordless phone are not working properly. The only buttons I can press are [Up], [Down] and [Call]. [Up] and [Down] can be used to navigate in my recent calls and [Call] can be used to call the selected name. My phone has a list that holds N recent calls, and I know that a...
stackexchange_codegolf
Inspired by a restriction on What do you get when you multiply 6 by 9? (42) By order of the President, we are no longer permitted to use confusing fake numbers (i.e. numbers other than integers from 0 to 99 inclusive), and are instead to use only real numbers, that is, those that are not fake. Unfortunately, most maths...
stackexchange_codegolf
Time sheets In a work place you often have to complete time sheets. This task is write code to help this. Input Two times in a slightly non- standard 12 hour clock signifying the start and end of the day separated by a space. A third number represents the number of minutes taken for lunch. For example 9:14 5:12 30 Th...
stackexchange_codegolf
The task: Output a value for x, where a mod x = b for two given values a,b. Assumption a and b will always be positive integers There won't always be a solution for x If multiple solutions exist, output at least one of them. If there aren't any solutions, output nothing or some indication that no solutions exist. Buil...
stackexchange_codegolf
It's Christmas in July, so what better way to celebrate than a virtual white elephant gift exchange! For this King of the Hill challenge, you must create a bot that plays in a White Elephant exchange simulation, trying to get the highest-valued present it can. Game Rules The game will be played over many rounds, each ...
stackexchange_codegolf
An isolated character is a character (other than a newline) that doesn't have an adjacent character of the same type. Adjacent characters can be to the left, the right above or below, but not diagonals. For example in the following text H is isolated: Ybb YH% %%%% All the other characters are not isolated because ea...
stackexchange_codegolf
Intro Given radius \$r\$, draw a circle in the center of the screen. Sandbox. The Challenge Here is a simple challenge. Plot a circle using the formula \$x^2+y^2=r^2\$, or any other formula that will plot a circle according to the given parameters. You may use any units that your language provides, so long as they are ...
stackexchange_codegolf
Note: This challenge has nothing to do with actual assembly language. As the head of Code-Golf Factory Inc., you must create an assembly line to generate a specific piece of code. Today, the foreman has asked you to produce quines. Specification: In this challenge, the goal is to write a quine such that a proper subse...
stackexchange_codegolf
Disclaimer: This challenge inspired by me spending the morning debugging recursive functions, which have been frying my brain a little. Here's an example of recursion, from a letter, we keep going to the previous letter of the alphabet, printing out each one as we go, until we hit the letter a, then we print that and s...
stackexchange_codegolf
Your task is to palindromize a string as follows: Take the string. abcde Reverse it. edcba Remove the first letter. dcba Glue it onto the original string. abcdedcba But here's the catch: since this challenge is about palindromes, your code itself also has to be a palindrome. Remember, this is code-golf, so the code...
stackexchange_codegolf
Challenge: In the last stage of a two players Texas hold 'em, given a two-card hand and five cards on table, determine your probability to win versus an opponent by the standard ranking of poker hands. Input: Seven cards (sdtin or arguments). The first two cards are your hand while the last five are on the table. Each ...
stackexchange_codegolf
Given a string of printable ASCII text (including newlines and spaces) that contains at least one character that is neither a newline nor a space, output a truthy value if the string is rectangular, and a falsey value otherwise. Additionally, the source code for your solution must be rectangular. A string is rectangula...
stackexchange_codegolf
We're back! And this time with an objective scoring criteria! This is a challenge I thought of recently which I think is not hard but allows for a wide range of possible solutions. Seems like a perfect fit for the creativity of PPCG users :) Your Task Define two functions combine and separate with respective types Str...
stackexchange_codegolf
Drunkard's Journey Home In this challenge you are to write a program which simulates a drunkard stumbling his way home from the bar. Input: The input will be an adjacency matrix (representing a directed graph) which represents paths the drunkard can take. At each location, the drunkard will choose one path at random (E...
stackexchange_codegolf
A string is considered to be square if the following conditions are met: Each line has the same number of characters The number of characters on each line is equal to the number of lines. Your task is to write a program or function which determines whether or not a given input string is a square. You may require inp...
stackexchange_codegolf
Inspired by this comment chain... I wanna enklact my way out of this challenge but I can't... @ETHproductions to enklact (v): to implement a lookup table using a subsection consisting of unique elements. Enklacting is a very useful way to compress a lookup table. For example, let's say you had the following list of ...
stackexchange_codegolf
Find what is the distance for a given string to its closest palindrome of the same length. For this task I decided to give the characters further away from the string's center more weight (think of it as contributing more torque), proportional to their distance to the center. Let's define the palindrome distance for a ...
stackexchange_codegolf
A Pythagorean Triple is a positive integer solution to the equation: A Trithagorean triple is a positive integer solution to the equation: Where Δn finds the nth triangular number. All Trithagorean triples are also solutions to the equation: Task Given a positive integer c, output all the pairs of positive integers...
stackexchange_codegolf
It is the year MDLXVII in a world in which the Roman Empire never fell, and the collapse into the dark ages never occurred. Due to the extended period of Pax Romana, the empire's economic stability enabled technology to progress at a rapid rate. The Romans have begun to dabble with circuitry, and have invented an inge...
stackexchange_codegolf
NDos' Numeral System NDos' numeral system is a numeral system invented by me. It represents every nonnegative integer by a binary tree. Given a nonnegative integer \$n\$: If \$n=0\$, it is represented as the empty tree. Otherwise, the tree has a root. With the binary expansion of \$n\$: The left sub-tree of the root...
stackexchange_codegolf
A bracelet consists of a number, \$\mathit{N}\$, of beads connected in a loop. Each bead may be any of \$\mathit{C}\$ colours. Bracelets are invariant under rotation (shifting beads around the loop) and reflection (turning the bracelet over). Here are all \$11\$ bracelets with exactly two beads of each of three differe...
stackexchange_codegolf
Whyte Notation is a classification method mainly for steam locomotive, that classifies by wheel arrangement. On a steam locomotive ( we're only focusing on non articulated locomotives here ), the wheels are generally disposed like this : you have a specific number of leading wheels, then a specific number of driver whe...
stackexchange_codegolf
For this challenge, we are writing the time in the following form: hh:mm:ss Some examples: 12:34:08 06:05:30 23:59:00 The challenge is to output the time after an amount of hours, minutes and seconds have elapsed, with as starting time 00:00:00. You can compare this with a timer that started at 00:00:00. Here is an e...
stackexchange_codegolf
Buzzby Berkeley Robot Hokey Pokey Task Write a program or function to produce an ASCII art animation depicting a line of robots dancing to the lyrics of the Hokey Pokey (or Cokey, if you prefer) in the style of a Busby Berkeley number! Example Output Input Accepts three arguments (assumed to be valid): N = number of r...
stackexchange_codegolf
The code: function L(){N=null;E=[N,N];t=this;h=E;t.u=i=>h=[i,h]; t.o=_=>h==E?N:h[+!(h=h[1])];t.e=(i,l)=>h=(l||h)==E?[i, E]:[(l||h)[0],t.e(i,(l||h)[1])];t.s=_=>{o="";while(i=t.o()) {o+=i+","}return o}} For my response to this (old) question: https://codegolf.stackexchange.com/a/196783/72421 (my linked answer has a com...
stackexchange_codegolf
The periodic table gets its shape from the arrangement of elements into blocks: An element is assigned its block based on what type of orbital holds its valence electron(s). For instance, the sole valence electron of neutral hydrogen occupies the 1s orbital in the 1s subshell, and so hydrogen belongs to the s-block. T...
stackexchange_codegolf
Given a word, decide if it is an ambigram. When rotated: b > q d > p l > l n > u o > o p > d q > b s > s u > n x > x z > z Assume only lowercase letters as input. Test input: this, another, lll, lol, dad, dab, dap, wow, ooi, lollpopdodllol, Ones That Should Return Truthy Values: lll, lol, lollpopdodllol, Note tha...
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
This is my 12th question, so I thought of this idea. Goal: Output 12, with any preceding or trailing whitespace permitted In as many languages as possible (where different versions or flags count as the same language) Without using any numbers The criteria for a valid programming language are the same as those of The ...
stackexchange_codegolf
You task here is very simple: Given a positive integer n without leading zeroes as input, split it in all possible ways Examples Input->Output 111 -> {{111}, {1, 11}, {11, 1}, {1, 1, 1}} 123 -> {{123}, {12, 3}, {1, 23}, {1, 2, 3}} 8451 -> {{8451}, {845, 1}, {8, 451}, {84, 51}, {84, 5, 1}, {8, 45, 1}, {8, 4, 51}...
stackexchange_codegolf
Cops thread Your task as robbers is to find cops solutions and write a program in the language provided that computes the nth term of the sequence using only the bytes in the provided set. The goal will be to crack as many cops answers as possible. With each crack awarding you a single point. Cracks need not be th...
stackexchange_codegolf
Here's an interview question I've seen on a few sites. People claim that an O(n) solution is possible, but I've been racking my brain these last 2 days and I couldn't come up with a solution, nor find one anywhere on the web. Given an array of integers, find two disjoint, contiguous subarrays such that the absolute dif...
stackexchange_codegolf
Challenge In this challenge, we will use a language that is very similar to Brainfuck but slightly different. This variant of BF does not have any input and output commands; instead, it simply takes a tape as input and modifies it until it halts. The final state of the tape is considered the output of the program. The...
stackexchange_codegolf
The barfoos, a hypothetical alien species, go about charity in an interesting way. Every morning, barfoo Specialists come up with an ordered list of causes to donate to, and for each cause they recommend what quantity of resources should be donated. That wasn't the weird part. Here's the weird part: A random civilian b...
stackexchange_codegolf
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
Background We've had challenges before on Fibonacci coding and Zeckendorf representation. These representations follow naturally from Zeckendorf's theorem, which states that every positive integer can be represented uniquely as the sum of one or more distinct, non-consecutive Fibonacci numbers. For example: $$ \begin...
stackexchange_codegolf
Write a program or function that takes in a positive integer N (via stdin/command line/function arg) and prints or returns a string representation of a two dimensional random walk that is N steps long, drawn out of slashes: / \ (plus spaces and newlines for spacing). A 2D random walk starts at the origin of an infinite...
stackexchange_codegolf
This challenge is to write a minimax function in a language of your choice, to output the next best move in an NxN game of tic-tac-toe given the current board state. The board input can be accepted as a Matrix, 2D Collection or anything else that makes sense to you, but adheres to the rules. The output being the next b...
stackexchange_codegolf
Your task is to sort an array containing the strings "quarter", "dime", "nickel", and "penny" any number of times in no specific order and sort them so that they are in this order: quarter dime nickel penny (in other words, greatest to least monetary value). Rules Your program must take an array as input containing...
stackexchange_codegolf
Create a program that find the latest 50 challenges with the code-golf-tag that have at least 20 answers. Then, extract the scores for each language in each of the challenges. If there are more than one answer using the same language, count all scores. Thereafter, take the top 20 most common languages and output a list...
stackexchange_codegolf
The task is simple, given an integer n of how many lines the next n lines is and, a multi-line input, output the resulting 90 degree tilted grid in a clockwise formation. E.g. Input: 2 c d o e Output: o c e d I/O format: Input will have spaces in between them Input always contains alphabetical characters except the ...
stackexchange_codegolf
A palindrome is a word which is spelled the same backwards and forwards. For example, "racecar" is a palindrome as is "redder". A double palindrome is a palindrome whose halves are also palindromes. For example, "abbabba" is a double palindrome, as the half "abba" is also a palindrome. Similarily, "abaababaaba" is a tr...
stackexchange_codegolf
In the UTF-8 encoding bytes of the Form 10****** can only appear within multi-byte sequences, with the length of the sequence already being determined by the first byte. When UTF-8 text is split within a multi-byte UTF-8 character sequence, this prevents that the second part of the sequence is wrongly detected as anoth...
stackexchange_codegolf