instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Given two binary numbers (strings containing 0s and 1s), perform operations on them, with one problem: You must keep them in binary. That means no going binary(integer(n1)+integer(n2)) or anything like that. Input: Two binary numbers, n1 and n2, and a number between 0 and 3, o, defining the operator. The two binary num...
stackexchange_codegolf
Given a word, treat every letter as its number in English alphabet (so a becomes 1, b becomes 2, z becomes 26 and so on), and check if all of them, including duplicates, are pairwise coprime. The input is exactly one word of lowercase English letters. The output is the fact if the word is coprime: any truthy/falsey val...
stackexchange_codegolf
Before 1994, Spanish dictionaries used alphabetical order with a peculiarity: digraphs ll and ch were considered as if they were single letters. ch immediately followed c , and ll immediately followed l. Adding the letter ñ, which follows n in Spanish, the order was then: a, b, c, ch, d, e, f, g, h, i, j, k, l, ll, m, ...
stackexchange_codegolf
Given a string of N, S, E and W, output a bearing (angle clockwise from North in degrees), correct to 5 decimal places. In traditional compass notation, a string is made up of only 2 of these characters (like NNW or ESE). Here you must also accept strings that contain all 4 (like WNNNSE). Using only 2 symbols allows hu...
stackexchange_codegolf
This is a cops-and-robbers challenge, the robbers' 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: choose a programming language write two programs / functions, one th...
stackexchange_codegolf
Task Given is a square matrix of any dimension and any integer n. Output all possible matrices(without duplicates) by removing columns and rows from the input matrix such that the determinant of these new matrices is n. Rules Output should include original if determinant of original is n. Output should be all the chopp...
stackexchange_codegolf
On a recent episode of QI, the first 5 multiples of 142857 were described as anagrams of the original number. Of course, anyone with more than a passing knowledge of that number will know that those numbers are actually cyclic, not just anagrams. But that got me thinking. Please write a program or function that outputs...
stackexchange_codegolf
As in this challenge, the task is to generate the vertices of a polyhedron. The polyhedron here is the one obtained by dividing a regular icosahedron's triangular faces into smaller triangles so that each edge is divided into \$b\$ segments (denoted \$\{3,5+\}_{b,0}\$ here) and projecting onto the unit sphere. Your pro...
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
Let's say I'm ten steps away from my destination. I walk there following the old saying, "Two steps forward and one step back". I take two steps forward, one back, until I'm standing exactly on my destination. (This might involve stepping past my destination, and returning to it). How many steps did I walk? Of course, ...
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
A half cardinal cyclic quine is a cyclic quine with two states, one perpendicular to the other. Rules You can decide which rotation you want to implement, clockwise or counter-clockwise. Once rotated, any gaps in your code should be replaced with spaces to preserve the positioning. Your program must satisfy the communi...
stackexchange_codegolf
Inputs: current hour: from 0 to 23 (inclusive) delta of hours: [current hour] + [delta of hours] = withing the range of Integer Output: delta of days: the value which shows difference in days between day of current hour and day of sum [current hour] + [delta of hours] Scoring Answers will be scored in bytes with ...
stackexchange_codegolf
Background As you probably learned in biology class, DNA and RNA are composed of strands of nucleotides; each nucleotide consists of a chemical called a base together with a sugar and a phosphate group. The information stored in the DNA or RNA is coded as a sequence of bases. DNA uses the bases A, C, G, and T (standing...
stackexchange_codegolf
This is my first question in Code golf I found it in stack-overflow (originally in JavaScript however all languages are acceptable): Render on screen NxN (where N in range 1-16) grid where each cell have black boundary and red number inside - cells are numerated in hex starting from left-upper corner to bottom-right. E...
stackexchange_codegolf
Background Page 219 of A New Kind of Science (a book by Stephen Wolfram, the creator of Mathematica) shows an interesting 2D pattern generated by constraints. The relevant section in the book starts at page 210; you can browse other pages for more context. In short, the large binary image is the result generated by 12...
stackexchange_codegolf
Think of cleave as the conceptual inverse of map. If map applies a function to each number in a list... map([1, 2, 3], x -> x * 5) -> [5, 10, 15] then cleave applies each function in a list to a number. cleave(5, [x -> x * 2, x -> x - 1, x -> x * x]) -> [10, 4, 25] More formally, given: \$n\$, an integer, and \$L\$, a...
stackexchange_codegolf
Let us define a sequence. We will say that \$a(n)\$ is the smallest number, \$x\$, that has the following properties: \$x\$ and \$n\$ are co-prime (they share no factor) \$x\$ does not appear earlier in the sequence \$|n - x| > 1\$ Unlike most sequences the domain and range of our sequence are the integers greater t...
stackexchange_codegolf
Two lists A and B are congruent if they have the same length, and elements that compare equal in A compare equal in B. In other words, given any two valid indices x and y: If A[x] = A[y], then B[x] = B[y]. If A[x] != A[y], then B[x] != B[y]. For example, the lists [1, 2, 1, 4, 5] and [0, 1, 0, 2, 3] are congruent. Th...
stackexchange_codegolf
Given two strings \$A\$ and \$B\$ with edit (Levenshtein) distance \$x\$, find a third string with edit distance \$a\$ to \$A\$ and edit distance \$b\$ to \$B\$ so that \$a+b=x\$ and \$a=int(x/2)\$ (that is half of \$x\$ rounded down to the nearest integer). The input is the two strings \$A\$ and \$B\$ and their edit d...
stackexchange_codegolf
A pangram is a sentence or excerpt which contains all twenty-six letters of the alphabet, as is demonstrated in this code golf challenge. However, a pangrammatic window is a pangram in the form of some segment of text, which may end or begin halfway through a word, found somewhere within a larger work. These naturally ...
stackexchange_codegolf
Your task is to write a program that, on input n, outputs the minimal expression of each number 1 through n in order. The shortest program in bytes wins. A minimal expression combines 1's with addition and multiplication to result in the given number, using as few 1's as possible. For example, 23 is expressed as 23=((...
stackexchange_codegolf
A lot of PPCG users helped with the creation of this challenge, both in chat and the Sandbox, specifically Martin Ender, AdmBorkBork, Emigna and user202729 Our community has found it necessary to create a set of languages designed specifically for golfing, "golfing languages" as we call them. Such languages have evolve...
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
Introduction A disk is a linear container with blocks indexed 0 through size-1. A file is a named list of block indexes used by that file. An example filesystem is expressed like this: 15 ALPHA=3,5 BETA=11,10,7 "The disk has 15 blocks, the first block of file ALPHA is the disk block at index 3..." The disk map could b...
stackexchange_codegolf
Take the decimal number \$0.70710678\$. As a fraction, it'd be \$\frac{70710678}{100000000}\$, which simplifies to \$\frac{35355339}{50000000}\$. If you were to make the denominator \$1\$, the closest fraction is \$\frac{1}{1}\$. With \$2\$, it'd be \$\frac{1}{2}\$, and with \$3\$ it's \$\frac{2}{3}\$. Because \$0.\bar...
stackexchange_codegolf
SVG is an XML vector graphics markup language embeddable in web content. Your tips should be at least somewhat specific to SVG. Please post one tip per answer.
stackexchange_codegolf
Introduction Eisenstein integers are complex numbers of the form a+bω Where a,b are integers, and ω = e^(2πi/3) The Eisenstein integers form a triangular lattice in the complex plane: We say that an Eisenstein integer z=a+bω is prime if it cannot be written as the product of two non-unit (not 1,-1,ω,-ω,ω^2, or -ω^2) ...
stackexchange_codegolf
This is the cops' thread, the robbers' thread is here A polyglot is a program, that without modification, can run in multiple languages. Allowed languages Any language that was made before the challenge and isn't made for the purpose of the challenge, it is allowed, though discouraged, to use languages that are easy t...
stackexchange_codegolf
It's back to school season! So for a part-time job, you're helping out at the school's library. The problem is, the head librarian has never even heard the words "Dewey Decimal," let alone implemented that system. Instead, the sorting system in use has grown "organically" as the library has expanded... In an effort to ...
stackexchange_codegolf
Rosetta Stone Code Challenges are challenges where you must complete the task in as many languages as possible. The Challenge You will be given two numbers, n and s, in a list as input. The n will be a number you have to count up to. n will be any number from 2 to 10000. s will be the number you skip by when counting u...
stackexchange_codegolf
Overview Given a list of digits, find the fewest operations to make 100 Input A string of digits, which may or may not be in numerical order. The order of the digits cannot be changed, however plus (+) or minus (-) operators may be added between each so that the total sum is equal to 100. Output The number of operators...
stackexchange_codegolf
The partition function: In number theory, the partition function p(n) represents the number of possible partitions of a positive integer n into positive integers For instance, p(4) = 5 because the integer 4 has five possible partitions: 1 + 1 + 1 + 1 1 + 1 + 2 1 + 3 2 + 2 4 Your task: Accept an input (let's call i...
stackexchange_codegolf
Introduction A "lobster number", by my own designation, is a number that contains within itself all of its prime factors. The "lobster" description was inspired by the recent question "Speed of Lobsters". The basic idea is that each prime factor can be made by lobsters munching away digits of the number until you are...
stackexchange_codegolf
It's that time of year when many of us get our advent calendars! If you are unfamiliar with an advent calendar, these are special calendars used to count down advent in anticipation of Christmas. In my experience the doors are placed randomly, and part of the fun as a child was working out where tomorrow's door was! O...
stackexchange_codegolf
This task is rather simple, and makes use of three distinct "operator" characters. Your task is, given a simple sequence of letters, perform the following task to encode it using <,>,*. You may choose to use either upper or lowercase letters, you do not have to handle both. Cipher Explanation The cipher is simple, you...
stackexchange_codegolf
Challenge Build the Wheat Wizard's stove using 2-input NAND gates. The solution with the fewest NAND gates wins. Externally, it works in the following way: (the first line is added from the original spec for physical output) It has 10 levels, from 0 to 9. The display has 9 lights, and if the current level is L, exactl...
stackexchange_codegolf
In order to defend someone’s baffling decision, people often say that that person is going over everyone’s heads and playing “3-dimensional chess”. Now it’s your chance to play 3-dimensional chess! Rules There are many variants of 3D Chess, but for this challenge I’ve made up my own. My version is just like regular che...
stackexchange_codegolf
Assumption A cigarette can be made by combining four cigarette butts. Cigarette butts last infinitely until smoked. Explanation Say you have 31 butts. That means, you can make 7 cigarettes from 28 butts and have 3 left over. Now, these 7 cigarettes will yield 7 butts when you're done smoking them. That means you have 3...
stackexchange_codegolf
Your task is to create a program where if any one character is deleted, it will detect which character was deleted and then re-insert the deleted character in its own source file. For instance, if your program is RadiationHardened and it is modified to RadiaionHardened, then your program must output that the 5th byte (...
stackexchange_codegolf
It is known that any natural number can be decomposed into the sum of three triangular numbers (assuming 0 is triangular), according to Fermat's Polygonal Number Theorem. Your task is to come up with an algorithm of decomposing number into 3 triangular numbers that has the best asymptotic complexity. As an input you ar...
stackexchange_codegolf
Given a string, replace all left-double-quotes into two backticks and all right-double-quotes into two single-quotes. Left-quotes means the quotes that starts a quote. Right-quotes means the quotes that ends a quote. Quotes cannot be nested. You may assume that there are an even number of double-quotes in the string. E...
stackexchange_codegolf
The challenge given to me is comparatively easy, and specific to MySQL only. I'm given a table expressions which have mathematical calculations done by a kid. Basically, I've to select all the right calculations! The table have the following properties, a : an integer, the left operand. b : an integer, the right opera...
stackexchange_codegolf
(related: one, two, three) An acrostic is a style of poem/writing where the beginning character of each line, when read vertically, also produces a word or message. For example, Together Everyone Achieves More also spells out the word TEAM when the first column is read vertically. Acrostics are a subset of mesostics, ...
stackexchange_codegolf
Write shortest possible code that will return true if the two given integer values are equal or their sum or absolute difference is 5. Example test cases: 4 1 => True 10 10 => True 1 3 => False 6 2 => False 1 6 => True -256 -251 => True 6 1 => True -5 5 => False The shortest I could come up with in python2 is 56 chara...
stackexchange_codegolf
The goal of this challenge is to determine if a move is a legal English Checkers move. This challenge will use an 8x8 board. A moved piece should be treated as a man (not a king) that can only move diagonally forward. The board will have 0 or more black pieces and 1 or more white piece. One white piece will be current...
stackexchange_codegolf
Australians love public holidays, and drinking. Yesterday, the 26th January, was Australia day, which is a public holiday. I was glad to not be at work yesterday, and eager to know the next time I get a public holiday! Unfortunately, I had a bit too much to drink, and I'm not able to work it out for myself. Write a pro...
stackexchange_codegolf
Your task is to create a good multiplication table for others to use. Given an integer \$n\$, generate a multiplication table that displays products up to \$n×n\$. You should start with \$2×2\$ as 1 times any number is itself and that is reflected in the row/column indices. Scientific notation and floating-points are N...
stackexchange_codegolf
In Java/.NET/C/JavaScript/etc. you can use ternary-ifs to shorten if-statements. For example (in Java): // there is a String `s` and an int `i` if(i<0)s="Neg";else if(i>0)s="Pos";else s="Neut"; Can be shortened with a ternary-if to: s=i<0?"Neg":i>0?"Pos":"Neut"; Challenge: Input: A regular if-else (possible with nes...
stackexchange_codegolf
Mr Seckington is a mobile grocer. He drives his van door-to-door selling his produce all around the nearby villages. Mr Seckington needs a method to weigh the produce he is selling so he knows how much to charge his customers. Because space is at such a premium on his van, he uses an interesting sequence of weights ...
stackexchange_codegolf
Given a non-empty 2D array consisting of 0 and 1, find the number of squares whose 4 corners are all 1. The squares do not need to be "upright". All the rows are guaranteed to have the same length. Reasonable input/output methods are allowed. Testcases: 0001000 1000000 0000000 0000100 0100000 This returns 1. 10101 000...
stackexchange_codegolf
The Fibonacci sequence is a well know sequence in which each entry is the sum of the previous two and the first two entries are 1. If we take the modulo of each term by a constant the sequence will become periodic. For example if we took decided to compute the sequence mod 7 we would get the following: 1 1 2 3 5 1 6 ...
stackexchange_codegolf
Challenge Your goal is to write a function that puts quotes around a sequence of capital letters in a string. So some examples (everything on the left (before function) and right (after function) are STRINGS): Hello the name's John Cena -> "H"ello the name's "J"ohn "C"ena I got BIG OLD truck -> "I" got "BIG" "OLD" truc...
stackexchange_codegolf
I don't like typing, so I draw my mazes in a very simple format: # ##### # # # ### # # # # # # # # ##### # Isn't it a-maze-ing? Of course, I think all mazes should look 3d, similar but not he same as this challenge, for maximum a-maze-ingness, so I (grudgingly) manually updated the maze to look like this: +-----...
stackexchange_codegolf
Introduction Logic gates! Everyone knows them, everyone loves them (unless you're starting to learn them). Take two booleans, compare them, get a single boolean in return. AND, NAND, OR, NOR, XOR, XNOR. Fun! But, what if you only had the inputs and output, but not the operator? Challenge Given a three digit number, xy...
stackexchange_codegolf
This challenge is based on a video in which Andrew Huang discusses unusual time signatures... https://www.youtube.com/watch?v=JQk-1IXRfew In it, he advises that you can understand time signatures by dividing them into 3's and 2's. So you count to a small number a few times, instead of counting to a large number. Here's...
stackexchange_codegolf
Description : Given a string as input, check if it is a valid ordinal number in English or not. If it is valid return truthy value otherwise return falsy value. (Suggested by @Arnauld. Thanks . Also by @JoKing) For users who want to know about ordinal numbers go here : https://www.mathsisfun.com/numbers/cardinal-ordina...
stackexchange_codegolf
Note to Moderators and editors: This post's title is for effect and should not be changed. The misspelling is intentional and part of the challenge. Backstory The (stereo)typical bad SO question asks something along the lines of "plz send teh codez!" In other words, it asks someone to do the work for the asker and ...
stackexchange_codegolf
Consider a grid of NxN unique elements. Each element has a letter (from A to the Nth letter, inclusive) and a number (from 1 to N, inclusive). Hence, each number/letter pair is in the grid exactly once. Your job is to arrange a grid such that: Each row, column, and diagonal (including wrapping) contains each letter a...
stackexchange_codegolf
Given input of a positive integer n, write a program that completes the following process. Find the smallest positive integer greater than n that is a perfect square and is the concatenation of n and some other number. The order of the digits of n may not be changed. The number concatenated onto n to produce a perfect...
stackexchange_codegolf
We are doing a PCG challenge at work, and I'm submitting answers in C#. This is a modification of the "M'Kay" challenge. My solution has been deemed correct by the requirements, I'm just trying to shrink it further if possible. A filler word is an apparently meaningless word, phrase, or sound that marks a pause or h...
stackexchange_codegolf
Today your challenge is to produce all possible full parenthesizations of an expression. Your input is a single line of printable ASCII containing one or more terms separated by operators. The input might also contains spaces - you must ignore these. A term is [a-zA-Z0-9], an operator is [^ ()a-zA-Z0-9]. You may assume...
stackexchange_codegolf
The Challenge: Find if a number contains a digit. The number and the digit are to be taken as input. Output must be a boolean value. But you are not allowed to use the string representation of the number at any time. Now don't count upon a char* either. You must devise a mathematical way to do it. Rules: • You can't us...
stackexchange_codegolf
Your task is to create one brainfuck program for each of the following binary operators. Each program should take one or two 8-bit numbers (A and B) from input and calculate the specified operation: A XOR B A AND B A OR B A Shifted Left by 1 (circular shift) NOT A You do not have to implement all 5. Score is calculat...
stackexchange_codegolf
Take as input an integer in any reasonable format. Then, output all the proper sub-strings of the base-10 digits of that integer that are powers of two, in any reasonable format. Test cases 10230 -> [1, 2] 13248 -> [32, 1, 2, 4, 8] 333 -> [] 331 -> [1] 32 -> [2] # As 32 is not a proper sub-string, since it is the whole...
stackexchange_codegolf
Your task here is simple: Given a list of integer sets, find the set union. In other words, find the shortest list of integer sets that contain all the elements in the original list of sets (but no other elements). For example: [1,5] and [3,9] becomes [1,9] as it contains all of the elements in both [1,5] and [3,9] [...
stackexchange_codegolf
Write the shortest possible program which takes a numeric input and outputs the result of adding 42 to the input. f(x) -> x + 42 There's only one restriction. Your program can only be composed of rod logic characters... The definition for a rod logic character is a one that is composed purely of straight lines. They ...
stackexchange_codegolf
Output # # # # # ##### ## # ## #### ####### # # ## #### ## ## # ### ####### # # # # ##### ### # # # # ### ##### ##### # ...
stackexchange_codegolf
Presumably everybody here knows that for the legacy BIOS, the tiniest bootable disk image is 512 bytes (the lower bound is due to the 2-byte magic at offset 510), and there is a bootsector demoscene where people try to fit the entire demo into the 510 bytes of usable space. Now that the BIOS is being superseded by UEFI...
stackexchange_codegolf
I found this YouTube video with a table on it showing some card suits with ampersands. You might not understand what it is about, but I still want to make a challenge about it. The input is two suits, being one of the following: heart diamond spade club You can do anything for any other input. Then the output is their...
stackexchange_codegolf
Goal In light of the World Series being around the corner, I need a program that can read the box scores and tell me what inning it is. This is complicated slightly because baseball uses an odd method to record the score. They don't write down the at-bat team's score for the inning until they've scored a run (and are s...
stackexchange_codegolf
I hope this picture looks familiar to you. It's one of Pacman's ghosts in his "vulnerable" state, after Pacman has eaten a power pill. The challenge Picture our ghost in a little frame, using ASCII art. At normal scale (more about this later), each square in the above image should correspond to one character, and the ...
stackexchange_codegolf
How many petals around the rose How many petals around the rose is a dice game you can play with your friends. Similar to "can I join the music box", there is a person that knows how the game works and the others have to discover the rule. In this game, someone rolls some dice (usually two or more) and then people have...
stackexchange_codegolf
Imagine we get a slice of some mountainous region, this would result in a shape similar to this: 4 _ 3 _ _ __/ \ 2 / \__/ \ _/ \_ / 1 / \ / \_/ 0 \/ 12322223210012233343221112 As we can see, we can represent this (to a certain degree) with a sequence o...
stackexchange_codegolf
Task Implement a kind of "some users are typing" system, which can be found in Discord and some other chat clients. If 1 user (say, Bubbler) is typing, output Bubbler is typing... If 2 users (say, Bubbler and user) are typing, output Bubbler and user are typing... If 3 or more users are typing (say, Bubbler, randomuse...
stackexchange_codegolf
This is a cops-and-robbers challenge based around defining languages and proving they are Turing complete. This is the cops' thread. The robbers' thread is here. Cops As a cop, you will prepare two things: A formal specification of a programming language, or other computational system. (Computational systems are defin...
stackexchange_codegolf
Today's Google doodle is about Celebrating 50 years of Kids Coding: The goal is program the path of a little bunny so that it can eat all the carrots. There are 4 types of blocks (see pictures below): From left to right: O("...", k) = orange piece: these are for loops which executes k times the program "...". G = g...
stackexchange_codegolf
The challenge is to make a program that sorts a list of words, only that the words need to be in the order of a random given alphabet. Your program will accept a string of comma-separated words and a new alphabet. Your program will output every word in the same way in the new sorted order. Example: Input: home,oval,cat...
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
Challenge Given two non negative integers a < b, output all countries, from the below Top 100 Countries, where area is between a and b: a<= area <= b. Example 147500,180000 --> uruguay, suriname, tunisia, bangladesh 1200000,1300000 --> peru, chad, niger, angola, mali, south africa 1234567,1256789 --> angola, mali T...
stackexchange_codegolf
It's almost Christmas, so Santa has to plan his route. You're helping him, for reasons unknown. Santa needs help planning the route and wants you to give him a solution, but since you're all ungrateful and unwilling to give to the man who has given you so much, so have decided to give him a program with as few bytes as...
stackexchange_codegolf
Introduction: Aaron is a young game developer. He recently joined the development team of a game where the players select their character from a predefined set, aka "heroes". Unfortunately, the names of the existing heroes are not evenly distributed throughout the alphabet. For example, there are 6 heroes that have a n...
stackexchange_codegolf
This challenge is inspired by a series of young children's books by Fiona Watt and Rachel Wells, which I've recently been enjoying with my daughter. In each book a mouse (illustrated, but not part of the text) complains that a succession of 5 things of the same type are not its thing. It then backs this up by declarin...
stackexchange_codegolf
We have a challenge to output your own score, but it seems like all the answers there just hardcode the output and that's boring1. So lets have a new challenge. Your program must output its own length in bytes followed by the string " bytes", but in order to prevent hardcoded solutions if we reduce its size by removi...
stackexchange_codegolf
On CodingGame, there is a Puzzle that ask to write words with ascii art. I solve the puzzle then tried to golf it. What improvement can I do on it? INPUT >>> 20 >>> 11 >>> MANHATTAN >>> .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------...
stackexchange_codegolf
Given an array of letters in the range 'a' to 'o', compute how to construct the array by successively inserting the letters in alphabetical order. You will always start the insertion with a base array of all the 'o's that are in the array to be reconstructed. Examples Let the input array be: ['o', 'b', 'o', 'b', 'a'] ...
stackexchange_codegolf
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. Oh no, Santa spilled wine all over his great book. Now most of the letters are illegible. How will Santa now know who is groovy and who is unspeakable? Challenge There was once a sequence of words, like this: groovy groovy groovy unspe...
stackexchange_codegolf
Inspired by wezl. Your challenge is to take words (sequences of [a-zA-Z]) and truncate them to length 3. For example, never gonna give you up would become nev gon giv you up. Words will not necessarly be delimited by spaces - for example, youtube.com/watch?v=dQw4w9WgXcQ will become you.com/wat?v=dQw4w9WgX. Input will b...
stackexchange_codegolf
Introduction Logic gates! Everyone knows them, everyone loves them (unless you're starting to learn them). Take two booleans, compare them, get a single boolean in return. AND, NAND, OR, NOR, XOR, XNOR. Fun! But, what if you only had the inputs and output, but not the operator? Challenge Given a three digit number, xy...
stackexchange_codegolf
Cosmic rays are bad for computers. They corrupt RAM, and that causes problems. Computer chips are shrinking, and that makes them more vulnerable to the cosmic rays. We will not give in to these high-energy particles. Turing-completeness shall live on! Task Your task is to write a Turing machine. But not just any Turing...
stackexchange_codegolf
On the TV cooking show Guy's Grocery Games, the chefs cannot begin shopping until Guy Fieri, the show's host, says "Three, two, one, go!" However, the words do not have to be all together. He often "hides" the words in things like this (based on a real example, but not quoting verbatim): There are three of you here; a...
stackexchange_codegolf
using Prefixed Length Code We are going to implement a compression of text (string, array/list of characters/bytes) by simple substitution of each character by a binary code, based on the frequency of that character in the text. The characters that occur more frequently will be replaced by shorter codes. The resulting ...
stackexchange_codegolf
You are in fact writing an interpreter for the language "Wrong keyboard position". You can pretend that you are not doing this and just follow the instructions below. I typr re;atively accuratrly, but so,etimes I made a whole nlock of text illegible by shifting a key right. So I need a program that corrects my text ba...
stackexchange_codegolf
Program Write a program to display repeating terms of a given sentence. Explanation The program must output the repeating terms of two or more letters from the given input (input is a sentence separated by spaces without any punctuation except the full-stop indicating the end.) Repeated terms may not span across or in...
stackexchange_codegolf
So, last week I posted a challenge to play Duck, Duck, Goose. This lead to a number of Minnesotans commenting about their regional 'Gray duck' variation. So here's the rules: Using this list of colours: Red Orange Yellow Green Blue Indigo Violet Gray Write a program to follow these rules: Select one of these colours,...
stackexchange_codegolf
Code Bots I hate private and protected variables. I just want to access anything and everything! If you are like me, then this challenge is for you! Write a bot that works together in harmony with other bots makes other bots do what you want. You are a programmer, and you know how things are supposed to work. Your j...
stackexchange_codegolf
Guidelines Task Given a DNA strand, return its RNA complement (per RNA transcription). Both DNA and RNA strands are a sequence of nucleotides. The four nucleotides found in DNA are adenine (A), cytosine (C), guanine (G) and thymine (T). The four nucleotides found in RNA are adenine (A), cytosine (C), guanine (G) and ur...
stackexchange_codegolf
Guidelines Task Given two notes, inputted as strings or lists/arrays, calculate how many semitones apart they are (inclusive of the notes themselves), outputting as a number. Explanation of a semitone: A semitone is one step up or down the keyboard. An example is C to C#. As you can see below the note C is on a white n...
stackexchange_codegolf
Inspired and looted from this dice challenge by Arnauld Input You are given a 5x1 or 1x5 (your choice) dice matrix which consist of binary 3x3 sub-matrices. Goal Given a valid dice matrix, you are to score it using the rules of 6,5,4 which are as follows: If the roll contains 6,5,4, add the other two dice together and...
stackexchange_codegolf
Intro Imagine a list of elements and their outcomes when some non-commutative function is applied to them. For example, we will use the elements Rock, Paper, and Scissors, the outcomes Win, Lose, and Tie, and an operator * such that X*Y = what would happen if you played X against Y As a list, you might write it this wa...
stackexchange_codegolf