instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Given an expression like 4 / 2 + 3, determine whether the expression has the same value in Python 2 and Python 3. Recall that in Python 2 division rounds down (so that 5 / 2 -> 2), whereas in Python 3 division returns a float (so that 5 / 2 -> 2.5). For simplicity's sake, we will only consider expressions of the form: ...
stackexchange_codegolf
Your goal is to write a program that takes no input and outputs the following text: ca e na ŋa va o sa; þa ša ra la ła. ma a pa fa ga ta ča; în ja i da ða. ar ħo ên ôn ân uħo; carþ taŋ neŋ es nem. elo cenvos. But there's a catch: for each letter (any character whose general category in Unicode starts with L) in your s...
stackexchange_codegolf
Challenge: In the language of your choice, write a program that generates a leaderboard with random scores and outputs it, then take a new score as input and check if it can be placed in the leaderboard, and output which place it is in. Specifications: You must generate a list of 50 "random" scores, in descending orde...
stackexchange_codegolf
A void list is a list that at no level contains any non-list objects. Or if you prefer a recursive definition The empty list is void A list containing only other void lists is void All void lists have a finite depth. Here are some examples of void lists (using python syntax): [] [[]] [[],[]] [[[]]] [[[]],[]] [[],[[]...
stackexchange_codegolf
You must write a program or function that sorts a nested list. Here are the rules for sorting a nested list: Let's take this list as an example: ((5, 2), 2, 7, (2, 1, (3, 4)), 9) Each element in this list has a "priority". An element counts as a number or a sublist. First, get the priority of each element at the same ...
stackexchange_codegolf
On most new-years challenges when it is currently not the corresponding year of the challenge, It says this in the front. It's [current year] already, folks, go home. You have to output this text with the current year substituted. I/O Input: None. Output: It's [current year] already, folks, go home.
stackexchange_codegolf
You are the electoral strategist for a sudden late entrant in the 2020 US presidental election. Your task: print out the names of states* your candidate will win, totalling at least 270 electoral college votes. Background Each state (and Washington DC) in the US system has an arbitrary number of "electoral college vot...
stackexchange_codegolf
Suppose there are 5 positive integers in an array or list as 14, 12, 23, 45, 39. 14 and 12 cannot be taken in the subset as 1 is common in both. Similarly {12, 23}, {23, 39}, {14, 45} cannot be included in the same subset. So the subset which forms the maximum sum is {12, 45, 39}. The maximum sum such formed is 96. the...
stackexchange_codegolf
We all know the classic dad joke that goes something like this: Somebody says a sentence to describe their self (e.g. I'm tired or I'm confused). A dad-joke enthusiast comes along and replies Hi <adjective>, I'm Dad!, because introductions follow the same format (I'm Peter follows the same format as I'm hungry). Yo...
stackexchange_codegolf
You are given an \$ 25 \times 25 \$ square lattice graph. You are to remove certain nodes from the graph as to minimize your score, based on the following scoring system: Your score will be the \$ \text{number of nodes removed} \$ \$ + \$ the \$ \text{size of the largest connected component} \$. In the smaller \$ 4 \ti...
stackexchange_codegolf
This challenge is inspired by a talk about Schläfli symbols, etc that I gave in a Geometry seminar. While I was putting together this challenge, I saw that Donald Knuth himself was interested in (some subset of) this problem. In October 2016, he commented on a related OEIS sequence: If [the OEIS author] is wrong about...
stackexchange_codegolf
Task is pretty simple. Your program should take a number N from 1 to 20 and draw the following ASCII art. When N=1: _____ | | | | | | | | | | | | | | | | | | | | | |_|_| \ / \-/ v When N=2: _______ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ...
stackexchange_codegolf
Adapted from Tips for restricted source in Python Just like code-golf, restricted-source pushes one to exploit quirks and hidden features of the Powershell language. Now, We already have a place to collect all these tips for code-golf, those for restricted-source remain transmitted by word of mouth or hidden deep wit...
stackexchange_codegolf
Santa's Shortest Path Problem Trying to be as time-efficient as possible Santa needs to plan his trips carefully. Given a 5X5 grid representing a map of villages it is your task to be Santa's flight controller. Show santa the shortest and therefor fastest route to fly his sleigh and give him a list of coördinates (or d...
stackexchange_codegolf
This challenge is one of the two challenges which were planned for Advent of Code Golf 2021, but didn't fit into the 25-day schedule. Related to AoC2020 Day 22, Part 2. Combat is a simple two-player card game played with a deck of cards. A unique positive integer is written on each card. The game proceeds as follows: ...
stackexchange_codegolf
A string is considered to be square if the following conditions are met: Each line has the same number of characters The number of characters on each line is equal to the number of lines. Your task is to write a program or function which determines whether or not a given input string is a square. You may require inp...
stackexchange_codegolf
In my previous challenge, I drew the first diagram mostly by hand (with the help of vim's visual block mode). But surely there must be a better way... Given an input of two dimensions, a width and a height, output a hexagonal grid with those dimensions in ASCII art. Here's the diagram referenced in the intro (with min...
stackexchange_codegolf
The objective is to print a graph from an array of numbers, of the design below. Printing the X and Y scale exactly as in the "design", with padding, is part of the challenge. The input array of numbers can be of virtually any range of integers in X and Y, but not 0 and not negative - though I would suggest keeping it ...
stackexchange_codegolf
Create a program that outputs itself. However, if the source code is repeated n times (meaning to concatenate a copy of the source code to the end n-1 times), then there should be 1/n probability outputting the original source code, a 1/n probability of outputting the source code repeated twice, a 1/n probability of o...
stackexchange_codegolf
I posted this challenge a while ago, which concerns how many elves Santa needs to deliver presents. Due to population increase, Santa is a little more pressed for time this year. Although in the past we operated very asynchronously, we are beginning to experiment with being more and more synchronized. So, Santa needs t...
stackexchange_codegolf
Sandbox Finding radicals of arbitrary ideals in rings is hard! However, it's a doable task in polynomial rings, since they are Noetherian (all ideals are finitely generated) Background A quick introduction to radical ideals A ring is a set, paired with two binary operations + and * such that 0 is a additive identity, 1...
stackexchange_codegolf
Intro More complex than A square of text since this requires padding and input has unknown data type. Every year, Dyalog Ltd. holds a student competition. The challenge there is to write good APL code. This is a language agnostic code-golf edition of this year's tenth problem. I have explicit permission to post this ch...
stackexchange_codegolf
The point of this challenge is to find the smallest positive integer that uses up at least all of the digits supplied in the input after it is squared and cubed. So, when provided an input such as 0123456789 (i.e. a number that finds the result): 69² = 4761 69³ = 328509 It means that 69 is the result of such an input....
stackexchange_codegolf
When playing Rock-Paper-Scissors-Lizard-Spock, your robot reflexes let you see your opponent's throw before they make it. You just need to choose a throw that beats theirs, in as few bytes as possible of course. There's always two winning throws, and either one will work. Input -> Possible outputs ----------------...
stackexchange_codegolf
Look at the following string. Notice a pattern? ABEFNOPEFGH DC G Q I M H R J LKJI S K D T L C U M BAZYXWV N E O D P C Q BAZYXWVUTSR As some might have noticed, it's basically a spiral of the alphabet, where the distances between rows / columns are gradually increasing b...
stackexchange_codegolf
Code a daily horoscope for the 12 zodiac signs, it needs to be self-sustained (no external ressources), quite randomized but fixed by zodiac sign for each day. It needs to extract three "variables" from 1 to 3 : love work money Each one ranked from 1 to 3. Ex. of variables that can be used (vars fixed for a d...
stackexchange_codegolf
The challenge is to golf a program that checks if a statement of propositional calculus/logic is a logical tautology (i.e. it is true for all possible values of the variables). Input Input formulas will use P, P', P'' ect. as variables. They can either be true or false. (P and P') means both P and P' are true. (P or P'...
stackexchange_codegolf
A JAPH is a grand tradition of making a program that prints "Just another Perl hacker,". We already have a question about JAPH on this site but they seem more concerned with hiding the text, but JAPH has always been more about hiding the method by which it does what it does. Therefore I challenge you to show off your f...
stackexchange_codegolf
Challenge Given a positive integer, determine whether that number is currently being used to represent a question on PPCG. The question must not have been removed, but may be open or closed. The number is the one being used in the URL of the question, such as: https://codegolf.stackexchange.com/questions/[input] Note...
stackexchange_codegolf
Challenge: Create a function or program that will take an input N (a number from 0 - 24) which represents the HOUR. Output should draw an analog clock out of asterisks showing the hour N. Notes: •The minute hand must be longer than the hour hand (in terms of number of asterisks used) •The minute hand must be at least...
stackexchange_codegolf
Background A polyomino of size \$n\$ is a contiguous shape made from joining \$n\$ unit squares side by side. A domino is a size-2 polyomino. A polydomino of size \$2n\$ is defined as a polyomino of size \$2n\$ which can be tiled with \$n\$ dominoes. The following are some examples of polydominoes for \$n=3\$ (hexomino...
stackexchange_codegolf
Challenge Joe the rapper is struggling with rhyming words in his lyrics. He needs your help. For this situation, we will use rhymes where the last syllable in a word is the same as the other word (spelled the same). When Joe inputs a word, the program will read a list of words from a file and output those that rhyme wi...
stackexchange_codegolf
In this challenge, your past self comes back to help or hurt someone else! The task is simple: write a full program, not a function, that prints the first code submission on this site submitted by the previous user, in the language of your first answer. (In the case that your first answer was purely prose, for example ...
stackexchange_codegolf
Implement a function diff that takes as input three integers x, y, and z. It should return whether subtracting one of these numbers from another gives the third. Test cases: diff(5, 3, 2) yields True because 5 - 3 = 2 diff(2, 3, 5) yields True because 5 - 3 = 2 diff(2, 5, 3) yields True because 5 - 3 = 2 diff(-2, 3, 5)...
stackexchange_codegolf
This challenge has two threads. This is the cops' thread. The robbers' thread is located here. Your challenge is to choose an OEIS sequence and write two full programs in two different languages that produces that nth item in the sequence when given an n via STDIN, or an other forms of standard input, where n is any p...
stackexchange_codegolf
Your task today is to implement a time limit for getting input, a task I've found rather annoying to achieve in most languages. You will create a program function which prompts the user for input. Immediatly after the user supplies input, print the message input received and end execution/return. However, if the user w...
stackexchange_codegolf
The Levenshtein distance between two strings is the minimum number of single character insertions, deletions, or substitutions to convert one string into the other one. The challenge is to compute the average Levenshtein distance between two independent and uniformly random chosen binary strings of length n each. Your...
stackexchange_codegolf
Given an alphabet represented as a nonempty set of positive integers, and a word made up of symbols from that alphabet, find that word's position in the lexicographically ordered set of all words, assuming words can't contain duplicate symbols. Example Consider the alphabet {1, 2, 3} and the word [2, 3, 1]. The set of ...
stackexchange_codegolf
Note This is the decryption challenge. The encryption challenge can be found here. Challenge The challenge is to decrypt a given string, using the rules as specified below. The string will only contain lowercase alphabets, digits, and/or blank spaces. If you want to know how the input string has been encrypted, refer t...
stackexchange_codegolf
Based on the interpretation user @ThePirateBay made from the first version of my own challenge Output diagonal positions of me squared now I challenge you to make ASCII art that draws diagonal lines based on a square character matrix based on a given number n. Input A number n. Output A square matrix of size n^2 which...
stackexchange_codegolf
Write a program which runs forever and allocates more and more memory on the heap the longer it runs, at least until you reach the limit of the operating system on the amount of memory that can be allocated. Many kernels won't actually reserve memory you allocate until you use it for something, so if your program is in...
stackexchange_codegolf
Write a function or program that accepts one character (or a string of length 1) as input, and outputs the number of times that character occurs inside the code. This program must be a Proper Quine, only in the sense that it cannot, for example, read itself as a file, etc. Input can be any character, printable or not...
stackexchange_codegolf
Given a positive input \$n\$, output a random pair of primes whose difference is \$n\$. It's fine if there's another prime between them. Every pair should possibly appear and the program should have zero possibility to fall into infinite loop. It's promised that such pair exist, but not always infinite, so beware. You ...
stackexchange_codegolf
Look at these photographs of natural scenes, with one of the RGB channels taken out of them: Source (with red): https://en.wikipedia.org/wiki/File:Altja_j%C3%B5gi_Lahemaal.jpg Source (with green): https://commons.wikimedia.org/wiki/File:2007_mather-lake_hg.jpg Source (with blue): https://commons.wikimedia.org/wiki/F...
stackexchange_codegolf
Strangely never asked before, this question pertains to the generation of a list of prime numbers within a given range using the shortest possible code. Several algorithms, such as the Sieve of Eratosthenes and trial division, are known to be effective for this purpose, but require significant code length. Is there an ...
stackexchange_codegolf
For Gregorian calendars, the date format varies from a country to another. There are three main formats recognized: YY-MM-DD (big-endian) DD-MM-YY (little-endian) MM-DD-YY (middle-endian) Your task is to write a program which, given an input string representing a date, output all the possible date formats by which th...
stackexchange_codegolf
Background Conway criterion is a method to test if a given polygon can tile (i.e. cover without overlapping) an infinite plane. It states that a polygon can tile the plane if the following conditions are met: The given polygon does not have any holes in it. It is possible to choose six consecutive1 points \$A,B,C,D,E,...
stackexchange_codegolf
Credit: Marco Verch CC BY 2.0 A two-cube calendar, as shown in the picture, uses two cubes with digits painted on the faces to display the date. For dates in the range 1-9, a leading zero is used ("01", "02", ..., "09"). Now, if you do the math, you might come to the conclusion that these calendars should be impossibl...
stackexchange_codegolf
Inspired by this and the following chat: Your task is to output the following: _ _ _ /_/_/_/\ /_/_/_/\/\ /_/_/_/\/\/\ \_\_\_\/\/\/ \_\_\_\/\/ \_\_\_\/ Extra leading or trailing whitespace is allowed, as long as it does not change the appearance of the cube. As usual, returning the above or a list of strings ...
stackexchange_codegolf
You're organizing a treasure hunt for your friends. To conduct things more easily, you want to draw a map of all locations where you hid the precious objects. Input Any form of input denoting a list of points consisting of (nonnegative) x- and y-coordinate, 0 0 being the upper left corner is permitted (Note: You may al...
stackexchange_codegolf
Context As a conlanger, I am interested in creating a uniform, naturalistic language. One of the tricks is to create vocabulary according to certain structures of words. An example from English: In English, we have the word “tap” structured consonant-vowel-consonant. Usually, this means that there are many other words ...
stackexchange_codegolf
Donald Trump is very impressed with the work of the people on this site. He saw how amazing of a job you did helping Ben Carson, so he even hired you to build his wall. He thinks you're terrific. Now he needs your help again. While he has successfully built his wall, now he needs the Mexican government to pay for it. H...
stackexchange_codegolf
This is a code golf version of a similar question I asked on stack earlier but thought it'd be an interesting puzzle. Given a string of length 10 which represents a base 36 number, increment it by one and return the resulting string. This means the strings will only contain digits from 0 to 9 and letters from a to z. B...
stackexchange_codegolf
A jigsaw puzzle consists of (usually rectangular-ish) pieces. On each side of a piece, there is either an edge or a connector (a term I made up). A connector is either a tab sticking out (outie) or a slot facing inwards (innie). Two pieces can be joined if the outie tab can fit into the innie slot. The goal is to assem...
stackexchange_codegolf
Take a string, s containing printable ASCII-characters as input, and output its "binary split sum". Need an explanation? How do you get the binary split sum? We'll use the string A4 as an example in the following explanation. Convert the characters to binary, treating each letters as a 7-bit ASCII character A -> ASCII...
stackexchange_codegolf
In this challenge, you will play the noisy iterated prisoner's dilemma. The Prisoner's dilemma is a scenario in game theory where there are two players, each with two options: cooperate, or defect. Each player does better for themself if they defect than if they cooperate, but both players would prefer the outcome wher...
stackexchange_codegolf
Challenge Taken with permission from my University Code Challenge Contest For some years now, the number of students in my school has been growing steadily. First the number of students was increased by classroom, but then it was necessary to convert some spaces for some groups to give classes there, such as the gym s...
stackexchange_codegolf
The reason for this question is because I made a deadlineless bounty and I need a tips question to link in the bounty Vyxal 3 is the third major version of the Vyxal golfing language. As it is significantly different to Vyxal 2, the tips there don't apply. Therefore, what tips and tricks do you have for golfing in Vyxa...
stackexchange_codegolf
There are several ways to create headers on posts on the Stack Exchange network. The format that's most commonly1 used on PPCG seems to be: # Level one header ## Level two header ### Level three header Note the space after the hash marks. Also, note that trailing hash marks are not included. Challenge: Take a (possib...
stackexchange_codegolf
Randall Munroe (author of XKCD) held a survey to give names to colors. The main outcome is a list of names for the 954 most common RGB monitor colors. For ease of programming, here is the list in plain text: http://xkcd.com/color/rgb.txt. Beware, the first line is not data, but contains the license. Write a program or ...
stackexchange_codegolf
Task: Input will consist of some text, with nested [] separating some of it into nested groups: abc[d[fgijk]nopq]rst[u[v[[w]]]xy[[[z]]]] Your task is to remove all brackets, and everything wrapped in an odd number of brackets. For example, a[b]c would remove the [], and the b inside of it. a[[b]]c, however, would only...
stackexchange_codegolf
Goal Generate (N) random line segments of uniform length (l), check if they cross the equidistant (t) parallel lines. Simulation What are we simulating? Buffon's needle. Smooth out the sand in your sandbox, draw a set of equally spaced parallel lines (call the distance in between t). Take a straight stick of length l a...
stackexchange_codegolf
Deleted questions on Stack Overflow sometimes make for great golf material. Write a function that takes a nonnegative integer as input, and returns true if all the digits in the base 10 representation of that number are unique. Example: 48778584 -> false 17308459 -> true Character count includes only the function. If ...
stackexchange_codegolf
Challenge Given a Youtube playlist, output the number of videos in it. I/O The playlist will be given as an URL; for example, https://www.youtube.com/playlist?list=PL_3jnZNPYn7qUatgDYBS5NShkfXoehSRC (this is a playlist a friend sent me to try to get me to listen to K-Pop because she's obsessed with it and I don't like ...
stackexchange_codegolf
Santa's Decision: In this challenge, you will help Santa Claus decide whether somebody on their list has been naughty or nice, and subsequently get coal or toys. But unfortunately, Santa is unorganised, in some of his entries, the naughty, nice and name fields are in the wrong order. Input Input will come in the follo...
stackexchange_codegolf
A triangular number is a number that can be expressed as the sum of consecutive positive integers, starting at 1. They can also be expressed with the formula n(n + 1) / 2, where n is some positive integer. A number's digitangular counterpart is calculated in the following way: Split a number into an array of its digit...
stackexchange_codegolf
This is an alternate version of this earlier challenge with a twist that adds a significant bit of difficulty. Like last time, you are going to be given a string containing some alphabetic characters along with [ and ]. Your task is to split into sections that are enclosed in a "group" created by [...] and those that ...
stackexchange_codegolf
In 2014, demoscener Jakub 'Ilmenit' Debski released a 250-byte(1) procedural graphics demo for the Atari XL called Mona. It's drawing the following picture(2): Your task is to generate the exact same picture, using the language of your choice. (1) Breakdown: 136 bytes of data + 114 bytes of code. (2) The original pic...
stackexchange_codegolf
The Triforce is a fictional artifact in The Legend of Zelda, made of three identical-looking equilateral triangles representing power, wisdom and courage. Several games in the saga include an animation when the three parts finally join together. The purpose of this challenge is to draw a single 2D frame of such a simpl...
stackexchange_codegolf
Surprisingly, I don't think we have a code-golf question for determining if a number is semiprime. A semiprime is a natural number that is the product of two (not necessarily distinct) prime numbers. Simple enough, but a remarkably important concept. Given a positive integer, determine if it is a semiprime. Your ou...
stackexchange_codegolf
Introduction Some months are completely symmetric, meaning they have central symmetry as well as reflection symmetry, like February of 2010: February 2010 ┌──┬──┬──┬──┬──┬──┬──┐ │ │ │ │ │ │ │ │ ├──┼──┼──┼──┼──┼──┼──┤ │ │ │ │ │ │ │ │ ├──┼──┼──┼──┼──┼──┼──┤ │ │ │ │ │ │ │ │ ├──┼──┼──┼──┼──┼...
stackexchange_codegolf
Write a program which, according to whether the script has access to the internet, produces an output which is "Truthy/Falsey". You may try and connect to any existing site, at your own discretion (don't use a shady site which only has 10% uptime - try to keep to above 80% annual uptime). If the site is down, your prog...
stackexchange_codegolf
I am trying to use C# to find the index of the first 1 (right to left) in the binary representation of a number. For example, since 100 in binary is: 0b1100100 The first 1 is in the third position from the right, so it should yield 3. 234 should yield 2, 0 should yield 0, etc. Here is my current solution: k < 1 ? 0 :(...
stackexchange_codegolf
Task Given two integers \$d\$ and \$n\$, find the number of ways to express \$n\$ as a sum of \$d\$ squares. That is, \$n = r_1^2 + r_2^2 + ... + r_d^2\$, such that \$r_m\$ is an integer for all integers \$1 ≤ m ≤ d\$. Note that swapping two different values (e.g. \$r_1\$ and \$r_2\$) is considered different from the o...
stackexchange_codegolf
Given an integer N > 1, output all other numbers which prime decompositions have the same digits as the prime decomposition of N. For example, if N = 117, then the output must be [279, 939, 993, 3313, 3331], because 117 = 3 × 3 × 13 therefore, the available digits are 1, 3, 3 and 3 and we have 279 = 3 × 3 × 31 939 =...
stackexchange_codegolf
Background Inspired by Octave's (and, by extension, MATL's) very convenient interpretation of truthy/falsy matrices, Jelly got the Ȧ (Octave-style all) atom. Ȧ takes an array as input and returns 1 if the array is non-empty and does not contain the number 0 (integer, float, or complex) anywhere in the tree structure; o...
stackexchange_codegolf
Vim is a great text editor for unix systems, but it's notorious for being difficult to exit. Write a full program that will output :q to exit Vim. It should then read a single line of input, as it will then either be given a bash prompt, in which case the exit was successful, or an error, in which case there are unsave...
stackexchange_codegolf
Challenge Given an image of the Moon as input, output the phase of the Moon. Phases of the Moon Your program will be supplied one of these images in png format and you must output the phase exactly as given: new moon hexdump waxing crescent hexdump first quarter hexdump waxing gibbous hexdump full moon hexdump...
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
The cosine similarity of two vectors \$A\$ and \$B\$ is defined using their dot product and magnitude as: \$\frac{A\cdot B}{\|A\|\|B\|}\$ Or in other terms \$\frac{\sum_{i=1}^nA_iB_i}{\sqrt{\sum_{i=1}^nA_i^2}\sqrt{\sum_{i=1}^nB_i^2}}\$ Challenge Given two nonempty, nonzero vectors containing only integers (can be taken...
stackexchange_codegolf
This is a potato: @@ @@@@ @@@@@@ @@@@@@ @@@@ @@ More generally, a size N potato is defined as the following shape: If N is even, it is 2 centered @ symbols, followed by 4 centered @ symbols, followed by 6 centered @ symbols, all the way up to N centered @ symbols; then, N centered @ symbols, followed by N-2 ce...
stackexchange_codegolf
Background / Description Note: as @HelkaHomba points out, the actual GitHub identicons are not actually random but based on the hash of a username The default GitHub avatar is a 5x5-pixel image. A color is picked randomly, and then random pixels are filled in on one side (right or left, 2x5 size) using that color. Then...
stackexchange_codegolf
Given a sequence of bytes, output the SHA-256 hash value of the sequence. The SHA-256 Algorithm The following pseudocode is taken from the Wikipedia page for SHA-2. Note 1: All variables are 32 bit unsigned integers and addition is calculated modulo 2^32 Note 2: For each round, there is one round constant k[i] and one ...
stackexchange_codegolf
I like anagrams. I like programs that reference their own source code. So this challenge combines them! Input. The input to the program could be anything, including letters, numbers, symbols, you name it. Output. A truthy value if the input's characters can be rearranged to give the source code, and a falsy value if th...
stackexchange_codegolf
Given an expression matching the regex /^[-~]*x$/, evaluate it in terms of x and output a string matching the regex /^-?x[+-]\d+$/. For example, the string -~x evaluates to x+1, while the string -~-x evaluates to -x+1, and the string -~-~--x evaluates to x+2. We start from x and evaluate the string right to left. - neg...
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
The famous game of Qwirkle has simple but intricate rules (See part 2 of this question for a summary of the rules!) The Challenge You are somehow (text input, function parameter, whatever) given a board of a Qwirkle game, like a snapshot from any current timeframe within a game. This board can be anything from complet...
stackexchange_codegolf
Description "Imtiaz Germain primes" is not a technical name in Mathematics, but my weird creation, in the memoir of the famous mathematician Sophie Germain. These primes can be generated by the following process: 1. Take a Safe prime 2. Apply 2p + 1 on it to obtain a composite number 3. Apply 2p + 1 once more to obtain...
stackexchange_codegolf
This challenge is about implementing Shm-reduplication, originating in Yiddish, where one takes a word, duplicates it, and replaces the first syllable in the second word with "Shm" in order to indicate that one does not care. Some examples include: "Isn't the baby cute?", "Eh, baby shmaby" "Come buy from my store, we ...
stackexchange_codegolf
In this polyglot challenge, you will work together to figure out how to output all the 26 letters of the English alphabet! How does this work? For each answer, you must pick a new language (or a new major version of a language, for example, python 2 and python 3 are counted separately) that prints the next letter after...
stackexchange_codegolf
Question: Print out all the coordinates of a NxN grid. Preferably in C, however other languages also accepted Input: N (integer) Output: for N=3, a 3x3 grid: 0,0 1,0 2,0 0,1 1,1 2,1 0,2 1,2 2,2
stackexchange_codegolf
There seems not to be a contest for this one yet. The task is simple. Add the first n numbers of the Fibonacci sequence that are even and output the result. This is given by OEIS A099919, except that sequence is shifted by one, starting with fib(1) = 0 instead of fib(1) = 1. This is code golf. Lowest byte count wins. E...
stackexchange_codegolf
Goal: Create a program to find the smallest file in the current folder. File size may be measured in bytes or characters. If multiple files have the same size, you can either choose one or display all of them. You can assume there will be at least one file in the folder, and no files will have a size of 0. Assume t...
stackexchange_codegolf
Background We've had challenges before on Fibonacci coding and Zeckendorf representation. These representations follow naturally from Zeckendorf's theorem, which states that every positive integer can be represented uniquely as the sum of one or more distinct, non-consecutive Fibonacci numbers. For example: $$ \begin...
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
Thanksgiving in the United States is coming up on November 24th. Many people will have a large dinner with their families, traditionally including turkey and many side dishes. This typically means the family members must coordinate who's going to bring each of the various dishes. In this challenge, the goal is to write...
stackexchange_codegolf
Given a single digit integer and a three digit integer, output a mathematical formula that uses only the single digit and a given list of operators to equal the three digit integer. Input: A one digit positive integer (1-9) and a three digit integer (100-999) Output: A mathematical formula meeting the following requir...
stackexchange_codegolf
Given n, k, and p, find the probability that a weighted coin with probability p of heads will flip heads at least k times in a row in n flips, correct to 3 decimal digits after decimal point (changed from 8 because I don't know how to estimate the accuracy of double computation for this (was using arbitrary precision f...
stackexchange_codegolf
Make a program that outputs the number of seconds from the beginning of today (00:00:00 of the day you run it) to the second you ran it. However, if this number is divisible by three, print Fizz instead. If it is divisible by five, print Buzz instead. If it is divisible by three and five, print FizzBuzz. Don't pad the ...
stackexchange_codegolf
This idea came to me when I saw my little brother playing with my calculator :D The task Taking a integer as an input, print that many graphical square roots under each other, like this: n = 1 ___ \/ 1 n = 3 _______ / _____ / / ___ \/\/\/ 3 n = 5 ___________ / _________ / / _______ / ...
stackexchange_codegolf