instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Yesterday, I left my sandwich on the table. When I got up today, there was a bite in it... Was it mine? I can't remember... Problem: Take a representation of the sandwich and my bite pattern and tell me if it was my bite or not. Examples: Example 1: My bite pattern: .. . Sandwich: ##### .#### ..### Output: truthy Ex...
stackexchange_codegolf
Introduction A farmer needs help calculating the least time it will take him to pick his fruit each day. Challenge This farmer has X orchards. Each orchard has Y fruits in it. If the orchard has no fruits, then it will contain the string "none". The farmer has a list, this list contains the fruit he must pick. The f...
stackexchange_codegolf
For some part of history people in France used a decimal clock. with the clock having 10 hour day, 100 minutes an hour and 100 seconds per minute. Though this clock simplified calculations a bit the idea wasn't appreciated by most of the world which used our current 24 hour, 60 minute hour, and 60 second minute. And he...
stackexchange_codegolf
Given a black and white image with a white background and a set of black dots, paint a set of white pixels red, such that there is a path between each pair of black pixels. Details A path is a set of connected pixels (8-neighbourhood connectivity). Black pixels can be used as part of the paths. The goal is trying to ...
stackexchange_codegolf
The board game In the board game "Carcassonne" players place tiles by matching their edges and earn the highest scores through creating large contiguous areas of terrain. The following are (roughly) the types and quantities of tiles included in the game: #01 x4 #02 x5 #03 x8 #04 x2 #05 x9 #06 x4 #07 x1 #08 x3 #...
stackexchange_codegolf
Your challenge is to expand some brackets in a program's input as shown: Find a string s between two matching brackets [ and ], with a single digit n after the closing bracket. Remove the brackets. Replace s with itself repeated n times. (If n is 0, simply remove s.) Go to step 1 until there are no more matching brack...
stackexchange_codegolf
Given guaranteed strictly positive integers \$w\$ and \$n\$, output An equilateral triangle array with side length \$w\$, filled with two distinct, consistent values. I'll call these 0 and 1 but they do not have to be equal to 0 and 1. The number of 1s inside this array must be equal to \$n\$. The output triangle must...
stackexchange_codegolf
Given an \$m \times n\$ matrix of integers A, there exist a \$m \times m\$ matrix P, an \$m \times n\$ matrix D, and an \$n \times n\$ matrix Q such that: \$A = P D Q\$. P and Q are unimodular matrices (i.e. matrices which are invertible and whose inverses are also integer matrices); D is diagonal; each diagonal entry...
stackexchange_codegolf
Inspiration The longest words that can be typed with only the left hand on a standard QWERTY keyboard are "sweaterdresses", "tesseradecades", and "aftercataracts" (Source: Wikipedia). Challenge Given as input a "keyboard" \$K\$ and a string \$S\$ determine whether \$S\$ can be typed using only the left hand on keyboard...
stackexchange_codegolf
Using the word “conemon” print each character 2 times more than the last. The first letter, “c”, should be printed 10 times, the second 12 and so on. Each repeated-letter-string should be printed on a new line. So the end-result becomes: cccccccccc oooooooooooo nnnnnnnnnnnnnn eeeeeeeeeeeeeeee mmmmmmmmmmmmmmmmmm ooooooo...
stackexchange_codegolf
In this challenge, your input is an integer value. Your task is to find the sum of the range of the sum of the range of n. Examples: Input -> Output 1 -> 1 2 -> 6 3 -> 21 4 -> 55 5 -> 120 6 -> 231 7 -> 406 8 -> 666 9 -> 1035 10 -> 1540 This challenge should be fairly simple to co...
stackexchange_codegolf
Produce a program to correctly number a crossword grid. Input The input will be the name of a file representing the crossword grid. The input filename may be passed as an argument, on the standard input, or by other conventional means other than hardcoding. Grid file format: A text file. The first line consists of two ...
stackexchange_codegolf
Create a program to display some approximation of a bell curve. You are free to use whatever method you wish for generating the data, but the data must be displayed vertically, as in oriented like so: Other restrictions: Your code must create the approximation, that is, don't hardcode or take data from the internet. ...
stackexchange_codegolf
This challenge is in honor of mathematician John Conway who passed away April 11, 2020 due to COVID-19. He was famous for coming up with the Game of Life cellular automaton and many other mathematical contributions such as the surreal numbers and the monster group. The advanced math of those topics is out scope for thi...
stackexchange_codegolf
Background The sequence in the title is A245788 "n times the number of 1's in the binary expansion of n" ("times" here means multiplication), which starts like this: 1, 2, 6, 4, 10, 12, 21, 8, 18, 20, 33, 24, 39, 42, 60, 16, 34, 36, 57, 40, 63, 66, 92, 48, 75, 78, 108, 84, 116, 120, 155, 3...
stackexchange_codegolf
First attempt at a question. Calculating Transitive Closure According to Wikipedia, "the transitive closure \$R^*\$ of a homogeneous binary relation \$R\$ on a set \$X\$ is the smallest relation on \$X\$ that contains \$R\$ and is transitive." Also, "a relation \$R\$ on a set \$X\$ is transitive if, for all \$x, y, z...
stackexchange_codegolf
There's a lot of questions about Conway's Game of Life, but nothing about customization (Related: 2-Player Life). Given an input, determine the result on a 100x100 grid after some iterations. The input is given as a string. For example: Using the character #, follow the following rules: If there are 2 or 3 neighboring ...
stackexchange_codegolf
The subfactorial or rencontres numbers (A000166) are a sequence of numbers similar to the factorial numbers which show up in the combinatorics of permutations. In particular the nth subfactorial !n gives the number of derangements of a set of n elements. A derangement is a permutation in which no element remains in the...
stackexchange_codegolf
Definition \$a(0) = 0\$ \$a(n) = n-a(a(a(n-1)))\$ for integer \$n > 0\$ Task Given non-negative integer \$n\$, output \$a(n)\$. Testcases n a(n) 0 0 1 1 2 1 3 2 4 3 5 4 6 4 7 5 8 5 9 6 10 7 11 7 12 8 13 9 14 10 15 10 16 11 17 12 18 13 19 13 20 ...
stackexchange_codegolf
Anyone remember Boaty? You could totally make any old word, right? Write a function to turn a string into Somethingy McSomethingface. It should accept one string as input. Ignore the case of the input. If the word ends in 'y', your function should not add an additional 'y' to the first instance, but should remove it i...
stackexchange_codegolf
What does "jelly" mean in the title?. Cop's thread Robbers, you are to choose an uncracked Cop answer, and attempt to find a Jelly program which is: shorter than the Cop's answer solves the linked challenge, according to the rules of the challenge So long as these two bullet points are met, your answer cracks the Cop...
stackexchange_codegolf
Challenge Inspired by this SMBC comic, discussed on reddit, math.stackexchange, and calculus7, the challenge is to return the lowest base such that a number is "fouriest." Description [From the comic] "It's called a Fourier Transform when you take a number and convert it to the base system where it has more fours, thu...
stackexchange_codegolf
Challenge You just entered a room. Here's how it looks (you are the X): |\ /| | \/ | | X | | | |----| You challenge yourself to see if you can reach where you started by following the walls. You go right until you find a wall. Then, you turn clockwise until you are facing parallel to the wall. For example, if you...
stackexchange_codegolf
To simulate a zombie invasion, start with a grid of # and representing the map: ## ## ### # ## ## # ### # #### # represents land. represents water. The zombies start at a point on the map... ## ## ### # ## %# # ### # #### ...and spread. % denotes land infected by zombies. However, zombies cannot...
stackexchange_codegolf
Information Create a diagonal line given its length (let’s call the variable, say, \$n\$ where \$n > 0\$) The diagonal line starts from the top left and goes to the bottom right. You must use the ASCII character \ for the line. The input number can be given from STDIN or if your program doesn’t support that, use a har...
stackexchange_codegolf
Background SKI combinator calculus, or simply SKI calculus, is a system similar to lambda calculus, except that SKI calculus uses a small set of combinators, namely S, K, and I instead of lambda abstraction. Unlike lambda calculus, beta reduction is possible only when a combinator is given enough arguments to reduce. T...
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
Overview: From Wikipedia: An Egyptian fraction is the sum of distinct unit fractions. That is, each fraction in the expression has a numerator equal to 1 and a denominator that is a positive integer, and all the denominators differ from each other. The value of an expression of this type is a positive rational number a...
stackexchange_codegolf
Input A dictionary with string keys and string values. Output The 'inversedict' of this dictionary. How to make an inversedict An inversedict is a dictionary with string keys and string array values. The keys are the values from the original dictionary, and the values are the keys from the original dictionary with th...
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
Given a string of text that contains lowercase letters, encode it as follows: (I will be using abcdef) First, encode the alphabet cipher, but this time, 0-indexed. 000102030405 Reverse it. 504030201000 Loop through the string. If the next two digits together are 25 or smaller, encode those two numbers. 5 04 03 02 01...
stackexchange_codegolf
Steganographic Squares Your job is to take in a string, and generate an NxN image that represents this string. You must also write the algorithm that takes in the image and turns it back into a string as well. The scoring will be will include the byte count of both algorithms: "Encryption" Algorithm + "Decryption" Algo...
stackexchange_codegolf
The cross product of two three-dimensional vectors \$\vec a\$ and \$\vec b\$ is the unique vector \$\vec c\$ such that: \$\vec c\$ is orthogonal to both \$\vec a\$ and \$\vec b\$ The magnitude of \$\vec c\$ is equal to the area of the parallelogram formed by \$\vec a\$ and \$\vec b\$ The directions of \$\vec a\$, \...
stackexchange_codegolf
Introduction A palindromic closure of an input string is the shortest palindrome that can be constructed out of the input string where the final palindrome starts with the input string. For this challenge, we will consider a two-way palindromic closure such that Left Palindromic Closure of an input string is the short...
stackexchange_codegolf
Background In the sport of Table Tennis (aka Ping-Pong or Whiff Whaff), two opponents play a sequence of rounds, where each round consists of players hitting a ball back and forth until one player (may or may not be the server) gains a point. Table Tennis has some official rules that make for a good game, but we will u...
stackexchange_codegolf
A finite-permutation is a function which takes an \$n\$-tuple and produces an \$n\$-tuple such that every element of the input is present in the output, and the ordering does not rely on the values of the inputs. We can unambiguously represent these permutations with an \$n\$-tuple where each element is the index of wh...
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 fifth challenge in this series (links to the first, second, third and fourth challenge). I...
stackexchange_codegolf
We don't have a challenge for conversion between Cartesian and polar coordinates, so ... The challenge Write two programs (or functions) in the same language: one that converts from polar to Cartesian coordinates, and the other from Cartesian to polar coodrinates. The score is the sum of the two program lengths in by...
stackexchange_codegolf
Challenge Implement binary search on a list of length 256 with no branches. Specification Input an integer X and a strictly increasing list of integers Output is the greatest element of the list that is less than or equal to X The output will always exist List will always have exactly 256 elements and be strictly incr...
stackexchange_codegolf
Given a list of date ranges r as input, output or return any ranges not found in r. For the sake of this example, input will be in YYYY-MM-DD format. Let's say you have three date ranges: [2019-01-01, 2019-02-01] [2019-02-02, 2019-04-05] [2019-06-01, 2019-07-01] You can see that there is a gap in between 2019-04-05 an...
stackexchange_codegolf
The Steenrod algebra is an important algebra that comes up in algebraic topology. The Steenrod algebra is generated by operators called "Steenrod squares," one exists for each positive integer i. There is a basis for the Steenrod algebra consisting of "admissible monomials" in the squaring operations. It is our goal to...
stackexchange_codegolf
Rules You will start with only two elements: Points \$A\$ and \$B\$ such that \$A \neq B\$. These points occupy a plane that is infinite in all directions. At any step in the process you may do any of the three following actions: Draw a line that passes through two points. Draw a circle centered at one point such tha...
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
Question Given the atomic number of an element in the range [1-118] output the group and period, of that element as given by the following Periodic Table Of Elements. For elements in the Lanthanide and Actinide series, (ranges [57-71] and [89-103]), you should instead return L for the Lanthanides and A for the Actinide...
stackexchange_codegolf
What does "jelly" mean in the title?. Robber's thread Jelly has an "Evaluate the argument as Python 3" atom, ŒV which takes a string as an argument as evaluates that string as Python 3 code: Try it online!. It also has compressed strings, delimited with “...» that can compress any string containing printable ASCII (plu...
stackexchange_codegolf
Create a function that accepts a list of dates (unsorted with possible duplicates) and returns the days of the week in one of the following formats: A format similar to MTWTFSS or SMTWTFS (i.e. beginning with Monday or Sunday), with non-days replaced by an underscore _, illustrated below. WEEKDAY if all the dates are ...
stackexchange_codegolf
In the fewest bytes possible, determine whether the two values given each match one of the following: First value 2 string or integer - whichever you prefer to case insensitive too case insensitive two case insensitive t0 case insensitive (t zero) Second value b case insensitive be case ins...
stackexchange_codegolf
A little context: Book has 411 Pages Read a random number of pages on the first day which is unknown Number of pages to read next day is the square of the sum of the digits of the page currently on I.e. on Page 36: read 81 pages next day On day 6 The square answer directly adds to current page number to make 411 Fini...
stackexchange_codegolf
Write a non-empty program or function that when called outputs a single value, 1 or 0, and when called multiple times, the output numbers produce the binary representation of your program's source code (in the same code page from which your code is compiled/interpreted). For instance, if your source code was abc (in AS...
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
Play the Fruit Box Game Intro Fruit Box is a game consisting of a 10x17 grid of numbers, each between 1 and 9, where the goal is to clear as many numbers as possible in a two-minute time window. In order to clear numbers, one selects a rectangle aligned with the grid, and if the numbers inside of it sum to 10, they are...
stackexchange_codegolf
My electric garage door works like this: There is just one push button to control the door If the door is fully closed and I hit the button, the door starts to open. It takes 10 seconds to open fully If the door is fully open and I hit the button, the door starts to close. It takes 10 seconds to close fully If the d...
stackexchange_codegolf
Input A string that contains at most one of each of the letters A, B, and C. They may be in any order. The empty string is valid input. Note: A previous version of this challenge used the letters LEJ instead of ABC and they may still be used if desired. Output A string of the A, B, C letters that were not present in th...
stackexchange_codegolf
Note: as this question has been marked as a duplicate, I have accepted an answer. However, I will still check this question if users can find a shorter way of doing it, and accept that answer. Given two numbers (which are multiples of 0.5) representing heads-percentage and tails-percentage from a series of coin-flippin...
stackexchange_codegolf
Well, Brexit happened. And Sky News, being the geniuses they are, have decided to create a countdown on the side of a bus. Your job is to do something similar. The UK leaves the the EU on 31st of March 2019 and you have to create a digital countdown for this that changes every second (with a 0.05 second deviation allo...
stackexchange_codegolf
You will be given a 2-D array A of integers, and a length N. Your task is to find within the array the straight line (horizontal, vertical or diagonal) of N elements that yields the highest total sum, and return that sum. Example N = 3, A = 3 3 7 9 3 2 2 10 4 1 7 7 2 5 0 2 1 ...
stackexchange_codegolf
Code-Bowling You've been hired by Brunswick Bowling to create a simple program to output the text Code Bowling on their monitors. This company is worth a pretty penny and you feel you can swindle them for quite the bit of cash. The job description clearly states that they pay on a scoring basis and you're pretty confi...
stackexchange_codegolf
Challenge Description You have to show a simulation of rain in terminal. In the example given below its adding 100 raindrops at random (use the default random function which your language offers) coordinates, waiting for 0.2 seconds and then redrawing again until the given time expires. Any character can be used for r...
stackexchange_codegolf
Given a list of positive integers as input you are to determine if there is a way to pair up the elements such that: All but one element is in a pair No element is in more than one pair Every pair is of equal elements No two pairs have elements separated by the same distance in the original list For example if the in...
stackexchange_codegolf
Background Suppose that there are 2*n people to be married, and suppose further that each person is attracted to exactly n other people under the constraints that: Attraction is symmetric; i.e. if person A is attracted to person B, then person B is attracted to person A. Attraction is antitransitive; i.e. if person A ...
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
I like patterns in time. My favorite is when the time lines up. For example, all of these line up: 3:45 12:34 23:45 3:21 6:54 This is because each digit in the hour/minute is increasing/decreasing by one each time. Your task is to take the current time and check if it "lines up" in this pattern in a program. (You will...
stackexchange_codegolf
Inspired by Is this Flow Free puzzle trivial? by @Bubbler. Lengthy chunks of this challenge are borrowed from there. This may be one step of a solution for the linked challenge, depending on chosen strategy. Background Flow Free is a series of puzzle games whose objective is to connect all the same-colored pairs of dot...
stackexchange_codegolf
In this challenge you will receive a list of positive integers \$W\$ called a word, and a square symmetric matrix \$M\$. Your task is to determine if the word can be turned into the empty list by applying a series of valid moves. The valid moves are: If two consecutive values in the list are equal you may remove them ...
stackexchange_codegolf
This is a Cops and Robbers challenge. This is the robber's thread. The cop's thread is here. The cops will pick any sequence from the OEIS, and write a program p that prints the first integer from that sequence. They will also find some string s. If you insert s somewhere into p, this program must print the second inte...
stackexchange_codegolf
Challenge Write a program P, taking no input, such that the proposition “the execution of P eventually terminates” is independent of Peano arithmetic. Formal rules (In case you are a mathematical logician who thinks the above description is too informal.) One can, in principle, convert some Universal Turing machine U (...
stackexchange_codegolf
Your task, if you wish to accept it, is to write a program that outputs a positive integer (higher than 0). If the source code is duplicated the output must remain the same. The tricky part is that if the source code is typed three times (triplicated?) the output will be multiplied by 3. Rules You must build a full pr...
stackexchange_codegolf
Cops thread (read first) Robbers, your task is to find a Shue program p that when given the cops input i, outputs a program h, which outputs "Hello Shue!". The length of your p has to be less than or equal to the length of the cop's p. The robber with the most cracks wins.
stackexchange_codegolf
Given a sorted list of unique positive floats (none of which are integers) such as: [0.1, 0.2, 1.4, 2.3, 2.4, 2.5, 3.2] Evenly spread out the values that fall between two consecutive integers. So in this case you would get: [0.333, 0.666, 1.5, 2.25, 2.5, 2.75, 3.5] (I have truncated the values 1/3 and 2/3 for ease of...
stackexchange_codegolf
You will create a program that generates the stereographic projection of polyhedra. In particular, to keep things simple, we'll only focus on n-chamfered dodecahedron. Given a natural number n as input, and also a natural number d your program will output an d pixels by d pixels image which is the stereographic project...
stackexchange_codegolf
For golfing practice, I have been doing the assignments in my girlfriend's Intro to Python class. I found that for this assignment, there were multiple strategies that came very close in character count, and I'm sure people here can find even better ways. Although I am most interested in ways to do this in Python, I wo...
stackexchange_codegolf
Challenge Factory workers are usually very hard-working. However, their work is now being commonly replaced with machines. You have to write a program that takes a number as input. It will print out a factory of 10 workers 10 times. Every time, each worker has a 1/input chance of being 'fired' and replaced by a machine...
stackexchange_codegolf
A long period prime is a prime number \$p\$ such that decimal expansion of \$1/p\$ has period of length \$(p-1)\$. Your task is to output this number sequence. For purposes of this challenge we will consider only odd primes. Period of a decimal expansion of a rational number is the smallest period \$k\$ that makes the ...
stackexchange_codegolf
Sandbox Background (not necessary for the challenge) A standard number theory result using the pigeonhole principle is the fact that given any natural number k, there is a Fibonacci number that is a multiple of k. We can see this by considering modular pairs (F(n-1) % k, F(n) % k), and noting that there are only a fini...
stackexchange_codegolf
I got into code-golfing recently and tried to write the smallest tautogram checker. A tautogram is a sentence in which all words start with the same letter, for example: Flowers flourish from France. Given a sentence as input, determine whether it is a tautogram. Test Cases Flowers flourish from France True This i...
stackexchange_codegolf
Inspired by a challenge from the OUCC 2022 Seniors competition. Background Two teams are playing "capture the flag". They take turns invading each other's base and capturing their opposing team's flag in the shortest amount of time. The attacking players each have one soft ball they can throw at the defenders. Teams ge...
stackexchange_codegolf
Background The Zundoko Kiyoshi function originates from this tweet by kumiromilk. Translated from Japanese, it reads roughly as follows: The test for my Java lecture had a problem that said "Implement and describe your own function". I made it continuously output either "zun" or "doko" randomly; if the sequence "zun",...
stackexchange_codegolf
CHALLENGE This is a fastest-code challenge. Count how many n-dimensional hypercubes with n=1,2,3,4 exist, with vertices labeled with either 1 or 0, such that there does not exist any rectangle formed by 4 vertices such that one diagonal is 1-1 and the other diagonal is 0-0. To be more clear, the forbidden rectangles ha...
stackexchange_codegolf
Gödel's β function takes three natural numbers as arguments. It is defined as β(x,y,z) = rem(x, 1 + (z + 1) · y) = rem(x, (z · y + y + 1) ) where rem(a, b) denotes the remainder after integer division of a by b. The β Lemma now states that: For any sequence of natural numbers (k_0, k_1, … , k_n), there are natural nu...
stackexchange_codegolf
The task is simple: given a 32 bit integer, convert it to its floating point value as defined by the IEEE 754 (32-bit) standard. To put it another way, interpret the integer as the bit-pattern of an IEEE binary32 single-precision float and output the numeric value it represents. IEEE 754 single precision Here is a conv...
stackexchange_codegolf
It's asked to write a script to generate a source data to feed a JavaScript renderer. JS Renderer documentation The JS renderer is this script: function o(x){ r=x.split(' '); (d=document).write('<style>i{position:absolute;width:10;height:10;background:#000}</style>'); for(i=0;i<r.length;++i){c=r[i].split(',');d.w...
stackexchange_codegolf
Steve Ballmer is the ex-CEO of Microsoft, and in a recent article, claimed that he "still does not know what he did wrong with mobile". As CodeProject's newsletter pointed out, "That article's title could be ended at so many spots and still be accurate". Given no input, output the following: Steve Ballmer still does no...
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
Upon the rumor that Codegolf will have a Rock-Paper-Scissors tournament you look into the topic of square-free words. A word made of the letters R, P, S is square-free if it does not contain a sequence that repeats twice. That is to say, the word can not be written as a x x b where a and b are words of any length and ...
stackexchange_codegolf
You are a package handler for Big CompanyTM and your job is to load boxes into a truck. These are special, stretchy trucks: their length can be adjusted at will. But stretching trucks are expensive, so keep the truck lengths as short as possible! The Challenge Write a full program or function that, when given the truck...
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
The species of geese known as Alex A are known for residing in triangular grids consisting of 64 cells: (Picture taken from this unrelated Project Euler problem.) We'll label each cell with the numbers 0 to 63 starting from the top row and then moving from left to right on each row below that. So the top cell is 0 and...
stackexchange_codegolf
Challenge Your task is to encode an integer as a string of ASCII characters, then successfully decode it after said string has been randomly shuffled. You will write two programs/functions, which will be referred to as Encoder and Decoder. Encoder Input: an integer \$n\$ in the range \$[0,2^{31}-1]\$. Output: a string...
stackexchange_codegolf
Input: A positive integer n=p^q where p and q are prime. Output: Output the result of q^p Test cases (in, out): 4, 4 8, 9 25, 32 27, 27 49, 128 121, 2048 125, 243 343, 2187 1331, 177147 3125, 3125, 16807, 78125, 823543, 823543 161051, 48828125 19487171, 1977326743 Scoring: This is code-golf, so may the shortest code...
stackexchange_codegolf
Challenge Your task is to write a piece of code that outputs another piece of code. That code must in turn output yet another code until the final code outputs the integer 1. The chain ends the first time 1 is outputted. None of your programs may share any characters (there's one exception in the Rules-section). The w...
stackexchange_codegolf
You and your friend want to send each other secret messages. However, because you are conspiracy theorists and think that the government has a quantum computer that can crack any standard encryption. Therefore, you are inventing one of your own. The first step of this is as follows: taking an input string, you check...
stackexchange_codegolf
In my answer, I have this code: s.match(/[AEIOU]/) This seems too verbose to check if a string is one of A, E, I, O, or U. I tried: "AEIOU".includes(s) But that's 1 byte longer. Can I do this in a shorter way?
stackexchange_codegolf
The difference list of a list of integers is the list differences of consecutive members. For example the difference list of 1, 3, 2 ,4 is 2, -1, 2 Your task is to take as input a difference list and output what the difference list would look like if the original list were sorted. For example the difference list 2, 1...
stackexchange_codegolf
There are popular check digit algorithms such as Luhn and then there are good ones, for example the Damm algorithm. The only possible reason behind the popularity of algorithms such as Luhn is that there exist code golfed implementations of them. This means that we as a community have the power to change the world by p...
stackexchange_codegolf
The world has been invaded by aliens. They are everywhere killing people and taking over the world. You are hiding with your friend. They have one weakness - the high pitched sounds. You can't go yell at them, because you'd get caught before, so you remember the state had a conveniently made machine that emits a high p...
stackexchange_codegolf
The oldest Polish salt mine, located in Bochnia*, was started in year 1248, which we can consider a magical number. We can see that it's equal to 4 digits from the sequence of exponentiations: . As the date is actually 4 digits from the sequence, we could make it longer. We could repeat the process until we reach infin...
stackexchange_codegolf
Given a list of integers, group the elements which occur most first, then group the next most and so on until each unique element in the list has been grouped once. Examples: Input: [1,2,3] Output: [[1,2,3]] Input: [1,1,1,2,2,3,3,4,5,6] Output: [[1],[2,3],[4,5,6]] Input: [1,1,1,4,5,6,6,6,7,7,8,8,8,8,8,8,8,9,5,6,5,6,...
stackexchange_codegolf
This time, we want render the count of bytes in a human readable way to user. Let's write a program (a full one or a function or other acceptable formats) to do this. Input An non-negative integer, in range \$0\leq n<2^{31}\$, which means n bytes. Output A string, the human friendly representation of n bytes. Conventio...
stackexchange_codegolf
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. As soon as the Elves get bored with the last week's game, Bin comes up with a new game. The rules are similar, except the Elves are supposed to say the numbers that have its "left side" equal to its "right side" when written in binary....
stackexchange_codegolf
A standard Scrabble board is a 15×15 grid of spaces to place letter tiles. Most of the spaces are blank but some are double word scores (pink), triple word scores (red), double letter scores (light blue), and triple letter scores (blue). There is usually a star in the very center (which counts as a double word score). ...
stackexchange_codegolf