instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
There is a challenge Let's play tennis by Daniel. He proposes to place a court in the North-South direction. My proposal is to create a court to play tennis in the East-West direction too. You have to print a tennis court, but you have to do it in the fewest bytes possible because of confidential reasons. Tennis court...
stackexchange_codegolf
What general tips do you have for golfing in Lexurgy? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Lexurgy (e.g. "remove comments" is not an answer). Please post one tip per answer. Lexurgy is a tool created by Graham Hill/def-gthill meant for conlang...
stackexchange_codegolf
Create quine variant such that the program prints its first character, then the first two, then three and so on until the whole program is printed. Example Suppose your code is @@@@@2 in some language. Then the output should be @ @@ @@@ @@@@ @@@@@ @@@@@2 in that order, each line separated by a newline. The winner is t...
stackexchange_codegolf
This is a cops-and-robbers challenge. Answer here if you are a cop (crossword maker), answer the companion question if you are a robber (crossword solver). You may take on both roles. Cops (Puzzlers) Your task is to write a 10×10 crossword puzzle where, instead of words or phrases, snippets of code are the solutions to...
stackexchange_codegolf
Shikaku is a 2D puzzle. The basic rundown of it is that a rectangular grid has some numbers in it, and you want to partition the grid into rectangular components such that each component contains exactly one number which is the number of grid squares in that component. This challenge involves a 1D simplification of thi...
stackexchange_codegolf
At the time of writing this puzzle, there are soon to be 269 puzzles related to primes. To celebrate/mourn this event (269 is prime), this challenge will be about exploding primes. In preparation for this task, I've obtained a permit (legal, I assure you) for dynamite charges of military grade, along with enormous dyna...
stackexchange_codegolf
Yet another blatant rip-off of a rip-off of a rip-off. Go upvote those! Your task, if you wish to accept it, is to write a program/function that outputs/returns its string input/argument. The tricky part is that if I reverse your source code, the output must be reversed too. For simplicity, you can assume that the inpu...
stackexchange_codegolf
End the tabs versus space war So, there has been a great deal of debate of whether to use tabs or spaces to indent/format code. Can you help the university settle the dispute, by going to an incredibly crazy unique method of formatting. Your job is to write a full program or function which expands all tabs into four s...
stackexchange_codegolf
SPICE is an electrical circuit simulation program originating from UC Berkeley. Your goal is to implement a minimalistic version which can solve for the nodal voltages and branch currents of a circuit composed of resistors and DC current sources. Input Format The input may come from a file, io stream, or the nearest eq...
stackexchange_codegolf
This is a code golf challenge I thought of with a mathematical bent. The challenge is to write the shortest code possible such that it is an open question whether or not the code terminates. An example of what I mean could be the following piece of python code, adapted from an anwser to this cs stackexchange question. ...
stackexchange_codegolf
Challenge Given a positive integer, find the fastest way to iterate over its digits. Bytecode size doesn't matter as much as speed of execution. Examples For 6875, the program would output 6 8 7 5. For 199182, it would output 1 9 9 1 8 2. For 0, it would output 0.
stackexchange_codegolf
Given a textual representation (case-insensitive full name or 3 character abbreviation) of a month return the number of days in the month. For example, december, DEC, and dec should all return 31. February can have either 28 or 29 days. Assume the input is a month in one of the correct forms.
stackexchange_codegolf
Your task is to make a quine, that is a non-empty computer program that prints it's own source without reading it. In addition if you remove any one byte from your original program the new program should print the source of your original program. This is code-golf so answers are scored in bytes with fewer bytes being ...
stackexchange_codegolf
In this challenge, you receive a string as input containing a string of X's, Y's and Z's eg. "XYZZ". X, Y and Z represent a particular character. This pattern is then compared with a second string input. If the pattern exists as a substring in the second input, return True, otherwise, return False. Once a pattern is fo...
stackexchange_codegolf
Given (by any means) two different natural numbers (of any reasonable size), output (by any means) the square of their sum as in the examples below: Given 4 and 3, output: 12 12 12 12 9 9 9 12 12 12 12 9 9 9 12 12 12 12 9 9 9 16 16 16 16 12 12 12 16 16 16 16 12 12 12 16 16 16 16 12 12 12 16 16 16 16 12 12 12 ...
stackexchange_codegolf
Given a set of two strings guaranteed to be the same length, print their criss cross. The criss cross of two strings is obtained as follows. Yield the second character of the second string, then the first character of the first string. Yield the first character of the second string, then the second character of the fi...
stackexchange_codegolf
Goal: Write a piece of code that produces a array containing all integer values in a set range in random order (upper and lower bounds included). Use any language you like, but use as little built-in functions as possible (ie PHP's array_shuffle should be avoided) Rules: All ints in the range must be used once, and on...
stackexchange_codegolf
Task Your task is to generate a password that is both secure and short in the fewest bytes possible given an integer seed as input. Input No seed Or An integer seed Output A password Scoring Your score is how many seconds the password takes to crack on How secure is my password divided by (bytes * password length) Scor...
stackexchange_codegolf
The random Fibonacci sequence is defined as follows: $$ f_n = \begin{cases} f_{n-1}+f_{n-2} \text{ with probability } 1/2 \\ f_{n-1}-f_{n-2} \text{ with probability } 1/2 \\ \end{cases} $$ $$ f_1 = f_2 = 1 $$ i.e. whether the next term is the sum or difference of the previous two is chosen at random, independently of ...
stackexchange_codegolf
This question was inspired this question and @orlp's comment and a lot of the explanation was copied from there. Write a GOLF assembly program that given two arbitrary size decimal integers a, and b from stdin outputs two decimal integers to stdout, Q and R such that b * Q + R = a. In other words write divmod with arb...
stackexchange_codegolf
The Question Given a two dimensional array, o[][], create a 2-dimensional graph such that o[xCoordinate][yCoordinate] is the hue of the point at (xCoordinate, yCoordinate), and the value and saturation are always 100. Let the hue go from -50 to 50, where -50 and 50 are 0 and 100 respectively. Rules You may use any lan...
stackexchange_codegolf
A natural number (written in the decimal base) is qualified as digisible if and only if it fulfills the following 3 conditions: none of its digits is zero, all the digits that compose it are different, the number is divisible by all the digits that compose it. The challenge is to output all the digisibles (there are ...
stackexchange_codegolf
Monday Mini-Golf: A series of short code-golf questions, posted (hopefully!) every Monday. (Sorry I'm late again; I was away from my computer basically all of yesterday and today.) Us programmers (especially the code-golfers) sure love arbitrary integer sequences. We even have an entire site dedicated to these sequenc...
stackexchange_codegolf
Your challenge is to compute the Lambert W function. \$W(x)\$ is defined to be the real value(s) \$y\$ such that $$y = W(x) \text{ if } x = ye^y$$ where \$e = 2.718281828...\$ is Euler's number. Sometimes, \$y\$ may not be real. Examples W(-1) = non-real W(-0.1) = -0.11183, -3.57715 W(1) = 0.56714 W(2) = 0.85261 Here'...
stackexchange_codegolf
Background At the time of writing this, the P vs NP problem is still unsolved, but you might have heard of Norbert Blum's new paper claiming proof that P != NP, which is already suspected to be erroneous (but we will see). The problem discussed in this paper is the clique problem. At least that's what I read in a newsp...
stackexchange_codegolf
Your task is to write a program that, given a number n, returns a list of all valid, halting Smallfuck programs of length n, in any order. Actually, we're using a variation of Smallfuck called F2, which is just Smallfuck with a right-unbounded tape. For the purposes of this challenge, a program that moves left from the...
stackexchange_codegolf
Note to challenge writers as per meta consensus: This question was well-received when it was posted, but challenges like this, asking answerers to Do X without using Y are likely to be poorly received. Try using the sandbox to get feedback on if you want to post a similar challenge. It's 2017 2018 2019 2020 2021 20...
stackexchange_codegolf
Goal You will be given a positive integer number less than 10^20. You must convert it to Korean. For example, if the input is 12345, the output should be 일만이천삼백사십오. Technical details (Small) Let's starts with simple numbers. // 1 - 9 1 -> 일 2 -> 이 3 -> 삼 4 -> 사 5 -> 오 6 -> 육 7 -> 칠 8 -> 팔 9 -> 구 // 10, 100, 1000 10 ->...
stackexchange_codegolf
Challenge Write a program or function that takes in 4 non-negative integers, A, B, C, and D, that represent two fractions, A/B and C/D, where B and D are non-zero and A <= B and C <= D. Output an ASCII art depiction of the fractions made of |x- characters on two lines as follows: The lines will always be the same, min...
stackexchange_codegolf
My wires are all tangled! Isn't it annoying when wires get all tangled up? Well, that just happened to me, so I'd like to to help me untangle them! For your convenience, I've disconnected them all from the device, but they're all still connected to the outlet. Your challenge is to figure out how to untangle them! Input...
stackexchange_codegolf
You want to draw a regular polygon but you have limited space! In this challenge, you should draw a polygon with n sides which is as big as possible for a given square container image. I found surprisingly little information on the Internet about inscribing a polygon into a square. To save you the hassle, I verified th...
stackexchange_codegolf
A very common need in algorithms classes and computer science in general is to iterate 4-directionally over a grid or matrix (such as in BFS or DFS). This seems to often result in a lot of clunky and verbose code with a lot of arithmetic and comparisons within loops. I've seen many different approaches to this, but I c...
stackexchange_codegolf
Steganography hides a given message inside a given carrier, producing a package that does not look suspicious. For this challenge, you will write a program that takes an ASCII message and an ASCII carrier as input, and return or print a package that is identical to the carrier except characters corresponding to the mes...
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
In case you missed Encode Factor Trees, here is the definition of a Factor Tree: The empty string is 1. Concatenation represents multiplication. A number n enclosed in parentheses (or any paired characters) represents the nth prime number, with 2 being the first prime number. Note that this is done recursively:...
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
Given a positive integer \$n\$, your task is to find out the number of partitions \$a_1+a_2+\dots+a_k=n\$ where each \$a_j\$ has exactly \$j\$ bits set. For instance, there are \$6\$ such partitions for \$n=14\$: $$\begin{align}&14 = 1_2+110_2+111_2&(1+6+7)\\ &14 = 10_2+101_2+111_2&(2+5+7)\\ &14 = 10_2+1100_2&(2+12)\\ ...
stackexchange_codegolf
I thought of a new way to generate my passwords, and even though it's probably not very clever in the long run, it could still make for a fun code-golf. Taking a string of words, the password is generated thus: Pick the nth character in the nth word If n is larger than the word, continue counting backwards Example: T...
stackexchange_codegolf
Background You have again x4 been given the task of calculating the number of landmines in a field. But this time, the field is not a number field... it's a field of letters. Our landmine letter operator is sick and requires you to cover for them. They left you the following note: Things work a little differently with...
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
We had a challenge on Multiplicative Persistence here. As a recap, to get a multiplicative persistence of a number, do these steps: Multiply all the digits of a number (in base \$10\$) Repeat Step 1 until you have a single digit left. Then count the number of iterations. More here on Numberphile: Numberphile "What's...
stackexchange_codegolf
Validate a proposed crossword grid. Entries should be full programs that simply test a proposed grid to determine if it meets a set of conditions for making crossword solvers happy. Input The input will be the name of a file representing the crossword grid. The input filename may be passed as an argument, on the standa...
stackexchange_codegolf
Definition The infinite spiral used in this question has 0 on the position (0,0), and continues like this: 16-15-14-13-12 | | 17 4--3--2 11 | | | | 18 5 0--1 10 | | | 19 6--7--8--9 | 20--21... It is to be interpreted as a Cartesian plane. For example, 1 is on the position (1,0), and 2 i...
stackexchange_codegolf
Task: You are an amazing programmer and Stackoverflow-answerer, and you decide to answer every question with a bounty on Stackoverflow. You are so good, that you manage to get all the bounties in all the questions. While you wait for the rep to come flooding in, you write a program that goes and find out what the total...
stackexchange_codegolf
What general tips do you have for creating a bot to participate in a King of the Hill challenge? What strategies do you use to go from considering the challenge to creating your bot? What data structures do you find most useful? Please post one tip per answer.
stackexchange_codegolf
Challenge Display to the screen or write to stdout this exactly: ** ** **** **** **** **** **** **** **** ********** ********** ********** Winning This is code-golf, so the shortest submission (in bytes) wins.
stackexchange_codegolf
Given three numbers m,n and p, your task is to print a list/array of length p starting with m and n and each element after p represents the difference of the 2 numbers before it, m-n (Counter-Fibonacci Sequence) For this challenge you can either use a function to return or print the result or a full program. Input Thr...
stackexchange_codegolf
Your program should take as input a number n that is greater than 0 and output a bar composed of n // 8 ▉ characters (U+2588), as well as a final character which should be one of ▉ ▊ ▋ ▌ ▍ ▎▏(U+2589 to U+258F) representing n % 8. If n % 8 is 0, your program should not output any additional characters. This is difficult...
stackexchange_codegolf
Challenge Given a (floating-point/decimal) number, return its reciprocal, i.e. 1 divided by the number. The output must be a floating-point/decimal number, not just an integer. Detailed specification You must receive input in the form of a floating-point/decimal number... ...which has at least 4 significant digits o...
stackexchange_codegolf
Your task Given a integer input, \$ n \$ (such that \$ n > 1 \$), decide whether it can be written as the sum of (at least 2) consecutive square numbers. Test cases Truthy: Input Explanation 5 1 + 4 13 4 + 9 14 1 + 4 + 9 25 9 + 16 29 4 + 9 + 16 30 1 + 4 + 9 + 16 41 16 + 25 50 9 + 16 + ...
stackexchange_codegolf
This is a somewhat proof-golf-like cops-and-robbers challenge. This is the robbers' thread; the cops' thread is here. Robbers The cops will post abstract rewriting systems. Your task is to crack their submissions by proving that the target string either can or can not be reached from the source string by applying their...
stackexchange_codegolf
Sandbox Inspired by a Codingame challenge I tried (and failed at) about a month ago. Given a binary tree of words, say: HELLO / \ WORLD EATING / / \ ARCH IDAHO GUARD / DOOZY / ...
stackexchange_codegolf
In atomic physics and quantum chemistry, the electron configuration is the distribution of electrons of an atom in atomic orbitals. For example, the electron configuration of the neon atom is 1s2 2s2 2p6 (From Wikipedia) Challenge Your challenge is to take a number representing the atomic number of an element and out...
stackexchange_codegolf
Background As described here http://www.ericharshbarger.org/dice/#gofirst_4d12, "Go First" Dice is a set of four dice, each with unique numbering, so that: There will never be a tie. Each die has a unique set of numbers. Regardless of what subset of dice are rolled against one another, each player will always have an...
stackexchange_codegolf
Remove one stick and output the stack updated. Description You can remove only sticks on top( completely drawn). You can assume: there are 5 sticks on the table. there's one and only one stick you can remove. sticks are recognizable : there aren't overlapping sticks on the same orientation and there aren't sticks join...
stackexchange_codegolf
Cop's thread here In this cops-and-robbers challenge cops will think of a positive integer. They will then write a program or function that outputs one value when provided the number as input and another value for all other positive integer inputs. Cops will then reveal the program in an answer keeping the number a...
stackexchange_codegolf
You will be given a String consisting of printable ASCII (without newlines). Your task is to build a nice Stairway for my Castle. How to build a nice Stairway? First off, you should get all the rotations of the String. For example, the String abcd has the following rotations: abcd, bcda, cdab, dabc (each character is ...
stackexchange_codegolf
I'm looking for the shortest code to generate the following sequences: Sequence A i | y x 0 | 0 0 1 | 0 1 2 | 1 0 3 | 1 1 The best I have is x = i % 2, y = i / 2, there is probably no beating that. Those are coordinates of corners of a box in 2D, but they are not in a good order for drawing. To draw a box as line loop...
stackexchange_codegolf
Goal The goal of this challenge is to write code that will execute once and only once. This means basically that it damages the program, script, or environment in some way. If rebooting the system allows the code to run again that is permitted. Scoring Number of votes. All assumptions must be clearly listed. Any an...
stackexchange_codegolf
You have a little robot with four distance sensors. It knows the layout of a room, but it has no sense of orientation other than being able to lock onto the grid orientation. You want to be able to find out where the robot is based on the readings, but it can be ambiguous because of the limited sensors. Challenge Expla...
stackexchange_codegolf
Consider an array x such as [1 5 3 4] and a number n, for example 2. Write all length-n sliding subarrays: [1 5], [5 3], [3 4]. Let the minimax of the array be defined as the minimum of the maxima of the sliding blocks. So in this case it would be the minimum of 5, 5, 4, which is 4. Challenge Given an array x and a pos...
stackexchange_codegolf
Using the fewest Unicode characters, write a function that accepts three parameters: Total number of dominoes nth affected domino Topple direction of the affected domino (0 or L for left, 1 or R for right) Once a domino is toppled, it must also topple the remaining dominoes in the same direction. You should output th...
stackexchange_codegolf
In this challenge, the goal is to create a pristine truth machine in as few bytes as possible. For reference, a truth machine does the following: Takes input, which is always 0 or 1 If the input is 0, it is printed and the program terminates If the input is 1, it is printed forever A pristine program is one that does...
stackexchange_codegolf
When I was posting answers for the Husk Language of The Month thread, I realized it took more time to enter them in the thread than it took to actually write the answers. So, why not automate it? Write a program/function which inputs a language name, and displays all answers in that language during the current month so...
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
Task Your goal, should you choose to accept it, is to write a program, that, given an input string (or array of characters), outputs every possible permutation of the letters in that string. I'm finicky with my output, so it should be sorted alphabetically, with no duplicates. Example: Input: buzz Output: buzz bzuz bzz...
stackexchange_codegolf
Recently, my reputation was 25,121. I noticed that each digit grouping (i.e. the numbers separated by commas) was a perfect square. Your challenge is, given a non-negative integer N and a unary boolean Black Box Function f : Z* → B , yield a truthy value if each value of f applied to the digit groupings of N is truthy,...
stackexchange_codegolf
Task Given two strictly positive integers n and d as input, determine whether n is evenly divisible by d, i.e., if there exists an integer q such that n = qd. You may write a program or a function and use any of the our standard methods of receiving input and providing output. The output should be a truthy or a falsy v...
stackexchange_codegolf
Here's an array representing a standard deck of cards, including two Jokers. [ "AS", "2S", "3S", "4S", "5S", "6S", "7S", "8S", "9S", "10S", "JS", "QS", "KS", "AD", "2D", "3D", "4D", "5D", "6D", "7D", "8D", "9D", "10D", "JD", "QD", "KD", "AH", "2H", "3H", "4H", "5H", "6H", "7H", "8H", "9H", "10H", "JH", "QH", "K...
stackexchange_codegolf
Related: Sort these bond ratings Credit rating agencies assign ratings to bonds according to the credit-worthiness of the issuer. The rating business is mostly controlled by "Big Three" credit rating agencies (i.e. Fitch Ratings, Moody's, and Standard & Poor's (S&P)), which use a similar tiered rating system. Task For ...
stackexchange_codegolf
You're at integer coordinates \$(x,y)\$ facing one of North, South, East, or West. Your goal is to walk home to \$(0,0)\$. At each step, you may do one of: Walk one step in the current facing direction, that is to whichever of \$(x+1,y)\$, \$(x-1,y)\$, \$(x,y-1)\$, or \$(x,y+1)\$ you're facing. Rotate 90 degrees left,...
stackexchange_codegolf
This is a King of the Hill challenge in a round robin. It's a battle to find the best gunman of the west! To be able to compete in this contest you need to make two functions. The first one sets the attributes of your gunman and the second is the main logic function for the gunman. Attribute Function function () { ...
stackexchange_codegolf
Given \$A = (a_1,\dots,a_k)\ k\ge2 \$ a sequence of positive integers, in which all elements are different. Starting from \$i=2\$, while \$a_i\in A:\$ (until the last element) If \$d=|a_i-a_{i-1}|\$ is not already in \$A\$, append \$d\$ to \$A\$ Increase \$i\$ Output the completed sequence. This is code-golf Example ...
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
I am making a customizable password generator. But I (for some reason) thought it'd be better to let you guys do it. Umm.. then? You only get one integer. That will include all the information about the customization. The first 4 bits (1,2,4,8) will be used for choosing which charsets will be used. Each bit correspond...
stackexchange_codegolf
In this challenge you will write code to take a list of positive integers and output all maximal linear sublists. A sublist is is a list which can be created by deleting values from the the input list. Sublists have more structure than just lists. They in a way "remember" which values are deleted. Similarly we say tha...
stackexchange_codegolf
Here the first 100 numbers of an easy sequence: 0,1,0,2,1,4,3,7,6,11,10,16,15,22,21,29,28,37,36,46,45,56,55,67,66,79,78,92,91,106,105,121,120,137,136,154,153,172,171,191,190,211,210,232,231,254,253,277,276,301,300,326,325,352,351,379,378,407,406,436,435,466,465,497,496,529,528,562,561,596,595,631,630,667,666,704,703,74...
stackexchange_codegolf
Rearrange a given list such that all the odd numbers appear before all the even numbers. Besides for this requirement, the output list may be in any order. The input will only contain integers, but they may be negative and there may be duplicates, and they may appear in any order. Shortest solution wins. Test cases [1,...
stackexchange_codegolf
Background Hamiltonian circuit problem is a decision problem which asks whether a given graph has a Hamiltonian circuit, i.e. a cycle that visits every vertex exactly once. This problem is one of the well-known NP-complete problems. It is also known that it remains so when restricted to grid graphs. Here, a grid graph ...
stackexchange_codegolf
Given a string, character list, byte stream, sequence… which is both valid UTF-8 and valid Windows-1252 (most languages will probably want to take a normal UTF-8 string), convert it from (that is, pretend it is) Windows-1252 to UTF-8. Walked-through example The UTF-8 string I       ♥        U  T  F  -  8 is represente...
stackexchange_codegolf
You work at a bakery, and every day you make pastries. You make 100 of each of several different types. However customers are less predictable. Some days they order all of one kind of pastry and you run out, some days they order hardly any and you have some left over. So your boss has made up a chart which tells you ho...
stackexchange_codegolf
It is quite simple, any language, make output show the time in the HH:MM or HH:MM:SS while the numbers and the colons being ascii art(The output is ascii art not the program) Sample output: ____________ ________ _____ .________ ________ /_ \_____ \ /\ \_____ \ / | | /\ | ____// _____/ | ...
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
The setting "Well I actually wrote the sql library they, the maintainers actually.." "Right, but do you have any experience working with django?" " ...no I don't use frameworks" After the phone interview is over, you feel like you really need a coffee. While the brew is heating, you check your messages on BusinessBook....
stackexchange_codegolf
Given a polynomial \$p(x)\$ with integral coefficients and a constant term of \$p(0) = \pm 1\$, and a non-negative integer \$N\$, return the \$N\$-th coefficient of the power series (sometimes called "Taylor series") of \$f(x) = \frac{1}{p(x)}\$ developed at \$x_0 = 0\$, i.e., the coefficient of the monomial of degree ...
stackexchange_codegolf
Given any string, print it in the form of a triangle where the text runs up and down along each diagonal. For example, an input of "Hello World" should output: d l r d o l W r d o l o W r d ...
stackexchange_codegolf
map is a very basic yet important function in functional programming. All FP programming languages have it built-in but it is always fun to see how shortly you can define it yourself. This will be scored in AST nodes, not bytes. A token is the second-smallest building block of a program, over characters. A token is: a...
stackexchange_codegolf
This was inspired by a function I recently added to my language Add++. Therefore I will submit an short answer in Add++ but I won't accept it if it wins (it wouldn't be fair) Don't you hate it when you can multiply numbers but not strings? So you should correct that, right? You are to write a function or full program...
stackexchange_codegolf
Task Provide two programs/functions A and B (not necessarily in the same language) with the following properties: Either program, when given its own source code as input, produces an accepting output. Either program, when given the other program's source code as input, produces a rejecting output. It doesn't matter w...
stackexchange_codegolf
Background An ex-increasing set sequence of order \$N\$ is defined as a sequence of integer sets \$S_1,S_2,\cdots,S_n\$ which satisfies the following: Each \$S_i\$ is a non-empty subset of \$\{1,2,\cdots,N\}\$. For \$1\le i<n\$, \$S_i \cap S_{i+1} = \varnothing\$, i.e. any two consecutive sets have no elements in comm...
stackexchange_codegolf
Given a list of positive integers determine if there is an element that is either greater than its two neighbors or less than its two neighbors (a "bump"). To be clear a bump can never be the first or last item of the list because they only have one neighbor. Your program should output one of two consistent values eac...
stackexchange_codegolf
There seems to be this ongoing craze about people tediously learning new keyboard layouts like Dvorak or Neo because it supposedly makes them more productive. I argue that switching keyboard layouts is a bad idea, because it can take you months to get up to speed, and when you're finially 5% faster than the rest, you'r...
stackexchange_codegolf
Use any programming language to display numbers between 1 and 99 (including both) in such a way, so that: the numbers are separated by single space, if a number is divisible by 3, it should be in parentheses, if a number is divisible by 4, it should be in square brackets, if a number is divisible by both 3 and 4, it s...
stackexchange_codegolf
Your task is to write the shortest algorithm in a language of your choosing that accomplishes the following: Given two matrices it must return the euclidean distance matrix. The euclidean distance between two points in the same coordinate system can be described by the following equation: \$D = \sqrt{ (x_2-x_1)^2 + (y_...
stackexchange_codegolf
Traditionally presents are kept secret in boxes wrapped in paper. Since the ice caps are melting Santa Claus has begun to investigate some ways they might make the whole gift wrapping operation a little more eco-friendly. The first thing they've decided to do is to put all presents in perfectly cubic boxes. This makes...
stackexchange_codegolf
Challenge: Given a number, take the largest prime strictly less than it, subtract it from this number, do this again to this new number with the biggest prime less than it, and continue doing this until it's less than 3. If it reaches 1, your program should output a truthy value, else, the program should output a false...
stackexchange_codegolf
Check out this challenge: https://www.hackerrank.com/codesprint4/challenges/leibniz (The competition has already ended, so I'm just curious about the Python solution, which the organizers refused to reveal, so this is not cheating in any way.) Modified from that page: In Calculus, the Leibniz formula for \$\pi\$ is gi...
stackexchange_codegolf
Let's build a simulation for an aspect in the card game, which I personally know by the Dutch name 'Oorlog' (translates to 'War'). How does 'Oorlog' work? Two decks of cards (each including two Jokers) are equally divided between the amount of players playing. Each player shuffles their own stock, put it upside down in...
stackexchange_codegolf
Let us define a sequence. We will say that \$a(n)\$ is the smallest number, \$x\$, that has the following properties: \$x\$ and \$n\$ are co-prime (they share no factor) \$x\$ does not appear earlier in the sequence \$|n - x| > 1\$ Unlike most sequences the domain and range of our sequence are the integers greater t...
stackexchange_codegolf
Brachylog is a language that's beginning to rise in prominence in code-golfing recently (and just received a major update with a terser syntax). Like Prolog, it has the advantage that it can often solve a problem (typically via brute force) merely from a sufficiently accurate description of what a problem looks like, a...
stackexchange_codegolf