instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Given a non-empty string, keep removing the first and last characters until you get to one or two characters. For example, if the string was abcde, your program should print: abcde bcd c However, if it was abcdef, it should stop at two characters: abcdef bcde cd Trailing newlines and trailing spaces at the end ...
stackexchange_codegolf
Gemtext is a very simple markup format used by the alternative web protocol Gemini. Write a Gemtext to HTML converter. From the Wiki: A line of text is a paragraph, to be wrapped by the client. It is is independent from the lines coming before or after it. A list item starts with an asterisk and a space. Again, the r...
stackexchange_codegolf
Introduction Adam (A) and Bubbler (B) are playing coin toss, where the one who wins 5 times first would win the prize of $32. If the game is aborted when the scores are A:B = 4:3, how should they distribute the prize? Assume the coin toss is fair, so the winning chance of either player is 1/2 for each game. The answe...
stackexchange_codegolf
Given an input string consisting of only letters, return the step-size that results in the minimum amount of steps that are needed to visit all the letters in order over a wrapping alphabet, starting at any letter. For example, take the word, dog. If we use a step-size of 1, we end up with: defghijklmnopqrstuvwxyzabcde...
stackexchange_codegolf
Challenge You are given the following function:- which is the same as:- with the base cases q(r, b, L) = 1 whenever r ≤ L, q(r, 0, L) = 0, if r > L and q(r, 0, L) = 1, if r ≤ L. Your task is to code a program that takes r as input, and outputs the value of q(r, r - L, L) for all L taking integer values from 1 to (r-...
stackexchange_codegolf
Related to: Make a ;# interpreter In the above linked challenge the task was to create an interpreter for the esoteric language ;#. The ;# language The language has exactly two commands: ; and # (all other characters are ignored by the interpreter): ;: Increment the accumulator #: Modulo the accumulator by 127, print t...
stackexchange_codegolf
Input: A string Output: The rarity of the string, as described below. To find the rarity of a string, follow the steps below. Start with 0. Subtract 3 for each E, A, T, or O in the string. Subtract 2 for each I, N, S, or H in the string. Subtract 1 for each R, D, L, or C in the string. Add 1 for each W, F, G, or Y in ...
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
Introduction Congratulations! You've been selected to do research a a newly discovered animal called a fuzzy, a docile, simple creature that strongly resembles a cotton ball. Fuzzies love to be near other fuzzies, but not all fuzzies want to be near each other. There are 6 types of fuzzies, 1a, 1b, 2a, 2b, 3a, and 3b. ...
stackexchange_codegolf
I love functional programming in Octave, but it's rather unwieldy in practice. I'm wondering about the shortest way to define an anonymous recursive function. I have some ideas, but I'm wondering if there is a way to combine these ideas to make them even shorter (or equally short but more versatile). For the sake of th...
stackexchange_codegolf
An EAN-8 barcode includes 7 digits of information and an 8th checksum digit. The checksum is calculated by multiplying the digits by 3 and 1 alternately, adding the results, and subtracting from the next multiple of 10. For example, given the digits 2103498: Digit: 2 1 0 3 4 9 8 Multiplier: 3 1 ...
stackexchange_codegolf
This question was profoundly inspired by Joe Z's question. But, with a twist... So, now that it's almost 2017, it's time for a code question involving the number 2017. Your task is to make a program that counts up from 0, printing each number until it reaches 2017. without using any of the characters 012345678 or 9 in...
stackexchange_codegolf
Lets create a system of numbers where the biggest digit in the nth place value (counting from right to left) of a number length m is always equal to m - n + 1. To give an example the largest 5 digit number expressible in this system is written 12345. Apart from the number of digits available to be used in a particular ...
stackexchange_codegolf
A math Olympiad will be held, and participants are being registered. The highest number of participants is 100. Each participant is given an ID number. It is given in a sequence like \$100, 97, 94, 91, 88, ...., 1\$, and when the first sequence is over, then \$99, 96, 93, 90, 87, ...., 3\$ sequence and so on. Let's ass...
stackexchange_codegolf
This is a simple(ish) web scraping challenge. Input Your code should take an MPAA film rating and a number from 0 to 100 as input. It can do this in any way you find convenient. Output Your code should return the name of any movie which has a) that film rating and b) the numerical score on the Tomatometer from rottento...
stackexchange_codegolf
Hexagonal tessellations, or tilings of the plane, are three-colorable -- meaning that using only three colors, such as Red, Blue, and Green, every hexagon can be colored without any two hexagons that share a border sharing a color. A partial example showing such a pattern. Given a partial hexagonal tiling in ASCII (via...
stackexchange_codegolf
I have previously posted a challenge, smallest number of steps for a knight in chess. Now I would like to go a step further by adding the possibility to choose your piece. If you place a piece on any square of a chessboard, what is the smallest number of steps to reach every possible position? Rules It is an 8 by 8 bo...
stackexchange_codegolf
Objective Given a nonnegative integer, calculate its NDos-size as defined below, and output it. NDos' numeral system The concept of NDos-size comes from the numeral system I made. It represents every nonnegative integer by a nested list, as follows: With the binary expansion of given nonnegative integer, each entry of...
stackexchange_codegolf
Given an integer n, print out n * reversed(n) reversed(n) is the number you get when you reverse the digits of n. reverse(512) = 215 reverse(1) = 1 reverse(101) = 101 >>>>>>>> func(5) = 5*5 = 25 func(12) = 12*21 = 252 func(11) = 11*11 = 121 func(659) = 659*956 = 630004 Shortest code wins! Leaderboard var QU...
stackexchange_codegolf
Given a list of positive integers as input you are to determine if there is a way to pair up the elements such that: All but one element is in a pair No element is in more than one pair Every pair is of equal elements No two pairs have elements separated by the same distance in the original list For example if the in...
stackexchange_codegolf
Background The Fibonacci sequence is defined as $$f(1) = 1 \\ f(2) = 1 \\ f(n) = f(n-1) + f(n-2)$$ The Fibonorial, similar to the factorial, is the product of the first \$n\$ Fibonacci numbers. $$g(n) = f(1) \times f(2) \times ... \times f(n-1) \times f(n)$$ The Fibonomial coefficient, similar to the binomial coefficie...
stackexchange_codegolf
Back to the basics! You're in you comp sci class again, except wiser and golfier. You have the tools, you have the power… but do you have the skill? Probably. Crash Course for the non-Computer Scientist (skip if you don't need it) A string is symbolically represented by an arbitrary letter (usually, for our purposes, w...
stackexchange_codegolf
Let's begin with a thought experiment. You have a clock and a timer, in which you start the timer when the clock shows exactly hh:mm.00. Clock: The clock employs 24-hour time. So the range of hh is 0<=h<23. (Because 23 inputs are unsolvable, you aren't required to handle that) Timer: It starts exactly on 00.00. The nu...
stackexchange_codegolf
Example given an image which width and height is a power of two . First step : Divide each image into Cartesian coordinate quadrants _____ _____ | | | | 2 | 1 | |_____|_____| | | | | 4 | 3 | |_____|_____| Second step : Divide each quadrant to another four quadrants and add new quadrant id a...
stackexchange_codegolf
@BeastlyGerbil presents, the world's very first MOBIUS SUDOKU: Google Sheets version (The left most square backs onto the right most square, and the middle squares back onto each other. The ends are then attached as indicated.) RULES: Normal sudoku rules apply for rows and boxes - boxes are split into groups of 3...
stackexchange_codegolf
Introduction Humans are a remarkable species, but we can be very awkward to understand sometimes—especially for computers. In particular, we seem to like writing polynomials in a very convoluted fashion with seemingly arbitrary rules. What is the shortest program you can write to format a polynomial correctly using t...
stackexchange_codegolf
Spreadsheet Columns In most spreadsheet programs, columns go A, B, C, ... X, Y, Z. After this comes AA, AB, AC ... AX, AY, AZ, BA and so on. Your task is to convert one of these strings in to a column number. You must support inputs up to the maximum length of your language, to a minimum of 3. Test Cases: A => 1 B ...
stackexchange_codegolf
An Automorphic number is a number which is a suffix of its square in base 10. This is sequence A003226 in the OEIS. Your Task: Write a program or function to determine whether an input is an Automorphic number. Input: An integer between 0 and 10^12 (inclusive), that may or may not be an Automorphic number. Outpu...
stackexchange_codegolf
Code-Bowling Quine Challenge You must bowl a quine following the rules of code bowling and quines but the source code must be in the shape of a rectangle (details specified below) Quine Quines returned must be returned via the ways defined in the standard I/O rules. Rules Code-Bowling Rules Character : Byte Ratio I...
stackexchange_codegolf
Starting with a positive integer N, find the smallest integer N' which can be computed by repeatedly dividing N by one of its digits (in base-10). Each selected digit must be a divisor of N greater than 1. Example #1 The expected output for N = 230 is N' = 23: Example #2 The expected output for N = 129528 is N' = 257:...
stackexchange_codegolf
Given two inputs -- one of them a non-empty printable ASCII string (including space, excluding newline), the other being one of two distinct, consistent values of your choice (1 / 0, l / r, left / right, etc.) -- output an ASCII art airplane banner of the string, pointing either left or right. For consistency, I'll be ...
stackexchange_codegolf
Background Skip to "Task" if you are familiar with Tic-Tac-Toe (I think most are!) Tic-Tac-Toe is a famous two-player game. It consists of a 3x3 board that is filled gradually by two players (clarifications below); The first player uses the character X and the other one uses O. The winner is the first to get 3 consecut...
stackexchange_codegolf
Input A string S of length between 10 and 16 inclusive. The characters are taken from the 95 printable ASCII characters, byte values 32 (0x20) to 126 (0x7E) ( to ~) Output Your code must compute and output all strings within Levenshtein distance 2 of S. You can have duplicates as long as you also have all the differen...
stackexchange_codegolf
This was fun! However with only three digits, the fun was over way too soon. This challenge is similar, but we'll keep the fun going. The Challenge Print as many digits of the Golden Ratio φ as possible. The Golden Ratio is defined as the number that satisfies φ = (φ + 1)/φ and the first 100 digits are given by: 1.618...
stackexchange_codegolf
Warning: Contains minor Deltarune Chapter 1 Spoilers Within the Forest section of the first chapter of Deltarune, there are a few puzzles that consist of entering playing-card suits in a certain order to move to the next section. Below is an example of such a puzzle: The way to solve the puzzle is to do any of the ...
stackexchange_codegolf
CODE GOLF & Coding Challenges: In today's challenge, you'll be asked to print the following very special AND tricky AND satisfying Prime Number...! Are you golfers ready? 67796869327179767032383267111100105110103326710497108108101110103101115583273110321161111009712139115329910497108108101110103101443212111111739108108...
stackexchange_codegolf
Challenge Your challenge is to make a simple program that takes the [input] and formats it as "Hello, [input]!" Input Either a function call variable or STDIN, this is the name. Can contain any character, UTF-8, and can be empty - would result in Hello,!. Also newlines in the input are fine - On a new line -> Hello, O...
stackexchange_codegolf
Task Write a program/function that when given three 2d points in cartesian coordinates as input outputs a truthy value if they are collinear otherwise a falsey value Three points are said to be collinear if there exists a straight line that passes through all the points You may assume that the coordinates of the three ...
stackexchange_codegolf
When I write documentation, comments, etc. I love making ASCII tables. They usually end up looking pretty good, but I always feel that they could look even better - especially since UTF-8/Unicode includes the box drawing characters. However, these characters are very burdensome to use, requiring several key presses to ...
stackexchange_codegolf
The brilliant engineers at <enter company you love to hate> have struck again. This time they've "revolutionised" the generation of random permutations. "Every great invention is simple" they say and their magical new algorithm is as follows: Start with a list 1,2,3,...,n of numbers to permute. For each element x in t...
stackexchange_codegolf
Yes, I know there is a similar question, but this one specifically concerns any possible words, even with letters left over, while the linked one restricts to a permutation of the input Objective Have you ever had those moments in a Scrabble game where you're staring at your letters, trying to find a good word, and y...
stackexchange_codegolf
Given 4096 16-bit integers, only four of which are unique and others appeared twice (so 2050 different integers exist). Find the four uniques. To time precisely and limit RAM usage, your program will be run on a 12MHz 8051(with 128B RAM). I'll test with a random case generated by some code to test, but we aim at the wo...
stackexchange_codegolf
Overview I was playing with Desmos and discovered a really cool spiral: Doing some research, I discovered that this spiral was the Archimedian spiral. Every point on the spiral is exactly \$\theta\$ away from the origin, where \$\theta\$ is the angle from the origin. That is, any point on the spiral has the polar coo...
stackexchange_codegolf
AlienWar This game takes place in a very crowded planet where aliens are the superior race. Your task is to create your own alien and beat all other. The Board It is a 2 dimensional board. The length of one side of the board is Math.ceil(sqrt(species * 100 * 2.5)) = ~40% of board used. The board is a planet, so if you ...
stackexchange_codegolf
This challenge is completely ripped offheavily inspired by All Light, developed by Soulgit Games. Challenge You are an electrician, and it's your job to wire up all the lights to the battery. The lights and battery are laid out in a grid. You can connect a light or battery to the nearest light or battery to its north,...
stackexchange_codegolf
You're a farmer and your flock of sheep has escaped! Oh no! Round up those sheep by building fences to contain them. As a farmer on a budget you want to use the least amount of fence possible. Luckily for you though, they aren't the smartest sheep in the world and don't bother moving after having escaped. Task Given...
stackexchange_codegolf
In a far-off kingdom, a chess queen takes a daily walk across a spiral path, numbered from 1 to n, not caring to follow the spiral itself, but simply making queen's moves as she would on a chessboard. The queen is beloved by her subjects, and they make a note of every square she visits on her path. Given that the queen...
stackexchange_codegolf
What general tips do you have for golfing in sed? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to sed (e.g. "remove comments" is not an answer). Please post one tip per answer.
stackexchange_codegolf
Challenge Convert and print out a time in a 12-hour format. HH:MM AM/PM Examples Input: 'Fri Jun 30 2017 21:14:20 GMT-0700 (PDT)' 'Fri Jun 30 2017 00:10:23 GMT-0700 (PDT)' 'Fri Jun 30 2017 12:10:23 GMT-0700 (PDT)' 'Sat Jun 31 2018 8:06:20 GMT-0700 (PDT)' 'Fri Jul 01 2017 01:14:20 GMT-0700 (PDT)' 'Sat Apr 10 2020 09:06...
stackexchange_codegolf
Conways' 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
Given a non-empty string, keep removing the first and last characters until you get to one or two characters. For example, if the string was abcde, your program should print: abcde bcd c However, if it was abcdef, it should stop at two characters: abcdef bcde cd Trailing newlines and trailing spaces at the end ...
stackexchange_codegolf
In this challenge you will receive a list of pairs of non-negative integers representing a mushroom forest. Each pair represents a mushroom whose center is at that horizontal coordinate. The only part of the mushroom we care about is the cap (the flat bit at the top). The first integer in each pair represents which ro...
stackexchange_codegolf
On Unix-like systems, the ls command lists files. GNU's version of ls also colors them according to their properties and the environment variable LS_COLORS. The main file property that ls bases its colors on is the file's mode. In this challenge, you will determine what keys from LS_COLORS ls should look for a given mo...
stackexchange_codegolf
Introduction For this example, let's take the string Hello, World! and the array [3, 2, 3]. To find the substring chain, we go through the following process: The first number of the array is 3, so we get the substring [0 - 3], which is Hel. After that, we remove the first 3 characters from the initial string, which lea...
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
EDIT It is not clear how answers to the question of compressing a long text, without cumulative properties are relevant to golfing a short cumulative strong, any more than general Lempel Ziv techniques are relevant to code-golfing. Take note that the complexity of 99 bottles of beer is not O(Sqrt(n)) Knuth suggested t...
stackexchange_codegolf
Given a non-negative integer n, print the result of P(P(...P({}))), where the number of P's is n (P is the power set function). 0 => {} 1 => P({}) 2 => P(P({})) 3 => P(P(P({}))) n => P(f(n-1)) input result 0 {} 1 {{}} 2 {{},{{}}} 3 {{},{{}},{{{}}},{{},{{}}}} ... The result should only contai...
stackexchange_codegolf
You might already be familiar with the game: Basketball FRVR in facebook. There are two types of score you can make: A virgin-shot:(we call it so in our country :D) When the ball enters the basket without touching the rim or A stale shot: When the ball enters the basket, but after touching the rim. The game is over ...
stackexchange_codegolf
If you are given an array of numbers between 1 and 100 and an integer n, you must remove any instances of an item that appear greater than n times. For example: In : [92, 41, 81, 47, 28, 92, 84, 92, 81], n = 1 Out: [92, 41, 81, 47, 28, 84] The most aesthetic/simple algorithm wins. And since this is a popularity-contes...
stackexchange_codegolf
An ordinary N-digit combination lock consists of N rotating discs. Each disc has digits 0-9 inscribed in order, and you need to turn them to the correct password to open it. Obviously, if you don't know the password, you will need to try at most 10N times before unlocking it. That's not interesting. So let's consider ...
stackexchange_codegolf
What makes the ideal question? Perhaps it is merely the abstraction of a profound thought and the initialization of a dream, a hope, a thought, a (… 5,024.2 characters omitted). Therefore, I propose that we find such a factor to quantify questions. I propose also that this factor be called QF, or the Q-factor. I determ...
stackexchange_codegolf
Write a regular expression substitution string which can base64 decode a string using only a regular expression engine built into the language. Eg: # Example in python import re print(re.sub(..., ..., "SGVsbG8gd29ybGQK")) # "Hello world\n" # ^^^ ^^^ # These count towards your byte count, the...
stackexchange_codegolf
Input a datetime, format the datetime in YYYY-MM-DD HH:mm:ss format using 30-hour clock time. The 30-hour clock time works as: After 6 a.m., it is same as 24-hour clock time Before 6 a.m., it use date for previous day, and plus Hours by 24. For more examples, you may checkout the testcases. Rules To simplify the que...
stackexchange_codegolf
It's time for CGCC to demonstrate our musical talent! In this challenge, you're going to compose songs while keeping your byte count as small as possible. On Day 0, multiple answerers will post a function or program that outputs nothing/an empty string. They will also give a single line that next day's answers must out...
stackexchange_codegolf
Given an array of integers, count the number of contiguous subarrays with an even sum. You may assume that the array is non-empty, and contains only non-negative integers. This is code-golf, so the shortest code in bytes wins. Test Cases Input -> Output [7] -> 0 [8] -> 1 [3, 5] -> 1 [6, 2] -> 3 [2, 4, 5] -> 3 [7, 4, 0,...
stackexchange_codegolf
Seven countries lay official claims to parts of Antarctica: Argentina, Australia, Chile, France, New Zealand, Norway, and the United Kingdom. We will focus only on the claims of the main Antarctic landmass south of 60° S, which are: Chile: between 90° W and 53° W United Kingdom: between 80° W and 20° W Argentina: betw...
stackexchange_codegolf
Overview Shue (Simplified Thue) is a language that was designed by AnttiP for this challenge. A Shue program consists of the possible outputs and a list of string replacements. For example, the following program prints "yes" if an unary string is even: yes no 11=2 12=1 22=2 1=no 2=yes Try it online! The possible outpu...
stackexchange_codegolf
Write a regular expression substitution string which can base64 decode a string using only a regular expression engine built into the language. Eg: # Example in python import re print(re.sub(..., ..., "SGVsbG8gd29ybGQK")) # "Hello world\n" # ^^^ ^^^ # These count towards your byte count, the...
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
\$\left\{ n \atop k \right\}\$ or \$S(n, k)\$ is a way of referring to the Stirling numbers of the second kind, the number of ways to partition a set of \$n\$ items into \$k\$ non-empty subsets. For example, to partition \$\{1,2,3,4\}\$ into \$2\$ non-empty subsets, we have $$\begin{matrix} \{\{1\},\{2,3,4\}\} & \{\{2\...
stackexchange_codegolf
Röda is a stream-based scripting language created by fergusq. What general tips do you have for golfing in Röda? I'm looking for ideas that can which can be applied to code-golf problems and which are also at least somewhat specific to Röda (e.g. "remove comments" is not an answer). Please post one tip per answer.
stackexchange_codegolf
Given two lists of numbers, a source and a pattern, reorder the source to match the relative ordering of the pattern. Any two entries of the reordered source should compare the same way as the entries at those same positions of the pattern. For example, the input s = [-5, 9, 4, 13, 11, -6, 0] p = [7, -4, 1, -8, 4, -3, ...
stackexchange_codegolf
The Riemann R function is as follows: $$R (x)=\sum _{n=1}^{\infty } \frac{\mu (n) \text{li}\left(x^{1/n}\right)}{n}.$$ This uses the Möbius function as well as the logarithmic integral. From Wikipedia, the Möbius function is defined so that for any positive integer \$n\$, \$μ(n)\$ is the sum of the primitive nth roots...
stackexchange_codegolf
Given a number n > 77, write a program or function that finds a set of distinct positive integers such that the sum of the set equals n, and the sum of the reciprocals of the set equals 1. Example for 80: 80 = 2 + 4 + 10 + 15 + 21 + 28    ⟶     1/2 + 1/4 + 1/10 + 1/15 + 1/21 + 1/28 = 1 Your program or function must...
stackexchange_codegolf
Before you leave, you do not have to understand much musical notation to do this challenge. EXPLANATION In standard sheet music, double clefs go across the page serving as reference points to the notes, letting you know what note should be played. If you are not already familiar with the treble and bass clef, here i...
stackexchange_codegolf
For a given list of number \$[x_1, x_2, x_3, ..., x_n]\$ find the last digit of \$x_1 ^{x_2 ^ {x_3 ^ {\dots ^ {x_n}}}}\$ Example: [3, 4, 2] == 1 [4, 3, 2] == 4 [4, 3, 1] == 4 [5, 3, 2] == 5 Because \$3 ^ {(4 ^ 2)} = 3 ^ {16} = 43046721\$. Because \$4 ^ {(3 ^ 2)} = 4 ^ {9} = 262144\$. Because \$4 ^ {(3 ^ 1)} = 4 ^ {...
stackexchange_codegolf
The computational parity of an integer is defined as 1 if the integer has an odd number of set bits, and 0 otherwise. (src). Input You will receive one nonnegative integer that you will take the parity of. Optionally, you may take the size of the integer in bytes or bits as an argument, but you must specify this in yo...
stackexchange_codegolf
Given an array of positive integers A as the input, generate a program that, when repeated for k times, output the kth(1-index) value of the array. For example, if the array is [1,11], the output should be a program that outputs 1, and when repeated twice, output 11. Code like print(end="1"); in Python 3 works: print(e...
stackexchange_codegolf
In this challenge you will be asked to take a knot and determine if it can be colored in a particular way. First we draw a diagram of the knot. We use the standard way of drawing knots where we put gaps in strands where they pass under each other. Here is an example of some knots drawn this way: Taken with permissio...
stackexchange_codegolf
Given an infix expression, determine whether all constants are of the same type. Operators will consist only of these dyadic operators: +-/* Your program or function should take a valid expression string as input, and output a truthy value if the constants in the expression are of the same time, and a falsey value othe...
stackexchange_codegolf
Given a directed graph on the nodes 0, 1, ..n, where each edge has two non-negative integer costs, return the set of all possible Pareto Optimal path costs between node 0 and node n. These are the costs of paths for which you cannot decrease the first component of the cost without increasing the second component, and c...
stackexchange_codegolf
Write a GOLF assembly program that reads an integer from stdin (followed by a trailing newline), and outputs its prime factors seperated by newlines, followed by a trailing newline on stdout. The prime factors need not be in a particular order. 1 is not a prime factor. Your GOLF binary (after assembling) must fit in 81...
stackexchange_codegolf
You are given a string \$s\$ of characters from a to z. Your task is to count how many unique strings of length \$n\$ you can make by concatenating multiple prefixes of the string \$s\$ together. Since the result can be superlative you can either choose to output the whole result, the result mod \$2^{32}\$ or the resul...
stackexchange_codegolf
The winding number is the integer number of net counterclockwise revolutions an observer must have made to follow a given closed path. Note that any clockwise revolutions count negative towards the winding number. The path is allowed to self intersect. Some examples (shamelessly taken from Wikipedia) are given below: ...
stackexchange_codegolf
Consider a date formatted in YYYY-MM-DD. You can use the joker * at the end of the date string. E.g. 2016-07-2* describes all the dates from 2016-07-20 to 2016-07-29. Now, consider a period represented by a start date and an end date. The algorithm must find the smallest possible list of dates representing the period....
stackexchange_codegolf
You have to decompose a positive integer/fraction as a product of powers of factorials of prime numbers. For example 22 = (11!)^1 × (7!)^(−1) × (5!)^(−1) × (3!)^(−1) × (2!)^1 10/9 = (5!)^1 × (3!)^(−3) × (2!)^1 Use this special notation: prime number#power to denote each term, e.g. (11!)^4 is denoted as 11#4. Output...
stackexchange_codegolf
Output the following table: 一一得一 一二得二 二二得四 一三得三 二三得六 三三得九 一四得四 二四得八 三四十二 四四十六 一五得五 二五一十 三五十五 四五二十 五五二十五 一六得六 二六十二 三六十八 四六二十四 五六三十 六六三十六 一七得七 二七十四 三七二十一 四七二十八 五七三十五 六七四十二 七七四十九 一八得八 二八十六 三八二十四 四八三十二 五八四十 六八四十八 七八五十六 八八六十四 一九得九 二九十八 三九二十七 四九三十六 五九四十五 六九五十四 七九六十三 八九七十二 九九八十一 Or you can use the first three letters in its ...
stackexchange_codegolf
The Chinese Remainder Theorem can be quite useful in modular arithmetic. For example, consider the following set of congruence relations: For sets of congruence relations like this, where all the bases (3, 5, 7 in this example) are co-prime with each other, there will be one and only one integer n between 1 and the pr...
stackexchange_codegolf
Background Bilibili is a China-based video sharing platform, similar to Nico Nico Douga in Japan, and Youtube around the world. Since the establishment, Bilibili had been using the AV code to reference a video. An AV code is a string of 3 or more characters, starting with av and followed by a natural number, like av820...
stackexchange_codegolf
Shortest program wins, of course.
stackexchange_codegolf
The Lisp language has a family of functions car, cdr, cadr, etc for accessing arrays. For each one, an a defines taking the first item of an array, and a d defines taking the rest. For example, running cadr on [[1,3,4],5,7] will return [3,4] as the a gets the first item ([1,3,4]) and the d removes the first item. We've...
stackexchange_codegolf
Legendre's Conjecture is an unproven statement regarding the distribution of prime numbers; it asserts there is at least one prime number in the interval \$(n^2,(n+1)^2)\$ for all natural \$n\$. The Challenge Make a program which only halts if Legendre's conjecture is false. Equivalently, the program will halt if there...
stackexchange_codegolf
Find the moves that bring a chess squad to a given destination. You control a chess squad consisting of a king and several other pieces, on a larger chess board. Your army is placed so that no piece is further than K=8 squares away (horizontally and vertically) from your king. You will receive a destination square for ...
stackexchange_codegolf
Some people count sheep to get to sleep. Others count goats. Write a program or function that takes in a positive integer N and outputs N-1 awake goats followed by one sleeping goat, as if someone was counting N goats and at the very last one they fell asleep. Awake goats look like this: \ ___/o> -(___)" '' ''...
stackexchange_codegolf
Given a unix timestamp as an input, give a datetime string, in a format like so: "YYMMDD.HHmm" Rules The input is a number (integer) of a millisecond-precise UNIX epoch time (milliseconds since 1970 January 1st 00:00:00.000 UTC). The values must be padded with zeroes if they are 1 character instead of 2. (e.g.: for "D...
stackexchange_codegolf
Task Given a wrapper element and a non-jagged 3D array, wrap the array top, bottom, and all-around. You must handle both character and numeric data, but the wrapper and the present will have the same data type. Character example For character data, you may chose to handle either 3D arrays of single characters or 2D ar...
stackexchange_codegolf
The determined Real Programmer can write Fortran programs in any language. from Real Programmers Don't Use Pascal Your task is to write program in your programming language of choice, but you are allowed to use only another language. That is, throw away all coding conventions from one language and replace them with c...
stackexchange_codegolf
Several Mathematica functions have system-defined short forms, e.g., /@ for Map. Many of them are listed here: https://reference.wolfram.com/language/tutorial/OperatorInputForms.html However, there also exist some system-defined short forms for function-option combinations. E.g., Log2@ninstead of Log[2, n] and Log10@...
stackexchange_codegolf
Apparently, we really like printing the alphabet in different languages. How about the Russian Cyrillic alphabet? Print/output/return this exact text (trailing whitespace is permitted) АаБбВвГгДдЕеЁёЖжЗзИиЙйКкЛлМмНнОоПпРрСсТтУуФфХхЦцЧчШшЩщЪъЫыЬьЭэЮюЯя This is the Russian Cyrillic alphabet with upper and lower case int...
stackexchange_codegolf
Input: A string (the wave-snippet) with a length >= 2. A positive integer n >= 1. Output: We output a single-line wave. We do this by repeating the input string n times. Challenge rules: If the first and last character of the input string matches, we only output it once in the total output (i.e. ^_^ of length 2 beco...
stackexchange_codegolf