instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Stack Exchange automagically detects serial voting (when one user either upvotes or downvotes many of another user's posts) and reverses it. In this challenge, you will implement a very, very simple "serial vote" detector. Input The input is a string representing a list of votes. Every group of two characters represent...
stackexchange_codegolf
Just because the reverse and palindrome were not too challenging individually :) Write a program (full program or function) that satisfies the following: given a string input, the program as-is outputs the input string unchanged. the program reversed outputs the input string reversed. the program palindromized outputs...
stackexchange_codegolf
Let's define a function \$f\$ which, given a positive integer \$x\$, returns the sum of: \$x\$ the smallest digit in the decimal representation of \$x\$ the highest digit in the decimal representation of \$x\$ (which may be the same as the smallest one) For instance: \$f(1)=1+1+1=3\$ \$f(135)=135+1+5=141\$ \$f(209)=...
stackexchange_codegolf
Chinese Hearts, also known as Gong Zhu (拱猪, Chase the Pig), is a variance of the Hearts game. It is a 4 player card game with the aim to earn the highest amount of points. You may read more about it on Wikipedia. This time, we want implement a program (full or function) to calculate ones score. Scoring The player who p...
stackexchange_codegolf
Balanced ternary is a modified version of ternary (base 3), using the three digits 1,0 and -1 (written as T) to represent numbers. The balanced ternary representation of -n can be obtained by replacing 1 with T and T with 1 in the balanced ternary representation of n. Examples: 1 // decimal: 1 T // decimal: -1 ...
stackexchange_codegolf
Given a string, determine if it is an int, a float or neither. Examples 123 - int 62727.0033 - float 644c.33 - neither Your code should output a different value depending on which it is. For example it could return "i" for int, "f" for float and "n" for neither. Details The following are floats: 1.00 -0.0 1.0 The fo...
stackexchange_codegolf
A triangle-shaped table is constructed such the first row is "1, 3, 5, 7, ..., 99" Each subsequent row has the following properties: One less element than the row above Each element is the sum of the two elements above it Like so: 1 3 5 7 9 11 .... 4 8 12 16 20 .... ............... This co...
stackexchange_codegolf
Inspired by a bug in a solution to this challenge, your challenge is to produce this exact text: ZYXWVUTSRQPONMLKJIHGFEDCBA YXWVUTSRQPONMLKJIHGFEDCBA XWVUTSRQPONMLKJIHGFEDCBA WVUTSRQPONMLKJIHGFEDCBA VUTSRQ...
stackexchange_codegolf
Background This challenge is based on a personal project I did, UnitDC. This challenge is a super-miniaturized version of UnitDC. Challenge Please write a simple unit-aware calculator that evaluates a sequence of positive integers, units and operators in RPN (postfix) notation, while checking whether the units are comp...
stackexchange_codegolf
Given a nonnegative integer \$n\$, determine whether \$n\$ can be expressed as the sum of two square numbers, that is \$\exists a,b\in\mathbb Z\$ such that \$n=a^2+b^2\$. 0 -> truthy 1 -> truthy 2 -> truthy 3 -> falsy 4 -> truthy 5 -> truthy 6 -> falsy 7 -> falsy 11 -> falsy 9997 -> truthy 999...
stackexchange_codegolf
Proton is a quite new language created by PPCG user Hyper Neutrino. It is very similar to Python, and has similar syntax to the language Cheddar, hence there are some clever tricks you can use in order to reduce your byte count. Let's get those cool tricks listed here. As usual, please post one tip per answer and avoid...
stackexchange_codegolf
The challenge: Assuming you have \$ X \$ collections, each collection \$ C_i \$ has a name \$ N_i \$ and a capacity \$ N_i \$ of elements - Determine which collection will be overflowed first while counting the occurrences of the names in a cyclic list. Also print how many cycles of the list occurred. Example: 4 Collec...
stackexchange_codegolf
An arithmetic sequence is a sequence of numbers of the form a,a+n,a+2n,a+3n, etc. In this case, a and n will both be either integers or decimals. Given two inputs, a, n, and a top number value, return a list of numbers where the last term is less than or equal to the top number value. The input can be formatted in any ...
stackexchange_codegolf
Challenge Write a non-empty program/function p that, given a non-empty input string s, outputs the position of the first occurrence of each character of s in the source code of p. For example, if your program is main() { cout << magic << cin } ^0 ^5 ^10 ^15 ^20 ^25 and it receives an input abcd{, the output sh...
stackexchange_codegolf
Given a number N from 2 to 8, place any nonzero number of queens on a grid of any size so that every queen has exactly N queens (counting itself) in each of its row, column, and each diagonal. This challenge has a significant restricted-time runtime limit. Your code must finish all N from 2 to 8 (combined) within the 6...
stackexchange_codegolf
This is a cops-and-robbers challenge, the cops' thread is here You can change the word code into golf by changing a letter at a time in four steps: CODE COLE COLD GOLD GOLF Today, we’ll be doing the same thing with programs. Your challenge is to crack an answer on the cops' thread. Cops will create a series of program...
stackexchange_codegolf
The task Most Casio calculators featured a variable M, which has 3 operators related to it: M, M+, and M- M, as you can expect, returns the value stored in the variable. M+ takes the number on the left and add it to M. M- does the same thing as M+, but subtract instead. To make the challenge just a bit more difficult, ...
stackexchange_codegolf
In response to here. Unlike the previous one, this focuses on code-golf and a new logo, no longer consisting of 6 sticks and the graying-effect as the position of the sticks go deeper. Make the Stack Overflow logo using the following criteria: The tray: Make a gray tray shaped like a bracket facing upwards using th...
stackexchange_codegolf
Your should write a program or function that takes a 4-character string as input and outputs a value indicating if the string is an English word or not. You are allowed to make mistakes in 15% of the provided testcases. Input details: Input is a 4-character string containing only the lowercase English letters (a-z). Ou...
stackexchange_codegolf
Minecraft 1.12 will be released tomorrow, so let's celebrate! Write code that takes in a non-negative integer N which represents the number of items of something in Minecraft. Output it in a way more helpful to players, giving the number of chests, stacks, and items N is equivalent to. Use the format XcYsZi where X i...
stackexchange_codegolf
Given 4 points on the 2D planes A, B, C, D, calculate the area of the intersection region of the triangles OAB and OCD, where O is the center of the plane, having coordinate (0, 0). Algorithms that runs in constant time complexity (in terms of arithmetic operations) are encouraged, but not forced. Rules Each point is ...
stackexchange_codegolf
Imagine this short function to clamp a number between 0 and 255: c = n => n > 0 ? n < 255 ? n : 255 : 0 Is this the shortest possible version of a clamp function with JavaScript (without ES.Next features)? P.S: Not sure if it's relevant but, the 0 and 255 are not random, the idea is to clamp a number as an 8-bit unsig...
stackexchange_codegolf
Given a rectangular board of cells with some number of holes in it, determine whether it is possible to complete a "holey knight's tour" (That is, a path that visits every non-hole cell exactly once using only chess knight moves, not returning to the starting cell) that starts on the top-left cell. For the sake of comp...
stackexchange_codegolf
Create a function or program that takes a number as input, and outputs a string where ASCII-code points for the lower and upper case alphabet are substituted by their character equivalents. The upper case alphabet use the code points: 65-90 The lower case alphabet use the code points: 97-122 If any adjacent digits i...
stackexchange_codegolf
Blatant 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 integer input/argument. The tricky part is that if I reverse your source code, the output must be the original integer negated. Examples Let's say your source code is ABC and its i...
stackexchange_codegolf
This is a game of capture the flag, heavily inspired and based off of Red vs. Blue - Pixel Team Battlebots. That was an awesome question (thank you very much Calvin'sHobbies; I hope you don't mind that I shamelessly stole a lot of code from you) -- here's another team based king-of-the-hill. Hopefully, capture the flag...
stackexchange_codegolf
What general tips do you have for golfing in Common Lisp? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Common Lisp (e.g. "remove comments" is not an answer). Please post one tip per answer.
stackexchange_codegolf
Given the following Python "reference implementation" of non-terminating FizzBuzz: i=1 while True: if i%15 == 0: print("FizzBuzz") elif i%3 == 0: print("Fizz") elif i%5 == 0: print("Buzz") else: print(i) i += 1 We can represent its output as an infinite array of char...
stackexchange_codegolf
Background Stick Bomber is a two-player game I just made up. Initially, some sticks are placed in one or more groups, and the sticks in each group are laid out in a straight line. So a configuration with three groups of 3, 5, and 8 sticks each may look like the following. For conciseness, we can call it a (3,5,8) confi...
stackexchange_codegolf
You will be given two Arrays / Lists / Vectors of non-negative integers A and B. Your task is to output the highest integer N that appears in both A and B, and is also unique in both A and B. You may assume that there is at least one such number. Any reasonable Input and Output method / format is allowed. These Looph...
stackexchange_codegolf
You are playing a famous game called \$1\text{D Array BattleGround}\$. In the game, the player can be stationed in any position from \$0\$ to \$10^5\$. You are a Paratrooper in the game and have the ability to do two types of operation \$-\$ Advance, which would multiply your position by \$2\$ Fall-back, which would d...
stackexchange_codegolf
Introduction Let's observe the following string: ABCDEFGHIJKLMNOP If we swap the ends of the string, which are these: ABCDEFGHIJKLMNOP ^^ ^^ We get the following result: BACDEFGHIJKLMNPO After that, we delete the ends of the string, which in this case are B and O. The result is: ACDEFGHIJKLMNP If we repe...
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
I was asked this question in an interview but I was unable to figure out any solution. I don't know whether the question was right or not. I tried a lot but couldn't reach any solution. Honestly speaking, nothing came to my mind. Rocco numbers A positive integer \$n\$ is a Rocco number if it can be represented either a...
stackexchange_codegolf
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
At time of writing, my reputation is \$16,256\$. As I noted in chat, Oh cool my rep is the concatenation of two powers of 2: 16,256 Or even the concatenation of a power of 2 and its square, which is much more interesting which then spawned a CMC about checking if a number has this property. Given an integer \$n > 0\...
stackexchange_codegolf
You are given two arbitrary integer lists, e.g. [-10, 99, -6, 43], [100, 32, 44]. You are to pick one integer from each list and sum them up, then sort the best pairs ordered by the absolute distance to 100 in ascending order. Paired up integers from each list shall not be repeated in the output. For instance, we have ...
stackexchange_codegolf
Minecraft has a fairly unique lighting system. Each block's light value is either one less than the brightest one surrounding it, or it is a light source itself. Your task is to write a method that takes in a 2D array of light source values, and then returns a 2D array with spread out lighting, where 0 is the minimum v...
stackexchange_codegolf
Create A "Hello, World!" program but without any vowels. Winner is the program with the least bytes. Rules: No vowels are allowed in the code. Must print to STDOUT Must be a full program. Submissions are measured in Bytes Any language goes as long as there aren't any vowels Edit: Y is only a vowel if there aren't any...
stackexchange_codegolf
This simple challenge is very similar to this one: How many days in a month? The only difference is you yield the number of days in a month given the index of the month instead of its name. The reason I ask this near-duplicate is curiosity about mathematical patterns in the sequence of numbers. For example, a simple ob...
stackexchange_codegolf
Challenge Create a program that outputs a square grid showing visible and non-visible points \$(x, y)\$ from the origin based on their greatest common divisor (GCD). A point \$(x, y)\$ is considered visible from the origin \$(0, 0)\$ if the \$\gcd(x, y) = 1\$. Otherwise, it's non-visible. Input An integer \$n\$, repre...
stackexchange_codegolf
This question is about abelian sandpiles. Read this previous challenge and watch this numberphile video to learn more. An abelian sandpile of size n by n is a grid containing the number 0, 1, 2 and 3 (representing the number of grains of sand). Adding two sandpiles works by first adding element by element, and then to...
stackexchange_codegolf
As we all know, meta is overflowing with complaints about scoring code-golf between languages (yes, each word is a separate link, and these may be just the tip of the iceberg). With so much jealousy towards those who actually bothered to look up the Pyth documentation, I thought it would be nice to have a little bit mo...
stackexchange_codegolf
Input Name of a stackexchange site or any way to uniquely identify the site. Output The hour of the day that had the largest number of answers posted over the previous 24 hours. E.g. 14:00-15:00 GMT. You can take the input and give output in any easily human readable format. Your code can access the Internet but only t...
stackexchange_codegolf
Background Related: a golflang theory I posted in TNB a while ago At-most-\$n\$-ary trees are rooted trees where each internal node has between 1 and \$n\$ children (inclusive). Two trees are considered identical only if the shapes exactly match without re-ordering each node's children. In other words, the left-to-righ...
stackexchange_codegolf
What is the shortest way we can express the function f(a,b)(c,d)=(a+c,b+d) in point-free notation? pointfree.io gives us uncurry (flip flip snd . (ap .) . flip flip fst . ((.) .) . (. (+)) . flip . (((.) . (,)) .) . (+)) which with a little bit of work can be shortened to uncurry$(`flip`snd).((<*>).).(`flip`fst).((....
stackexchange_codegolf
This contest is over. There are no remaining crackable answer in the cops challenge. Companion thread of Cryptographic hash golf As a reminder, here are the rules for robbers from the main challenge: Task Crack any of the cops' submissions by posting the following in the robbers' thread: two messages M and N in I ...
stackexchange_codegolf
Given a positive integer N ("virality"), your program should create an ASCII-art drawing of a tree with two branches of length N extending downwards and/or rightwards from the top-left corner. The direction taken by each branch after the first asterisk can be either rightwards or downwards, and this choice should be ma...
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
Swapping two elements in a vector/matrix is very simple in Octave: x='abcde'; x([4,1])=x([1,4]) x = dbcae Unfortunately, I have yet to find a way to do this inside an anonymous function. While the function below is syntactically correct, it only gives back the two elements that are swapped, not the entire x vector...
stackexchange_codegolf
Your task is to, given a map as input, zoom it out or in, depending on the scale. Note that the scale given is the scale by which to zoom out, so a scale between 0 and 1 will actually zoom in. For example, given the following (badly made) map: ..____.... ../OOO\... ..\OO/\... .......... And a scale factor of 2, you sh...
stackexchange_codegolf
Today Neil Sloane of the OEIS sent out an email asking for a confirmation of the current terms, and computation of some larger terms of the latest OEIS sequence A337663 with the keyword "nice". Here's how this sequence works: You label \$n\$ cells on the infinite square grid with \$1\$s, and then place the numbers \$2...
stackexchange_codegolf
Task Define a simple regex as a non-empty regular expression consisting only of characters 0 and 1, grouping parentheses ( and ), one-or-more repetition quantifier +. Given a non-empty string of 0s and 1s, your program should find the shortest simple regex matching the full input string. (That is, when matching a sim...
stackexchange_codegolf
Background A checkered tiling of a rectangular grid is a tiling using some polyominoes, where each region can be colored either black or white so that no two polyominoes sharing an edge has the same color. In graph-theoretic terms, the chromatic number of the adjacency graph is 2. Terminology adapted from a Fillomino v...
stackexchange_codegolf
Create a cat program, a.k.a a program that takes an input and prints it. ...Except, the program will randomly take characters away from your input and print that instead. Each character in the input should have generally equal odds to be removed with the program, though, as it is hard to make that, the odds for each ch...
stackexchange_codegolf
Background In the game stick ranger, there is an item which grants the character the ability to get critical hits. Each time a projectile hits an enemy, it has some probability to be a critical hit (crit). For most weapons this is calculated independently each time, but for one class (the angel) things work differently...
stackexchange_codegolf
Your task is to create a program which outputs a completed tournament bracket given a list of entrants, their seeds, and their scores in each game; in the fewest characters possible. Input Your entrants will have the following data. You can organize your data in whatever form you like, but you cannot pre-sort your arra...
stackexchange_codegolf
Your task is to write a program, function or snippet (yes, snippets are allowed) that simply outputs an integer. However, you must be able to separate your submission into prefixes that also produce distinct integers. You cannot use any bytes that have appeared in previous prefixes. For example, we can have the prefixe...
stackexchange_codegolf
Today (or tomorrow, depending on your timezone, by the time of posting) is the birthday of the great mathematician and physicist Leonhard Euler. To celebrate his birthday, this challenge is about one of his theorems in geometry. For a triangle, we define its incircle to be the largest circle inside the triangle and its...
stackexchange_codegolf
The Lisp language has a family of functions car, cdr, cadr, etc for accessing arrays. For each one, an a defines taking the first item of an array, and a d defines taking the rest. For example, running cadr on [[1,3,4],5,7] will return [3,4] as the a gets the first item ([1,3,4]) and the d removes the first item. We've...
stackexchange_codegolf
When making a Minecraft data/resource pack, you need to include a pack.mcmeta file, which specifies information about it. pack.mcmeta contains a description, but it also contains a pack_format number, which tells Minecraft which versions this pack is for. Your task is to take a version string, and output what pack_form...
stackexchange_codegolf
This is a challenge I thought of recently which I think is not hard but allows for a wide range of possible solutions. Seems like a perfect fit for the creativity of PPCG users :) Your Task Define two functions which together form a lossless round-trip String × String → String → String × String. More specifically, defi...
stackexchange_codegolf
The above image displays a hexagonal grid of hexagons. Each cell in the grid is assigned an index, starting from the center and spiraling counterclockwise around as shown. Note that the grid will continue indefinitely - the above picture is simply the first section. The next hexagon would be adjacent to 60 and 37. You...
stackexchange_codegolf
Jack is a little businessman. He found out a way to earn money by buying electricity on days when it's cheap and selling it when it's much more expensive. He stores the electricity in a battery he made by himself. Challenge You are given N (if required), the number of days Jack knows the cost of electricity for, and X,...
stackexchange_codegolf
I'm surprised this hasn't been posted before! The Consistent Overhead Byte Stuffing (COBS) algorithm is used to delimit byte streams. We choose a frame marker (we'll use 0x00) and wherever 0x00 occurs in the stream it is replaced with the number of bytes until the next 0x00 occurs (we'll call this a milestone). This re...
stackexchange_codegolf
Your challenge is to output the number of twisted corners given a 2x2 Rubik's Cube scramble. For the purpose of this challenge, twisted corners are defined as corners where the colour of the top/bottom face before (usually white or yellow) is not facing the top/bottom after the scramble. Eg. if the cube were to be orie...
stackexchange_codegolf
The task is a rather simple quine challenge with a twist, you must output your source code in the shape of a pyramid. The shape of a pyramid is defined below: 1 234 56789 ABCDEFG HIJKLMNOP QRSTUVWXYZa bcdefghijklmn ......etc...... The main limitation of this challenge is that your quine mus...
stackexchange_codegolf
A bipartite graph is a graph whose vertices can be divided into two disjoint set, such that no edge connects two vertices in the same set. A graph is bipartite if and only if it is 2-colorable. Challenge Your task is to, given the adjacency matrix of an undirected simple graph, determine whether it is a bipartite grap...
stackexchange_codegolf
Introduction The challenge itself was something I came across and had to try and figure out for a personal of project of mine. I ended up branching out and asking family members if they could provide an equation to meet the requirements. Note: I have (with the help of others) found a solution for this but now I'm just ...
stackexchange_codegolf
(randomly inspired by this question) Let's make a drawing from some pipes | and hyphens -. Choosing a subset, if chosen carefully, you can form a rectangular box or block shape (meaning that the corners are formed by |- or -|). For this challenge, we're concerned only with identifying the corners -- the vertical and ho...
stackexchange_codegolf
Specifically, Conway's PRIMEGAME. This is an algorithm devised by John H. Conway to generate primes using a sequence of 14 rational numbers: A B C D E F G H I J K L M N 17 78 19 23 29 77 95 77 1 11 13 15 15 55 -- -- -- -- -- -- -- -- -- -- -- -- -- -- 91 85 51 38...
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
You have been given N piles of coins. You have decided to divide each of those B1, B2, ..., BN piles among separate groups of people. The amount of people receiving coins has to be a prime number and the amount of money given to each person must be different in each pile. Input: N, B1, B2, ..., BN (The amount of coins ...
stackexchange_codegolf
The reverse of an n-bit number is just its n binary digits in reverse order: 001010010 → 010010100 Given a number n, generate all n-bit integers ([0, 2n-1]) in an arbitrary order, with only one restriction: there must be a splitting point such that the reverse of an integer is on the opposite side of the splitting p...
stackexchange_codegolf
RollerCoaster Tycoon 2's maze is the inspiration for this question. Credit to Marcel Vos for thoroughly breaking the classic RCT2 AI. The pathfinding AI in this question is the AI in the latest version of OpenRCT2 at the time of writing, which was updated in response to that video. Suppose a guest enters a \$w \times...
stackexchange_codegolf
Challenge : Given a string rotate every char by its index. e.g --> 'Hello' should be 'Hfnos'. Input : Input is given as string s length of string is 2 < s ≤ 100. Input will either be alphabet , number or one of the following whitespace , ! , @ , # , $ , % , ^ , & , * , ( , ) Output : Output will be a string with all...
stackexchange_codegolf
This challenge is inspired by dmenu, the program I use to launch other programs on my Linux box. To start, for example, GIMP, I simply hit the keyboard shortcut I have assigned to dmenu, type "gimp" and hit enter. However, I don't have to type the whole name. On my machine, if I type "gim", that's enough. Here's how d...
stackexchange_codegolf
NDos' Numeral System NDos' numeral system is a numeral system invented by me. It represents every nonnegative integer by a binary tree. Given a nonnegative integer \$n\$: If \$n=0\$, it is represented as the empty tree. Otherwise, the tree has a root. With the binary expansion of \$n\$: The left sub-tree of the root...
stackexchange_codegolf
Slope fields or direction fields, are a graphical representation of the solutions to a first-order differential equation of a scalar function. A slope field shows the slope of a differential equation at certain vertical and horizontal intervals on the cartesian plane, and can be used to determine the approximate tangen...
stackexchange_codegolf
Background The recurrence of the Fibonacci sequence is defined as $$ f(n+2) = f(n+1) + f(n) $$ From this recurrence alone, the following gap formulae (recurrences relating three terms with certain amount of gaps) can be derived: $$ f(n+4) = 3f(n+2) - f(n) \\ f(n+6) = 4f(n+3) + f(n) \\ f(n+8) = 7f(n+4) - f(n) $$ You mig...
stackexchange_codegolf
Given a string consisting of only upper and lower case letters, output an if it begins with a vowel, and a if not. For the purposes of this challenge, we'll ignore normal grammar rules, and use a very basic rule instead: if the input begins with a vowel (any of AEIOUaeiou), then output an. Otherwise, output a. Your pro...
stackexchange_codegolf
Sometimes, while golfing, one needs to represent large number(s) in their code. Writing them as is can significantly increase the byte-count. What general1 tips do you have for representing long numbers concisely in code? Please post one tip per answer. 1With general, I mean tips that can be applied to more than a sin...
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
As part of its compression algorithm, the JPEG standard unrolls a matrix into a vector along antidiagonals of alternating direction: Your task is to take a matrix (not necessarily square) and return it in unrolled form. As an example: [1 2 3 4 5 6 7 8 9 1 2 3] should yield [1, 2, 5, 9, 6, 3, 4, 7, 1, 2, 8, 3] Rule...
stackexchange_codegolf
You love lunch. However, you are on a diet and want to make sure you don't accidentally eat lunch twice in one day. So you need to make a program to help you make sure. However, one complication is that you eat lunch on a very weird schedule. The time you eat lunch at is MONTH:DAY PM (you can use UTC or localized time ...
stackexchange_codegolf
You are an evil wizard, doing evil wizard business, when suddenly your crystal ball alerts you of a hero on their way to defeat you. To crush their hopes and dreams, you decide to trap the hero in a maze. You could just make a big maze but where would be the fun in that? Instead, you decide you want to make the maze as...
stackexchange_codegolf
Sometimes a long absolute path, in e.g. a command-line parameter to a linux tool, can be shortened, using current working directory as reference: $ pwd /home/heh $ cat /home/heh/mydir/myfile my stuff $ cat mydir/myfile my stuff In this challenge, you should make a function or a program that receives two parameters: ...
stackexchange_codegolf
I'll start off by saying I checked and checked again that this question should be on topic. I will also clearly state that this is a tips question about further golfing a certain set of code not a challenge. I recently answered the following challenge: Scramble words while preserving their outlines: It is well know...
stackexchange_codegolf
Write a function that gets as an input a sorted array of positive numbers A, and an additional number n. The Task is to print out all distinct subsets of A, that sum to n. Example: Input: A = [1,2,2,4,4] n = 9 Output: [1,2,2,4] [1,4,4] Bonus: -50% if your code doesn't store duplicate subset (the same subset but in d...
stackexchange_codegolf
I love sardines, I can't get enough of them, and so does my computer, the Omnilang 5000, which is language agnostic. To give my computer the joy of experiencing sardines, I've decided to feed him a number of programs that are capable of displaying on the screen tins of sardines in various orientations, and showing up t...
stackexchange_codegolf
Input Two lists A and B of nonnegative integers. Output Either 1, 0, or -1, depending on whether A is larger than, equal to, or smaller than B with respect to the twisted lexicographical ordering as defined below. If you want, you can replace 1, 0 and -1 with any other three constant values. The twisted lexicographical...
stackexchange_codegolf
A normal Brainfuck program starts out with an array of cells, all containing the number 0. This program, on the other hand, must be able to run starting with any number x in the leftmost cell. The only rule is that at the end of program execution, the "pointed-to" cell must be cell x. (The leftmost cell is cell 0). Ea...
stackexchange_codegolf
The aim is to create an algorithm to detect that one of the string in a small list of strings contains %s, %d, %f, or %r. All sub-string will start by '%' and be 2 characters longs. Input string will be from 1 to 500 characters with a median of around 20 characters and contain zero to multiple of the possible sub-stri...
stackexchange_codegolf
There are a range of questions revolving around this concept, but these all seem to just involve causing a crash, resulting in many answers which are very obviously designed to cause a crash. So the challenge I set you is to write some plausible code (although what the codes supposed "intention" is I leave up to you), ...
stackexchange_codegolf
Welcome to BBC Casting. We need a program that we can use to select a new actor to play The Doctor on Doctor Who. In the spirit of the show, your program will perform a regeneration from one actor's name to the next. We will test your program by running through the 13 names of actors who have already played The Doctor ...
stackexchange_codegolf
When encountering a problem whose input is meant to be read sequentially, but you may also want to push back onto the input like a stack, which languages have the optimal boilerplates for doing so, and how? For example, from Create a Boolean Calculator, we have a string like: 1AND0OR1XOR1 We want to "pop" 5 chars 1AND...
stackexchange_codegolf
Write a program or function that takes N, and S and outputs the number of palindromes of length S you can build using an alphabet of size N such that any prefix of size between 2 and S-1 is not a palindrome. For example if N were 2 and S were 5 The valid palindromes would be 01110 10001 And thus the answer would be 2 ...
stackexchange_codegolf
A composition of an integer \$n\$ is a representation of \$n\$ as a sum of positive integers. For example the eight compositions of 4 are as follows: 4, 3 + 1, 1 + 3, 2 + 2, 2 + 1 + 1, 1 + 2 + 1, 1 + 1 + 2, 1 + 1 + 1 + 1. The challenge is to output the number of compositions of \$n\$ in which the greatest part is odd....
stackexchange_codegolf
Like Brainfuck or JSFuck would be efficient in terms of number of characters needed, but what languages would have the highest amount of information per character? I was thinking of APL and J but there has to be more. My goal with this question is to find a program that would allow a person with theoretically infinite ...
stackexchange_codegolf
One of my favorite mathematical pastimes is to draw a rectangular grid, then to find all of the rectangles that are visible in that grid. Here, take this question, and venture for yourself! Can you count the number of rectangles? +-----+-----+-----+-----+ | | | | | | | | | | +-----+----...
stackexchange_codegolf