instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Introduction I have an even number of bottles, all of different sizes. Unfortunately, I only know the size of the smallest bottle: 300ml. I also know the following: Half of the bottles are twice the size of the other half, meaning that the smallest small bottle and the smallest large bottle are in a ratio of 2:1. The...
stackexchange_codegolf
The challenge is to parse a string like Python does and print the contents of the string. Input (command-line argument or stdin): a string literal (e.g. "hello") (or multiple literals, see string literal concatenation below) Output (stdout): the contents of the string (e.g. hello) Rules for parsing the string: A str...
stackexchange_codegolf
Background As far as we can tell from trying everything (besides cheating with ZWSPs), you can't type `\ in Stack Exchange chat. However, you can type \` by doing `\\``. So, if you want to tell someone in chat how to type backslash-backtick, you'd need to type out `\`\\`\`` to format `\\`` into a codeblock. Challenge Y...
stackexchange_codegolf
This is a Cops and Robbers challenge. For the Cops' thread, go here. The Cops have three tasks. 1) Pick a sequence from the OEIS. 2) Pick a language (this is suggested to be a golflang, but doesn't have to be) that, when given input n, outputs A(n) (where A(n) is the sequence chosen) using all usual code-golf rules. ...
stackexchange_codegolf
Input The first line will be a certain string repeated any amount of times. For example, it could be abcabcabcabc, [];[];[];, etc. It may be cut off; for example: 1231231231. Always find the shortest string; for example, if the line is 22222, then the string is 2, not 22 or 22222 or anything else. The string will alway...
stackexchange_codegolf
Introduction OnePlus is a Chinese smartphone manufacturer founded in December 2013. Their latest phone, OnePlus 5, was unveiled on June 20, 2017. I am sure you have seen that the name of the phone can easily be translated to a sum. OnePlus can be written like 1+ thus OnePlus 2 = (1+ 2) = 3 Input The name of one OnePlu...
stackexchange_codegolf
Challenge Create a 3D word puzzle where the cube's dimensions match the length of the input word. The uppercase word (A-Z) must be validly placed within the cube in one of the fixed orientations: horizontally, vertically, or diagonally. The program should randomly place the hidden word and fill the rest of the cube wit...
stackexchange_codegolf
ASCII reflections in a box You probably all know the Law of Reflection, in this challenge you'll visualize the trajectory of a ball in a box. Related: ASCII Ball in Box Animation and ASCII Doodling: Laser in a Box Task You're given three integer pairs W,H, x,y and dx,dy - the first represents the size of the box, the s...
stackexchange_codegolf
In physics, like electric charges repel, and unlike charges attract. The potential energy between two unit charges separated by a distance d is 1/d for like charges and -1/d for unlike charges. The potential energy of a system of charges is the sum of the potential energies between all pairs of charges. Challenge Deter...
stackexchange_codegolf
In the future when Time Travel (abbreviated as TT) will be common, coin tossing will become a serious mind-sport. To prepare for the future we create a competition for programs where time traveling will be really happening from the viewpoints of the entries. The competition is a round-robin style King of the Hill consi...
stackexchange_codegolf
Inspired by this glove-themed 538 Riddler Express Puzzle. Task You are given a positive integer n, and a list A = [a_1, a_2, ..., a_k] of k distinct positive integers. Then a restricted composition is an ordered list P = [p_1, p_2, ..., p_m] where each p_i is a (not necessarily distinct) member of A, and p_1 + p_2 + .....
stackexchange_codegolf
Challenge ¡We're going to give exclamation and question marks inverted buddies! Given a body of text containing sentences ending in ., ?, or !, prepend inverted question marks, ¿, to interrogative sentences (sentences ending in ?) and inverted exclamation marks, ¡, to exclamatory (sentences ending in !). Sentences endi...
stackexchange_codegolf
In a challenge of CodingGame, there is a challenge that ask you to decode a string composed by reversed words ('Hello world' > 'olleH dlrow') then each characters converted into ascii value separeted by space: >>> decode('111 108 108 101 72 32 100 108 114 111 119 32 41 58') Hello world :) The challenge is to be the fa...
stackexchange_codegolf
Your challenge is to output a Base64-encoded version of your source code, and optionally a line break. You must output the correct padding, if any. Standard quine rules apply, shortest answer wins. It must be a valid RFC 4648 encoded base64 string, with no linebreaks (except optionally a trailing newline). Test cases: ...
stackexchange_codegolf
Write a program in any language that takes a single natural number n as input and generates a Pyth program that, in turn, produces, using nested lists, the nested set given by S(n), where: S(0) = ∅ S(n+1) = S(n) ∪ {S(n)} S(n) giving the set representation of the corresponding ordinal number. Using the list representa...
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
Conway's Game of Life is a well known cellular automaton "played" on an infinite grid, filled with cells that are either alive or dead. Once given an initial state, the board evolves according to rules indefinitely. Those rules are: Any live cell with 2 or 3 living neighbours (the 8 cells immediately around it) lives ...
stackexchange_codegolf
The goal is simple, print out each day of the twelve days of Christmas, the text should match this exactly On the first day of Christmas my true love gave to me A partridge in a pear tree On the second day of Christmas my true love gave to me Two turtle doves, and A partridge in a pear tree On the third day of Christ...
stackexchange_codegolf
Input A string of text. Output The string of text, however, every consonant is the next consonant in the alphabet, and every vowel is the next vowel in the alphabet (z becomes b, u becomes a). The case of the new letter should be the same as the letter it is replacing (a becomes e, A becomes E). If there are two conson...
stackexchange_codegolf
Input is a single integer in ascending digit order. The only valid inputs are: 12 123 1234 12345 123456 1234567 12345678 123456789 The only valid output is an array (set; list) of length equal to the factorial of input: Input - Factorial of input - Output array length 12 -> 1*2 -> 2 123 -> 1*2*3 -> 6 1234 -> 1*2*3*4 ->...
stackexchange_codegolf
Challenge For each character of the string except for the last one, do the following: Output the current character. Followed by randomly outputting from the following list a random number of times between 1 - 5 (inclusive): The current character The next character of the string The switchcase version of the character...
stackexchange_codegolf
Here is the challenge as proposed by @trichoplax thanks to him for consolidating my post and standarizing it to PPCG common-rules. A galaxy is a group of numbers where each one is mapped to another via a precise function f either a symbolic one or mathematical, a structure of numbers sharing some common points with t...
stackexchange_codegolf
The Tabula Recta (sometimes called a 'Vigenere Table'), was created by Johannes Trithemius, and has been used in several ciphers, including all variants of Bellaso's Vigenere cipher and the Trithemius cipher. It looks like this: ABCDEFGHIJKLMNOPQRSTUVWXYZ BCDEFGHIJKLMNOPQRSTUVWXYZA CDEFGHIJKLMNOPQRSTUVWXYZAB DEFGHIJKLM...
stackexchange_codegolf
Getting hit in the knee with arrows seems to be the injury of choice right now. As such, I propose the following golf challenge. You have an adventurer that looks like this: O /|\ / | \ | | / \ / \ Given a text file that contains one bow (drawn as a } symbol), a set of walls (drawn as # symbols) and one adve...
stackexchange_codegolf
iBug recently got a long bar made of composite, yet valuable materials. The bar is so long that iBug can't easily sell it for credits, so he wants to cut it. The bar is made of such fragile and magic materials that, if a part is broken, all parts of the bar made of the same material will break, too, making it hard to c...
stackexchange_codegolf
Challenge You find yourself in a bash terminal, and want to do some simple tests on sqlite3. So you issue the following command: echo "CREATE TABLE T (id INT NON NULL PRIMARY KEY)" | sqlite3 test.db Now you want to insert the first N integers (starting from 0, excluding N) into the table T. For convenience, you execut...
stackexchange_codegolf
Scoreboard Here are the raw scores (i.e. domino counts) for VisualMelon's submission. I'll turn these into the normalised scores described below, when more answers come in. The existing solution can now solve all circuits in the benchmark: Author Circuit: 1 2 3 4 5 6 7 8 9 10 11 12 13 ...
stackexchange_codegolf
The Pi function is an extension of the factorial over the reals (or even complex numbers). For integers n, Π(n) = n!, but to get a definition over the reals we define it using an integral: In this challenge we will invert the Π function. Given a real number z ≥ 1, find positive x such that Π(x) = z. Your answer must b...
stackexchange_codegolf
Program your robots to deliver packages in a warehouse infested with destroyer drones. Avoid the drones and get your packages to the right place as fast as you can. Delivery Robots There are packages labeled a-z in a warehouse. Packages must be delivered to a matching chute A-Z. A robot cannot move to a square that co...
stackexchange_codegolf
Context At Hogwarts School of Witchcraft and Wizardry, students are sorted into 4 houses, Gryffindor, Ravenclaw, Slytherin and Hufflepuff. This sorting is done by a magical hat, called the Sorting Hat. Task Your task is to code a sorting hat. In other words, you should create some deterministic rule that, given the nam...
stackexchange_codegolf
Your goal is to output the strictly increasing sequence of consecutive, identical digits of pi (π). Each term in the sequence must be one digit longer than the previous. So 3 (0th digit of pi) is the first time a run of digits occurs (length 1). The next to occur is 33 (digits 24 and 25 of pi). Of course, this sequence...
stackexchange_codegolf
Write a program to generate a rectangular word-search of size 6x9. Words may go downwards, rightwards and diagonally (downwards and to the right), they may also overlap on the board. The challenge is to include as many different English words as possible from https://www.ef.co.uk/english-resources/english-vocabulary/to...
stackexchange_codegolf
The task is the following. Given an integer x (such that x modulo 100000000003 is not equal to 0) presented to your code in any way you find convenient, output another integer y < 100000000003 so that (x * y) mod 100000000003 = 1. You code must take less than 30 minutes to run on a standard desktop machine for any in...
stackexchange_codegolf
There already is a Brainfuck interpreter question, but it is from 2011 and not up to date with current site standards and vague in places. I have proposed reposting this in chat, and it was well-received. Here goes. Objective Given the Brainfuck code and the program's input as input, run the Brainfuck code. As there ar...
stackexchange_codegolf
In Magic: the Gathering, mages (known as "planeswalkers") battle each other by casting spells. Spells cost mana. Five colors of mana exist: White, Blue, Black, Red, and Green, represented as {W}, {U}, {B}, {R}, and {G}, respectively. A spell's cost is slightly more complex. The cost can be any combination of the follow...
stackexchange_codegolf
A Bit of Background The exterior algebra is a central object in topology and physics (for the physics concept cf. fermion). The basic rule dictating the behavior of the exterior algebra is that \$yx = -xy\$ (and consequently \$x^2 = -x^2 = 0\$). Applying this rule twice we see that \$yzx = -yxz = xyz\$. The product of...
stackexchange_codegolf
Traditionally when you compare two strings you use lexicographical comparison. That can be described by the recursive algorithm: $$ f(x, y)= \left\{\begin{array}[rr] \\ \mathrm{EQ} & \mathrm{if}\,\mid x\mid=0\,\mathrm{and}\,\mid y\mid=0 \\ \mathrm{GT} & \mathrm{if}\,\mid x\mid>0\,\mathrm{and}\,\mid y\mid=0 \\ \mathrm{L...
stackexchange_codegolf
I recently saw this question on stackoverflow. It's a great question, but there's one fatal problem with the question. They are asking for the best way to do it. E.g, easiest to read, most idiomatic, neatest etc. Don't they know that isn't what matters? You're supposed to ask about how to do it with the fewest bytes of...
stackexchange_codegolf
Blatant rip-off of a rip-off. Go upvote those! Your task, if you wish to accept it, is to write a program/function that outputs/returns its integer input/argument. The tricky part is that if I reverse your source code, the output must be the original integer negated. Examples Let's say your source code is ABC and its i...
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
Given a string and the characters used to encode it, you need to compress the string by only using as many bits as each character needs. You will return the character codes for each character needed to create a compressed string. For example, given the string "the fox" and the encoder characters " abcdefghijklmnopqrstu...
stackexchange_codegolf
Write code to evaluate whether a chain of inequalities is true or false. An example input is the string 3<=4!=9>3==3 This is true because each of its components is true: (3<=4) and (4!=9) and (9>3) and (3==3) Input: A string that represents a chain of one or more inequalities. The allowed comparison operators are == ...
stackexchange_codegolf
Background The newest version of the C standard, C23, adds preprocessor macros like INT_WIDTH, ULONG_WIDTH, and SIZE_WIDTH that tell you the bit width of various integer types (here, int, unsigned long, and size_t, respectively). However, while the majority of us are stuck with pre-C23 compilers/standard libraries, it...
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
The challenge is to calculate the digit sum of the factorial of a number. Example Input: 10 Output: 27 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800, and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27 You can expect the input to be an integer above 0. Output can be of any type, but the answer sh...
stackexchange_codegolf
Your task is to create a program that performs a bubble sort on a given array until it is sorted. Algorithm In order to qualify as a bubble sort, the program must operate as follows: Each pass goes through the array, looks at every two adjacent elements in turn, and potentially swaps them. Each pass goes through the ...
stackexchange_codegolf
In chess, Forsyth-Edwards Notation, more commonly called "FEN", is a textual way of transcribing boards. It describes each of the board's eight rows (called "ranks" in chess) from top to bottom from White's perspective. The pieces are written as K (king), Q (queen), R (rook), B (bishop), N (knight), and P (pawn). Black...
stackexchange_codegolf
A binary relation on a set \$X\$ is simply a subset \$S \subseteq X \times X\$; in other words, a relation is a collection of pairs \$(x,y)\$ such that both \$x\$ and \$y\$ are in \$X\$. The number of different relations grows quickly with the size of the set: if \$X\$ contains \$n\$ elements, there are \$2^{n^2}\$ bin...
stackexchange_codegolf
A person has to complete N units of work; the nature of work is the same. In order to get the hang of the work, he completes only one unit of work in the first day. He wishes to celebrate the completion of work, so he decides to complete one unit of work in the last day. He is only allowed to complete x, x+1 or x-1 uni...
stackexchange_codegolf
The aim is to create an algorithm to detect that one of the string in a small list of strings contains %s, %d, %f, or %r. All sub-string will start by '%' and be 2 characters longs. Input string will be from 1 to 500 characters with a median of around 20 characters and contain zero to multiple of the possible sub-stri...
stackexchange_codegolf
A number is whole if it is a non-negative integer with no decimal part. So 0 and 8 and 233494.0 are whole, while 1.1 and 0.001 and 233494.999 are not. Input A floating-point number in the default base/encoding of your language. For example, the default integer representation for Binary Lambda Calculus would be Churc...
stackexchange_codegolf
\$\left\{ n \atop k \right\}\$ or \$S(n, k)\$ is a way of referring to the Stirling numbers of the second kind, the number of ways to partition a set of \$n\$ items into \$k\$ non-empty subsets. For example, to partition \$\{1,2,3,4\}\$ into \$2\$ non-empty subsets, we have $$\begin{matrix} \{\{1\},\{2,3,4\}\} & \{\{2\...
stackexchange_codegolf
This is a simple challenge: given n in any way practical (Function arg, stdin, file, constant in code) output the internal angles (NOT the sum of the internal angles, just one) of a regular polygon with n sides. The output can be in degrees, gradians or radians, and can be displayed in any way practical (Function retu...
stackexchange_codegolf
So, there's a famous children's rhyme... This is the house that Jack built. This is the malt That lay in the house that Jack built. This is the rat That ate the malt That lay in the house that Jack built. This is the cat That killed the rat That ate the malt That lay in the house that Jack built. This is the do...
stackexchange_codegolf
A Quat is a combination of a quine and the popular esolang cat program. Challenge The challenge is to write a standard cat program. Whatever the user inputs, the program will echo the input to stdout. However, when the length of the input is greater than 0 and a multiple of 4, the program should output its own source c...
stackexchange_codegolf
Input A string S of length between 10 and 16 inclusive. The characters are taken from the 95 printable ASCII characters, byte values 32 (0x20) to 126 (0x7E) ( to ~) Output Your code must compute and output all strings within Levenshtein distance 2 of S. You can have duplicates as long as you also have all the differen...
stackexchange_codegolf
Santa's Shortest Path Problem Trying to be as time-efficient as possible Santa needs to plan his trips carefully. Given a 5X5 grid representing a map of villages it is your task to be Santa's flight controller. Show santa the shortest and therefor fastest route to fly his sleigh and give him a list of coördinates (or d...
stackexchange_codegolf
Write a program that outputs all possible Tic Tac Toe positions including the corresponding game outcome. Avoid duplicate output of equal positions. The program takes no input. Rules: A position output must consist of 9 characters, using X and O for the taken squares, and an arbitrary non-whitespace character for the ...
stackexchange_codegolf
In the video game Minecraft, the player can obtain experience points (XP) from various activities. In the game, these are provided as XP "orbs" of various sizes, each of which give the player various amounts of XP. The possible orbs are shown in the image below, along with the smallest and largest amount of XP that orb...
stackexchange_codegolf
This challenge will have give you a positive integer \$n\$ and ask you to output \$t(n)\$, the number of triangles (up to congruence) satisfying the three conditions: The triangles have perimeter of 1, the triangles have side lengths \$\displaystyle\frac{a_1}{b_1}, \frac{a_2}{b_2}\$, and \$\displaystyle\frac{a_3}{b_3}...
stackexchange_codegolf
I assume everyone here is familiar with the Caesar Cipher that shifts letters to a certain index. https://en.wikipedia.org/wiki/Caesar_cipher for those who still needs introduction. But, we can all agree that plain Caesar is unfun and way too easy. So here's a version that also shifts characters around. This version fi...
stackexchange_codegolf
Given a word, get the indexes of each letter in the alphabet. For example: uncopyrightable becomes: [21, 14, 3, 15, 16, 25, 18, 9, 7, 8, 20, 1, 2, 12, 5] Convert these indexes to the given numeral system. For example, if the radix is 36, then the array above would become: ['l', 'e', '3', 'f', 'g', 'p', 'i', '9', '7',...
stackexchange_codegolf
Your challenge is to print/output/return this text: _____ _____ | 1 | | 2 | | H | ...
stackexchange_codegolf
You have a line with two endpoints a and b (0 ≤ a < b) on a 1D space. When a or b has a fractional value, you want to round it to an integer. One way to do this is to round a and b each to its nearest integer, but this has a problem that the length of the rounded range (L) can vary while b - a stays the same. For examp...
stackexchange_codegolf
Challenge Given a positive integer \$n\$, count the number of \$n\times n\$ binary matrices (i.e. whose entries are \$0\$ or \$1\$) with exactly two \$1\$'s in each rows and two \$1\$'s in each column. Here are a few examples of valid matrices for \$n=4\$: 1100 1100 1100 1100 0011 01...
stackexchange_codegolf
The input message consists of ASCII characters The encoded output message consists of blocks of 0 A block is separated from another block by a space Two consecutive blocks are used to produce a series of same value bits (only 1s or 0s): After the ACSII character(s) have been converted to binary, go through the string: ...
stackexchange_codegolf
You are an employee at the hip new grocery store Half Foods, and it's the day before Thanksgiving Christmas Easter. Since the store will be packed with customers rushing to get their foodstuffs, the store needs a traffic manager to send everyone to the appropriate lines. Being lazy, you'd like to automate this so that ...
stackexchange_codegolf
The Challenge: Just as the title says, your challenge is to use the printable ASCII characters to create a program that prints out a random polygon in the terminal based on the number of sides, n provided by the user, where n is an integer in the range 3 -> 10 including 3 and 10, in as few bytes as possible. For exampl...
stackexchange_codegolf
UPDATE: Added a Python framework to get started. The space-station has been overtaken by crusher-bots. You must direct as many of our expensive and fragile tech-bots called "rabbits" to an exit teleporter before the station self-destructs, but the crusher-bots are patrolling the corridors. Your program is given an ASCI...
stackexchange_codegolf
If we take a positive integer \$n\$ and write out its factors. Someone can determine \$n\$ just from this list alone. In fact it is trivial to do this since the number is its own largest factor. However if we take \$n\$ and write only the first half of its factors (factors that are smaller than or equal to \$\sqrt{n}...
stackexchange_codegolf
My preferred way to approximate a derivative is the central difference, its more accurate than forward difference or backward difference, and I'm too lazy to go higher-order. But the central difference requires a data point on either side of point you are evaluating. Normally this means you end up not having a derivati...
stackexchange_codegolf
When you export data in JSON from Facebook, the multi-byte Unicode characters are broken. Example Unicode characters and their representation inside JSON: '\u00c2\u00b0' : '°', '\u00c3\u0081' : 'Á', '\u00c3\u00a1' : 'á', '\u00c3\u0089' : 'É', '\u00c3\u00a9' : 'é', '\u00c3\u00ad' : 'í', '\u00c3\u00ba' : 'ú', '\u00c3\u00...
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
Given a \$2\times N\$ maze, determine if you can get from the start top left corner to end bottom right corner using only up, down, left, and right moves. Input A \$2\times N\$ block (\$1 \le N \le 100\$) of your choice of two distinct characters, one representing walls and the other representing empty tiles that can b...
stackexchange_codegolf
Simple Mancala Game Create a mancala game using as few bytes as possible. The game Mancala is a family of games where a player has a control over a set amount of pots filled with stones/seeds. The particular version which you should implement has a board with 14 pots, of which two are designated as scoring pots. At the...
stackexchange_codegolf
Design a random number generator where the i th number has i% chance of occurring for all 0 < i < 14. 0 should have exactly 9% chance of occurring. The seed for the generator should be the system time. You cannot use a pre-defined function for random number generation. Basically 1 has 1% chance of occurring, 2 ...
stackexchange_codegolf
This is the robbers' thread. For the main rules to this challenge see the cops' thread In this challenge, robbers will choose a cop's vulnerable or safe post and try to figure out a pair of languages such that they print the correct results for the 4 programs. When you find a solution post an answer of it here and lea...
stackexchange_codegolf
I presume you've all heard of the Rosetta Stone, an ancient stone found to have essentially the same passage written on it in three different scripts. This challenge is based upon that: you have to write three versions of the same program in different languages. The three programs must output the first n iban numbers, ...
stackexchange_codegolf
This is the robbers' thread, the cops' thread is here A polyglot is a program, that without modification, can run in multiple languages. Robbers' Challenge First, find a vulnerable cop's answer, then try to find languages that the submission works in, if you found any that weren't listed by the cop, then you just cra...
stackexchange_codegolf
Schlosberg Numbers In issue 5 of Mathematical Reflections, Dorin Andrica proposed the problem of characterising the positive integers n such that is an even integer. Eight people submitted correct solutions showing that these are the integers n for which is even. The published solution was by Joel Schlosberg, so I c...
stackexchange_codegolf
For any String that is composed of lower cased alphabetical characters, make a function that returns a list of all of it's variations, empty strings returns empty list Test Cases "" -> [] "a" -> ["a", "A"] "ab" -> ["ab", "Ab", "aB", "AB"] "abc" -> ["abc", "Abc", "aBc", "ABc", "abC", "AbC", "aBC", "ABC"] This is Code-g...
stackexchange_codegolf
The Challenge Write a program that can break down an input chemical formula (see below), and output its respective atoms in the form element: atom-count. Input Sample input: H2O Your input will always contain at least one element, but no more than ten. Your program should accept inputs that contain parentheses, which...
stackexchange_codegolf
The king of Ancient Rome is having difficulties determining if a magic square is valid or not, because the magic square he is checking does not include any separators between the numbers. He has hired a software engineer to help him determine if a magic square is valid or not. Input Description Input comes in on STDIN...
stackexchange_codegolf
Related Exposition After winning the SO raffle, you could have been on top the world, and you were! The raffle had been going on for a year, now, and you were one of a hundred programmers who were selected to enter into the SO stronghold. And finally, the wait is over. Today is the day you go to--[obfuscated text proce...
stackexchange_codegolf
Challenge In this task you would be given an integer N you have to output the nearest prime to the integer. If the number is prime itself output the number. The input N is given in a single line,the inputs are terminated by EOF.The number of inputs would not exceed 10000 values. The challenge is to implement the ...
stackexchange_codegolf
Find the moves that bring a chess squad to a given destination. You control a chess squad consisting of a king and several other pieces, on a larger chess board. Your army is placed so that no piece is further than K=8 squares away (horizontally and vertically) from your king. You will receive a destination square for ...
stackexchange_codegolf
The task is simple: Create an if-statement from scratch in x86 assembly that runs in as few clock-cycles as possible. Must be x86 assembly. Can't use any of the conditional jump/branch instructions (e.g. je, jne, jz, jg, jge, jl, jle). Can use jmp to jump to existing blocks of code. Can use cmp if necessary. Can't cal...
stackexchange_codegolf
Consider the 74 characters from the 2016 time capsule string (note the leading space): !!!!!#$$%&())))*+...1449:=@@@AHILOQQQTTZ\\^`````````eefmpxy{||||~~~~~~~~~ Your task is to write as many programs as possible (in the same language) using these characters. The output of each program must be nonempty. When all of th...
stackexchange_codegolf
You are on a plane filled with boxes, and you get a sequence of movements, say "up right right down left": You move up, pushing all boxes in front of you away: You move right, right and down, getting and finally left. This time you only push one box rather than infinite boxes: At the end, there are 4 spaces. Given ...
stackexchange_codegolf
There are 4 regular polygons that we can construct using ASCII art: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...
stackexchange_codegolf
Given a matrix, output a representation of the matrix where the top left element is on top, the anti-diagonal is the central row and the bottom right element is at the bottom. For example, consider the following matrix: 1 2 3 4 5 6 7 8 9 The diamond version of this matrix is: 1 4 2 7 5 3 8 6 9 Inputs and output...
stackexchange_codegolf
Given an integer n >= 2, output the largest exponent in its prime factorization. This is OEIS sequence A051903. Example Let n = 144. Its prime factorization is 2^4 * 3^2. The largest exponent is 4. Test Cases 2 -> 1 3 -> 1 4 -> 2 5 -> 1 6 -> 1 7 -> 1 8 -> 3 9 -> 2 10 -> 1 11 -> 1 12 -> 2 144 -> 4 200 -> 3 500 -> 3 1024...
stackexchange_codegolf
Blackbeard was an English pirate of the early 18th century. Although he was known for looting and taking ships, he commanded his vessels with the permission of their crews. There are no accounts of him ever harming or murdering his captives. This challenge is in honor of the infamous Blackbeard and inspired by Internat...
stackexchange_codegolf
Given an ASCII art with simple closed paths using | and - (pipes and dashes), output a random point inside the boundary. Eg. given: ---- ---- | |- --- => |12|- --- | | | | |345| |6| ----- --- ----- --- Any point 1-6 should have an equal probability of being printed. Specs T...
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
Round away from zero Inspired by Round towards zero. Given a number input via any reasonable method, round the number "away from zero" - positive numbers round up, and negative numbers round down. If you intend to take the input as a string (via STDIN, for example), you should be able to handle numbers with or without ...
stackexchange_codegolf
A tower is made out of layers, each one being one unit shorter than the one below it. Every layer is completely on top of the previous layer. For example, here is a tower along with it's height map: # ## ### #### ##### 14532 Because the lengths of the layers are the integers from 1 to n, and because the layers ar...
stackexchange_codegolf
Like the previous SmokeDetector challenge? This one is for you too ;) Note: SmokeDetector is a bot that detects spam and offensive posts on the network and posts alerts to chat. What to implement Smokey's !!/coffee command uniformly at random picks one of these words (sorts of coffee): Espresso Macchiato Ristretto A...
stackexchange_codegolf
Given a string containing decimal numbers: teststring134this 123test string54 100 increment every number in this string by one to give the new string teststring135this 124test string55 101. The string can be provided as: a command line argument STDIN a hard-coded variable or function argument Cover all possible posit...
stackexchange_codegolf
It turns out that my toaster is a tad broken. It lost WiFi (You know, it's one of those newfangled smart toasters), and its been going bonkers! Since it no longer works, I've been having to hack into my breakfast's source code and run Plate.bread.toastAs(3); every morning. Will you help? My toaster takes one input: the...
stackexchange_codegolf