instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Giving n(any amount) of points (x,y). What's the minimum amount of circles required to cross every point given? Task Your program will get n (you can have n as part of input or use EOF instead) points (x,y). The points might at same place => (x1,y1) = (x2,y2) can happen x and y will be integer of range -10000~10000, wh...
stackexchange_codegolf
Oh no! There are a bunch of meteoroids on my way through the universe ... what am I and my space ship, the SP4C3, supposed to do? I need to manoeuver my shuttle through these rocks or I am done for! Your Task Write a program that guides my shuttle through a map of asteroids, using as few bytes as possible since I don't...
stackexchange_codegolf
Introduction Write a solver for the Hitori puzzles using least bytes. Challenge Your task is write a solver for the Hitori (ひとり, the word for "alone" in Japanese; the meaning of the game name is "Leave me alone") logical puzzles. The rules are as follows: You are presented with a n-by-n grid of cells, each cell contai...
stackexchange_codegolf
Can Alice win the game? The game's rules are as follows. First, a finite non empty set of positive integers \$X\$ is defined. Then, Alice and Bob take turns choosing positive integers, with Alice going first. Each integer must be strictly less than the previous one, and the game ends when one of the players chooses \$1...
stackexchange_codegolf
How, you can’t remember the 6 or 7-digit phone number that appeared on the TV screen for a second?! Using the special technique described below, you will turn into a walking phonebook! Obviously, the number 402 is easier to remember than the number 110010010, and the number 337377 is easier to remember than the number ...
stackexchange_codegolf
The challenge here is simple, and not at all about byte-count. Your job is to output the first 50 characters of the previous quine's source code, concatenated with the first 50 characters of yours starting with the 50 characters I've placed below: abcdefghijklmnopqrstuvwxyzACDEFGHIJKLMNOPQRSTUVWXY So, lets take an exa...
stackexchange_codegolf
Challenge Giving a valid arithmetic sum with some missing numbers, output the full expression. Example: 1#3 123 + 45# => + 456 -------- -------- 579 579 Input Expression format can be an array ["1#3", "45#", "579"], a string "1#3+45#=579", or 3 inputs f...
stackexchange_codegolf
Introduction Today I went fishing alone with my canoe, unfortunately I fell asleep and the stream brought me away, I lost my oars, now it's night and I am lost in the ocean! I can't see the coast so I must be far away! I have my cell phone but is malfunctional because it got wet by the salty water, I can't talk or he...
stackexchange_codegolf
Background The Rearrangement Inequality is an inequality that is based on rearranging numbers. If I have two lists of numbers of the same length, x0, x1, x2...xn-1 and y0, y1, y2...yn-1 of the same length, where I am allowed to rearrange the numbers in the list, a way to maximize the sum x0y0+x1y1+x2y2+...+xn-1yn-1 is ...
stackexchange_codegolf
Given a number n and an upper limit l list the numbers that can be created by multiplying two or more numbers consisting of only sevens of length n or less that are less than l. A161145 is close to this challenge, however, you will NOT be including the 7, 77, 777, 7777, 77777, etc.. Examples n=anything, l<49 would resu...
stackexchange_codegolf
makina is a cell-based esolang composed of automata which move around a grid. These automata follow paths of instructions that direct their movement. Your task is to, given a makina program using only the below instructions (so a subset of normal makina) as input, output two distinct values depending on whether or not ...
stackexchange_codegolf
Write a function to produce, for a non-negative integer, a string containing a sum of terms according to the following: 3 -> "3" 805 -> "800 + 5" 700390 -> "700000 + 300 + 90" 0 -> "0" 13 -> "10 + 3" 200 -> "200" Any input other than a non-negative integer can be ignored. Zero terms must be skipped unless the inp...
stackexchange_codegolf
Given a positive integer n > 1 determine how many numbers can be made by adding integers greater than 1 whose product is n. For example if n = 24 we can express n as a product in the following ways 24 = 24 -> 24 = 24 24 = 12 * 2 -> 12 + 2 = 14 24 = 6 * 2 * 2 -> 6 + 2 + 2 ...
stackexchange_codegolf
Given a, b, c the length of the three sides of a triangle, say if the triangle is right-angled (i.e. has one angle equal to 90 degrees) or not. Input Three positive integer values in any order Output Either a specific true output (true, 1, yes, ...) or a specific false output (false, 0, no, ...) Example 5, 3, 4 ...
stackexchange_codegolf
You have a bunch of cities on a grid which you wish to link up. Roads can be placed on any tile that doesn't contain a city, and connect to all roads or cities adjacent to them, vertically, horizontally or diagonally. Roads can link up via cities, for example C \ C-C is fully linked up. However, there are some moun...
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
Background It can be shown that for any integer k >= 0, f(k) = tan(atan(0) + atan(1) + atan(2) + ... + atan(k)) is a rational number. Goal Write a complete program or function which when given k >= 0, outputs f(k) as a single reduced fraction (the numerator and denominator are coprime). Test cases The first few values ...
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
Goal: Given any non-zero natural number a, find the smallest non-zero natural number b such that a•b is palindromic, e.g. it reads the same forwards and backwards. Input a through any reasonable means (STDIN, function argument, etc.), And output b through any reasonable means (STDOUT, function return value.) Notes: In...
stackexchange_codegolf
Winner found It seems as if we have a winner! Unless anyone plans on contesting the world's current fastest Sudoku solver, user 53x15 wins with the staggeringly fast solver Tdoku. For anyone still working on their solvers, I'll still benchmark new submissions when I have time. The challenge The goal of a game of Sudoku...
stackexchange_codegolf
Challenge Given any positive integer supported by your language: Take the input and divide it into two halves. For all divisions in this program, if the input is odd, round one half up and one half down (ex: 7 -> 3,4, not 7 -> 3.5,3.5). Divide either number in half, then take the larger of these two new halves and add...
stackexchange_codegolf
The following problem is a common interview question, thus dull answers are discouraged. Go short or creative, best if both: Create the following pattern ########### ## ## # # # # # # # # # # # # # # # # # # # # # # # # # # # ## ## ########### In case you cry "dupe", I see y...
stackexchange_codegolf
This is a sequence question of the usual type, as applied to OEIS sequence A038666. That is, do either of the following: Accept no or any input, and output A038666 until the heat death of the universe. Accept a positive integer as input, and output the \$n\$th term of A038666 or its first \$n\$ terms. (If using \$0\$-...
stackexchange_codegolf
Write a function in Python 2.7 that takes a list of integers as an argument. It should return True or False depending on whether there are any 2 integers in the argument list that sum to zero. [4,-4,9,6,5] True [6,5,-3,2] False
stackexchange_codegolf
Given two non-zero 16-bit integers a and b, decide the smallest number of shift operations needed to turn a into b. A shift is one of the following (big-endian) operations: shl (shift left): move all bits to the left, adding a 0x0 bit to the right. shr (shift right): move all bytes to the right, adding a 0x0 bit to th...
stackexchange_codegolf
Your Task: Write a program or function that, when given a number, outputs its persistence. The persistence of a number is the number of times you can add its digits before arriving at a one-digit number. All one digit numbers have a persistence of 0. Note that this is different from questions about finding the digit...
stackexchange_codegolf
The ubiquitous Catalan numbers \$C_n\$ count the number of Dyck paths, sequences of up-steps and down-steps of length \$2n\$ that start and end on a horizontal line and never go below said line. Many other interesting sequences can be defined as the number of Dyck paths satisfying given conditions, of which the Fine se...
stackexchange_codegolf
Challenge: make a program that outputs a MD5 hash of its source code. You should not use tricks that would be considered cheating in a quine sense (discussed here). Using built-in functions and external libraries is allowed. The program should be a full program (not a function/subroutine). Code-golf: shortest solution ...
stackexchange_codegolf
Description There have been quite a few other challenges concerning these numbers before, and I hope this one is not among them. The n th triangular number equals the sum of all natural numbers up to n, simple stuff. There are a wikipedia page and an entry at OEIS, for those who wish to inform themselves further. Now, ...
stackexchange_codegolf
I'd like you to build me a clock that displays time in this format: 18 ---------- 19 -------------------------------------------------- This displays '18:10'. The current hour and the next hour are shown at the front of the line, followed by a space and a number of dashes: on the first line the number of minutes that ...
stackexchange_codegolf
The challenge How well can you gerrymander North Carolina into 13 voting districts? In this challenge, you use the following files to draw different maps for Republicans and Democrats. File 1: NC_2016_presidential_election.csv File 2: NC_county_adjacency.csv File 1 gives county-level voting data from the 2016 president...
stackexchange_codegolf
A Latin square of order n is text which is arranged as a square of n lines by n columns, contains n different characters, and each character appears once in each line and column. For example, here is a Latin square of order 9: Code gOlf ode gOlfC de gOlfCo e gOlfCod gOlfCode gOlfCode OlfCode g lfCode gO fCode gOl M...
stackexchange_codegolf
your challenge is to draw this ASCII art: | | |- - - - | | - - - | | | | | | | |- - -| |- - - | | | | | | | | | | | | | |- - - - |- - - |- - - - - - remember this is code golf meaning you have to answer in the leas...
stackexchange_codegolf
Letters of the words want fairness. They decided to appear same number of times in a sentence equally. Example: Priorities Will become: Ppprrioooritttieeesss Each letter appears 3 times, as the most common letter was i, appearing 3 times. It does not matter where you put the repeated letters, as long as they are next...
stackexchange_codegolf
It seems we've managed to go all this time without a plain vanilla Number-To-Binary challenge! Whilst this will inevitably be only one element in many languages, it should put a few esolangs through their paces. I truly looked for this challenge to no avail. If it already exists, comment as such and I'll delete this po...
stackexchange_codegolf
Story The god of base is opening heaven’s gate for mortals to join the base party. You, as one of the believers, want to follow their steps to ascend to heaven. But not everyone can get in. The god posts this question to let you prove you are worthy of their party. Task You will get 2 inputs First being X which is a n...
stackexchange_codegolf
Given a string containing only 0's 1's, 2's and brackets, output the grammar tree of the string. A 2 requires 2 arguments - one to the left and one to the right A 1 requires a single argument - to either the left or right A 0 doesn't require any arguments and is the base case A pair of brackets counts as one argument a...
stackexchange_codegolf
The coefficients of a perfect square polynomial can be calculated by the formula \$(ax)^2 + 2abx + b^2\$, where both a and b are integers. The objective of this challenge is to create a program that not only can find if an input trinomial is a perfect square, but also find its square root binomial. The input trinomial ...
stackexchange_codegolf
With this challenge we pay homage to everyone around the whole world fighting against the coronavirus crisis; particularly represented are the people tied to medicine, as the Rod of Asclepius is a symbol associated with medicine and health care. For that matter, we resort to some ASCII art found at asciiart.eu (wrongfu...
stackexchange_codegolf
Following the great advice (what do you mean it's not advice?!) on Adding unnecessary fluff we can devise the following task: Take a list of positive integers and a positive integer \$m\$ as input. Only keep the prime values from the list. Define \$f(n) = F_{n^2 + 1}\$ (the \$n^2+1\$-th element in the Fibonacci sequen...
stackexchange_codegolf
Related but different. Part II Taken from the book: Marvin Minsky 1967 – Computation: Finite and Infinite Machines, chapter 14. Background As the Gödel proved, it is possible to encode with a unique positive integer not just any string but any list structure, with any level of nesting. Procedure of encoding \$G(x)\$ i...
stackexchange_codegolf
I don't like numbers, but I do like the Fibonacci sequence. I'm sure we could work something out. Please read one integer n from STDIN and output the nth Fibonacci number in base 26 (abcdefghijklmnopqrstuvwxyz instead of 0123456789) to STDOUT. The first Fibonacci number is 0. The second one is 1. The nth fibonacci num...
stackexchange_codegolf
You are given an integer n as input, and, regardless of the current date, must return the calendar year (Gregorian calendar, other calendars not allowed) taking place n seconds from now. Rules You may not assume that the current year is 2021. In other words, imagine a user testing your solution in five years. Standard...
stackexchange_codegolf
Challenge Choose any number of languages. Call this set L. Write a program so that running it in any language in L produces an interpreter for a different language in L. Each language in L must have exactly one interpreter for it. This is to prevent, for example, Nothing or Text being part of L and all interpreters be...
stackexchange_codegolf
Inspired by Braille graphics and Build an analog clock. The goal there is to create a tool that use terminal console to draw and animate a clock by using UTF-8 fonts \U2800: ⠀ to \U28FF: ⣿. 00:[⠀] 01:[⠁] 02:[⠂] 03:[⠃] 04:[⠄] 05:[⠅] 06:[⠆] 07:[⠇] 08:[⠈] 09:[⠉] 0A:[⠊] 0B:[⠋] 0C:[⠌] 0D:[⠍] 0E:[⠎] 0F:[⠏] 10:[⠐] 11:[⠑] 12:...
stackexchange_codegolf
Inspired by Find the “unwrapped size” of a list. Define the Recursive Size, RS, of a list containing no lists as its length (number of items contained) and the Recursive Size of a list containing any lists as the sum of its length and the Recursive Size of those lists. Challenge Write a program or function that outputs...
stackexchange_codegolf
Write a program, given an input n, will generate all possible n-tuples using natural numbers. n=1 (1),(2),(3),(4),(5),(6)... n=2 (1,1),(1,2),(2,1),(2,2),(1,3),(3,1),(2,3),(3,2),(3,3)... n=6 (1,1,1,1,1,1) (1,1,1,1,2,1) (1,1,1,2,1,1)... The output may be in any order that does not break any other rules. The program...
stackexchange_codegolf
Goal You are given an integer n (n > 1). You must output how many permutations of the integers 1 to n there are which start at 1, end at n, and don't have two consecutive integers which differ by 1. Alternatively, if you take the complete graph K_n and remove the edges of the path 1-2-3-...-n you must count the Hamilto...
stackexchange_codegolf
This is based off this challenge. Given an input string, check whether the string is blurry. What's a blurry string? A blurry string is a string that's contained in the set of all blurrified pure-ASCII strings. Take a non-blurrified pure-ASCII string abc as an example. You repeat every character of this twice: aabbcc ...
stackexchange_codegolf
Given two different positions on a chess board and the type of piece, output the minimum number of moves it will take for that piece to go from one position to another. Rules The given piece can be King,Queen,Rook,Knight and Bishop. (This input can be taken as any 5 unique characters) The 2 positions can be taken in an...
stackexchange_codegolf
In this question each answer will get a "toolbox" that can be used to construct a program/function. The toolbox will consist of two things: a list of programming languages a list of valid characters You must write a valid program/function in one of the languages provided using only the characters in the toolbox. Yo...
stackexchange_codegolf
As you probably know, there have been multiple lovely Jimmy challenges recently popping up. In these challenges, you were challenged with our beloved friend's acrobatics skills. Now we've got a different challenge for you. Today you will be identifying different types of Jimmys! Explanation There are three varieties o...
stackexchange_codegolf
Challenge An ascii string is made 'dank' when exactly one space is inserted between any two consecutive letters and all capital letters are replaced with lowercase ones. In this challenge I would like you to write a program that takes a string (not necessarily 'dank') as input and outputs a 'dank' version of that strin...
stackexchange_codegolf
Background (feel free to skip) Ordinals are the abstract representation of well-orders. A well-order of a set is a total order, which basically means that every element in the set can be compared against any other element in the set, and one of them is either smaller or larger. Also there are no cycles. The crucial dif...
stackexchange_codegolf
Your network scanning tool is annoyingly picky about input, and immediately crashes if you feed it an IPv4 address that contains improper characters or isn't properly formatted. An IPv4 address is a 32-bit numeric address written as four numbers separated by periods. Each number can be zero to 255. We need to write a...
stackexchange_codegolf
The Challenge Your challenge is to write a program that evaluates the following function: f(x, t) = d^x / dt^x (sin t) That is, the x-th derivative of sin t. In case you aren't familiar with calculus, here is a table of derivatives for the sine function: ... f(-1, t) = -cos t f(0, t) = sin t f(1, t) = cos t f(2, t)= -s...
stackexchange_codegolf
There are 3 (commonly used) trigonometric functions sin cos and tan each of these functions has an inverse function You goal is to write 3 programs or functions (one for each inverse trigonometric function asin acos atan) that take a (real) number a input and return the result of the corresponding inverse trigonometric...
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
We see a lot of challenges here asking for a function to create a sequence from the OEIS. While these challenges are fun, as a programmer I see an opportunity for automation. Your challenge is to make a program that takes the index of a sequence (e.g. A172141) and some integer n (e.g. 7), and pulls the appropriate val...
stackexchange_codegolf
What is the shortest way of generating a random string with a given length and with only alphanumeric characters allowed? example of a random string: with N = 9 output would be aZua7I0Lk the given length N can be assumed to be always greater than 0 if necessary you can assume 256 as a maximum value for N, but solution...
stackexchange_codegolf
You are to write a program or function that outputs this exact text: OPQRSTU NQPONMV MREDCLW LSFABKX KTGHIJY JUVWXYZA IHGFEDCB May also be lowercase and trailing spaces and newlines are allowed. Standard loopholes are disallowed This is code-golf, so smallest byte count wins.
stackexchange_codegolf
This challenge is inspired by turn based videogames like "Heroes of Might and Magic" Implement this game mechanic: There is some units(Imps, Swordsmans etc...) in our game Every unit have an integer "initiative" Your program must decide which unit's turn now - based on unit's initiative The more initiative means mor...
stackexchange_codegolf
A lawn is defined as a rectangular field with of one character surrounded by two layers of visible whitespace. This means two lines above and twos lines below, and a two space padding on the left (the right has visible whitespace, so you do not need to include it).     ||||| ||||| |||||     A mowed lawn is...
stackexchange_codegolf
I saw a problem which asks you to print "Hello World" using the fewest characters, including spaces. How can I further shorten this code? Thank you in advance! #include<iostream> int main(){printf("Hello World");}
stackexchange_codegolf
A number is in base-b simplified Goodstein form if it is written as b + b + ... + b + c, 0 < c ≤ b The simplified Goodstein sequence of a number starts with writing the number in base-1 simplified Goodstein form, then replacing all 1's with 2's and subtracting 1. Rewrite the result in base-2 simplified Goodstein for...
stackexchange_codegolf
Part of Advent of Code Golf 2021 event. See the linked meta post for details. The story continues from AoC2015 Day 3, Part 2. This challenge was kindly contributed by Wheat Wizard (Grain Ghost). Santa is delivering presents to an infinite two-dimensional grid of houses each 1 unit apart. The delivery begins delivering...
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
Write code that outputs the smallest integer \$n > 5\$ such that \$\frac{\sqrt{\log_2{n}}}{(\log_2 {\log_2 n})^2} > 1\$. Your code may have at most one digit in its source code. You can use your chosen digit more than once however. By digits we are only counting the ASCII characters between 0x30 and 0x39 (inclusive).
stackexchange_codegolf
Let's just see how this goes If you've ever listened to the radio program "I'm sorry, I haven't a clue", then you've probably heard of the game called "Mornington Crescent". For those who haven't, it's a game where players name random stations on the London Underground network. The first person to name "Mornington Cres...
stackexchange_codegolf
Who doesn't love action movies with fast noisy cars, especially those with a lot of crashes? Who doesn't love action shots in ascii art? The scene is: Two cars are starting at opposite sides of a straight road (with 60 spaces between). They start driving towards each other at constant speeds. The car to the left drives...
stackexchange_codegolf
Write a full program or a function taking an unsigned integer number N and doing this cut out work: Cut out a hollow hexagon 'donut' shape with side B-C equal to 2N times '/' Translate the piece above by 3 lines. Repeat the job N times (from the piece obtained) decrementing by 2 '/' side B-C , until smallest hexagon ...
stackexchange_codegolf
A Bingo card is five columns of five squares each, with the middle square designated "FREE". Numbers cannot duplicate. The five columns are populated with the following range of numbers: B:1-15 I:16-30 N:31-45 G:46-60 O:61-75 In as few characters as possible, output a string that can be interpreted as a randomized B...
stackexchange_codegolf
Imagine you have a grid where some squares are walls, some are empty, and some are lights that shine for arbitrary distances in the four cardinal directions until they meet walls: ####.#### ##..L.... ####.##.# ####.##L. ##......L In the above grid, the lights cover all the tiles. But in some cases, they may not be: ##...
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
It's one of these again :D Your task, if you wish to accept it, is to write a program/function (without any uppercase letters) that outputs/returns its string input/argument. The tricky part is that if I convert your source code to uppercase, the output must be reversed. For simplicity, you can assume that the input is...
stackexchange_codegolf
Introduction: I collect twisty puzzles, so I'm quite the fan of rubiks-cube-challenges (even though most are fairly difficult). So, let's try a fairly easy rubiks-cube-challenge for a change. When an NxNxN Cube gets scrambled during a WCA (World Cubing Association) competition, the cube is always held in the same way b...
stackexchange_codegolf
The Task Build a function that takes a string of coins ending with an item index, and generates change as a string of coins using the least amount of coins possible. The following are the items that can be bought (0-indexed): [0.45, 0.60, 0.75, 0.95, 1.10, 1.25, 1.40, 1.50, 1.75, 2.00] The following are the coins that ...
stackexchange_codegolf
In the description of this challenge, the following board will be used as a reference for positions: ABC DEF GHI For instance, in a game of ordinary tic-tac-toe, B E A C G D F H I describes the following: -X- -X- XX- XXO XXO XXO XXO XXO XXO --- -O- -O- -O- -O- OO- OOX OOX OOX --- --- ...
stackexchange_codegolf
Write a function that takes an ASCII-printable-only (all charcodes ∈ [32..126]) string input x and provides an ASCII-printable-only output string f(x), such that for every x f(f(x))=x f(x) is all-numeric (all charcodes ∈ [48..57]) iff x is not all-numeric You can assume input is not empty and never provide empty outp...
stackexchange_codegolf
As the June 2021 Language of the Month is Red, what are some general tips for golfing in Red language? Please suggest tips that are at least somewhat specific to Red (e.g. "remove comments" isn't a valid tip here). Please one tip per answer!
stackexchange_codegolf
It is fairly simple to, given a number n, create a range from 0 to n-1. In fact, many languages provide this operation as a builtin. The following CJam program reads an integer, and then prints out such a range (Try it online!): ri, Notice that it prints out numbers without a separator. The Challenge Your task is to r...
stackexchange_codegolf
Your task is to create a program or function that creates a paste on sprunge.us. Your program/function must receive the text to sprunge from your language's usual input mechanism, such as standard in; or in the case of a function, it can be a string or whatever makes the most sense to you. Your program will POST the te...
stackexchange_codegolf
I've been using a library called Djangular recently, which integrates Django and Angular. After a while I thought 'Wouldn't it be fun to programmatically generate portmanteau?' Here are some examples (e.g. testcases): Django + Angular -> Djangular Camel + Leopard -> Cameleopard Spoon + Fork -> Spoork Ham + Hammer -> Ha...
stackexchange_codegolf
With challenges like Output with the same length as the code and Create output twice the length of the code, I thought of a separate, but similar challenge. The task is to produce an output. It can either be a string, a list of characters, or whatever is the default output format of your program. However, your output ...
stackexchange_codegolf
I've tried this question on two forums and have been told this is the best place for this type of question. I'm trying to print from 0 to 1000 then back to 0 again (and all numbers in-between), printing 1000 only once. Also, each number must be on a separate line using vanilla PHP. My current code is 60 characters long...
stackexchange_codegolf
You are given three parameters: start(int), end(int) and list(of int); Make a function that returns the amount of times all the numbers between start and end are multiples of the elements in the list. example: start = 15; end = 18; list = [2, 4, 3]; 15 => 1 (is multiple of 3) 16 => 2 (is multiple of 2 and 4) 17 => 0 18...
stackexchange_codegolf
Challenge: Given a list of integer, sort descending by their single largest digit(s). The order for numbers with the same largest digit are then sorted by second largest digit, etc. We ignore duplicated digits in numbers. And if all digits in a number are the same, the order of those numbers in the list can be in any w...
stackexchange_codegolf
Given an integer k and either a block of text, or a 2d array that the inner arrays may have unequal lengths (that resembles a block of text), rotate every character or element in the k-th column up or down to the next position that exists. Example Rotate the 20th column of the following text (1-based): A line with more...
stackexchange_codegolf
A portmanteau word is a combination of two words that takes part of each word and makes them into a single new word. For example, lion + tiger => liger. Let's write a program to generate portmanteaus from a pair of input words. Computers aren't the best at English, so we'll need to establish some rules to ensure that t...
stackexchange_codegolf
Not a dupe to this. That question asks specifically for counting up forever, while this question allows many other approaches. Write a program or function which, given infinite time and memory, would print an infinite non-periodic output. Clarifications 'Infinite' means the solution keeps outputting something without ...
stackexchange_codegolf
Given a number x, find the sum of all primes up to that number. The input will always be a positive number, bigger than 2. An upper limit isn't defined, so data types can be ignored. Use whichever you want. This is a code-golf, so the shortest code in bytes wins. Example for 5: 2 + 3 + 5 = 10 Test cases: Input Ou...
stackexchange_codegolf
Challenge Given a single letter (a-z) as input, output the 2 lines of Blackalicious' Alphabet Aerobics that correspond to that letter (ignoring the intro & outro). Rules You may take input by any reasonable, convenient means as long as it's permitted by standard I/O rules. Input must either be case insensitive or con...
stackexchange_codegolf
Are there any functional programming languages designed for code golfing? I know that golfscript and CJam fulfill the same category for stack based, but I couldn't find a functional code golfing language.
stackexchange_codegolf
In chess, the queen piece can move arbitrarily far in each cardinal and intercardinal direction. What does this mean? Well, I'll show you with an ASCII drawing: \..|../ .\.|./. ..\|/.. ---Q--- ../|\.. ./.|.\. /..|..\ It means the queen (notated as Q) can move along these lines (notated as \, |, /, and -), and cannot r...
stackexchange_codegolf
Laguerre polynomials are nontrivial solutions to Laguerre's equation, a second-order linear differential equation: \$xy''+(1-x)y'+ny=0\$. For a given value of \$n\$, the solution, \$y\$, is named \$L_n(x)\$. To avoid trivial solutions, the polynomials are non-constant except for \$n=0\$. The polynomials can be found wi...
stackexchange_codegolf
Super permutations Input: A string The program should loop through all lengths of the input (decrementing one each time), generate all combinations with replacement of the string, then make permutations out of the generated combinations, and display all of the strings. They can be separated with anything (doesn't need...
stackexchange_codegolf
During work on some project I needed to draw pixels on screen. I found some put-pixel function in JS, but code was quite big and clumsy - so I wonder, how small put-pixel function can be... Challenge Create the smallest put-pixel function. We count size of whole program: initialization code (if needed), function and co...
stackexchange_codegolf
A zigzag scan is a method of encoding 2D information in one dimension: Write a function or program that, given a one-dimensional string of printable ASCII characters, will reverse the zigzag scan to arrange its characters into a square. For example, given the input string ABeIfCDgJmnKhLop, your program should return: ...
stackexchange_codegolf
A polyglot is a program that runs in several languages. Your challenge is to: Choose at least two languages (Different versions count as different languages) Create a program or function that takes several positive integers (one for each language you chose) and returns a program that: Is a valid program in all of those...
stackexchange_codegolf
The Mathematica SE question Creating the Yin Yang symbol with minimal code seems to be an out-of-the-box ready-to-go Code Golf SE question! The following code creates the Yin Yang symbol Graphics[{Black, Circle[{0, 0}, 1], White, DiskSegment[{0, 0}, 1, {1/2 \[Pi], 3/2 \[Pi]}], Black, DiskSegment[{0, 0}, 1, {3/...
stackexchange_codegolf