instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
A binary multiple of a positive integer k is a positive integer n such that n is written only with 0s and 1s in base 10 and n is a multiple of k. For example, 111111 is a binary multiple of 3. It is easy to show that a positive integer has infinitely many binary multiples. See here for a construction proof of one binar...
stackexchange_codegolf
The aim of this post is to gather all the tips that can often be applied to radiation-hardening challenges. Please only post answers which can apply to a large number of languages, and one tip per answer.
stackexchange_codegolf
Given a list of production rules and start symbol of a proper finite context-free grammar (CFG) of printable characters, your program or function must output its formal language (the set of all sentences which can be constructed from it). Task A context-free grammar is formally defined as a 4-tuple of a few parts. Here...
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
This challenge is inspired by turn based videogames like "Heroes of Might and Magic" Implement this game mechanic: There is some units(Imps, Swordsmans etc...) in our game Every unit have an integer "initiative" Your program must decide which unit's turn now - based on unit's initiative The more initiative means mor...
stackexchange_codegolf
Your challenge: Write a function that takes a string s, a character c, and finds the length of the longest run of c in s. The length of the run will be l. Rules: If s is of length 0 or c is empty, l should be 0. If there are no instances of c in s, l should be 0. Standard loopholes and Standard I/O Rules apply. No mat...
stackexchange_codegolf
Your task is to write a program that calculates the amount of different ways to display any given whole positive number using the following rules: Meet the 'advanced binary system': Any whole positive number can be displayed in binary form, but each bit can have every number from 0 to 9. This means, a valid number migh...
stackexchange_codegolf
Challenge For any two non-empty strings A and B, we define the following sequence : F(0) = A F(1) = B F(n) = F(n-1) + F(n-2) Where + denotates the standard string concatenation. The sequence for strings "A" and "B" starts with the following terms: A, B, BA, BAB, BABBA, ... Create a function or program that, when given...
stackexchange_codegolf
The alternating factorial is an alternating sum of decreasing factorials. For example, we could calculate the alternating factorial of 4 as follows: First, calculate the factorials from 4 down to 1: $$ 4!\quad3!\quad2!\quad1!\quad = \\ 4\cdot3\cdot2\cdot1\qquad3\cdot2\cdot1\qquad2\cdot1\qquad1\quad= \\ 24\quad6\quad2...
stackexchange_codegolf
The set of ten numbers below: 223092870 17237308840522 1075474925835771 12574206406402195 79458974087499419 265057843710517649 466012798920390527 926434345611831877 1390237791335182649 2336970054109245767 has the property that no two pairs of numbers have the same greatest common factor. (In this case, the greatest co...
stackexchange_codegolf
Challenge : Count the number of ones 1 in the binary representation of all number between a range. Input : Two non-decimal positive integers Output : The sum of all the 1s in the range between the two numbers. Example : 4 , 7 ---> 8 4 = 100 (adds one) = 1 5 = 101 (adds two) = 3 6 = 110 (adds two) = 5...
stackexchange_codegolf
Given an integer n as input, write a function that dynamically allocates n bytes and returns their address. Rules The allocator must be able to dynamically allocate memory at runtime. It doesn't matter where the memory is allocated to or in what form, as long as it's allocated in a valid location which can be read fro...
stackexchange_codegolf
Introduction How to prove that 1 = 2: 1 = 2 2 = 4 (*2) -1 = 1 (-3) 1 = 1 (^2) You can just multiply both sides by 0, but that's cheating. This is just bending the rules a little bit. Your challenge: Write a program/function that, when given two integers, outputs a "proof" that the two are equal. Rules Your program's...
stackexchange_codegolf
SageMath is an open-source mathematics software system, built on Python 2. Its extensive math library support makes it a strong choice for golfing in math-based challenges. What tips do you have for golfing in SageMath? One tip per answer, please. Tips should be specifically for SageMath, and not general golfing tips (...
stackexchange_codegolf
Challenge Your challenge is to make a simple program that takes the [input] and formats it as "Hello, [input]!" Input Either a function call variable or STDIN, this is the name. Can contain any character, UTF-8, and can be empty - would result in Hello,!. Also newlines in the input are fine - On a new line -> Hello, O...
stackexchange_codegolf
A Hamiltonian path in a graph is a path that visits each vertex exactly once; a Hamiltonian cycle is a Hamiltonian path that is a cycle – the path forms a simple closed loop. In this challenge the graph will be a n x n grid, where n is an even number greater than 2. Here is an example of a Hamiltonian cycle on 12x12 re...
stackexchange_codegolf
You might already be familiar with the game: Basketball FRVR in facebook. There are two types of score you can make: A virgin-shot:(we call it so in our country :D) When the ball enters the basket without touching the rim or A stale shot: When the ball enters the basket, but after touching the rim. The game is over ...
stackexchange_codegolf
After all assignments are submitted, a dictionary is created that maps student number to the hash of their file. This dictionary, or hashmap, or mapping (whatever your language calls it) will look as follows: {100: "aabb", 104: "43a", 52: "00ab", 430: "aabb", 332: "43a"} The key is the student number, and the value is ...
stackexchange_codegolf
(This is a variation on Print a Negative of your Code, which I enjoyed a lot! Thanks to Martin Büttner♦ - almost all of this text is his.) Let's consider the symbols to be the following printable ASCII characters (note that space is included): !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ And the alphanumerics to be these: 012345...
stackexchange_codegolf
Your challenge is to compute the Lambert W function. \$W(x)\$ is defined to be the real value(s) \$y\$ such that $$y = W(x) \text{ if } x = ye^y$$ where \$e = 2.718281828...\$ is Euler's number. Sometimes, \$y\$ may not be real. Examples W(-1) = non-real W(-0.1) = -0.11183, -3.57715 W(1) = 0.56714 W(2) = 0.85261 Here'...
stackexchange_codegolf
Final Standings +----------------------------------+---------+---------+---------+----------------------------+ | Name | Score | WinRate | TieRate | Elimination Probability | +----------------------------------+---------+---------+---------+----------------------------+ | 1. SarcomaBo...
stackexchange_codegolf
Grid: +---------------+---------------+---------------+---------------+---------------+ | id: 20 | id: 19 | id: 18 | id: 17 | id: 16 | | pos: (-2, -2) | pos: (-1, -2) | pos: (0, -2) | pos: (1, -2) | pos: (2, -2) | +---------------+---------------+---------------+---------------+---...
stackexchange_codegolf
When given a a list of values and a positive integer n, your code should output the cartesian product of the list with itself n times. For example, in pseudocode your function could be similar to: for x1 in list: for x2 in list: for x3 in list: ... for xn in list: pri...
stackexchange_codegolf
In anticipation of MathJax being temporarily disabled, the rendered MathJax in this question has been replaced with images. You are still welcome to post answers but you'll have to view the rendered MathJax on another site. PPCG just got MathJax! This means we can now easily include well formatted mathematical formulas...
stackexchange_codegolf
In this quine variant, your program must output its source code transposed across the diagonal from the top left to the bottom right. For example: your program on four lines outputs yof ono u u r r      p l r i o n g e r s a m The whitespace in the output is not arbitrary. Spaces appear in two situations...
stackexchange_codegolf
Introduction For those not familiar with steam - or at least this particular aspect: Often on peoples' profiles, people leave comments saying either "+rep _____" or "-rep _____". These are an unofficial means of showing whether you think someone in the community has a good or a bad reputation, for a number of reasons. ...
stackexchange_codegolf
Challenge Implement the 1-indexed sequence A054049, which starts like this: 1, 2, 3, 6, 13, 5, 9, 377, 21, 11, 89, 14, 8, 233, 16, 987, 18, 2584, 20, 6765, 55, 23, 28657, 25, 75025, 27, 196418, 29, 514229, 31, 1346269, 33, 3524578, ... This sequence is the lexicographically smallest sequence of positive integers, so t...
stackexchange_codegolf
The text of the children's book Polar Bear, Polar Bear, What Do You Hear? has a very simple pattern. You might use the text to teach introductory programming concepts. My son was quickly bored by this idea, so I decided to play some golf with it instead. The Challenge In your programming language of choice, write the...
stackexchange_codegolf
Introduction My grandpa is a fan of James Bond, but he is always unsure on how to rank his favourite actors. As such, he is always making lists, which is a lot of work. He asked me to produce a program that will make his life easier, but I do not have time for that, I have to work! So I will count on you guys. Challeng...
stackexchange_codegolf
Write a program to calculate the first 500 digits of the mathematical constant e, meeting the rules below: It cannot include "e", "math.e" or similar e constants, nor may it call a library function to calculate e. It must execute in a reasonable time (under 1 minute) on a modern computer. The digits are to include the...
stackexchange_codegolf
Challenge Given two numbers, output their quotient. In other words, integer divide one number by another. Both divisor/dividend will be under 10001. Division must be performed using integer division, rounding down. Here are some example inputs and outputs: 5 1 5 -4 2 -2 4 -2 -2 6 ...
stackexchange_codegolf
Your challenge is simple. Write two programs that share no characters which output each other. Example Two programs P and Q are mutually exclusive quines if: P outputs Q Q outputs P There is no character c which belongs to both P and Q Each program P and Q are proper quines This counts empty quines and quines that re...
stackexchange_codegolf
Challenge Recognize ASCII art numbers. To make things interesting, three random points in the image might be flipped. For example: ***** * ** ** ** ** ** Input A 7x7 ASCII art number generated by the below Python script. Output A digit. Testing script Here's a Python script (2.6+) to generate...
stackexchange_codegolf
You find yourself in a strange place. A frighteningly dark maze, lit only by dim candles resting in the occasional hallway. Numerous paths lie only in impassable darkness, foreboding and-- ...Hm? What? Pick up a candle and carry it with you? No, no, that would be extremely rude. The Task Given a maze as input, output t...
stackexchange_codegolf
The Collatz Conjecture The famous Collatz Conjecture (which we will assume to be true for the challenge) defines a sequence for each natural number, and hypothesizes that every such sequence will ultimately reach 1. For a given starting number N, the following rules are repeatedly applied until the result is 1: While N...
stackexchange_codegolf
Write a function (or a whole program) that outputs (or prints) an ASCII art of the initial position of Mölkky pins. Output : __ __ __ __(07)__(09)__(08)__ (05)__(11)__(12)__(06) | (03)__(10)__(04) | | | (01) (02) | | |__| | | | | |__| |__| |__| |__| |__| |__| Rules : This is code-go...
stackexchange_codegolf
Introduction The game Minecraft has a 1 in 10000 chance of showing "Minceraft" instead of "Minecraft" on the title screen. Your challenge Your challenge is to code a function or program that takes no input, and on average 1 of 10000 times, returns "Minceraft" and the rest of the time returns "Minecraft". Scoring This i...
stackexchange_codegolf
Overview As most of y'all who visit chat know, I am Russian by ethnicity[citation not needed]. Recently, I switched from a keyboard that maps the letters 1-to-1 (mnemonic) to Windows' default mnemonic keyboard. Here are the letter mappings: "`" -> "ъ" "q" -> "я" "w" -> "ш" "e" -> "е" "r" -> "р" "t" -> "т" "u" -> "у" "i...
stackexchange_codegolf
Introduction There is a plantation defined by one big square-board like this one: The numbers inside each small square represents its area's value/cash/... The farmer needs help to find the N squares that connected (it means all N squares should have at least one shared border) give him the greatest value. For example...
stackexchange_codegolf
Note: This challenge is finished. Submissions are still welcome but can not win. This is the cops' thread. The robbers' thread goes here. Write a code that outputs the integer 1. If you add, remove or substitute a single character (of your choosing), the code should output the integer 2. Change one more character (th...
stackexchange_codegolf
This! is an RGB colour grid... Basically it's a 2-dimensional matrix in which: The first row, and the first column, are red. The second row, and the second column, are green. The third row, and the third column, are blue. Here are the colours described graphically, using the letters R, G, and B. Here's how we calcu...
stackexchange_codegolf
A biquadratic number is a number that is the fourth power of another integer, for example: 3^4 = 3*3*3*3 = 81 Given an integer as input, output the closest biquadratic number. Here are the first 15 double-squares: 1, 16, 81, 256, 625, 1296, 2401, 4096, 6561, 10000, 14641, 20736, 28561, 38416, 50625 This is code-golf s...
stackexchange_codegolf
The reason for this question is because I made a deadlineless bounty and I need a tips question to link in the bounty Vyxal 3 is the third major version of the Vyxal golfing language. As it is significantly different to Vyxal 2, the tips there don't apply. Therefore, what tips and tricks do you have for golfing in Vyxa...
stackexchange_codegolf
What is the Fibonacci Rectangular Prism Sequence? The Fibonacci Rectangular Prism Sequence is a sequence derived from the Fibonacci sequence starting with one. The first 3 numbers of the Fibonacci sequence (starting with one) are 1, 1, and 2, so the first number of the Fibonacci Rectangular Prism Sequence is the square...
stackexchange_codegolf
Although what is a Pascal's triangle is well-known and we already can generate it, the task is now different: Output \$n\$ first lines of the Pascal's triangle as colored bricks. Color number is computed as maximal power of \$d\$, that divides the needed-to-color element or \$7\$ if power is more than \$7\$. Numbered c...
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've been working on this iOS app recently and I encountered a (rather easily solved) problem: How do I determine if my string is comprised only of emojis? Well, that's your job today! Input A string. If the presence of unicode characters is problematic for you then you may use a different reasonable format. Please st...
stackexchange_codegolf
Given a list of positive integers determine if there is an element that is either greater than its two neighbors or less than its two neighbors (a "bump"). To be clear a bump can never be the first or last item of the list because they only have one neighbor. Your program should output one of two consistent values eac...
stackexchange_codegolf
For Gregorian calendars, the date format varies from a country to another. There are three main formats recognized: YY-MM-DD (big-endian) DD-MM-YY (little-endian) MM-DD-YY (middle-endian) Your task is to write a program which, given an input string representing a date, output all the possible date formats by which th...
stackexchange_codegolf
Write a function or program that outputs the number of each type of element (vertex, edge, face, etc.) of an N-dimensional hypercube. As an example, the 3 dimensional cube has 1 cell (i.e. 1 3-dimensional cube), 6 faces (i.e. 6 2-dimensional cubes), 12 edges (i.e. 12 2-dimensional cubes) and 8 vertices (i.e. 8 0-dimens...
stackexchange_codegolf
You're a chef and you love cooking with your spices, but recently you've taken a liking to organizing your spices based on how often you use them. But you have no time to be writing down when you used your spice last. Simply, you swap and move spices around, and this seems to do the trick. But of course you're a chef a...
stackexchange_codegolf
Your task is to make a program which interprets the language it is run in, but also works in many languages. Let's say you make a Brainfuck-Underload self-interpreglot, as it will be called. Run in Brainfuck, this program should be a Brainfuck interpreter; run in Underload, it should be a Underload interpreter. Your pr...
stackexchange_codegolf
This was related to a program I am writing. Although the title is simple, the challenge is a lot more complicated. Your challenge You must write a program that takes an input, and your answer must match the sample outputs in this question. What the program should be is that you must output "HelloWorld" with the length ...
stackexchange_codegolf
Given a pattern and a ragged list of positive integers, your task is to decide whether the pattern matches the ragged list. The pattern is also represented by a ragged list. But in addition to positive integers, it may contain a wildcard value. Here is the rule for matching: A positive integer matches the same positiv...
stackexchange_codegolf
Given a string that consists entirely of printable ASCII, convert all lowercase letters to their uppercase equivalent. Non-lowercase characters are left untouched. I am not going to outright ban builtin solutions, but if you are going to post a solution that uses the builtin, please also post one that doesn't in your a...
stackexchange_codegolf
For the purpose of this challenge, arguments are things you pass to a function at the call site, while parameters are what the function uses in its implementation. Or, more succinctly: arguments = external, parameters = internal. While there are several modern languages that have support for argument labels for func...
stackexchange_codegolf
Convert short date format into English long date in as few bytes as possible. Input Input will be in the form of a string with format, yyyy-mm-dd, with zero padding optional for all values. You can assume that this is syntactically correct, but not necessarily a valid date. Negative year values do not need to be suppor...
stackexchange_codegolf
Given a set of formulas like this: bacb bcab cbba abbc Give an algorithm that finds the number of unique results you can get when each variable is substituted for either "0" or "1" in every formula. There are (k!)^2 formulas, each with 2k-1 variables and k^2 terms. Express your asymptotics in terms of k. Fastest algor...
stackexchange_codegolf
You have to write a program, implementing a function digitsum(int i). The program has to modify its own code (for languages, where this is not possible with f.e. reflection, please be creative) to get itself to solve the goal. You start with function digitsum(int i){ return i; } and implement an evolutionary algo...
stackexchange_codegolf
Given a non‑empty string containing only printable ASCII (codepoints 0x20 to 0x7E), write the shortest program or function that swaps the cases of A-Z and a-z. If a character is in [A-Z], convert it to its lowercase version. If a character is in [a-z], convert it to its uppercase version. Otherwise, leave the characte...
stackexchange_codegolf
The alternating factorial is an alternating sum of decreasing factorials. For example, we could calculate the alternating factorial of 4 as follows: First, calculate the factorials from 4 down to 1: $$ 4!\quad3!\quad2!\quad1!\quad = \\ 4\cdot3\cdot2\cdot1\qquad3\cdot2\cdot1\qquad2\cdot1\qquad1\quad= \\ 24\quad6\quad2...
stackexchange_codegolf
Abracadabra is a magic word. To make it even more magical, let's make several alterations to how it may be written: Change the casing for any subset of characters; for example: aBrAcAdAbRa Append an exclamation mark to it: abracadabra! Change each occurrence of a into a different vowel: ybrycydybry Change any single c...
stackexchange_codegolf
Challenge Given daily arrival and departure times of every train that reaches a railway station, find the minimum number of platforms required for the railway station so that no train waits. In other words, find the maximal number of trains simultaneously present in the station. Input a pair of lists of times: arrival...
stackexchange_codegolf
Goal: create a self-referencing tuple satisfying x == (x,) in any version of Python. Standard libraries, matplotlib, numpy, pandas only. Answers meeting this extra condition are prioritised (which may be impossible): this tuple should also be insertable into a dict or set. If the extra condition is impossible, apart fr...
stackexchange_codegolf
Introduction Time is confusing. Sixty seconds to a minute, sixty minutes to an hour, twenty-four hours to a day (and not to mention that pesky am/pm!). There's no room for such silliness nowadays, so we've decided to adopt the only sensible alternative: decimal days! That is to say, each day is considered 1 whole unit,...
stackexchange_codegolf
Background Conway immobilizer problem is a puzzle that reads like the following: Three positions, "left," "middle," and "right," are marked on a table. Three cards, an ace, a king, and a queen, lie face up in some or all three of the positions. If more than one card occupies a given position then only the top ca...
stackexchange_codegolf
Your program should print the following: **Language, XXX bytes** ``` CODE ``` or its equivalent. XXX should be substituted by the actual number of bytes your program takes, and CODE should be substituted by the source code of your program. Language should be substituted by the actual language your program is in. Your...
stackexchange_codegolf
Introduction The game Minecraft has a 1 in 10000 chance of showing "Minceraft" instead of "Minecraft" on the title screen. Your challenge Your challenge is to code a function or program that takes no input, and on average 1 of 10000 times, returns "Minceraft" and the rest of the time returns "Minecraft". Scoring This i...
stackexchange_codegolf
The question: Given an a number n ≥ 2, how many distinct pairs of points on an n-dimensional n x n x n x n x n x n ... x n lattice, where the coordinates range from 0 to n - 1, are a distance at least n apart? The pairs {(2,1,3,1), (3,2,1,3)} and {(3,2,1,3), (2,1,3,1)} are not considered distinct from each other, as th...
stackexchange_codegolf
[ CODE GOLF] BAM! - Fire and Smoke Your Oscilloscope has exploded from one too many waves. Re-create these waves assuming the following: All waves are Sine Waves An amplitude of 1 spans 3 lines (Therefore and amplitude of 2 would span 5 lines) [Vertically] We want to see 100 characters worth of sine (Can be any ch...
stackexchange_codegolf
Related as it requires you to measure the time between the first and last input. But here you're required to count how many inputs in a period of time. I was assigned a task to stand by a gate and count how many students enter it. The problem is that my memory is not as good as it was when I first started this job. I...
stackexchange_codegolf
In this challenge, your task is to decipher a string. Luckily, the algorithm is pretty simple: reading from left to right, each encountered digit N (0 to 9) must be replaced with the character which is N+1 positions before it. Example The input string "Prog2am0in6" would be decoded this way: Hence, the expected output...
stackexchange_codegolf
Background MQTT (Message Queuing Telemetry Transport) is an ISO standard publish-subscribe-based messaging protocol (Wikipedia). Each message has a topic, such as the following examples: myhome/groundfloor/livingroom/temperature USA/California/San Francisco/Silicon Valley 5ff4a2ce-e485-40f4-826c-b1a5d81be9b6/status Ge...
stackexchange_codegolf
Background The greatest common divisor (gcd for short) is a convenient mathematical function, since it has many useful properties. One of them is Bézout's identity: if d = gcd(a, b), then there exist integers x and y such that d = x*a + y*b. In this challenge, your task is to visualize this property with simple ASCII a...
stackexchange_codegolf
Given string s of even length as input, randomly capitalize exactly half of the letters. You can assume the input will always be a non-zero, even length You can assume the input will consist of only lowercase letters ([a-z]) Exactly half of the letters should be capitalized in the output Every permutation that has exa...
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
Task Given a matrix, your program/function should output a row-equivalent matrix in checkerboard form ( \$A_{ij}=0\$ if and only if \$i+j\$ is odd). Two matrices are defined to be row-equivalent if and only if one can be obtained from the other by a sequence of elementary row operations (EROs), where each ERO consists ...
stackexchange_codegolf
This challenge is related to some of the MATL language's features, as part of the May 2018 Language of the Month event. Associated challenge: Function clipboard: paste. Introduction MATL has several clipboards, where you can store values (copy) to be retrieved later (paste). Some clipboards are automatic, which means...
stackexchange_codegolf
Let's try to golf this piece of ascii-art representing a golfing man: '\ . . |>18>> \ . ' . | O>> . 'o | \ . | /\ ....
stackexchange_codegolf
I'm trying to plug this really old phone into my computer but the phone seems to use a very obscure plug. Luckily I have some adapters. Unfortunately, I can't figure out which of them to use to connect my phone to my computer. Can you find the smallest number of adapters that can link my phone and computer? Input A pai...
stackexchange_codegolf
Challenge Taken with permission from my University Code Challenge Contest The dependence we have on mobile phones makes us charge them every night up to the maximum level of the battery, so we do not run the risk of running out of power by the middle of the next day. There are even people who, when they see a free out...
stackexchange_codegolf
Cops challenge The Robbers' Challenge Find a vulnerable answer. That is, an answer which hasn't been cracked yet and which isn't safe yet either. Crack it by figuring out its language. That is, find any language in which the given program is a valid program (subject to the rules outlined in the Cops' Challenge above)...
stackexchange_codegolf
EDIT: I'm getting a lot of comments about this not terminating - I will give the "correct answer" tag to either the first person who gives me FF(3) (as in provides it in their answer) or proves that FF(3) does indeed blow up indefinitely. Task: Your task is make the smallest program possible that generates the list of ...
stackexchange_codegolf
Write a program that outputs its input unchanged. However: If all uppercase characters are removed from the program, it lowercases all uppercase letters. If all lowercase characters are removed from the program, it uppercases all lowercase letters. Transforming characters beyond the basic Latin [A-Za-z] range is opti...
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
Challenge Write a complete program that prints out the time it took to execute a certain part of itself. That part must include a process whose total number of operations (and therefore execution time) is dependent on a user-substituted numeric value - this can be denoted in any way in your code (uppercase N for exampl...
stackexchange_codegolf
Task A theatre has 10 rows, labelled A to J from front to back, and 15 seats in each row, numbered 1 to 15 from left to right. The program uses the following rules to choose the best seats. Rule 1: All seats in one booking must be in the same row, next to each other. Rule 2: The seats must be as close to the front as...
stackexchange_codegolf
The goal of radiation hardening is to make a program still work after you remove a byte. However, what if a skilled competitor is purposefully trying to mess with you? In this game, each bot will take turns removing one character from the next bot down the line. If the bot fails to produce valid output next turn you ga...
stackexchange_codegolf
Specification For this challenge you will: Take an array of positive integers. For each overlapping pair in the array, calculate the difference of it's integers. If the difference is a common divisor of the integers (they are both divisible by their difference), swap their positions in the array. The values of the nex...
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
Given a sequence of integers and an integer N, output the number of contiguous subsequences that contain at least N distinct integers. Each integer in the sequence is non-negative and will not be larger than the size of the sequence. For example, with the sequence 1,2,2,3 and N=2, there are 5 contiguous subsequences t...
stackexchange_codegolf
The Mathematica SE question Creating the Yin Yang symbol with minimal code seems to be an out-of-the-box ready-to-go Code Golf SE question! The following code creates the Yin Yang symbol Graphics[{Black, Circle[{0, 0}, 1], White, DiskSegment[{0, 0}, 1, {1/2 \[Pi], 3/2 \[Pi]}], Black, DiskSegment[{0, 0}, 1, {3/...
stackexchange_codegolf
Given \$ i = \sqrt{-1} \$, a base-\$ (i - 1) \$ binary number \$ N \$ with \$ n \$ binary digits from \$ d_{0} \$ to \$ d_{n - 1} \$ satisfies the following equation. $$ N = d_{n - 1} (i - 1) ^ {n - 1} + d_{n - 2} (i - 1) ^ {n - 2} + \cdots + d_{1} (i - 1) + d_{0} $$ For example, a decimal number \$ 15 \$ is \$ 1000111...
stackexchange_codegolf
I honestly can't believe this challenge does not already exist. The challenge Write a function. The specifics Your program must define some sort of callable function. This includes anything commonly known as a function, a lambda function, or a subroutine. All of these types of callables will be referred to as a "funct...
stackexchange_codegolf
Task Your task is to write a program that will take input, and then output the lyrics to We Are Number One, changing specific words. The input will contain both the words to be changed, and the replacement word. Input The input will be in the following format: one, two\n net, villain\n (\n is a newline, it's not actua...
stackexchange_codegolf
Befunge Chess is an esolang mini-game I invented that is centered around the Befunge esolang. The general gist of the game is to make the instruction pointer land on a specific target cell while avoiding the opponent's target cell. Today's challenge isn't to play the game, but to simply execute arbitrary boards. The Ru...
stackexchange_codegolf
Given a number 1≤n≤365, output the nth day of the year in "Day-numberth Month" format. For example, given 1, you should output "1st January", without "of". The Gregorian calendar will be used and the program should not account for leap years, so your program should never output "29th February" in any circumstance. Any ...
stackexchange_codegolf
You are to print this exact text: A ABA ABCBA ABCDCBA ABCDEDCBA ABCDEFEDCBA ABCDEFGFEDCBA ABCDEFGHGFEDCBA ABCDEFGHIHGFEDCBA ABCDEFGHIJIHGFEDCBA ABCDEFGHIJKJIHGFEDCBA ABCDEFGHIJKLKJIHGFEDCBA ABCDEFGHIJKLMLKJIHGFEDCBA ABCDEFGHIJKLMNMLKJIHGFEDCBA ABCDEFGHIJKLMNONMLKJIHGFEDCBA ABCDEFGHIJKLMNOPONMLKJIHGFEDCBA ABCDEFGHIJKLMN...
stackexchange_codegolf
Given a 24 hour time, e.g. 20:48, output the nearest time where each adjacent pair of digits has an absolute difference of 1, e.g. 21:01. That is, each number in the output must differ from the numbers next to it by 1, and the output must be the closest time, forwards or backwards, for which this is true. Time can be c...
stackexchange_codegolf
Your program will receive an ascii shape consisting of only underscores _, pipes |, spaces and newlines \n, which, together, represent a horizontally-aligned, right-angled shape. Together with this shape, on a new line, you will also receive either a positive or a negative integer, whose absolute value will be either ...
stackexchange_codegolf