instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
100 Prisoners and a light bulb You may have seen this puzzle over on the puzzles exchange or perhaps heard it somewhere else. If you are unfamiliar with this puzzle check out: 100 Prisoners and a Light bulb The gist of this puzzle is that there are 100 prisoners, each one is separated from one another and must go into...
stackexchange_codegolf
Back in 2018, there has been introduced new law in Poland to ban trading on sundays, but certain exceptions have been made (listed below). The task today is to determine, can one trade on the sunday provided by the user (according to these rules). Rules You can trade only if one of the following is satisfied: The day ...
stackexchange_codegolf
Aliens have arrived, and they aren't friendly. Turns out, they've been in the process of converting all matter in the universe into compute capability so they can have more fun in their VR simulations. Our solar system is the last bit of space they haven't converted yet, and they're about to remedy this oversight. Howe...
stackexchange_codegolf
Mr. Mackey is a South Park character well-known for adding "m'kay" in everything he says. Write a program or function that transforms a string of text into something Mr. Mackey would say. M'kay placement m'kay has a random 50% chance of being added after the punctuations ,, ., ? and !. If that is the case, it will be...
stackexchange_codegolf
As of 27/12/20, the challenge is over as no new answers were posted on the 26th. With an astounding 55 points (and 21 answers), the winner is pppery! A quick shout out to the top 5 scorers as well: 1st. pppery with 55 points across 21 answers 2nd. tsh with 50 points across 21 answers 3rd. SunnyMoon with 21 points acr...
stackexchange_codegolf
Given Color codes in CMYK, convert it to RGB value. Input: string of 4 integers(ranging from 0-100) separated by space 86 86 0 43 28 14 0 6 0 41 73 4 Output: #141592 #ABCDEF #F49043 Shortest code wins! HINT: For converting CMYK to RGB you may use formula such as: Red = 255 x (1 - Cyan/100) x (1 - Black/100) ...
stackexchange_codegolf
Background Minifiers are used, commonly, when serving JavaScript to your Web Browser. It is commonly used to reduce the number of bytes that have to be sent. Saving bandwidth is useful for obvious reasons. Some people use obfuscaters (that intentionally make code harder to read), I am not talking about those. We wil...
stackexchange_codegolf
Inspired/mostly copied but I don't think it's a dupe. Also Inspired. In this challenge, you will create polyglots that include all languages from previous answers, and another language which you won't share and others must guess. The first language prints 1, the second prints 2, etcetera. For example, if the first answ...
stackexchange_codegolf
Introduction Busy Beavers are programs (specifically Turing Machine programs) that aim to output the most ones as possible, while having the least states as possible and halting. Challenge Your challenge is to make a busy beaver, which outputs as many ones as possible, but also outputs a second busy beaver. That secon...
stackexchange_codegolf
Yes, really. Print it with a hardware printer to create a hard copy. Send the necessary commands/data to your printer such that the following text is printed on a piece of paper: Hello, World! You may use any local- or network-connected printer that is available to you. If your printer allows, you should use 8pt or...
stackexchange_codegolf
Program: To count the sum of all Unicode characters of a given input. (No need to display the output. The final answer can be calculated in any base no need to convert back to hexadecimal.) Test case : XyZ= 0058+0079+005A=012B Condition: If the program is inputted, then its output must be an integral multiple of 1729 (...
stackexchange_codegolf
Write a function or program that takes two words as input and outputs variants of the popular English tongue-twister "How much wood would a woodchuck chuck if a woodchuck could chuck wood?". The output will use the first word four times How much wood would a woodchuck chuck if a woodchuck could chuck wood? and the se...
stackexchange_codegolf
At time of writing, my reputation is \$16,256\$. As I noted in chat, Oh cool my rep is the concatenation of two powers of 2: 16,256 Or even the concatenation of a power of 2 and its square, which is much more interesting which then spawned a CMC about checking if a number has this property. Given an integer \$n > 0\...
stackexchange_codegolf
GPA Calculator (GPA = Grade Point Average) You are a stressed out college student during finals week. Instead of studying for your exams coming up, you decide it is best to determine what GPA you will have at the end of the semester. This way you have data to back up your decision of staying up all night to get that A ...
stackexchange_codegolf
Take a unit circle centered on the origin. In any two neighboring quadrants, mirror the curve of the circle across the lines connecting the circle's x and y intercepts. With the resulting shape, you can tile the plane: I made this image with the awesome 2D physics sandbox Algodoo! Write a program that outputs an image...
stackexchange_codegolf
Fast and Golfiest Robbers Thread Welcome to the first season of Fast and Golfiest, a cops-and-robbers challenge! I designed this challenge to encourage competitive coding for efficiency (fastest algorithm) to become more popular on the site. The rules are simple. The cops choose problems from LeetCode, a competitive co...
stackexchange_codegolf
A drug comes in 5mg, 2.5mg, and 1mg sized pills. The drug is taken once a day. The total daily dose will be only one of the following (all in mg): 1, 2, 3, ... 20, 22.5, 25, 27.5, 30, 32.5, 35, 37.5, 40, 42.5, 45, 47.5, 50 In words: any whole number less or equal to 20, then at 2.5mg increments up to 50. Your task is t...
stackexchange_codegolf
I want to write a function golf(C, A) that takes the height (C = 2*c) and the width (A = 2*a) of an oblate (left image) or prolate (right image) spheroid or a sphere as parameters and returns the volume V and the surface area S of the shape as tuple. The output must be rounded to two decimal places. All input and outp...
stackexchange_codegolf
Introduction Let's observe the following string: AABBCCDDEFFGG You can see that every letter has been duplicated, except for the letter E. That means that the letter E has been de-duplicated. So, the only thing we need to do here is to reverse that process, which gives us the following un-de-duplicated string: AABBCCD...
stackexchange_codegolf
This challenge is inspired by my earlier challenge "Create a program that prints the amount of characters it has, in words". This challenge's rules are simple: make a program that prints its character count, in words, which works in as many languages as possible. Each programming language the program works in must make...
stackexchange_codegolf
You want to create a square chessboard. Adjacent tiles must alternate black and white like a standard chessboard, and the bottom left corner can be either black or white. Your program will take in two positive integers, the number of black and the number of white tiles. These will always be less than 1024. You don't ha...
stackexchange_codegolf
Take a string as an input, and perform addition/subtraction of all the digits in the string and output the sum of those operations as the result. Rules The digits in the string are read from left to right If a digit (n) is odd, perform addition with the next digit (n + n1) If a digit (n) is even, perform subtraction ...
stackexchange_codegolf
Given an integer greater than 1, output the number of ways it can be expressed as the sum of one or more consecutive primes. Order of summands doesn't matter. A sum can consist of a single number (so the output for any prime will be at least 1.) This is code-golf. Standard rules apply. See this OEIS wiki for related i...
stackexchange_codegolf
Task Take in 3 inputs. The length of the wall, the height of the wall and the coverage of the paint. Output how many tins of paint are required. Output Since there's no way to purchase 1/3 tin of paint, you'll need to round the amount of paint tins up to the nearest integer. Assumptions/Stipulations Only 1 coat of pai...
stackexchange_codegolf
This challenge is very simple: Given an angle measure in degrees or radians (your choice), output the angle between 0 and 2π non-inclusive [0º, 360º) that is coterminal with it. Input A positive or negative angle measure. You can pick if you want to take it in degrees or in radians. Output The angle on [0, 2π) that ...
stackexchange_codegolf
What general tips do you have for golfing in ///? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to /// (e.g. "remove unnecessary whitespace" is not an answer). Tips for itflabtijtslwi and Lines are on-topic and valid here as well. Please post one tip per ...
stackexchange_codegolf
The task is to count the number of disjoint 11 blocks in a 64-bit word, using the minimum number of straight-line instructions. That is, how many nonoverlapping neighbored pairs of 1-bits can be found. Examples (imagine leading zeros to fill up to 64 bits) Input Output 111111 3 1110111 2 111100...
stackexchange_codegolf
The challenge here is to take a string and output all its rotations, by repeatedly moving the first character to the end, once per character in the string, ending with the original string: john -> ohnj, hnjo, njoh, john You may also cycle in the other direction, moving characters from the end: john -> njoh, hnjo, ohnj...
stackexchange_codegolf
Sliding doors have varying prices based on the width of the doors. The different prices are as follows: 60 - 80 cm: ¤150 81 - 100 cm: ¤200 101 - 120 cm: ¤220 When buying a closet you would obviously want to minimize the cost, so your task is to find the width of the doors that minimizes the total cost based on the...
stackexchange_codegolf
Do randomly generated drum loops sound good? A drum loop is a \$5\times 32\$ matrix \$A\$ of \$1\$s and \$0\$s such that \$A_{1,1}=A_{1,17}=A_{2,9}=A_{2,25}=1\$, for each \$i\$, the \$i\$th row has exactly \$f(i)\$ different \$1\$s, where \$ f(1)=3, f(2)=2, f(3)=6, f(4)=8, f(5)=5\$, for each \$j\equiv 1\bmod 4\$, the ...
stackexchange_codegolf
Warning: This challenge is only valid for languages with a compiler. Make a program (which is perfectly valid code) that outputs Hello, World, even before runtime. How? Let me explain. Many languages have a compiler. Some operations are made in the compile-time, and others, in runtime. You trick the compiler to outpu...
stackexchange_codegolf
Last Thursday user @SpookyGengar delighted us with his/her first challenge about Making Squared Words. What if we double the number of sides? The challenge Take a string as input in any reasonable format you need (string, char array...) and output an octogonal representation of the input (also in any reasonable format:...
stackexchange_codegolf
Too bad! I had such a beautiful equation, but I lost all my =+-*, so there is nothing left but a chain of digits, looking like a number: 7512. But was it 7+5=12 or 7-5=1*2 or 7=5*1+2 or 7=5+1*2? Or are there even more valid possibilities? Your task: For a given positive integer number, return the number of true equatio...
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
Ask questions if you need to, I'll elaborate on anything that needs clarified. My challenge is to unsolve a sudoku to a minimal state. Basically take a supplied, solved, sudoku board and unsolve it as far as possible while keeping the solution unique. I'll leave input up to you, I don't like forcing anything which woul...
stackexchange_codegolf
Triangularity is a new esolang developed by Mr. Xcoder where code structure has to follow a very specific pattern: For the nth line of code, there must be exactly 2n-1 characters of the program on it. This causes a triangular/pyramid shape, with the first line having only one character and the rest increasing by inc...
stackexchange_codegolf
Given a string, shuffle it so that it becomes a palindrome. For example, adadbcc can be arranged into dacbcad, or dcabacd, acdbdca and more. Any of these (or all) is acceptable, and duplicates are allowed if outputting all. Something like abc cannot be shuffled into a palindrome, and you can assume it won't be inputted...
stackexchange_codegolf
Suppose a codegolf challenge doesn't count whitespace in the length of your program. Cheat this system by encoding your script into whitespace, and golf a script which decodes and executes embedded whitespace. Example My solution to JBernardo's Meta Golf Challenge was to encode Sage (or Python) code into whitespace, a...
stackexchange_codegolf
This is an answer-chaining post, so in this challenge every answer (except the first answer) depends on the previous answer. The goal of this challenge is to output the restricted characters. The restricted characters are the most common n - 1 characters of all answers, if happens to be a tie, then the characters with ...
stackexchange_codegolf
Given a positive number \$n\$ we call another (not same as n) positive number \$m\$ good if we insert same digits in both n and m and the resulting fractional value is same. $$m/n = m_{\text{transformed}}/n_{\text{transformed}}$$ $$or$$ $$m*n_{\text{transformed}} = m_{\text{transformed}}*n$$ Clarifications: No leading...
stackexchange_codegolf
This is the cop's thread. The robber's thread is here. Write a code that takes an input n and creates a n-by-n "snake matrix". A snake matrix is a matrix that follows this pattern: 3-by-3: 1 2 3 6 5 4 7 8 9 and 4-by-4: 1 2 3 4 8 7 6 5 9 10 11 12 16 15 14 13 The exact output format is optiona...
stackexchange_codegolf
This challenge is one of the two challenges which were planned for Advent of Code Golf 2021, but didn't fit into the 25-day schedule. Related to AoC2020 Day 22, Part 2. Combat is a simple two-player card game played with a deck of cards. A unique positive integer is written on each card. The game proceeds as follows: ...
stackexchange_codegolf
Let's use augmented reality to hunt small creatures hidden in source-code. Write a quine program that outputs its own code source, except for 5 consecutive characters that will be modified and that will display a PCG-mon : (^_^) The 5 consecutive characters can be positioned anywhere in the source code (from position 0...
stackexchange_codegolf
Stolen from @Downgoat with permission The point of this challenge is to (not) settle the debate on the pronunciation of "gif". " The pronunciation of gif is debated and while it's supposed to be (and should be) pronounced jif, it's still commonly disputed. In this challenge you will be given a set of words that have ...
stackexchange_codegolf
Inspired by this chat message Your task will be to take a word and find the average position of its letters on the keyboard as a letter. Keyboard Layout Since layouts vary from keyboard to keyboard, we will be using a standard based of of my own keyboard in this question. The keyboard has 3 rows, the top row from lef...
stackexchange_codegolf
Given a constructible point \$(x, y) \in \mathbb R^2\$, output the steps required to construct \$(x, y)\$ Constructing a point Consider the following "construction" of a point \$(\alpha, \beta)\$ in the Cartesian plane: Begin with the points \$(0, 0)\$ and \$(1, 0)\$. Then, more points can be added by performing a fini...
stackexchange_codegolf
Input A nonnegative integer n, and a nonempty string s containing only alphanumeric characters and underscores _. The first character of s is not _. The underscores of s are interpreted as blank spaces that can be filled with other characters. We define an infinite sequence of "infinite strings" as follows. The string ...
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
Note: This is the cops' thread, where one should post the scrambled code. Here is the robbers' thread where the cracked source should be posted and linked to the cop's answer. Task: Write the shortest safe program which multiplies the square root of an integer n by the square of n This is cops-and-robbers, so the rule...
stackexchange_codegolf
This is a tips question for golfing in Python concerning the Evil Numbers question on Anarchy Golf. An number is evil if its binary expansion has an even number of 1's. The challenge is to print the first 400 evil numbers 0,3,5,...,795,797,798, one per line. The Python 2 submissions are led by llhuii with a 42-byte so...
stackexchange_codegolf
We all know what a quine is. A quine is a program which prints its own source code. And we also know about the printable ASCII characters. Well... this challenge mixes both. Your mission, should you accept it, is to create an index quine. An index quine is a non-empty program, composed only of the printable ASCII chara...
stackexchange_codegolf
Given a list of stack heights, calculate the number of ways those heights could have been arrived at by stacking blocks one at a time. Shortest code wins. Test cases: [2, 2] 6 [3,3,3] 1680 [1,5,9,1] 480480 [] 1 [10] 1 [2,2,2,10] 720720 Reference Python implementation: def stacking_count(stacks): if sum(stacks) ==...
stackexchange_codegolf
Consider a grid from \$(0,0)\$ in the bottom-left corner to \$(m,n)\$ in the top-right corner. You begin at \$(0,0)\$, and can only move in one of these three ways: Directly north \$(+0, +1)\$, Directly east \$(+1, +0)\$, or Directly north-east \$(+1, +1)\$ How many different paths are there from your start at \$(0,0...
stackexchange_codegolf
Introduction: I have loads of different ciphers stored in a document I once compiled as a kid, I picked a few of the ones I thought were best suitable for challenges (not too trivial, and not too hard) and transformed them into challenges. Most of them are still in the sandbox, and I'm not sure yet whether I'll post al...
stackexchange_codegolf
Challenge In this challenge, you have to fill an \$M\$ x \$N\$ rectangle grid with the most \$A\$ x \$B\$ rectangle pieces possible. Requirements: The sizes of the \$M\$ x \$N\$ rectangle grid is always bigger than the sizes of the \$A\$ x \$B\$ rectangle pieces. In other words, \$min(M, N) ≥ max(A, B)\$ You can freel...
stackexchange_codegolf
A traveler needs to stay for n days in a hotel outside town. He is out of cash and his credit card is expired. But he has a gold chain with n links. The rule in this hotel is that residents should pay their rent every morning. The traveler comes to an agreement with the manager to pay one link of the golden chain for e...
stackexchange_codegolf
Print or return the following string: zottffssentettffssenttttttttttttttttttttffffffffffffffffffffsssssssssssssssssssseeeeeeeeeennnnnnnnnno This is the first letter of each of the numbers zero, one, two, all the way up to one hundred. Standard I/O rules apply, but the output must be exactly as shown above, optionally ...
stackexchange_codegolf
Simple challenge: given a series of positive integer numbers, find the number that contains among its digits the longest run of consecutive digits. The trick? It's allowed for the digits in the runs to wrap around the possible values (0123456789) and to run backwards. So both 2345, 89012 and 5432109 are valid runs of c...
stackexchange_codegolf
NOTE: Some terminology used in this challenge is fake. For two integers n and k both greater than or equal to 2 with n > k, n is semidivisible by k if and only if n/k = r/10 for some integer r. However, n may not be divisible by k. Put more simply, the base 10 representation of n/k has exactly one digit after the decim...
stackexchange_codegolf
Imagine you have a positive integer number \$n\$. Let \$m\$ be the number obtained by reversing \$n\$'s digits. If \$m\$ is a whole multiple of \$n\$, then \$n\$ is said to be a reverse divisible number. If neither are a palindrome, \$m\$ is called a palintiple. For example, \$1089 \cdot 9 = 9801\$, so \$9801\$ is a pa...
stackexchange_codegolf
Inspired in part by this Mathologer video on gorgeous visual "shrink" proofs, and my general interest in the topic, this challenge will have you count regular polygons with integer coordinates in 3D. You'll be provided an input n, which is a non-negative integer. Your program should find the number of subsets of \$\{0,...
stackexchange_codegolf
As a programmer you certainly know the error of a stack overflow due to an obvious recursion. But there are certainly many weird and unusual ways to get your favourite language to spit that error out. Objectives: Must cause a stack overflow which is clearly visible on the error output. Not allowed to use an obvious ...
stackexchange_codegolf
Given π to an arbitrary number of places, your challenge is to locate indices of π where the index (1,2,3,4...) and the string of numbers from that index carry the same value for the length of the index. That sounds complex, so let's look at an example! Indices will count from +1 upwards through natural whole integers,...
stackexchange_codegolf
Not exactly sure if it belongs in this site, but I always have trouble thinking of all the certain edge cases in any kind of competitive programming or puzzles. For example, take this kind of problem Find the size of the smallest list of squares that add up to n f(16)-> 1 (16) f(17)-> 2 (16+1) One intuitive approach ...
stackexchange_codegolf
Problem: We have a two dimensional matrix of positive integer cells. On each turn any non-zero cell with a neighbor (top/bottom/left/right) of zero decreases by 1. We want count to the number of non-zero cells present and add them up across all turns. Is there a faster solution than to use a priority queue? Is there a...
stackexchange_codegolf
All the quine challenges on this site are focused on byte count, or the characters themselves. This one is different. Your challenge is to write a program that produces output which has a code point sum identical to the source's code point sum. To produce a code point sum: Find the values of the characters in the prog...
stackexchange_codegolf
Imagine travelling to a point lying A miles away horizontally and B miles away vertically from your current position. Or in other words, travelling from (0, 0) to point (a, b). How far would you need to end up travelling? This seems like a straightforward question, but the answer depends on who you ask. If you're a cro...
stackexchange_codegolf
Over is a higher-order function in multiple languages such as APL (⍥). It takes 2 functions and 2 values as arguments, applies the first function to both values, then applies the second to their result. For example, using ⍥ to represent Over: 1 ²⍥+ 2 We would first calculate ² of each argument: 1² = 1 and 2² = 4. We t...
stackexchange_codegolf
Your challenge is to parse nonsensical text and output a "congruous phrase" - which I shall define here to be text with any contiguous characters in between, and including, a given set of like symbols removed. The given set of like symbols (ignore all brackets and commas here, they're only for notation) are: {(< >), (^...
stackexchange_codegolf
The challenge Given two strings, each of length up to 30, consisting of printable ASCII characters (codes \$[32, 126]\$), put them onto a balance scale in the fewest bytes of code! This consists of the following steps: Calculate and compare the weights of the strings Choose the appropriately tilted ASCII-art scale Pla...
stackexchange_codegolf
Print integers 0 to 100 (inclusive) without using characters 123456789 in your code. Separator of numbers can be comma or white space (by default <blank>, <horizontal tabulator>, <newline>, <carriage return>, <form feed> or <vertical tabulator>). Shortest code wins.
stackexchange_codegolf
In set theory, a set is an unordered group of unique elements. A pure set is either the empty set \$\{\}\$ or a set containing only pure sets, like \$\{\{\},\{\{\}\}\}\$. Your challenge is to write a program that enumerates all pure sets, in some order of your choice. Standard sequence rules apply - you may: Output al...
stackexchange_codegolf
This is the robbers' thread for 'Almost Illegal Strings'. See the cop's thread for information on participating. A section from the post is included here for convenience. The Robbers' Challenge Find an uncracked answer. Write a program in the language specified that contains as a contiguous substring the almost illega...
stackexchange_codegolf
Modern regular expressions (regexes) have many features (\d, {n,m}, \1, etc.), but to define a regular language (modern regexes can define broader classes of languages, in their defense), all you need are three operators: concatenation (+), union (|), and the Kleene star (*). Here are some examples: a - Matches the str...
stackexchange_codegolf
Background Wuxings(五行) are the five "elements" in Chinese philosophy. They are Fire(火), Water(水), Wood(木), Metal(金), and Soil(土). You can find them on East Asian calendar, where some days (Tuesday through Saturday) are named by the Wuxings. Some Korean names are given according to Wuxings, so that father's name will ha...
stackexchange_codegolf
Task Your task is to make the smallest function/program that can, when gives an number N, return/print: the number of possible choices a, b such that \$1 \leq a < b < N\$ and a and b have exactly one common digit in base 10 (there exists a digit, and only one digit, which appears both in a and b, for example 12 and 23,...
stackexchange_codegolf
Your challenge is to print/output/return this text: _____ _____ | 1 | | 2 | | H | ...
stackexchange_codegolf
Context If a0 and b0 are two decimal numbers, with a and b representing the decimal expansion of all digits but the least significant one, then we know that $$\frac{a0}{b0} = \frac{a{\not\mathrel0}}{b{\not\mathrel0}}= \frac{a}{b}$$ Phony fraction A phony fraction is a fraction where the numerator and denominator share ...
stackexchange_codegolf
Given 3 bytes or RGB as input, calculate the nearest CMYK values, and output them. create either a function with parameters and return value or a program that operates on stdin/stdout use the color profile of your choice, but provide a reference input may be either separate numeric values in range [0;255] or a 6 digit...
stackexchange_codegolf
Curry is the Language of the Month this month and some users are starting to get into it, so let's get some tips together. Haskell and Curry are similar in a lot of ways and a lot of tips for Haskell work well in Curry and vice versa. So I'd like in this question to gather tips for code-golf in Curry, that would be use...
stackexchange_codegolf
Your task is to output a single number; the number of ISO weeks that a given date range intersects. To quote Wikipedia: An average year is exactly 52.1775 weeks long, but this is not about the average. Input consists of two space-separated ISO dates: 0047-12-24 2013-06-01 The end date is never before the start date. W...
stackexchange_codegolf
Your input is a list/sequence/vector/array of 5-255 positive integers, not necessarily unique. You may assume whatever input format is most suitable, and that each integer (as well as the quantity of integers) is chosen uniformly at random from the range 5-255. The goal is to output the same list, in the same (or equi...
stackexchange_codegolf
Backstory If you visit the Steward Badge Page, you will see no one has received one of these badges from PPCG yet. However, there are two users: DJMcMayhem & Martin Ender, that are only a few reviews away from this badge! Challenge Your challenge is to write a program or function that when run outputs DJMcMayhem's revi...
stackexchange_codegolf
A stochastic matrix is a matrix of probabilities used in the context of Markov chains. A right stochastic matrix is a matrix where each row sums to 1. A left stochastic matrix is a matrix where each column sums to 1. A doubly stochastic matrix is a matrix where each row and each column sums to 1. In this challenge, we ...
stackexchange_codegolf
In this challenge, all bots are wizards. At the beginning of each round, they create a wand which has a certain chance of successfully stunning another wizard. They then fight, by choosing one bot to attack in each turn. The last bot remaining wins. Results 500 games, 1000 rounds each Revenge!: 132101.68886125216 JustE...
stackexchange_codegolf
Consider an eight bit number in which an even position bit will never be 1 if one of its neighbors is 0 (considering MSB and LSB as neighbors). There are fewer than 64 such numbers, so there is at least some reversible mapping of them to 6 bit numbers. Your task is to write a pair of functions (or code blocks or your l...
stackexchange_codegolf
Task Write a function/full program that will be able to produce two different sequences of integers in [0, ..., 9]. You will take an input seed to decide whether to output your specific sequence or the common one. For that matter, you must choose one non-negative integer, let us call it k. When the input seed is equal ...
stackexchange_codegolf
This is a follow up of Print a maze question. If you like this question, please add more maze generation algorithms ;). For this task you'll have to implement a game engine for one player who must find the treasure in a maze and get out of the dungeon. The engine starts by reading the maze from standard input followed ...
stackexchange_codegolf
How many ways can one place (unlabelled) dominoes on a square chequerboard such that the number placed horizontally is equal to the number placed vertically? The dominoes must align with, and may not protrude, the chequerboard and may not overlap. This is OEIS sequence A330658, 1, 1, 1, 23, 1608, 371500, 328956227, 112...
stackexchange_codegolf
This is the robbers' thread. See the cops' thread here. In this cops and robbers challenge, the cops will be tasked with writing an algorithm that computes some function of their choice, while the robbers will try to come up with their algorithm. The catch is, the 'algorithm' must be a single closed-form mathematical e...
stackexchange_codegolf
This challenge is very simple. You are given as input a square matrix, represented in any sane way, and you have to output the dot product of the diagonals of the matrix. The diagonals in specific are the diagonal running from top-left to bottom-right and from top-right to bottom-left. Test Cases [[-1, 1], [-2, 1]] ->...
stackexchange_codegolf
Background We already have a challenge about throwing SIGSEGV, so why not a challenge about throwing SIGILL? What is SIGILL? SIGILL is the signal for an illegal instruction at the processor, which happens very rarely. The default action after receiving SIGILL is terminating the program and writing a core dump. The sign...
stackexchange_codegolf
In Applied Cryptography by Bruce Schneier (which I have been reading quite a lot recently), a protocol for splitting secrets is discussed. Here is a brief description: Trent generates a random byte string, R, the same length as the message, M. Trent XORS M with R to make S. He gives R to Alice and S to Bob. Your ...
stackexchange_codegolf
Bitshift Variations in C Minor by Robert Miles is a Code Golf music piece written in C (with some additional bash commands). It was originally presented in a 2016 Computerphile video Code Golf & the Bitshift Variations. You can listen to clean renderings of it here (by Lucia Ceionia). The original 2016 source code pres...
stackexchange_codegolf
(FB, or Functional-Basic, as found here Interpret Functional-Basic) Task Implement a linting program for FB, similar to JSLint for JavaScript. Error types Invalid identifier Identifiers can only have upper and lower case ASCII letters. Locations: The identifier right after a let expression The identifier in a for loo...
stackexchange_codegolf
Disclaimer: The story told within this question is entirely fictional, and invented solely for the purpose of providing an intro. My boss has gotten a new toy robot, and he wants me to help program it. He wants to be able to enter simple arrow instructions to get it to move. These instructions are: ^ (for move fo...
stackexchange_codegolf
Write a program to draw a 2-D diagram of a knot based on the knot's structure. A knot is exactly what it sounds like: a loop of rope that's tied up. In mathematics, a knot diagram shows where a piece of rope crosses over or under itself to form the knot. Some example knot diagrams are shown below: There's a break in t...
stackexchange_codegolf
As many of you will know, almost every programming language has a standard casing system; unfortunately, we have not been able to agree on a singular system to use and now must frequently switch between camelCase, snake_case, PascalCase and kebab-case. Now I know what you're thinking... wouldn't it be nice if we had a ...
stackexchange_codegolf
Challenge This challenge is pretty simple: Output the total number of possible Tweets. Given the fact that \$1{,}114{,}112\$ Unicode characters exist, and Tweets can be up to \$280\$ characters long, we calculate this number like so: $$\sum_{l=1}^{280}1{,}114{,}112^l$$ Calculated, this number becomes: 13806352273767118...
stackexchange_codegolf
Given a string s, return the smallest contiguous substring you can remove to create a palindrome. Examples: 800233008 -> 2 racecarFOOL -> FOOL abcdedcba -> (empty string) ngryL Myrgn -> "L " (or " M") 123456789 -> 12345678 (or 23456789) aabcdbaa -> c (or d) [[]] -> [[ (or ]]) a -> (empty stri...
stackexchange_codegolf