instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Given an array A of integers, there exists at least one positive integer p such that A[i] == A[j] for all i and j for which i % p == j % p == 0. Find the smallest p. Examples: Input array: [1, _, 1, _, 1, _, 1, _, 1]. Output: 2 Input array: [1, _, _, 1, _, _, 1, _, _]. Output: 3. Input array: [1, _, _, _, 1, _, _, _, ...
stackexchange_codegolf
Your toy in this challenge is a special abacus of 4 rows and 8 positions per row. There's one bead on the first row, 2 beads on the 2nd row, 3 beads on the 3rd row and 4 beads on the 4th row. Beads on a same row are glued together, which means that they can only be moved as a block. Below is a valid configuration of th...
stackexchange_codegolf
tl;dr? See bottom for The Competition Integer literals While programming, the 64-bit hexadecimal literal 0x123456789abcdefL is difficult to gauge the size of. I find myself mentally grouping digits from the right by fours to see that it's 15 digits' worth. Python PEP 515 allows you to express the above literal, insid...
stackexchange_codegolf
Write a formula using only the digits 0-9, +, *, -, /, % and ^ to output a 1000 distinct primes when given input (which can be used as a variable n in the formula) of numbers 1 to 1000. (Note that / will give the quotient as all arithmetic is integer arithmetic.) Solutions can use ( and ) freely and they will not be co...
stackexchange_codegolf
Your input is an array of numbers: a permutation of \$\{1, 2 \dots n\}\$ for some integer \$n \geq 2\$. How many times must you repeat this list before you can "pick out" the numbers \$[1, 2 \dots n]\$ in order? That is: find the lowest \$t \geq 1\$ so that \$[1, 2 \dots n]\$ is a subsequence of \$\text{repeat}(\text{i...
stackexchange_codegolf
In the esoteric programming language Curly, programs consist solely of curly braces {} and semicolons ;. Despite this humble toolset, Curly has literals that can represent any nonnegative integer. The format is a little hard for the uninitiated to read, though, so let's write some code to do the conversion for us. Form...
stackexchange_codegolf
The task is simple: given a 32 bit integer, convert it to its floating point value as defined by the IEEE 754 (32-bit) standard. To put it another way, interpret the integer as the bit-pattern of an IEEE binary32 single-precision float and output the numeric value it represents. IEEE 754 single precision Here is a conv...
stackexchange_codegolf
Traveling with electronics is always fun, especially when you need an adapter to charge them. Your challenge is to make planning a trip a little easier by checking if a given plug will be compatible with a given socket. Challenge Given a plug type and a socket type, return a value that indicates whether they will work ...
stackexchange_codegolf
Challenge: Take a rectangular figure consisting of the two characters # and (whitespace, ASCII-32), and identify which direction the lines are. The options are: 'Vertical', 'Horizontal', 'Left Diagonal' and 'Right Diagonal'. Input: The input will be a figure of size n-by-m where 5 <= m,n <= 20. There will be two space...
stackexchange_codegolf
disclaimer: I'm not aware of any non-bruteforce solutions A Graeco-Latin square is, for two sets of same length \$n\$, a \$n \times n\$ arrangement of cells, each containing a unique (across the entire square) pair of a element of the first set and a element of the second set, such that all first elements and all sec...
stackexchange_codegolf
You are given an array of strings , you have to construct a single array containing all of them so that the same array of strings can be reconstructed from the large array. The strings may contain any ASCII character. How to determine length of the single large array? Example= let a = ["asd";"dfg";"rew"]. Problem is to...
stackexchange_codegolf
Write a program that accepts HTTP requests on any port of your choice above 1024, and responds to requests on any URL of your choice with its own source code. It must work with, at least, Firefox and Chrome. The code should be delivered as text/plain (removed requirement because none of the answers but one met it) with...
stackexchange_codegolf
Most tip calculator apps simply take a flat percentage of the meal price. So, for example, if your meal is $23.45, you can leave a 15% tip = $3.52, or a more generous 20% tip = $4.69. Convenient enough for credit card users. But not so if you prefer to leave cash tips, in which case these oddball cent amounts get in ...
stackexchange_codegolf
Manually summing a Cubically cube's faces is tedious and time-consuming, sorta like writing code in Cubically itself. In Most efficient cubifier, I asked you to translate ASCII to Cubically source. One of the answers there uses a cube initialization sequence and then modifies the resulting cube based on the sums of the...
stackexchange_codegolf
Introduction Sometimes I get bored and there are no new questions on PPCG, so I want you to dig a random question from PPCG's past. Challenge Given a user's PPCG ID as input (e.g. my ID is 30525), output the URL of a randomly chosen PPCG question. If the question does not meet the following criteria, you must choose an...
stackexchange_codegolf
We say a string is non-discriminating if each of the string's characters appears the same number of times and at least twice. Examples "aa!1 1 !a !1" is non-discriminating because each of the characters , !, a and 1 appear three times. "abbaabb" is not non-discriminating because b appears more often than a. "abc" is ...
stackexchange_codegolf
Cross posted from my anagolf post (note: may contain spoilers, post mortem). Output the following text exactly. You may have additional trailing whitespace on each line, and trailing newlines as well. Shortest code, in bytes, wins. ...
stackexchange_codegolf
This is a new kind of challenge inspired by the Recover the mutated source code problem. You should write two programs or functions both in the same language. The first one should solve Task #1 and the second one should solve Task #2. Your score will be the sum of the longer program and the Levenshtein distance betwee...
stackexchange_codegolf
On the advice of Ms. Pac-Man who's worried about him getting overweight, Pac-Man has decided to keep track of his daily Pac-Dot intake. Help him count the number of Pac-Dots on a given path in the maze! The maze To help you build your own encoding of the maze, you can get some raw data here. Pac-Man's journey In the c...
stackexchange_codegolf
Summary: For any given language, what is the smallest amount of unique characters for your language to be Turing-Complete? Challenge: For any language of your choice, find the smallest subset of characters that allows your language to be Turing-Complete. You may reuse your set of characters as many times as you want. ...
stackexchange_codegolf
This contest is over. Due to the nature of cops-and-robbers challenges, the cops challenge becomes a lot easier when the interest in the associated robbers challenge has diminished. Therefore, while you can still post hash functions, your answer will not get accepted or form part of the leaderboard. This challenge is...
stackexchange_codegolf
The random Fibonacci sequence is defined as follows: $$ f_n = \begin{cases} f_{n-1}+f_{n-2} \text{ with probability } 1/2 \\ f_{n-1}-f_{n-2} \text{ with probability } 1/2 \\ \end{cases} $$ $$ f_1 = f_2 = 1 $$ i.e. whether the next term is the sum or difference of the previous two is chosen at random, independently of ...
stackexchange_codegolf
The bus driver picks up the children from their homes every morning for school. All the homes are positioned around a circular street and the bus driver has to stop at every home exactly once. One monday morning the bus driver decided to only pick up every second child he encountered along his way. However, he still ha...
stackexchange_codegolf
As George Orwell wrote in 1984: War is peaceFreedom is slaveryIgnorance is strength Write a program or function that takes in one of the six main words from the Orwell quote and outputs its counterpart. Specifically: [input] -> [output] war -> peace peace -> war freedom -> slavery slavery -> freedom ignorance -> stre...
stackexchange_codegolf
This task is about compressing and processing a sequence of conditionals. In the game Keep Talking and Nobody Explodes, a bomb defuser must disarm a bomb with the help of instructions relayed by experts consulting a convoluted Bomb Defusal Manual. This challenge deals with the module "On the Subject of Wires", explain...
stackexchange_codegolf
Introduction A childhood game designed to help children learn to count in french in Canadian schools is played as follows: Students go around the room counting up to 11 A number greater than 11 cannot be said A student can say either 1, 2, or 3 numbers If a student says the number 11 then they are removed from the nex...
stackexchange_codegolf
This time I will give you an easy challenge: Print the Om sign with \$\pi\$!(Sorry for many challenges with \$\pi\$) Here is the om sign drawn using pi numbers: 59 0 64 230781 3.14159 26 502884 535 83279 1971 89 433 6939 79 44 937 ...
stackexchange_codegolf
The premise of this is simple: A 10% chance is pretty unlikely, but everyone knows that a one-in-a-million chance is a sure thing! So, write code that implements the following "dramatic" probability rules: Take in a floating point P from 0 to 1 representing the unmodified chance of some plot-related event, and a boole...
stackexchange_codegolf
Background For my code-golf submissions in C, I need a processing tool. Like in many other languages, whitespace is mostly irrelevant in C source (but not always!) -- still makes the code much more comprehensible for humans. A fully golfed C program that doesn't contain a single redundant whitespace often is barely rea...
stackexchange_codegolf
Introduction Your job is to write a function or program that detects if a number a is less than a number b. But... You are not allowed to use built-in alternatives for equals, less than, greater than, less than or equal to, greater than or equal to, or not equal to operators. (Writing your own implementation is allowed...
stackexchange_codegolf
Above, you can see an image full of different colours. Click here for a hex-dump. One possible way to generate this image is by using a linear gradient rotated 90 degrees, however, this may not be the only way. Your task is to create a self-contained program that takes no input, and outputs an image with the same RGBA...
stackexchange_codegolf
Related: Multiply Quaternions Challenge Given a string made of ijk, interpret it as the product of imaginary units of quaternion and simplify it into one of the eight possible values 1, -1, i, -i, j, -j, k, -k. The evaluation rules are as follows: $$ ii = jj = kk = -1 \\ ij = k, \quad jk = i, \quad ki = j \\ ji = -k, \...
stackexchange_codegolf
Background: Take this input as an example: 1 1 2 1 1 2 1 3 1 3 If you look only at the first few digits, between 1 1 2 and 1 1 2 1 1 2 1, this input appears to consist of the pattern 1 1 2 repeating indefinitely. This would make its period 3, as there are 3 numbers in the pattern. Given only the first number, the peri...
stackexchange_codegolf
Challenge Implement a program that given three strings a, b, and c, substitutes all instances of the substring b in a with c. In other words, implement Ruby's String#gsub with strings instead of regexes (a.gsub b, c). Rules Standard loopholes apply. You may not use a builtin that performs this exact task. This is code...
stackexchange_codegolf
Background I want to display rich, vibrant images on my theoretical fancy custom display, but due to budget constraints, it displays everything in 3-bit colour! Whilst Regular Dithering would work, I don't want to sacrifice resolution, so I would like my images to be dithered through time! Specs Provided an Input Image...
stackexchange_codegolf
Your mission today is to create a vortex given a single parameter. This parameter determines the length of each arm in characters. Each "layer" of each arm contains one more character than the last. Here's how the vortex will look, given the arm length: 0: # 1: # ### # 2: # # # ### # # # 3: ## # ...
stackexchange_codegolf
You get a string which contains an integer between 1000 and 99999999 as input. The input string might contain leading zeroes but cannot be longer than 8 characters. Your goal is to output all dates between 6th of December 1919 and 5th of December 2019 which fit the input in these formats: day - month - year (dmy) mont...
stackexchange_codegolf
Your challenge is to write a program (full program, not a function), that will take an integer and output all prime numbers up to (including) the given integer. Output is any readable list containing all integer primes (array, string, 1 prime per line, whatever you want) and must run to stdout or equivalent. Simple? He...
stackexchange_codegolf
Your code may not contain the letter "e", but must count the number of "e"s in the inputted string and output that as a number. Bonus points if you use a language that is not a codegolf language and a language that actually uses the letter e (unlike brainfuck) --- not a required criteria.
stackexchange_codegolf
The goal is to raise the error message with the most bytes! The error message may not be generated by the program itself, such as Python's raise. errors that do not terminate the program are not allowed unless they do not show an error message. Here is an example in python that raises 243041 bytes of error code: def a(...
stackexchange_codegolf
Consider the number 99999999. That number is obviously a palindrome. The largest prime factor of 99999999 is 137. If you divide 99999999 by 137, you get 729927. This number is also a palindrome. The largest prime factor of 729927 is 101. 729927/101=7227 which again is a palindrome. The largest prime factor of 7227 is...
stackexchange_codegolf
A cyclic difference set is a set of positive integers with a unique property: Let n be the largest integer in the set. Let r be any integer (not necessarily in the set) greater than 0 but less than or equal to n/2. Let k be the number of solutions to (b - a) % n = r where a and b are any members of the set. Each solu...
stackexchange_codegolf
A manufacturing company wants to print a design on mats of varying dimensions, and they hired you to program a robot to make these mats. The design consists of alternating rings of any 2 symbols on a mat. Below are some sample looks: Column 9 by Row 7 Symbol 1: @ Symbol 2: - Input: 9 7 @ - @@@@@@@@@ @-------@ @-@@@@@-@...
stackexchange_codegolf
Goal: create a self-referencing tuple satisfying x == (x,) in any version of Python. Standard libraries, matplotlib, numpy, pandas only. Answers meeting this extra condition are prioritised (which may be impossible): this tuple should also be insertable into a dict or set. If the extra condition is impossible, apart fr...
stackexchange_codegolf
C++ implements a Turing-complete functional programming language which is evaluated at compile time. Hence, we can use a C++ compiler as an interpreter to run our metaprogram without ever generating code. Unfortunately, static_assert won't allow us to emit our result at compile-time, so we do need* to generate an exec...
stackexchange_codegolf
A simple way to scramble a 2x2x2 Rubik's cube is to make a sequence random moves. This is not how official scrambles are done, but can get pretty close to a uniform distribution of all possible scramble states. Due to the way a 2x2 only has two layers, doing one turn on one face is equivalent (without considering the p...
stackexchange_codegolf
Given an 8086 segmented ("logical") memory address, output its actual linear physical address. A segmented memory address has format xxxx:xxxx, where each of x is one of 0-9A-F, and the two parts are parsed as hexadecimal integers. Both parts are exactly 4 digits. To get its actual linear address, multiply the first pa...
stackexchange_codegolf
This challenge is to golf an implementation of SKI formal combinator calculus. Definition Terms S, K, and I are terms. If x and y are terms then (xy) is a term. Evaluation The following three steps will be repeated until none of them apply. In these, x, y, and z must be terms. (Ix) will be replaced by x ((Kx)y) will be...
stackexchange_codegolf
Write a program that has at least one byte that, when run, does absolutely nothing. I thought this would be done by now, but I can't find any other challenges like this. How to tell if it does nothing: No variables are declared Nothing is returned Input does nothing You could run a program after it and it would run no...
stackexchange_codegolf
This rar file, when decompressed, gives a 65024-byte exe file. Requiring you to output the contents of that file would be absolutely no fun. But you aren't required to do that. Actually, you're to do something opposite: Output a binary of the same length (65024 bytes), such that no byte equals the byte at same position...
stackexchange_codegolf
What is the Fibonacci Rectangular Prism Sequence? The Fibonacci Rectangular Prism Sequence is a sequence derived from the Fibonacci sequence starting with one. The first 3 numbers of the Fibonacci sequence (starting with one) are 1, 1, and 2, so the first number of the Fibonacci Rectangular Prism Sequence is the square...
stackexchange_codegolf
Inspired by Expand exponentation. Knuth's up arrow notation is used for big numbers such as Graham's number. If we look deeper, we can see how it makes big numbers. One arrow means exponentiation. e.g. 2↑3 equals 2^3 = 8. Two or more arrows means repeating the instructions of n-1 arrows. e.g. 2↑↑3 equals 2↑2↑2 equals 2...
stackexchange_codegolf
In this task you are given an odd number of white balls and the same number of black balls. The task is to count all the ways of putting the balls into bins so that in each bin there is an odd number of each color. For example, say we have 3 white balls. The different ways are: (wwwbbb) (wb)(wb)(wb) for the two differ...
stackexchange_codegolf
Vyxal is a golfing language that has 500+ different commands (achieved through overloads), and is a known beater of Jelly, 05AB1E and most golfing languages. Henceforth, it seems like a good idea to share some of the tips and tricks of the industry used to get terse programs in Vyxal. One tip per answer, and no stupid ...
stackexchange_codegolf
In this challenge we learned a way to encode every positive integer using factor trees. Here is how it works: The empty string has value of 1. (S) where S is any expression with a value of S evaluates to the Sth prime. AB where A and B are arbirary expressions with values of A and B respectively has value A*B. For ex...
stackexchange_codegolf
(Note: I'm not in the army so feel free to correct me if my formation is wrong, but I will not be changing the question. I will change any terminology mistakes though, because I'm trying to avoid air-cadet-specific wording choices) (Note: this follows the standards for Canadian Air Cadets, not any actual army thing) Ch...
stackexchange_codegolf
Recently I asked for tips on improving some code-golf of mine. The code was supposed to output every third value of the Fibonacci sequence starting with 2: 2,8,34,144,610,2584,10946,46368,196418,832040 However, I made a mistake in deriving my formula, and my code output a different sequence which is accurate for the ...
stackexchange_codegolf
You're at integer coordinates \$(x,y)\$ facing one of North, South, East, or West. Your goal is to walk home to \$(0,0)\$. At each step, you may do one of: Walk one step in the current facing direction, that is to whichever of \$(x+1,y)\$, \$(x-1,y)\$, \$(x,y-1)\$, or \$(x,y+1)\$ you're facing. Rotate 90 degrees left,...
stackexchange_codegolf
Input A string of text. Output The string of text, however, every consonant is the next consonant in the alphabet, and every vowel is the next vowel in the alphabet (z becomes b, u becomes a). The case of the new letter should be the same as the letter it is replacing (a becomes e, A becomes E). If there are two conson...
stackexchange_codegolf
In this programming-puzzle, your goal is to write the following function in JavaScript, using (essentially) point-free (tacit) programming: (f) => void(f()) Your submission should be an expression which returns a function which behaves like the above (taking a function as an argument and calling it, and returning unde...
stackexchange_codegolf
Your goal is to determine whether a given 2D point X lies within the area of the triangle with given vertices A,B,C. Write a function that takes in the coordinates of the test point X and the three triangle vertices (so that's 8 coordinates total) and returns True if the point lies inside that triangle, and False if it...
stackexchange_codegolf
Marching Squares is an algorithm from computer graphics, which is used to recover 2D isocontours from a grid of samples (see also, its big brother Marching Cubes for 3D settings). The idea is to process each cell of the grid independently, and determine the contours passing through that cell based on the values at its ...
stackexchange_codegolf
Introduction It is somewhat like DVORAK Keyboard layout , but MUCH harder. Let's talk about the Korean keyboard first. As you can see in Wikipedia, there is a Kor/Eng key to change between Korean and English key sets. Koreans sometime type wrong : they attempt to write in Korean on a qwerty keyboard or in English on a ...
stackexchange_codegolf
This is an answer chaining puzzle, where each answer must add on to the last. The \$n\$th submission must output its own source code in the \$n\$th language and the \$n−1\$ languages before it. A language can be either a dialect or a major version of a language, so Python version 2.121 is only counted as version 2 and ...
stackexchange_codegolf
There is a game I like to play. It happens on a grid of finite size (but it's wrapped, like a sphere). On that grid, a random (integer-only) point is selected. Then, I, the user, am prompted for a coordinate input. If my input matches the random point exactly, I am told that I have won. Otherwise, I am told the point-w...
stackexchange_codegolf
Introduction: I collect twisty puzzles. Most twisty puzzles are produced and sold by Chinese companies. Most well-known companies ask permission from puzzle designers to produce their designs and work together towards a product on the market. In this case, puzzle designers are of course very happy and proud that one of...
stackexchange_codegolf
To neutralize data, recursively replace all numbers (not digits!) with zeros and all characters (not strings!) with spaces. You must accept any single number, character, or string, or possibly recursive array* of mixed numeric/character data that your language can handle. For example, you must accept actual strings (an...
stackexchange_codegolf
Telephones in the United States (and perhaps some other places) have letters associated with some of the numbers. 2 = A, B, C 3 = D, E, F 4 = G, H, I 5 = J, K, L 6 = M, N, O 7 = P, Q, R, S 8 = T, U, V 9 = W, X, Y, Z No letters are associated with the number 0 or 1. Your challenge: Given any phone number in seven-digit...
stackexchange_codegolf
If you think this could be fun, but too much work, consider participating in this much smaller challenge. A bit of fun (and possibly frustration!) for 2016... Dyalog's "puzzle of the year". Enjoy! The Objective Find Dyalog APL (download) expressions (other languages are allowed, see Eligibility below) involving exactl...
stackexchange_codegolf
Create a program that prints the MD5 sum of its source in the form: MD5 sum of my source is: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx No cheating - you can't just read the source file and compute its sum. The program must not read any external information. Of course you can use a MD5 library available for your language.
stackexchange_codegolf
Write a quine that consists of real English words separated by single spaces. A "word" is defined as a string containing only lowercase and uppercase letters (/[a-zA-Z]+/ in regex). To be "real" your word must be recognized by the official Scrabble dictionary. I'm using the Scrabble dictionary since it gives a definiti...
stackexchange_codegolf
Task Create a program or a function that is valid in multiple programming languages, and when compiled/interpreted as a different language outputs "Hello, World!" in a different natural language. For example, a valid solution might output Hello World! (English) when compiled and run as C, Hallo Welt! (German) when comp...
stackexchange_codegolf
Given an input value \$n\$, construct an array of \$n\$ random 128 bit (unsigned) integers. The integers should be uniformly random. Your code can use any in built random number generation function it has or you can implement your own. Clearly this challenge is harder (and more fun) in lower level languages.
stackexchange_codegolf
Task Given a list of nodes representing a binary tree of positive integers serialized depth-first, return a list of nodes representing the same tree serialized breadth-first. To represent an absent child, you may use null, 0, 'X', Nothing, [], or any other value that is distinct from your representation of a node's val...
stackexchange_codegolf
When using a tool such as git to merge two files, a conflict could be detected and added to the result of the merge. A merge of these two files: my file: Common line of code 1 Common line of code 2 my lines Common line of code 3 Common line of code 4 their file: Common line of code 1 Common line of code 2 their lines ...
stackexchange_codegolf
This is the cops' thread. For the robbers' thread, click here. Cops' Task First, write a quine in a language of your choosing. Next, scramble the quine. Make sure to do this well as the robbers will be trying to unscramble it and find the original source code! Note that the scrambled code does not need to work. Post a...
stackexchange_codegolf
You step into the restroom, and notice that the toilet paper has missing! It occurs to you that someone had stolen it. Strangely enough, the first thing you would like to know is the amount of toilet paper the thief stole. Task You are given three integers \$ I \$, \$ R \$, and \$ G \$, the details of the toilet paper,...
stackexchange_codegolf
Titin is a protein found in muscle tissue. It is a pretty big protein, and its full chemical name is giant as well. Comprising 189819 characters, the full name of titin would take about 3.5 hours to pronounce. Your task is to output this entire name! Details The full name can be found here: Gist (this file does not inc...
stackexchange_codegolf
Lists can contain lists and we have nested lists. But we don't like nested lists and want to flatten them. By flattening I mean create a list which does not contain any list, but elements of lists it contained before. I'll explain it more. Input An arbitrary size list which has the below properties: it can contain int...
stackexchange_codegolf
MD5 checksums are relatively easy to crack. For this challenge you will create two separate programs, the first one writing Hello, World! and the second one writing Goodbye Cruel World! but with the source code having identical MD5 hashes. The source code of both programs must not be identical. The programs can use th...
stackexchange_codegolf
I have a list, l and a function f. f is not strictly increasing or decreasing. How can I find the item in the list whose f(item) is the smallest? For example, let's say the list is: l = [1, 2, 3, 4] and list(f(x)for x in l) is: [2, 9, 0, 3] f(3) is smaller than f of any of the other ones, so it should print "3". What...
stackexchange_codegolf
Assume the result of an exam has been published. After 5 minutes, First person knows the result. In next 5 minutes, new 8 persons know the result, and in total 9 know it. Again after 5 minutes, new 27 people know, and total 36 know. In similar fashion, total 100, 225..... people keep knowing it on 5 minute interval. Ch...
stackexchange_codegolf
Input: Ten unique integer coordinates, between (0,0) and (100,100). Output: The coordinates arranged in the order/an order such that a path drawn between the coordinates in that order is the shortest path possible. This is code golf so the shortest code wins!
stackexchange_codegolf
Problem You're a staircase engineer on a house and realize you only have n rectangles to create a staircase. So you are tasked with finding the number of ways to use n rectangles to tile a stairstep shape for the architects. Your task is to write a program that takes a non-negative integer n as input and calculates the...
stackexchange_codegolf
Introduction I would like to drawn a nice spinner by using eight braille patterns on two lines, drawing a square of 8x8 pixel, for showing a kind of snake growing and reducing: declare -a shapes=([0]=$'\E[A⠁⠀⠀⠀\E[B\E[4D⠀⠀⠀⠀' [1]=$'\E[A⠈⠀⠀⠀\E[B\E[4D⠀⠀⠀⠀' [2]=$'\E[A⠀⠁⠀⠀\E[B\E[4D⠀⠀⠀⠀' [3]=$'\E[A⠀⠈⠀⠀\E[B\E[4D⠀⠀⠀⠀' [4]=$'\E...
stackexchange_codegolf
Given one of the following as input: AK,AR,AS,AZ,CA,CT,DC,FL,GA,IL,IN,IA,KS,KY,LA,MD,MI,MN,MS,NV,NH,NJ,NM,NY,NC,ND,MP,OH,OK,OR,PA,PR,RI,SC,TN,TX,UT,VT,VA,WA,WI (with quotes) "AK","AR","AS","AZ","CA","CT","DC","FL","GA","IL","IN","IA","KS","KY","LA","MD","MI","MN","MS","NV","NH","NJ","NM","NY","NC","ND","MP","OH","OK",...
stackexchange_codegolf
What general tips do you have for golfing code in Pascal? I know this is a tricky language very few people use this but I would like to know any tips from the professionals out there :) I'm looking for tips that can reduce code size (every byte counts!) with special functions or even crazy combinations Please post each...
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 It's 2600 BC and people are building pyramids now. They already made the basis of the pyramid but don't know how to continue. So, they called you for help. The rules of making a pyramid is quite simple. For the layer above the previous layer, all you need to do is follow this step-by-step hand guide: Cut ...
stackexchange_codegolf
The Jaccard index / similarity coefficient, also known as the Tanimoto index / coefficient, is a statistic used for gauging the similarity and diversity of finite sample sets. It was developed by Grove Karl Gilbert in 1884 for the field of weather forecasting [1] and later independently developed by Paul Jaccard [2] wh...
stackexchange_codegolf
Given two arrays of non-negative integers \$A = [A_1,A_2,\ldots,A_n]\$ and \$R = [R_1,R_2,\ldots,R_n]\$ which are equal in length, return an array which has the element \$A_1\$ repeated \$R_1\$ times, then element \$A_2\$ repeated \$R_2\$ times, all the way up to \$A_n\$. Standard loopholes are forbidden. As this is co...
stackexchange_codegolf
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. Santa has a bunch of presents wrapped in cuboid boxes of various sizes. As his sled flies above a chimney, a stack of presents will be automatically dropped through it. Santa wants to carefully choose the presents so that all of them f...
stackexchange_codegolf
A number theory expression contains: There exists at least one non-negative integer (written as E, existential quantifier) All non-negative integers (written as A, universal quantifier) + (addition) * (multiplication) = (equality) >, < (comparison operators) &(and), |(or), !(not) (, ) (for grouping) variable names(all ...
stackexchange_codegolf
In this challenge, submissions will be programs or function which, when given an emoticon such as :-), :(, or :D, will rate their happiness from 0 to 3. An emoticon will be one of the following: :(: 0 :|: 1 :): 2 :D: 3 Emoticons may also have noses (a - after the :). Test cases: :( -> 0 :-| -> 1 :D -> 3 :-) -> 2 :|...
stackexchange_codegolf
Your task is to print this exact text: | | | | | | &***********& | Code Golf | | e---------f | | d___________l | | o-------------o | | C_______________G | ###Dennis$Dennis### ##################### Rules Trailing or leading newline is allowed code-golf, so shortest code wins!
stackexchange_codegolf
Today is November 11th, which for many regions is Remembrance Day. If you don't know anything about the history or context of Remembrance Day, you can read about it in the wiki page, but it's not relevant for this challenge. In Flanders Fields is a poem that is pretty well-known relating to this day. It opens like so: ...
stackexchange_codegolf
Tom the lumberjack is going to do his daily routine: chop trees. After all, it's his job to do so. His boss has ordered him to chop trees in a straight line marked with a special tape to identify them, so he knows which trees he is going to have to chop. However, Tom quickly realizes he has a problem. His axe will only...
stackexchange_codegolf
Your task is to take two single-variable integer polynomial expressions and multiply them into their unsimplified first-term-major left-to-right expansion (A.K.A. FOIL in the case of binomials). Do not combine like terms or reorder the result. To be more explicit about the expansion, multiply the first term in the firs...
stackexchange_codegolf
Given a multidimensional array, find the recursive alternating sum. An alternating sum is simply the sum of an array, where every other item (starting with the second) is negated. For example, the alternating sum of [7, 1, 6, -4, -2] is the sum of [7, -1, 6, 4, -2], or 14. In this challenge, you'll take the alternating...
stackexchange_codegolf
The following challenge is basically a simpler version of the one proposed by Dennis (Lossy ASCII art compression). I found the idea super interesting but a bit too convulted, and seeing as it didn't seem to be getting much attention I decided to modify it a little bit. You'll be downloading 5 ASCII art text files, eac...
stackexchange_codegolf