instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
I have recently been on a quest to create really really slow sorting algorithms that make Bogosort seem like it is the best. The task is simple: Sort an array of integers in as long average time as possible, with the average Bachmann–Landau notation begin as high as possible, while keeping the best case performance fas...
stackexchange_codegolf
inspired by thejonymyster's idea Rules This challenge is about finding languages that are very suitable for one task but quite the opposite in the other. The two tasks share a theme, but Task 1 is designed to be number-oriented while 2 is string-oriented. You can participate in three categories: Numbers: Choose a lang...
stackexchange_codegolf
Now that other users have helped Trump build the wall, its time for you to climb it. This is an ascii art challenge where you need to output a climbing wall with randomly placed holds. A climbing wall is made up of panels each of which has between 3 and 10 holds and is 5 panels high. Each panel is 4 characters high and...
stackexchange_codegolf
Your job is to take a string input and a number and align the string to the right, making the width of the text the number. When a line is too long, break it and put the rest on the next line, repeating until it's not necessary. If a line is shorter than the width, then pad it with spaces. Multiple newlines can occur, ...
stackexchange_codegolf
At a party, I was introduced to the game LCR. Now it's not a great game as there's no skill but only random chance. But it got me thinking, I could code this, and I made a quick program in R to model the game. Rules of the game modified from Wikipedia to match how we played: Each player receives at least 3 chips. Pla...
stackexchange_codegolf
Brain-Flak (a cross between Brainf**k and Flak-Overstow) is a stack-based esoteric language. Since this challenge was posted, the language has evolved and updated, but this first revision of the language is known as "brain-flak classic". You must write a program or function that takes a string of Brain-Flak classic cod...
stackexchange_codegolf
This challenge is based on, and contains test cases from, a programming course I took at Aalto University. The material is used with permission. Two and a half years ago there was a challenge about spoonerisms in English. However, in Finnish spoonerisms are much more complicated. Spoonerisms in Finnish In Finnish, the ...
stackexchange_codegolf
Your goal is to determine whether a given number n is prime in the fewest bytes. But, your code must be a single Python 2 expression on numbers consisting of only operators the input variable n integer constants parentheses No loops, no assignments, no built-in functions, only what's listed above. Yes, it's possible...
stackexchange_codegolf
Given two points A and B, find the angle from line AO to line BO about point O where O is the origin ((0,0)). Additionally, the angle may be positive or negative depending on the positions of the points (see examples). Input will be points A and B, and may be given in any convenient form. Output will be the angle in de...
stackexchange_codegolf
Imagine that a list of integers describes the heights of some two-dimensional terrain as seen from the side. Stamina: [ 4 4 4 4 4 4 3 3 3 3 2 2 2 - ] O /|\ / \ +---+ +---+ | | | | +---+ ...
stackexchange_codegolf
Context So the Dutch "Ministerie van Binnenlandse Zaken en Koninkrijksrelaties" (NL) - "Ministry of the Interior and Kingdom Relations" (EN) recently released the source code of their digid-app. They have some goofy code in there, which led to mockery and memes on reddit Source code of the offending method can be found...
stackexchange_codegolf
Given two strings: a string s and an alphabet a, implement string projection in the shortest code possible. String projection returns a string o that contains the characters in s that are in a. The order of the characters in o must match the order of characters in s. So if s = "abcd" and a = "12da34", o = "ad", since o...
stackexchange_codegolf
This is similar to the alignment used in word. Task 3 inputs: A 1 line string, a positive integer k, and direction (left or middle or right) Your job is to insert new lines(\n) and spaces in the string such that every line has k characters in it and aligned to the direction given. Rules The words must not be split(unle...
stackexchange_codegolf
Imagine you have an infinite sequence of the alphabet repeated infinitely many times: abcdefghijklmnopqrstuvwxyzabcd... You start at index 0, which corresponds to the letter a, and the should_write boolean flag is False. The input is a list or string of single-digit numbers. For each number n in the input, you should:...
stackexchange_codegolf
The usual correlation coefficient (in 2d) measures how well a set of points can be described by a line, and if yes, its sign tells us whether we have a positive or negative correlation. But this assumes that coordinates of the points can actually interpreted quantitatively for instance as measurements. If you cannot do...
stackexchange_codegolf
The Challenge Given a rectangular grid of characters A B C D E F G H I J K L M N O P Q R S T and a grid with the same dimensions of dots and spaces . . . . . . . . . . . Output the string which is generated by following the dots through the grid starting in the upper left corner. This example woul...
stackexchange_codegolf
My coworker, Jimmy is kinda new to C/C++. He's also kind of a slow learner. Now, to be fair, his code always compiles, but he has some really sloppy habits. For example, everybody knows that you can define an array like this: int spam[] = {4, 8, 15, 16, 23, 42}; Everybody that is, except for Jimmy. He is convinced tha...
stackexchange_codegolf
Task Given a positive integer number and a threshold, split into every possible way without generating any numbers above the threshold. Examples Input: 15008 Threshold: 400 Valid Output: [[1, 5, 0, 0, 8], [15, 0, 0, 8] [1, 50, 0, 8], [150, 0, 8]] Invalid outputs: [[1, 5, 0, 0, 8], [15, 0, 0, 8], [150, 0, 8], [1, 500...
stackexchange_codegolf
Introduction: You are a worker, who is in charge of managing a set of bridges, connecting a square grid of "nodes": N - N - N | | | N - N - N | | | N - N - N (the grid here is 3 by 3, but they can be larger). Each of the bridges has a set capacity from 1 to 10, and each of the bridges has a number of cars over...
stackexchange_codegolf
Minimum Scalar Product The inspiration for this code golf problem is from Google's code jam competition. The premise behind the problem is, given the input of two vectors of varying lengths, find the minimum possible scalar. A scalar can be found using the following formula: x1 * y1 + x2 * y2 + ... + xn * yn The probl...
stackexchange_codegolf
During the 49 days between Passover and Pentecost, Jewish liturgy provides four numerical problems that I've here phrased as code golf problems. Input/Arguments These four, in any order, and by any means: A text \$L\$ consisting of exactly 7 sentences. The first and last sentences have 7 words each, the middle one ha...
stackexchange_codegolf
I was asked this question in an interview but I was unable to figure out any solution. I don't know whether the question was right or not. I tried a lot but couldn't reach any solution. Honestly speaking, nothing came to my mind. Rocco numbers A positive integer \$n\$ is a Rocco number if it can be represented either a...
stackexchange_codegolf
INTRODUCTION I like Karma Fields : he's a music producer that creates original music tracks. His artwork also matches up really well his style. He has a logo witch I find really interessing : GOAL Your goal will be to reproduce that logo, graphically or in ASCII. Edit @NahuelFouilleul managed to provide a readable asc...
stackexchange_codegolf
Introduction Each Unicode codepoint can be represented as a sequence of up to 4 bytes. Because of this, it is possible to interpret some 2, 3, or 4-byte characters as multiple 1-byte characters. (See here for a UTF-8 to bytes converter). Challenge Given a UTF-8 character, output it split into a sequence of 1-byte chara...
stackexchange_codegolf
Context: Gynvael Coldwind, a famous security researcher, published a contest in his blog post (that is now complete). The goal was similar to the one described here, but with certain restrictions depending on which of the three allowed programming languages was chosen. I found the exercise fun and wanted to extend the ...
stackexchange_codegolf
Given some positive integer \$n\$ generate all derangements of \$n\$ objects. Details A derangement is a permutation with no fixed point. (This means in every derangement number \$i\$ cannot be in the \$i\$-th entry). The output should consist of derangements of the numbers \$(1,2,\ldots,n)\$ (or alternatively \$(0,1,...
stackexchange_codegolf
Challenge: Input: Two integer parameters a and b (where a<b and the difference is at least 2) Output: Output or return this text, where a and b are filled in: (a,b) = ]a,b[ = {a<x<b} = {a<x&&x<b} = a+1..b-1 [a,b) = [a,b[ = {a<=x<b} = {a<=x&&x<b} = a..b-1 (a,b] = ]a,b] = {a<x<=b} = {a<x&&x<=b} = a+1..b [a,b] = [...
stackexchange_codegolf
Need to write a JS function compare(a,b) for numbers which return 1 when a > b, 0 when a == b, -1 when a < b. Also following properties should hold: compare(NaN, NaN) = 0 NaN is bigger than any other number, so compare(NaN, any) = 1 and compare(any, NaN) = -1. compare(-0.0, 0.0) = -1 and compare(0.0, -0.0) = 1. Other ...
stackexchange_codegolf
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 appears twice. The aim of the game is to find words made o...
stackexchange_codegolf
Introduction Of course, we've got a lot of sequence challenges, so here is another one. The Kimberling sequence (A007063) goes as following: 1, 3, 5, 4, 10, 7, 15, 8, 20, 9, 18, 24, 31, 14, 28, 22, ... This is produced by shuffling the normal iteration: [1] 2 3 4 5 6 7 8 The first term of the sequence is 1. Aft...
stackexchange_codegolf
Martin Ender's 2D programming language Alice has two different modes depending on what orientation the IP has: orthogonal (Cardinal mode) or diagonal (Ordinal mode). Commands in Alice change their meaning depending on which mode the program is in when they're executed. One especially interesting implementation of this ...
stackexchange_codegolf
Since it was Pi day recently, I have noticed a number of challenges that ask you to calculate pi. Of course, a quiche lorraine is not quite a pie (you can claim a Bonus Score¹ of +1 if you guessed the challenge off of the title). As such, your job is to write an algorithm or method that looks like it approximates Pi at...
stackexchange_codegolf
A partition of a list \$A\$ is a way of splitting \$A\$ up into smaller parts, concretely it is list of lists that when concatenated gives back \$A\$. For example [[1],[2,3],[5,6]] is a partition of [1,2,3,5,6]. The trivial partition is a partition that "splits" the list into only one piece, so [[1,2,3,5,6]] is also a ...
stackexchange_codegolf
Input An integer \$n\$ greater than or equal to 1. Output The number of bits in the binary representation of the integer that is the product of the first \$n\$ primes. Example The product of the first two primes is 6. This needs 3 bits to represent it. Given unlimited memory and time your code should always output the ...
stackexchange_codegolf
Futoshiki is a logic puzzle where an \$n×n\$ Latin square must be completed based on given numbers and inequalities between adjacent cells. Each row and column must contain exactly one of each number from \$1\$ to \$n\$ while satisfying the inequalities. In a solved Futoshiki puzzle any row (or column) forms a linear ...
stackexchange_codegolf
Ray tracers are easy to write. At each pixel on the screen, you shoot a ray into the scene and see what it hits. For the most basic ray tracer, the ray acquires the color of the object it hit. If you're doing shading, then you don't color the pixel immediately, instead you try to trace a ray back to the light source....
stackexchange_codegolf
You know how many and which kinds of chess pieces were murdered. Can you come up with any possibility for who killed whom and how? Background During the course of a game of chess, there are between 2 and 32 pieces on the board. Call the collection of all pieces on the board (both white and black), without regard to p...
stackexchange_codegolf
Consider a horizontal line with vertical lines centered on the x-axis and placed at gaps of \$\sqrt{2}/2\$. For a positive integer \$n \geq 3\$, the first half of the lines have lengths \$0, \sqrt{2}, 2\sqrt{2}, 3\sqrt{2}, \dots, (n-1)\sqrt{2}\$ and then the second half have lengths \$(n-2)\sqrt{2}, (n-3)\sqrt{2}, \do...
stackexchange_codegolf
Make a program that outputs the number of seconds from the beginning of today (00:00:00 of the day you run it) to the second you ran it. However, if this number is divisible by three, print Fizz instead. If it is divisible by five, print Buzz instead. If it is divisible by three and five, print FizzBuzz. Don't pad the ...
stackexchange_codegolf
MarioLANG is a two-dimensional programming language where the source code resembles a Super Mario Bros. level. Furthermore, its instruction set is very similar to Brainfuck's. This means that MarioLANG is essentially a 2-D Brainfuck where the instruction pointer moves like Mario. So when I wrote my MarioLANG submission...
stackexchange_codegolf
The quaint hamlet of Кодгольф in the Russian far east has a problem: their population is low (below 66), and no new people have arrived for years. Moreover, after centuries of near-isolation, just about everybody is related to each other. Mayor Стекобмен has a solution that should keep the morale high: organise a weddi...
stackexchange_codegolf
Description I guess everyone knows the fairy tale of Rapunzel and the prince. For those who do not: read it here. However, Rapunzel had just had her hair cut, so it might not be long enough to let her prince climb up! She may get very sad.. Challenge Your task is to write a function that evaluates what Rapunzel will be...
stackexchange_codegolf
Given an non-negative integer \$n \ge 0\$, output forever the sequence of integers \$x_i \ge 3\$ that are palindromes in exactly \$n\$ different bases \$b\$, where the base can be \$2 \le b le x_i-2\$. This is basically the inverse of OEIS A126071, where you output which indices in that sequence have the value \$n\$. I...
stackexchange_codegolf
Given a strictly positive integer n (therefore 0 isn't a valid test case), produce an approximate triangle of height n. A non-programmatic process of drawing the picture Initially we start with the base of the triangle. | So, we want to draw a triangle of a height of 5. First we know that all the |'s align on a straig...
stackexchange_codegolf
Some two-dimensional esolangs, such as Forked, and some non-esolangs, such as Python, can sometimes require spaces before lines of code. This isn't very golfy. Also, I'm lazy and writing a 2d lang that needs lots of spaces before code. Your task is to write a tool that makes these languages golfier. Of course, this wil...
stackexchange_codegolf
Introduction Given a set of text-based "screenshots" consisting of printable ASCII chars merge them so that all of them form one long screenshot so that nobody has to do it themselves when reading it. Challenge Take input as a list of strings (referred to as "screenshots"). Each screenshot consists of several lines of ...
stackexchange_codegolf
Tamagotchi and Giga Pets were small electronic devices which simulated a little virtual pet. This pet had several stats, like health, hunger, etc. I recently wrote this example: import msvcrt,os,sys;d=m=100;h=s=t=p=0;f=10 while 1: os.system('cls'if os.name=='nt'else'clear');print("health:",d,"\nhunger:",h,"\nsleep:",...
stackexchange_codegolf
The famous C64 basic one liner 10 PRINT CHR$(205.5+RND(1)); : GOTO 10 prints a maze of slashes and backslashes. \\/\\\//\/\////\\/\/ \/\///\\///////\//\/ /\\\//\//\////\\//\\ \////\//\//\/\\\\\\/ /\/\\///\\\\/\\\\/\\ \/\//\\\\\\//\/\//// /\//\\///\/\///\//// \/\\\//\\/\\\//\\/\/ //////\\/\\/\/\/\/// \\/\/\\////\/\/\\/...
stackexchange_codegolf
Definition A number is positive if it is greater than zero. A number (A) is the divisor of another number (B) if A can divide B with no remainder. For example, 2 is a divisor of 6 because 2 can divide 6 with no remainder. Goal Your task is to write a program/function that takes a positive number and then find all of it...
stackexchange_codegolf
Determining whether a Turing machine halts is well known to be undecidable, but that's not necessarily true for simpler machines. A Foo machine is a machine with a finite tape, where each cell on the tape has an integer or the halt symbol h, e.g. 2 h 1 -1 The instruction pointer starts by pointing to the first cell: 2 ...
stackexchange_codegolf
Introduction Time is a really simple concept. Seconds pass, one after the other, all the same. But humans love making it hard. This Stackoverflow question has gathered many answers and even though they are surprisingly long and complex, most of them will still fail for certain inputs. Can you format a number of seconds...
stackexchange_codegolf
A superpermutation on n symbols is a string which contains every permutation of n symbols in its body. For instance, 123121321 is a superpermutation on three symbols because it contains 123, 132, 213, 231, 312 and 321 as substrings. The Challenge Given a string composed of n unique symbols (and, optionally, n), output ...
stackexchange_codegolf
This code-challenge is based on OEIS sequence A261865. \$A261865(n)\$ is the least integer \$k\$ such that some multiple of \$\sqrt{k}\$ is in the interval \$(n,n+1)\$. The goal of this challenge is to write a program that can find a value of \$n\$ that makes \$A261865(n)\$ as large as you can. A brute-force program ...
stackexchange_codegolf
Given a string and a substring and a positive integer n. Remove the n occurences of a substring from the end of the originally given string. If the substring is not present in the string or the number of times the substring appears is less than n, then the output is the original string. No space should be present in pl...
stackexchange_codegolf
What happens when the CapsLock key on your keyboard doesn't have a notch in it? "This hPPENS." The goal of this program is to consistently emulate keyboard misses where each A press is replaced with CapsLock. Uppercase 'A's from the source should yield the same effect. When CapsLock is enabled, capitalization is revers...
stackexchange_codegolf
Write a function that calculates a row of the pascal triangle and returns the middle number, if there are 2 it should return their sum. Example: 5 would return 20 Example 2: 4 would return 6 EDIT: To be clear: a) if the number inputted is odd then find then return the middle number of a row on the pascal triangle. ...
stackexchange_codegolf
Covalent bonding uses so-called "hybrid" orbitals to form tetrahedral, octahedral, etc. formations out of the s, p, and sometimes d orbitals. Their naming conventions are pretty much the concatenation of the component orbitals; for example, the hybridization of the s orbital and one p orbital would be the two sp orbita...
stackexchange_codegolf
What does "jelly" mean in the title?. Robber's thread Jelly has an "Evaluate the argument as Python 3" atom, ŒV which takes a string as an argument as evaluates that string as Python 3 code: Try it online!. It also has compressed strings, delimited with “...» that can compress any string containing printable ASCII (plu...
stackexchange_codegolf
Powers We define an important power as a number that can be represented as \$ x^y \$ where \$ x ≥ 2 \$ and \$ y ≥ 2 \$. Palindrome We define an important palindrome as a number that is the same written forwards and backward, and is greater than 10. Thus, the last digit must not be 0. Palindromic Power We define a Palin...
stackexchange_codegolf
Background Stick Bomber is a two-player game I just made up. Initially, some sticks are placed in one or more groups, and the sticks in each group are laid out in a straight line. So a configuration with three groups of 3, 5, and 8 sticks each may look like the following. For conciseness, we can call it a (3,5,8) confi...
stackexchange_codegolf
A right-truncatable prime is a prime where every prefix is a prime (in base 10). A left-truncatable prime is exactly the opposite, where every postfix is a prime (primes that start with 0 aren't allowed). Both of these sequences are finite (There are only 83 Right-truncatables, while there are 4260 Left-truncatables)...
stackexchange_codegolf
Write a function that takes a string of letters and spaces (no need to handle non-letters) and performs the ANNOUNCER VOICE translation algorithm as follows: First, uppercase everything. For each word, Elongate each consonant cluster by tripling each letter; except, if the word begins with a consonant cluster, do no...
stackexchange_codegolf
Creating a golfing language can be hard. Let's help budding golfing language creators out and provide some helpful tips on how to create one. I'm looking for tips on: The design process Implementation Community engagement One tip per answer would be appreciated, and tips like "don't create a new language, use an exis...
stackexchange_codegolf
You must write a program that encrypts an input into a string of characters. For every character i in the input up to the second to last character, take the i and i+1 characters and encode them by writing the letters of the alphabet, in order, that range in the same direction between those chosen characters. For examp...
stackexchange_codegolf
Write a program or a function that outputs the integer number of answers this question has. Your solution should still work as more answers are added. Languages that run in a browser may be run from the js console while on this page. Otherwise, you'd probably have to download this page. Multi-language solutions, e.g. w...
stackexchange_codegolf
This is a CC-BY-SA challenge from the CCSC Mid-South Programming Contest 2018. Author(s): Brent Yorgey Source: Consortium for Computing Sciences in Colleges Mid-South Programming contest 2018 https://ccsc18.kattis.com/problems/ccsc18.mountainrange Good news: you have been hired to do all the special effects for a fil...
stackexchange_codegolf
This is a cops-and-robbers puzzle the robbers' thread can be found here. Your task will be two write two programs (or functions) such that they are anagrams of each other and one performs the left inverse of the other. These programs may accept and output as many integers or complex numbers as you wish. If you choose...
stackexchange_codegolf
ASCII art is fun. Modern text editors are very good at manipulating text. Are modern programming languages up to the task? One common task in ASCII art manipulation is to crop text to a rectangle between two characters. This is the task you must implement in this challenge. Details Your program will take 3 inputs: t...
stackexchange_codegolf
In speedcubing, an Ao5 (Average of 5) is computed for a set of five times by removing the fastest and slowest times, and then computing the mean of the remaining three times. A "rolling ao5" is computed for a sequence of at least five times by computing the ao5 for every set of consecutive five times (some sets will o...
stackexchange_codegolf
Koronkorko is the Finnish word for compound interest. We don't want compound interest in our strings, so let's find the shortest possible regular expression to exclude it. Given a string consisting only of the uppercase alphabetic characters A-Z, determine the shortest possible regular expression that matches the strin...
stackexchange_codegolf
Write a program in any language that takes a single natural number n as input and generates a Pyth program that, in turn, produces, using nested lists, the nested set given by S(n), where: S(0) = ∅ S(n+1) = S(n) ∪ {S(n)} S(n) giving the set representation of the corresponding ordinal number. Using the list representa...
stackexchange_codegolf
Given a natural number n write a program or function to get a list of all the possible two factors multiplications that can be used to achieve n. To understand better what is pretended you can go to http://factornumber.com/?page=16777216 to see when n is 16777216 we get the following list: 2 × 8388608 4 × 41943...
stackexchange_codegolf
Your task: given a nonzero positive number i, calculate pi using the Nilakantha series unto i terms. The Nilakantha series is as follows: $$\text 3 + \frac{4}{2 \times 3 \times 4} - \frac{4}{4 \times 5\times 6}+\frac{4}{6 \times 7 \times 8} - ...$$ 3 is the first term, 4/2*3*4 is the second, -4/4*5*6 is the third, and...
stackexchange_codegolf
Given two natural numbers (less than 100) as input print the sequence of intermediate results obtained when computing the sum of the two numbers using only the following operations1: n <-> (m+1) for integers nand m satisfying that equation (a+b)+c <-> a+(b+c) for integers a,b and c (associative law) You are not allow...
stackexchange_codegolf
Introduction In this challenge, you are given as input the ASCII representation of the net (unfolded surface) of a rectangular cuboid (3D box). The format is this: ....+--+....... ....|##|....... ....|##|....... ....|##|....... +---+--+---+--+ |###|##|###|##| +---+--+---+--+ ....|##|....... ....|##|....... ....|##|.......
stackexchange_codegolf
Given a ragged array, find the length of the largest subarray that contains the depth of that subarray. The base array layer has a depth of 0. Here is an example: [1, 2, [3, 4, [2, 5]], 0] Here, the subarray [2, 5] contains its own depth 2 and has a length of 2 as well. But in the outermost subarray is a 0, its depth....
stackexchange_codegolf
This challenge is a little tricky, but rather simple, given a string s: meta.codegolf.stackexchange.com Use the position of the character in the string as an x coordinate and the ascii value as a y coordinate. For the above string, the resultant set of coordinates would be: 0, 109 1, 101 2, 116 3, 97 4, 46 5, 99 6, 11...
stackexchange_codegolf
Suppose we have a matrix like this: 11111 12221 12321 12221 11111 This matrix represents a terrain, and each cell represents a portion of terrain. The number in each cell represents the time the portion of terrain needs to be completely burnt (in minutes, if a measurement unit is needed), according to its combustibili...
stackexchange_codegolf
The word "levencycle" is inspired by cyclic levenquine challenge. Definitions A 1-dup permutation of order \$n\$ is some permutation of \$1, \cdots, n\$ plus one duplicate number in the range. For example, 1-dup permutations of order 3 include 1, 3, 2, 2 and 3, 2, 1, 3. There are 36 distinct 1-dup permutations of order...
stackexchange_codegolf
Related: Ellipse circumference Introduction An ellipsoid (Wikipedia / MathWorld) is a 3D object analogous to an ellipse on 2D. Its shape is defined by three principal semi-axes \$a,b,c\$: $$ \frac{x^2}{a^2} + \frac{y^2}{b^2} + \frac{z^2}{c^2} = 1 $$ Just like an ellipse, the volume of an ellipsoid is easy, but its surf...
stackexchange_codegolf
Backstory I was fiddling around with the Evolution of Trust and thought of this.Warning: I recommend you go check it out first before attempting this challenge. Summary for people who haven’t played A quick summary of what it says on the site: there is a machine. If you put in one coin, your opponent gets three coins (...
stackexchange_codegolf
SOMe PEOPle lIkE tO TYpE iN A LoGiCAL MAnNER, WITh CapITals aT tHe bEGiNnIng Of ThE SENtENCE and smaLl LETTErS EVeRYWHErE eLsE. NOT Us. NOt Us. Your joB iS to tAkE A SenTEncE Of A LL SMAlL LeTTeRS, And rANDOmly ChAnGe sOMe to caPiTAl. ThiS iS a Code gOLF so tHE SmaLleST coDE WIll win. the input will always be small l...
stackexchange_codegolf
To shuffle a string \$s\$, Alice applies the following algorithm: She takes the ASCII code of each character, e.g. "GOLF" → \$[ 71, 79, 76, 70 ]\$ She sorts this list from lowest to highest: \$[ 70, 71, 76, 79 ]\$ She reduces each value modulo the length of the string (4 in this case), leading to the list \$A = [ 2, 3...
stackexchange_codegolf
Write a program or function (or set of programs/functions) to encrypt and decrypt data given the following specification: Encryption Calculate an XOR hash of the input by XOR-ing every byte with each-other. XOR every byte of the input by this hash. Shift the result four bits left. Pad the left side with the first four...
stackexchange_codegolf
Today, Numberphile posted this video where it's stated that 1+2+3+4+...+n = -1/12. While this isn't really new (several ways to prove that have been found, you can look here for further informations), this leads us to our question! Your goal is to write a function that returns -0.083333 (feel free to stop at -0.083 if ...
stackexchange_codegolf
A \$k\$-hyperperfect number is a natural number \$n \ge 1\$ such that $$n = 1 + k(\sigma(n) − n − 1)$$ where \$\sigma(n)\$ is the sum of the divisors of \$n\$. Note that \$\sigma(n) - n\$ is the proper divisor sum of \$n\$. The sequence of \$k\$-hyperperfect numbers begins $$6, 21, 28, 301, 325, 496, 697, \dots$$ This ...
stackexchange_codegolf
Task: With the minimum amount of bytes, determine today's Zodiac sign using the programming language of your choice. Rules: This is code golf, the answer with the fewest characters wins. The initialization of getting the current date into a variable (e.g. var now = new Date();) does not add to the count. Leap years mu...
stackexchange_codegolf
This is a window: --- | | --- Let's add some walls |. Put two spaces on either side of it so that the window has plenty of room. | --- | | | | | | --- | Now let's add a roof and a ceiling. To keep the window in the middle of the room, let's add one more row above it and below it. --------- | | | --- | |...
stackexchange_codegolf
This is my first attempt at a Code Golf question. If it needs obvious edits, please feel free to make them. Below is a description of the basic Dropsort algorithm. Dropsort is run on a list of numbers by examining the numbers in sequence, beginning with the second number in the list. If the number being examined is l...
stackexchange_codegolf
Challenge Taken with permission from my University Code Challenge Contest For some years now, the number of students in my school has been growing steadily. First the number of students was increased by classroom, but then it was necessary to convert some spaces for some groups to give classes there, such as the gym s...
stackexchange_codegolf
This is a very simple challenge. Task Whenever your code is run, your code should output the next sunset date and time in GMT for all capital cities on Earth. You should get the list of capitals from the below table. The dates and times should be outputted sorted by the name of the capital. You don’t need to output t...
stackexchange_codegolf
Today Neil Sloane of the OEIS sent out an email asking for a confirmation of the current terms, and computation of some larger terms of the latest OEIS sequence A337663 with the keyword "nice". Here's how this sequence works: You label \$n\$ cells on the infinite square grid with \$1\$s, and then place the numbers \$2...
stackexchange_codegolf
The purpose of this task is to write a program or function to find the most common substring within a given string, of the specified length. Inputs A string, s, of any length and characters that are valid as inputs for your language. A number, n, indicating the length of substring to find. Guaranteed to be equal to or...
stackexchange_codegolf
EDIT (Jan 19, 2022, 18:00 UTC): This challenge is now over. The winner is Citty with this Pyth answer. Congratulations! This is an answer-chaining challenge where each answer must take an integer \$N\$ as input and return the 1-indexed ID of the answer which was written by the user whose ID is \$N\$. You may want to s...
stackexchange_codegolf
Setup: For two sets \$A,B\$, we say \$A \subseteq B\$ if every element in \$A\$ is also in \$B\$. Another way of saying this, is that we can order the elements of \$A,B\$ into two lists \$L_A,L_B\$, such that \$L_A[i] = L_B[i]\$ where \$i\$ ranges over the indices of \$L_A\$. We proceed to extend this idea, to define ...
stackexchange_codegolf
Your task is to write a non-empty program / function of byte count L, which, when repeated M times, checks whether a given positive integer N is equal to L × M. You should, in theory, support an arbitrary number of repetitions (an arbitrary positive integer value of M), but it's fine if, due to language limitations, it...
stackexchange_codegolf
It's become somewhat of a tradition in PPCG that some users temporarily change their names by an anagram (a new name formed by reordering the letters of the old). Sometimes it gets difficult to find out who is who. I could use a program or function to tell if two phrases are anagrams of each other. The challenge The pr...
stackexchange_codegolf
Pseudo-Quantum Bogosort Quantum Bogosort is as follows: Quantumly randomise the list, such that there is no way of knowing what order the list is in until it is observed. This will divide the universe into O(n!) universes; however, the division has no cost, as it happens constantly anyway. If the list is not sorted, ...
stackexchange_codegolf
We've had lots of questions about quines, programs where the source code and output are identical. For compiled languages, there are other combinations: we've already had a question about writing a program where the executable and output are identical. But there's one combination left. The task Using a compiled languag...
stackexchange_codegolf
Inspired by this Puzzling challenge. Challenge Given a 2D rectangular grid where each cell is either an empty space or a wall, find the path (or one of the paths) from the top left cell to the bottom right, which satisfies the following: Only movement to one of four adjacent cells is allowed. The path breaks (or passe...
stackexchange_codegolf