instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Bob got kidnapped and is stuck in a maze. Your job is to help him find a way out. But since it is a very dark and scary maze, he can't see anything. He can only feel walls when he runs in to it, and knows when he has found the exit, but doesn't know anything more that. Since he has to run your program by memory, it has...
stackexchange_codegolf
(This is my first code-golf question) When I was a child, my dad and I invented a game where the license plate we see on cars can give certain points based on some rather simple rules: X amount of the same letter or number give X-1 points, examples: 22 = 1 point aa = 1 point 5555 = 3 points The numbers must be next to...
stackexchange_codegolf
At work I've been acting as quality control on our public documents, to make sure that they are WCAG 2.0 compliant. Given the length of some of these documents there tend to be issues, and so I record the issues and the pages they occur on. The challenge: Given a string input, output a count of all distinct pages with...
stackexchange_codegolf
Given a positive integer \$n\$, output \$n\$ 2D bool images with the same width and height such that: Each image should be 4-connected, i.e. for each two pixels that are true, you can start from one and go up, down, left and right for some times to the other pixel, only passing through true pixels. Each image should h...
stackexchange_codegolf
Introduction hackertyper.net is a website that simulates "hacking" (as the media portrays it) by outputting complicated code from the crypto section of the Linux kernel onto the screen as you type at a rate of 3 characters per one inputted. Challenge Your program/function should either accept a file as a command-line a...
stackexchange_codegolf
In Bloons Tower Defense 6, the strength of different bloons can be measured by their Red Bloon Equivalent (RBE), or the number of single pops it takes to completely defeat the bloon. The RBE for the bloon types are as follows (sourced from the wiki) Bloon RBE red 1 blue 2 green 3 yellow 4 pink 5 black...
stackexchange_codegolf
You will be given a string. It will contain 9 unique integers from 0-9. You must return the missing integer. The string will look like this: 123456789 > 0 134567890 > 2 867953120 > 4
stackexchange_codegolf
Sandbox Have y'all ever written an answer with unprintable ASCII characters in it and wished that there was an easy way to represent those characters in a printable way? Well, that's why the Control Pictures Unicode block was invented. However, manually substituting these characters into one's answer is time-consumin...
stackexchange_codegolf
This is the second version of the task. The original task had a defect that the given range of integers was too small. This was pointed out by @harold that other methods couldn't defeat the way of hard-coding all the possible prime divisors. Now you have a larger range of integers to test from 0 to 2000000. Also, the r...
stackexchange_codegolf
This challenge but with a better spec. Spec Your program will take a linear equation containing a single variable x and output the value of x. Input / Parsing The input will only contain numbers, operators, parenthesis (()), x, and an = sign (this means no whitespace). Parenthesis will always be balanced. There will a...
stackexchange_codegolf
I need help making a brick road to go beside my brick wall! \ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \__ __\ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \ \__\ \__\ \__\ \__\ \__\ \__\ \__\ \_...
stackexchange_codegolf
Given two different positions on a chess board and the type of piece, output the minimum number of moves it will take for that piece to go from one position to another. Rules The given piece can be King,Queen,Rook,Knight and Bishop. (This input can be taken as any 5 unique characters) The 2 positions can be taken in an...
stackexchange_codegolf
Given an array where each number represent a color. After iterating each item in the array (for each item in the iteration the pointer can also point to the second-item-to-the-right), and the two colors in the iteration is the same, do the following checking: If there is a different color between the pointed colors, th...
stackexchange_codegolf
Challenge In this simple challenge, you have to print the public IP address of google.com. Rules You have to output either the IPv6 or IPv4 address, and do it by somehow using internet. Output does not strictly need to be the IP address, your answer will be valid if the correct IP address is somewhere in the output, ...
stackexchange_codegolf
(or: Output the plural demonym.) When in Rome, do as the Romans do. This is a well-known English phrase meaning that it’s best to follow what others are doing around you — to go with the flow. Today, you're going to rewrite the phrase to fit most (Western) place names. To get the name of a group that lives within a reg...
stackexchange_codegolf
Summary The goal of this challenge is to create an undone image-version of a 15-puzzle / sliding puzzle also called taquin in french. Details: Given an input composed of: an image, an integer n, an other integer r, your program, or function, or anything else that fits, must output the same image (i.e. same size and f...
stackexchange_codegolf
We are probably all used to the English alphabetical order: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z When we compare words in English for the sake of alphabetization we first compare the first letter, whichever word has the later first letter comes later. If they are the same we check the second letter and...
stackexchange_codegolf
(related) A Pythagorean Triple is a list (a, b, c) that satisfies the equation a2 + b2 = c2. A Primitive Pythagorean Triple (PPT) is one where a, b, and c are all coprime (i.e., the only common divisor between the three elements is 1). For example, the (3, 4, 5) right triangle is a famous Primitive Pythagorean Triple. ...
stackexchange_codegolf
Given an integral polynomial \$p\$, determine if \$p\$ is a square of another integral polynomial. An integral polynomial is a polynomial with only integers as coefficients. For example, \$x^2+2x+1\$ should gives truthy, because \$x^2+2x+1 = (x+1)^2\$. On the other hand, \$2x^2+4x+2\$ should gives falsy: \$2x^2+4x+2 = ...
stackexchange_codegolf
This quite literally came to me in a dream. A common combination padlock design has letters on the dials so you can set the combination to a word. Unfortunately, I can't read, but I can count. Considering I am in a hurry, send the shortest path around the dials to open the 4 letter lock, given the current letters and t...
stackexchange_codegolf
Objective Write a program or function (or equivalent) that sorts out and returns the odd letter in the matrix of random size. Details You will be passed a matrix (as a string) as input of random dimensions such as this. bbbbbbbbbb bbbbbdbbbb bbbbbbbbbb bbbbbbbbbb bbbbbbbbbb Your job is to find the letter that doesn't...
stackexchange_codegolf
Task Given a non-negative integer \$n\$, evaluate the factorial \$n!\$. The factorial is defined as follows: $$ n!=\begin{cases}1 & n=0\\n\times(n-1)!&n>0\end{cases} $$ Rules All default I/O methods are allowed. Standard loopholes are forbidden. Built-ins are allowed. There is no time or memory limit. Giving imprecise...
stackexchange_codegolf
The challenge is to write an acrostic piece of code. When read normally (horizontally), the code should take an input string and remove all but the first character on each line. For example, the input: float or and ord line bool var auto real Output: foo bar In addition to this, the code also must contain valid code...
stackexchange_codegolf
Similar to generating minesweeper grids, although the challenge is to make a working minesweeper grid. This will be longer code than normal (I think). more information on minesweeper. Minesweeper is a logic game found on most OS's. The goal of the game is to determine where the mines are on a grid, given numbers indi...
stackexchange_codegolf
This question is inspired by the fact that I love seeing questions with equal vote and answer counts... So here's a simple stack-exchange-api challenge for y'all: Challenge: Given a codegolf.stackexchange question id, output the ratio between the question's votes and number of answers (e.g. votes/answers). Specifics: ...
stackexchange_codegolf
Recamán's Sequence is defined as follows: \$a_n=\begin{cases}0\quad\quad\quad\quad\text{if n = 0}\\a_{n-1}-n\quad\text{if }a_{n-1}-n>0\text{ and is not already in the sequence,}\\a_{n-1}+n\quad\text{otherwise}\end{cases}\$ or in pseudo-code: a(0) = 0, if (a(n - 1) - n) > 0 and it is not already included in the sequ...
stackexchange_codegolf
Inspired by this question on AskUbuntu. Your job is extremely simple. Take the PATH environment variable (echo $PATH) and export it such that each entry (separated by the : character) is on its own line. For example, if the PATH is /bin:/usr/bin:/usr/local/bin, your program should output: /bin /usr/bin /usr/local/bin ...
stackexchange_codegolf
Characters in strings are sometimes represented as their ASCII hexadecimal codes. Printable characters have two hex digits in their representation. Swapping those digits leads to another character, which will be our output. The table of relevant character codes can be found on Wikipedia. Details Take a string as input...
stackexchange_codegolf
The fast growing hierarchy is a way of categorizing how fast functions are growing, defined the following way (for finite indices): \$ f_0(n)=n+1 \$ \$ f_k(n)=f_{k-1}^n(n)\$ with \$f^n\$ meaning repeated application of the function f Examples f0(5) = 6 f1(3) = f0(f0(f0(3))) = 3+1+1+1= 6 f2(4) = f1(f1(f1(f1(4)))) = 2*...
stackexchange_codegolf
In this challenge you must write a computer program that creates a stack of a thousand identical \$1 \times 1\$ frictionless homogeneous blocks such that each block is supported and the stack is stable under gravity when placed on the edge of a table which spans from \$x = -\infty\$ to \$0\$ horizontally, with the surf...
stackexchange_codegolf
According to this site a general rule recommended by The U.S. Government Printing Office Style Manual is Capitalize all words in titles of publications and documents, except a, an, the, at, by, for, in, of, on, to, up, and, as, but, or, and nor. This might not be true as I'm unable to find such a recommendation i...
stackexchange_codegolf
Rotonyms 2 A "Rotonym" is a word that ROT13s into another word (in the same language). For this challenge, we'll use an alternate definition: a "Rotonym" is a word that circular shifts/rotates into another word (in the same language). For example: 'stable' < 'tables' < 'ablest' 'abort' > 'tabor' 'tada' >> 'data' The C...
stackexchange_codegolf
The infinity symbol is also called a lemniscate. Your program must draw a lemniscate with text via standard out (formatted with newline feeds) or graphically. The infinity symbol (by my standards) must be continuous (that is, every non-whitespace character must be touching two other non-whitespace characters diagonally...
stackexchange_codegolf
This challenge, I hope, is simple to understand. Given a date-string (given in any format you prefer, so long as it has 4 digits of year and 2 digits of day and month), calculate the weekday for the particular date-string. You must output 7 different values, corresponding to the weekday you have calculated. It's okay i...
stackexchange_codegolf
Remember the kids game, 'Duck, Duck, Goose'? No? Me neither. The challenge Print the word 'duck' on individual lines an indeterminate amount of times. Print the word 'goose'. Your program ends. The rules Attempt to play the game in the fewest bytes. There must be at least one duck. There must be exactly one goose, a...
stackexchange_codegolf
Given an array of positive integers, output an array of all the elements that are greater than or equal to the adjacent ones. Most elements will have two adjacent elements; the first and last element are special cases, as they only have one adjacent element. You may assume that the array contains at least two elements....
stackexchange_codegolf
Output all 95 bytes from 0x20 to 0x7E inclusive (printable ASCII including space), in any order, each at least once. The source code of your program must use all of those bytes, each at least once. Your program must be irreducible (meaning you cannot strictly remove some characters from the program and then have it st...
stackexchange_codegolf
The Monkey has swung home to find his tree all in pieces. He likes order and scoops up all his 'tree-parts' and sets them out in 3 groups. The Monkey's 3 nested lists: STEP = [['S', '1', 'B', '3'], ['S', '3', 'B', '11'], ['S', '5', 'B', '12'], ['S', '4', 'B', '13'], ['S', '2', 'B', '14']] TRANSITION = [['T', '2', 'B',...
stackexchange_codegolf
Similar in spirit to Number of distinct tilings of an n X n square with free n-polyominoes and Partition a square grid into parts of equal area, this challenge will have you count ways of partitioning a triangle in a triangular grid. The goal of this code-golf challenge is to write a program that outputs \$ a(n,m)\$, t...
stackexchange_codegolf
This is the Robbers thread. For the Cops challenge, see here As the robbers, your job is to crack the cops' answers. Choose an uncracked, unsafe cop answer and attempt to figure out which languages, in which order, the cop used. Note that a crack is valid even if the languages are different. So long as the the language...
stackexchange_codegolf
At runtime, keep prompting for a line of input until the user inputs something (other than an empty newline), i.e. does not just press Enter or OK. Output or result is neither required nor prohibited. Pseudo-code 1 myform = new form("GUI") myform.mytxt = new editfield("") myform.ok = new button("OK") repeat waitfor(m...
stackexchange_codegolf
Background When I was in elementary school, we used to play a game in math class that goes as follows. All kids sit in a big circle and take turns counting, starting from 1. However, the following numbers must be skipped while counting: Numbers that are multiples of 3. Numbers that have a 3 in its decimal representat...
stackexchange_codegolf
I think we've all done this as a kid: some websites require a minimum age of 18, so we just subtract a few years from the year of birth and voilà, we 'are' 18+. In addition, for most rides at amusement parks the minimum height to enter is 1.40 meters (here in The Netherlands it as at least). Of course this can be cheat...
stackexchange_codegolf
Write a program that outputs the number 0. That's a bit trivial, isn't it? Let's sort all distinct permutations of your code in lexicographical order. When any of these codes are run, it should output the its location in the array (0-indexed or 1-indexed). This means that your code must be the lexicographically smalles...
stackexchange_codegolf
There are 5 different "special characters": % & # $ ! These special characters are in a string with numbers. Like so: "5 ! 60%2$5.3" (valid). You must determine the validity of the string and there are certain rules in order to determine validity of the string. Rules: These special characters can exist in a string...
stackexchange_codegolf
Part of Advent of Code Golf 2021 event. See the linked meta post for details. The story continues from AoC2015 Day 3, Part 2. This challenge was kindly contributed by Wheat Wizard (Grain Ghost). Santa is delivering presents to an infinite two-dimensional grid of houses each 1 unit apart. The delivery begins delivering...
stackexchange_codegolf
Introduction Some months are completely symmetric, meaning they have central symmetry as well as reflection symmetry, like February of 2010: February 2010 ┌──┬──┬──┬──┬──┬──┬──┐ │ │ │ │ │ │ │ │ ├──┼──┼──┼──┼──┼──┼──┤ │ │ │ │ │ │ │ │ ├──┼──┼──┼──┼──┼──┼──┤ │ │ │ │ │ │ │ │ ├──┼──┼──┼──┼──┼...
stackexchange_codegolf
You have a square board with a bunch of items laid out on it in one of a \$3 \times 3\$ grid of cells and you want to lift it up using balloons, but you can only attach balloons to the corners of the board. Your task is to determine the minimum number of balloons in each corner to make sure the board won't tip over in ...
stackexchange_codegolf
Background Inspired by I'm a palindrome. Are you?, where it is presented the shocking fact that “()() is not a palindrome, but ())(”, I asked myself what instead is ()() and the answer is simply: it is a string with a vertical symmetry axis! The task Write a program or function that takes a string S (or the appropriate...
stackexchange_codegolf
A first order separable ordinary differential equation is (arguably) the easiest type of differential equation to solve, and takes the form of $$N(y)\frac{dy}{dx} = M(x) \\ y(x_0) = y_0$$ For two given functions \$N(y)\$ and \$M(x)\$ and an initial condition \$y(x_0) = y_0\$. Your task is to take \$N(y)\$, \$M(x)\$, \...
stackexchange_codegolf
My obsession with set theory continues. I believe that most programming languages have neither sets as possible structures nor set theory operations such as Union and Intersection. If I am wrong then this question becomes trivial and I learn something new. It would be fun to ask for the code golf construction of a ful...
stackexchange_codegolf
Introduction (may be ignored) Putting all positive numbers in its regular order (1, 2, 3, ...) is a bit boring, isn't it? So here is a series of challenges around permutations (reshuffelings) of all positive numbers. This is the second challenge in this series. The first challenge can be found here. In this challenge,...
stackexchange_codegolf
Imagine a very simple language. It has just 2 syntax features: () indicates a block scope, and any word consisting only of 1 or more lower case ASCII letters, which indicates a identifier. There are no keywords. In this language, the value of identifiers is not important except when they appear multiple times. Thus for...
stackexchange_codegolf
XKCD Comic: Goal: Given a date, the current Dow Opening, and your current coordinates as a rounded integer, produce a "geohash." Input: Input through any reasonable means (STDIN, function argument, flag, etc.) the following: The current date. This does necessarily have to be the date of the system's clock, so assume ...
stackexchange_codegolf
Kids-related intro Whenever I take my kids to an amusement park, the kids get more nervous the closer we are to the park, with the nerve peak when we are in the parking lot and find no place to park. So I've decided I need a method to find the closest free parking space to minimise the time spent parking. Technical int...
stackexchange_codegolf
A simplistic version of English numeral calculator Task Write a program that takes a string as input and outputs the result of the expression. Rules The input string will be worded and not numeral. There will be no parentheses. Order of calculation will be divide,multiply,subtract then add. For same operations, the cal...
stackexchange_codegolf
Background Information Inspired by this answer on Arqade SE Minecraft has rails which allow you to move minecarts around on them for transporting players, entities, and items. There are many types of rails, but today we're only interested in regular rails, which are also the only type that can curve. When you place dow...
stackexchange_codegolf
A regular dodecahedron is one of the five Platonic solids. It has 12 pentagonal faces, 20 vertices, and 30 edges. Your task is to output the vertex coordinates of a regular dodecahedron. The size, orientation, and position of the dodecahedron are up to you, as long as it is regular. You may output the coordinates in a...
stackexchange_codegolf
The problem Given a binary number from 0 to 111111 convert it to trinary. (Base 3). Then print the result. Rules No using a list of conversions. Don't cheat You must use a string as the number No compressing the input string As I will be testing the code with several different numbers I can't use compressed strings Not...
stackexchange_codegolf
While writing my essay for Shakespeare, I realized that I needed to shorten my quote references to more manageable lengths. I had previously been writing this: (Act 1, Scene 2, Lines 345-346) But I've now been told to write them like this: (I.ii.345-6) Clearly, I need some golfed code to golf my Shakespeare quote ref...
stackexchange_codegolf
The objective of this programming puzzle is to reproduce the following gif. Simplification: If you notice the geometric figures don't exactly touch each other. I think it's simpler if you make each vertex to touch the respective edge, and not to go beyond it. I'm not sure though of how this will alter the configuratio...
stackexchange_codegolf
Inspired by this game Challenge: Given an ASCII art string representing a number, output that number. Example: Input: &&&& ##### .====.. .&&& $$$$$. %% %% % % . +. . @@@ . @@ . = . = . ???? +++. && &&. % % = = $$$ . @@@@@ # # . ===. .$$$$$ ...
stackexchange_codegolf
Background An Eisenstein integer is a complex number of the form \$ z = a + b\omega \$ where \$a, b\$ are integers and \$\omega\$ is the third root of unity \$\frac{1-\sqrt3i}{2}\$. The Eisenstein integers can be viewed as the triangular lattice points, as shown in the image below (from Wikipedia): Following the trian...
stackexchange_codegolf
With all the gyms closed down with the COVID-19 situation, we have to exercise with the weight we have lying around at home. The problem is, we have a small selection of plates at varying weights, and can't immediately determine if we can create a setup at the desired weight. Given an unsorted array of weighted plates...
stackexchange_codegolf
Solve an Inglenook Sidings Puzzle Background The Inglenook Sidings Puzzle is a shunting/switching yard puzzle by Alan Wright for model railroading. The rules for the puzzle are as follows: (Source) Form a departing train consisting of 5 out of the 8 wagons sitting in the sidings. The 5 wagons are selected at random. T...
stackexchange_codegolf
Quining has a long history - if you haven't heard of it, click the tag and read up a little on it. Your Task Output an infinite series of 1s (with no other spacing [newlines, spaces, etc.]) UNTIL SIGINT (typically CTRL-C) is called. When it is called, output the program source. Rules It must be a valid quine: No rea...
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
We already now how to strip a string from its spaces. However, as proper gentlemen/ladies, we should rather undress it. Undressing a string is the same as stripping it, only more delicate. Instead of removing all leading and trailing spaces at once, we remove them one by one. We also alternate between leading and trai...
stackexchange_codegolf
The knight is a chess piece that, when placed on the o-marked square, can move to any of the x-marked squares (as long as they are inside the board): .x.x. x...x ..o.. x...x .x.x. Eight knights, numbered from 1 to 8, have been placed on a 3×3 board, leaving one single square empty .. They can neither attack each other...
stackexchange_codegolf
Inspired (like 2 others) by this chat message. (and to some extent, my CMC) Given a string as an input, your task is to check whether or not that string is a number. What is a number? This is a list of all input formats that are "numbers": Integers: An integer is a string made entirely of characters from 1234567890, w...
stackexchange_codegolf
Older cellphones have 3 or 4 characters mapped to each number from 2-9 and that number must be pressed a certain number of times to get the required character. Let's assume our cellphone has this map: 1:1 2:abcABC2 3:defDEF3 4:ghiGHI4 5:jklJKL5 6:mnoMNO6 7:pqrsPQRS7 8:tuvTUV8 9:wxyzWXYZ9 0:<space><newline>0 If you wan...
stackexchange_codegolf
Produce a program A such that running it in language A produces Program B, and running program A in language B produces program C. Program B, when run in language B produces Program A, and running program B in language A produces program C. Program C, when run in language A or language B, prints "Wrong language!". Prog...
stackexchange_codegolf
Caves and Cliffs edition Part 1, Very related You're given a piece of ASCII art representing a piece of land, like so: /‾\ _ __ __/ _/ \‾ _/ __/‾\ | / / ‾\ | \_/‾ \_/ But unlike in the previous challenge, the terrain is mountainous, with caves and cliffs, and can turn b...
stackexchange_codegolf
Background Conway immobilizer problem is a puzzle that reads like the following: Three positions, "left," "middle," and "right," are marked on a table. Three cards, an ace, a king, and a queen, lie face up in some or all three of the positions. If more than one card occupies a given position then only the top ca...
stackexchange_codegolf
Given a binary number A as input with d > 1 digits, output a binary number B with d digits according to the following rules for finding the nth digit of B: The first digit of B is zero if the first and second digits of A are equal; otherwise, it is one. If 1 < n < d, then if the (n-1)th, nth and (n+1)th digits of A ar...
stackexchange_codegolf
Introduction OnePlus is a Chinese smartphone manufacturer founded in December 2013. Their latest phone, OnePlus 5, was unveiled on June 20, 2017. I am sure you have seen that the name of the phone can easily be translated to a sum. OnePlus can be written like 1+ thus OnePlus 2 = (1+ 2) = 3 Input The name of one OnePlu...
stackexchange_codegolf
Introduction Often, people refer to dates as the "second Friday in August, 2018" or the "fourth Sunday in March, 2012". But it's hard to tell what date that is! Your task to is to write a program that receives a year, a month, a day of the week, and an integer, and output that date. Challenge For input, you will get a...
stackexchange_codegolf
Given a PPCG user's user ID, calculate how much times is their Each SE site reputation is from average reputation in the Stack exchange sites they have made accounts. Let me explain, If someone's total network reputation (Total reputation in the stack exchange sites he has participated) is 10k, and if he has participat...
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
It is common to start countdowns 100 days prior to an event, probably because of our base 10 system. Examples of this can be found everywhere: 100 days until your birthday 100 days until the wedding 100 days until the election 100 days until our graduation 100 days until her due date 100 days until football season 100...
stackexchange_codegolf
Given an array of integers A, the task is to output another array B of the same length so that B[i] is the maximum over A for every index that is not i. That is \$B[i] = \max_{i' \ne i} A[i']\$. Examples: A = [1, 5, -3, 4, 2]. B = [5, 4, 5, 5, 5] A = [1, 2, 3]. B = [3, 3, 2] A = [-1, -2, -3, -1]. B = [-1, -1, -1, -1] ...
stackexchange_codegolf
Given an array a that contains only numbers in the range from 1 to a.length, find the first duplicate number for which the second occurrence has the minimal index. In other words, if there are more than 1 duplicated numbers, return the number for which the second occurrence has a smaller index than the second occurrenc...
stackexchange_codegolf
The Penrose triangle, also known as the Penrose tribar, or the impossible tribar, is an impossible object. The goal in this challenge is to display a Penrose triangle in the fewest bytes possible. Source: Wikipedia Rules: You must display the Penrose Triangle digitally after generating it. They must look the same as ...
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
I need to go to the bank and withdraw some money. I need to withdraw $30, $22 to pay my roommate for the internet and $8 for laundry. Since neither of these can make change, I need my $30 to be split into two partitions of the two sizes. That means when the teller asks me how I want my $30 I am going to have to make...
stackexchange_codegolf
Consider a triangle ABC where each side has integer length (an integral triangle). Define a median of ABC to be a line segment from a vertex to the midpoint of the opposing side. In the figure below, the red line segments represent the medians. Note that any given triangle has three medians. Let n be some positive int...
stackexchange_codegolf
This a code challenge. The winner will be the person to provide the most efficient implementation of the solution in terms of algorithmic complexity. Using the dictionary found in '/usr/share/dict' (on OS X and Linux), your task is to find the word with the most anagrams of itself in the dictionary, and print all of th...
stackexchange_codegolf
Your challenge is to translate a Cubically cube-dump to the format specified in this challenge. Input The input will represent a Rubik's Cube, formatted how Cubically prints its memory cube at the end of every program. This is a solved cube: 000 000 000 111222333444 111222333444 111222333444 555 555 5...
stackexchange_codegolf
\$P_k(n)\$ means the number of partitions of \$n\$ into exactly \$k\$ positive parts. Given \$n\$ and \$k\$, calculate \$P_k(n)\$. Tip: \$P_k(n) = P_k(n−k) + P_{k−1}(n−1)\$, with initial values \$P_0(0) = 1\$ and \$P_k(n) = 0\$ if \$n \leq 0\$ or \$k \leq 0\$. [Wiki] Examples n k Ans 1 1 1 2 2 1 4 ...
stackexchange_codegolf
For a given positive integer, try to find out the smallest possible rotation resulted by rotating it 0 or more bits. For example, when the given number is 177, whose binary representation is \$10110001_{(2)}\$: \$ 10110001_{(2)}=177 \$ \$ 01100011_{(2)}=99 \$ \$ 11000110_{(2)}=198 \$ \$ 10001101_{(2)}=141 \$ \$ 00011...
stackexchange_codegolf
Background As noted in the PPCG challenge Compress a maximal discrepancy-2 sequence – which inspired this challenge – the authors of the paper Computer-Aided Proof of Erdős Discrepancy Properties found a maximal discrepancy-2 sequence, namely -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, ...
stackexchange_codegolf
Definition Given some number, x calculate the smallest number i such that 2i≥x. This is not a duplicate of this question. It is slightly different in that an input of 16 should yield an output of 4 whereas 16 returns 5 in the linked question. Input Input will be an unsigned 32-bit integer. Output Output will be an unsi...
stackexchange_codegolf
This challenge is about converting 2D mazes into 1D mazes. Overview +-+-+-+-+-+-+ +-+-+-+-+-+-+ graph { | | | | |A| | B| A B A -- D + + + + +-+-+ + + + + +-+-+ \ | C -- D | | | | | | | | \ | D -- E +-+-+ +-+-+ + +-+-+...
stackexchange_codegolf
You are given a square matrix of width \$\ge2\$, containing square numbers \$\ge1\$. Your task is to make all square numbers 'explode' until all of them have disappeared. You must print or return the final matrix. More specifically: Look for the highest square \$x^2\$ in the matrix. Look for its smallest adjacent neig...
stackexchange_codegolf
The challenge Make 2 programs which convert decimal to and from base 94, or a bidirectional program. Base 94? Base 94 is like any other base, but instead of 0 to 9 and letters, it uses ASCII characters 33 to 126. Not 127 because chr(127) is DEL. Not 32 because that's a space. Examples 0 - ! or empty string 1 - " 93 - ~...
stackexchange_codegolf
If you have any tips regarding golfing in Sesos, a language made by Dennis, and nobody else has covered them yet, please post them here! Only one tip is allowed per answer. Your tip should be at least somewhat specific to Sesos itself, and not just brainfuck. If your tip is relevant to brainfuck in general, you should ...
stackexchange_codegolf
My wife is very, let's say, particular when it comes to putting ornaments on our Christmas tree. Let's get her some code to help her in this trying time. Input Given an input 2 < n < 10 the height of the tree and 0 < k < n the distinct number of ornaments. Task Decorate the tree starting with 1 and increment to k as we...
stackexchange_codegolf
A lazy physicist has the job to perform the double slit experiment. However, they are lazy and can't be bothered to set up all the equipment themselves and so are going to simulate the effects. They can't program though so are going to need some help. As they are lazy your program should be as short as possible. Given...
stackexchange_codegolf
Lean is a theorem prover and programming language. It's also as of writing the Language of the Month! What tips do people have for golfing in Lean? As always, tips should be specific to to Lean (e.g. "Remove comments" is not an answer), and stick to a single tip per answer.
stackexchange_codegolf
Recently a friend of mine posed the following: What subset of the integers satisfies the condition if distinct a and b are in the subset, their average is not in the subset? I know the set of non-0 squares satisfies the condition, but I wonder if there exists a more... dense set that satisfies the condition. (It turn...
stackexchange_codegolf