instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Given a positive integer \$n\$, output \$n\$ 2D bool images with the same width and height such that: Each image should be 4-connected, i.e. for each two pixels that are true, you can start from one and go up, down, left and right for some times to the other pixel, only passing through true pixels. Each image should h...
stackexchange_codegolf
This is a cops-and-robbers challenge the Robbers' Thread can be found here Your challenge is to write a program that outputs an anagram of its source code but not the original source code itself. For example the following Python program, print`'print*2``'*2` prints 'print*2``print*2``' which has all of the same chara...
stackexchange_codegolf
I recently solved a coding challenge in one of the challenge papers that my IT teacher gave to us. It was a seemingly simple, but fun challenge, so I thought it will make fun golfing. The task Given an input of a 2x2 matrix that contains 4 strictly positive integers (i.e. non-negative and non-zero), like this: $$\begin...
stackexchange_codegolf
A Window is an ASCII-art square with odd side length of at least 3, with a single character border around the edge as well as vertical and horizontal strokes in the middle: ####### # # # # # # ####### # # # # # # ####### An MS Window is a window where the border is made only of the characters M and S. Your tas...
stackexchange_codegolf
Input An integer k composed of 1 and 2, with at least 3 digits and at most 200 digits. Output Another integer k' obtained by removing at most one (could be none) digit from k, such that k' is composite, and then another integer p for a non-trivial (that is, not 1 or k') factor of k'. Test Cases 121212 -> 121212 10101 1...
stackexchange_codegolf
The task is to calculate the average "funniness" of a given number given the following scoring system: 1 point for each "420" in it 2 points for each "69" in it 3 points if its a palindrome (doesn't count if it's just a single digit) 4 points if it has (not for each) "800813" 5 points for ending in "420" 6 points for ...
stackexchange_codegolf
Write a program or function that alters the file at a user-specified filename via replacing all instances of UNIX line endings with Windows line endings and vice versa. Clarifications: For the purposes of this problem, a UNIX line ending consists of the octet 0A in hexadecimal, except when it is immediately preceded b...
stackexchange_codegolf
Background While a program is running on a computer, the computer needs to keep track of that program somehow, typically by either copying or mapping the compiled form of the program into memory. (Even interpreted languages do this; a few primitive languages work with source code directly, but in most interpreted langu...
stackexchange_codegolf
You are given a polynomial function, in the following format: \$x = (c_0 * y^0) + (c_1 * y^1) + (c_2 * y^2) + ... + (c_n * y^n)\$ where \$c_n\$ stands for the coefficient of the \$n^{th}\$ power of \$y\$ You have to plot the equation on a \$10 * 10\$ ASCII matrix. The value must be floored to an integer before plotting...
stackexchange_codegolf
Introduction: Before the task, here is what every element does on the map: Plain land (X): This does nothing. Destroyed land (-): This is the same as plain land, but destroyed by a bomb. The active bomb (!): On a map, this will destroy everything in a 3x3 square: XXXXX XXXXX XXXXX ...
stackexchange_codegolf
The premise of this is simple: A 10% chance is pretty unlikely, but everyone knows that a one-in-a-million chance is a sure thing! So, write code that implements the following "dramatic" probability rules: Take in a floating point P from 0 to 1 representing the unmodified chance of some plot-related event, and a boole...
stackexchange_codegolf
Challenge: Given two integers \$a\$ and \$b\$, with lengths \$A=length(a), B=length(b)\$, output an ASCII-art of the \$a^{th}\$ root of \$b\$, including the answer rounded to \$A\$ amount of decimal places. The size of the ASCII-art root also depends on \$A\$ and \$B\$. Example: \$a=123\$, \$b=1234\$ ____ 123 /123...
stackexchange_codegolf
Think of a road as a number line, starting at 0 and continuing indefinitely: ................................................................. There are two cars on the road: C and R. C is the cop who is trying to catch R, the robber. C starts at 0, and R starts somewhere on the road: C.............................R.....
stackexchange_codegolf
The goal is simple. Write a program that outputs itself encoded as a QR code. A QR code is a way to encode data in a black and white image, similar to a 2D image. An example implementation can be found here. The QR code is displayed as text, where each pixel is either a "#" for a black pixel, or a space for a white pi...
stackexchange_codegolf
What general tips do you have for golfing in Prolog? I am looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Prolog (e.g. one letter variables is not specific to Prolog to reduce the size of programs). Please indicate in your tips if it is specific to an imple...
stackexchange_codegolf
I recently solved a coding challenge in one of the challenge papers that my IT teacher gave to us. It was a seemingly simple, but fun challenge, so I thought it will make fun golfing. The task Given an input of a 2x2 matrix that contains 4 strictly positive integers (i.e. non-negative and non-zero), like this: $$\begin...
stackexchange_codegolf
Inspired by Digits in their lanes Input: An ASCII-art of width ≤ 11, consisting of spaces and #. (You can choose any two distinct characters instead.) Example: # ### # # # # # # # # # ### # # ### # ########### # # # # # ### # # ...
stackexchange_codegolf
So what might be the shortest language for this simple task? Task: You are given an input of type String - the string is a valid hexadecimal number ([0-9A-F]). Convert it to a decimal number and print it to the console. Tests: HEX -> DEC 1 -> 1 98 -> 152 539 -> 1337 1337 -> 4919 A5F9 > 42489 F -> 15 Win Condition: Th...
stackexchange_codegolf
Introduction In the United States, national elections are normally held on the first Tuesday after the first Monday in November. Challenge Write a program that takes a Year as integer, and a pair of (day of week as character and ordinal as integer) and output the date as "yyyy-mm-dd" Remember, the second pair is after...
stackexchange_codegolf
Input A string. Output The sum of all integers in the line. Constraints 1≤Length of line≤500 Sample test Case Input the 5is 108 seCONd4 a Output 117 Explanation Sum is: 5+108+4=117
stackexchange_codegolf
Creating a Crossed Square You are to take input of an integer of one or more and output a square made of any printable character of your choice with a diagonal cross through the centre. The general idea is for the output to be a hollow square that has a diagonal cross through it.: Input: 7 Output: ******* *# #* * # #...
stackexchange_codegolf
Introduction In the United States, national elections are normally held on the first Tuesday after the first Monday in November. Challenge Write a program that takes a Year as integer, and a pair of (day of week as character and ordinal as integer) and output the date as "yyyy-mm-dd" Remember, the second pair is after...
stackexchange_codegolf
The goal is to raise the error message with the most bytes! The error message may not be generated by the program itself, such as Python's raise. errors that do not terminate the program are not allowed unless they do not show an error message. Here is an example in python that raises 243041 bytes of error code: def a(...
stackexchange_codegolf
Challenge: Get the JavaScript string value containing only the "-" character using code only containing the following three symbols: +[]. Note: I'm not sure if this is possible. Scoring criterion: The number of bytes of code used. Why? I've set myself a challenge to be able to write code using only the above three char...
stackexchange_codegolf
In FIPS-197 (the Advanced Encryption Standard, known as AES), it is made heavy use of SubBytes, which could be implemented as unsigned char SubBytes(unsigned char x) { static const unsigned char t[256] = { 0x63,0x7C,0x77,0x7B,0xF2,0x6B,0x6F,0xC5,0x30,0x01,0x67,0x2B,0xFE,0xD7,0xAB,0x76, 0xCA,0x82,0xC9,0x7D,0xFA,0x59...
stackexchange_codegolf
One way to generalize the concept of a range from the integers to the Gaussian integers (complex numbers with integer real and imaginary part) is taking all numbers contained in the rectangle enclosed by the two ends of the range. So the range between two Gaussian integers a+bi and c+di would be all Gaussian integers x...
stackexchange_codegolf
This challenge is created in celebration of my first esoteric language, Backhand! Backhand is a one dimensional language with a non-linear pointer flow. The pointer moves three steps at a time, only executing every third instruction. The program 1..1..+..O..@ will add 1+1 and output 2 before terminating. The intermedia...
stackexchange_codegolf
This challenge is straightforward, but hopefully, there are plenty of avenues you can approach it: You need to print/return a valid JSON object of at least 15 characters, not counting unessential whitespace. Your program should work without any input. In the interest of clarity, a JSON object starts and ends with curl...
stackexchange_codegolf
Hermite polynomials refer to two sequences of polynomials: The "probabilist's Hermite polynomials", given by $${He}_n(x) = (-1)^n e ^ \frac {x^2} 2 \frac {d^n} {dx^n} e ^ {-\frac {x^2} 2}$$ where \$\frac {d^n} {dx^n} f(x)\$ refers to the \$n\$th derivative of \$f(x)\$ The "physicist's Hermite polynomials", given by $...
stackexchange_codegolf
The challenge is to write a golf-code program that, given n positive real numbers from 0 to 10 (format x.y, y only can be 0 or 5: 0, 0.5, 1, 1.5, 2, 2.5 … 9.5 and 10), discard the lowest and highest values (only one, even though they are repeated) and shows the average of the remaining, in x.y format (y can be 0 or 5, ...
stackexchange_codegolf
The challenge here is to accurately depict the flower of life (which is a sacred geometrical figure according to some) in the language of your choice. The design consists an arrangement of circles and partial circles of radius 1 as shown whose centres arranged on a triangular grid of pitch 1, plus one larger circle of...
stackexchange_codegolf
Simple problem, create a programme that takes one input, and the outputs that input in reverse. Some test cases are [input -> output]: Hello World! -> !dlroW olleH Code Golf -> floG edoC Reverse Cat Programme -> emmarporG taC esreveR Shortest answer wins Note: It doesn’t have to support multi-line inputs and it doe...
stackexchange_codegolf
What general tips do you have for golfing in Scala 3? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Scala 3 (e.g. "remove comments" is not an answer). Please post one tip per answer. Also see Tips for golfing in Scala
stackexchange_codegolf
Consider a square grid on the plane, with unit spacing. A line segment of integer length \$L\$ is dropped at an arbitrary position with arbitrary orientation. The segment is said to "touch" a square if it intersects the interior of the square (not just its border). The challenge What is the maximum number of squares th...
stackexchange_codegolf
Given a string containing only the characters -, |, + and newline determine the longest straight line contained in it. A straight line is either an uninterupted run of -s and +s in a single row or an uninterupted run of |s and +s in a single column. So for example: | | ---- | --+-- ...
stackexchange_codegolf
Introduction The Nineteenth Byte is CGCC's official chatroom (go check it out!). Its name is a play on the nineteenth hole, and it also refers to golf, which is appropriate for CGCC's chatroom's name. The name is also precisely \$19\$ bytes long, as its name states. Challenge Your task is to write a program that output...
stackexchange_codegolf
This is a code golf challenge I thought of with a mathematical bent. The challenge is to write the shortest code possible such that it is an open question whether or not the code terminates. An example of what I mean could be the following piece of python code, adapted from an anwser to this cs stackexchange question. ...
stackexchange_codegolf
I've recently been indulging myself in some nostalgia in the form of Bookworm Deluxe: In case you haven't seen it before, it's a word game where the goal is to connect adjacent tiles to form words. In order to determine whether a string is a valid word, it checks it against its internal dictionary, which is stored in ...
stackexchange_codegolf
Background The look-and-say sequence begins with \$1\$, each following term is generated by looking at the previous and reading each group of the same digit (eg. \$111\$ is three ones, so \$111 \rightarrow 31\$). The first few terms are $$ 1, 11, 21, 1211, 111221, 312211, \dots $$ Conway's cosmological theorem says tha...
stackexchange_codegolf
Powerball is an American lottery that has recently gained attention because the current jackpot (as of January 11, 2016) is the largest lotto prize in history, at about $1.5 billion (USD). Powerball players choose 5 distinct numbers from 69 numbered white balls, and 1 one "Powerball" number from 26 numbered red balls. ...
stackexchange_codegolf
This is a rock paper scissors competition. Algorithms will face each other in 100 rounds of rock paper scissors. Except that the algorithms will also be able to read the source code of each other! Leaderboard 1. Chaos Bot (by Aiden4) - 27 Points, 168 bytes 2. Anti-99%-of-posts (by Lyxal) - 24 Points, 489 bytes 3. Psued...
stackexchange_codegolf
Write two programs A and B. Program A (the encoder) takes 1024 pairs of integers \$(k,v)\$, where \$0≤k<2^{32}\$ and \$0≤v<1024\$, and all \$k\$ will be different. It will output a single positive integer (likely a few thousand digits long). Program B (the decoder) takes two inputs: the output-integer of program A, a...
stackexchange_codegolf
Introduction The \$RADD(n)\$ operation is defined as the sum of \$n + [\$ the number whose decimal representation are the decimal digits of \$n\$ in reverse order \$]\$, see A004086. After reversal, trailing zeros are lost. See Reverse-Then-Add Sequence and A056964. Not all numbers can be represented as the result of a...
stackexchange_codegolf
Given an input of a note, output an ASCII drawing of the corresponding major key on the treble clef. Here are all the major keys (that don't include double-sharps or double-flats) and their corresponding key signatures: Circle of fifths deluxe 4 by Wikipedia user Just plain Bill, copyright CC BY-SA 3.0 If the input is...
stackexchange_codegolf
Your task is to improvise a hardware random-number generator with whatever hardware you have lieing around. Challenge Write a program with the following properties: It prints either 0 or 1 (and nothing else). The output depends on a physical process and not just the internal state of the computer. There is no relation...
stackexchange_codegolf
Introduction: In Dutch, the words leading and suffering, being 'leiden' and 'lijden' respectively, are pronounced the same way. One is written with a "short ei", and one with a "long ij", as we Dutchman would say, but both 'ei' and 'ij' are pronounced [ɛi]. Challenge: Given a list of numbers, determine which (if any) a...
stackexchange_codegolf
Given a multi-line string as input containing characters "|", "_" and " " (space), count the number of cells it contains. A cell is the following structure of 3 characters by 2 lines: _ |_| That is, an underscore on one line (the characters to its right and left don’t matter), and "|_|" right below it. Two cells can ...
stackexchange_codegolf
Inspired by what I'm doing at work right now. Your program should take one parameter, the path to the file It should convert all the windows style newlines (\r\n) to unix style (\n) and write the result back to the file
stackexchange_codegolf
Given the output of the cop's program (o), the byte-count (n) and the number of unique bytes (c) used, come up with a corresponding piece of code that is n bytes long with c unique bytes which matches the cop's output o. This is the robbers thread. Post solutions that you cracked here. The COPS thread is located here....
stackexchange_codegolf
Introduction I don't see many regex challenges on here, so I would like to offer up this deceptively simple one which can be done in a number of ways using a number of regex flavours. I hope it provides regex enthusiasts with a bit of fun golfing time. Challenge The challenge is to match what I've very loosely dubbed a...
stackexchange_codegolf
Note: This challenge has been moved to Polyglot the (non constant) OEIS! to avoid closure. Introduction We all know and love the on-line encyclopedia of integer sequences (OEIS). So what if we made an off-line version? Well, that would be kinda too easy, wouldn't it and how would you select a sequence with our standa...
stackexchange_codegolf
Challenge The goal of this challenge is to make a function that takes an input string, a start keyword and a end keyword. The output extracted result is from (but excluded) the given start keyword to (but excluded) end keyword. The output sub-string follows the rules as below. In all cases, the leading/trailing spaces...
stackexchange_codegolf
In this challenge, you will write an interpreter for 2Ω (transcribed as TwoMega), a language based loosely on brainfuck with an infinite-dimensional storage space. The Language 2Ω contains three pieces of state: The Tape, which is an infinite list of bits, all initialized to 0. It has a leftmost element, but no rightm...
stackexchange_codegolf
This challenge is inspired by dmenu, the program I use to launch other programs on my Linux box. To start, for example, GIMP, I simply hit the keyboard shortcut I have assigned to dmenu, type "gimp" and hit enter. However, I don't have to type the whole name. On my machine, if I type "gim", that's enough. Here's how d...
stackexchange_codegolf
It frustrates me that when you say "base 16", the 16 is in base 10. We need a base neutral way of writing down numbers when favoring a specific base would be inappropriate. How it works We define <n> to be the nth prime. So <1>=2, <2>=3, <3>=5. Note that every positive integer can be uniquely represented by the product...
stackexchange_codegolf
Given a string of brackets tell the user whether or not the brackets are well matched or not. Brackets include []{}(). For example: () <---- Well Matched ([{}][]) <---- Well Matched ({)} <---- Not Well Matched ({]) <----- Not Well Matched This is a code-golf challenge so as always the shortest solution wins.
stackexchange_codegolf
You will take two positive integers n and x as input, and output Euler's totient function (number of positive integers less than x co-prime to x) applied n times. Testcases n x result 1 10 4 2 10 2 3 10 1 1 100 40 2 100 16 3 100 8 4 100 4 5 100 2 6 100 1
stackexchange_codegolf
Task: Consider the problem: "given a chessboard with one square missing, cut it into 21 L-triominoes". There is a well-known constructive proof that this can be done for any square chessboard size that is a power of two. It works by splitting the chessboard into a smaller chessboard with the hole in it and one big trio...
stackexchange_codegolf
Task Given a string composed of ASCII printable characters, return how many strings could fit the given pattern with character literals and regex-like ranges. Pattern string The pattern string follows this grammar (the | means an option and the * means 0 or more occurrences of whatever was immediately to the left): pat...
stackexchange_codegolf
Quine Relay! A quine relay of order \$n\$ is a series of programs \$P_1\dots P_n\$ in distinct languages such that each program \$P_i\$ outputs \$P_{i+1}\$ and \$P_n\$ outputs \$P_1\$. For example, a 2-quine relay can be seen here: Ruby → Perl 6: This Ruby program: $><<"print (" p (DATA.read*2).chars.map(&:ord) $><<".m...
stackexchange_codegolf
2fuck is a simple 2D variation on brainfuck. Like traditional brainfuck, there is an 1D memory tape that extends 30000 bytes to the right from its beginning, consisting of values between 0 and 255. Arithmetic should wrap around, adding 1 to 255 sets the cell to 0, and moving right from memory cell 29999 should move the...
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
In this challenge you will write a piece of text which when viewed from two different angles will create two different programs. Your string as viewed from above must take a string containing only characters ASCII 10, 32 - 126 and output it as viewed from above. Additionally your program when viewed from the left must...
stackexchange_codegolf
Given a positive integer N, output the innermost N×N square of an ASCII art spiral made of -|/\ that spirals clockwise inward. The - is used for horizontal portions, | for vertical portions, and / and \ for corners. The first character is - and the spiral proceeds left and down. Specifically, when N is 1 the output is:...
stackexchange_codegolf
The task is to display ascii table for a given array. Input The input is an 2D matrix. The matrix's row length is same with the length of an array. Alternatively, you can take input of an 2D matrix with the first row is a header. The outer dimension is the row. Example Input: [["License","2008-05-08","2009-03-11","2011...
stackexchange_codegolf
[Question inspired by Can you calculate the average Levenshtein distance exactly? . Thank you Anush. ] The longest common substring between two strings is the longest substring which is common to both. Please note this is not the same as the longest common subsequence whose fastest algorithm takes quadratic time. The ...
stackexchange_codegolf
Task: Output the Swiss flag. Happy Swiss National Day / Schweizer Bundesfeiertag / Fête nationale suisse / Festa nazionale svizzera / Fiasta naziunala svizra! Details: The flag consists of a white (#FFFFFF) cross on a red (#FF0000) background. The cross consists of a 6x6 square with arms of size 6x7 glued to each sid...
stackexchange_codegolf
Redivosite is a portmanteau word invented for the sole purpose of this challenge. It's a mix of Reduction, Division and Composite. Definition Given an integer N > 6: If N is prime, N is not a Redivosite Number. If N is composite: repeatedly compute N' = N / d + d + 1 until N' is prime, where d is the smallest diviso...
stackexchange_codegolf
Your task is to output all possible ways to end a game with a tie (all rows, columns, and diagonals are completely filled and do not have 3 X's or 3 O's, and there are exactly 5 X's and 4 O's in total) in Tic-Tac-Toe (assuming X goes first): OXO XXO XOX OXX XOX OOX XOX XOO XOX XXO OXO OXX XOX XOX OXX XXO O...
stackexchange_codegolf
A run ascending list is a list such that runs of consecutive equal elements are strictly increasing in length. For example [1,1,2,2,1,1,1] can be split into three runs [[1,1],[2,2],[1,1,1]] with lengths [2,2,3], since two runs are the same length this is not a run ascending list. Similarly [2,2,1,3,3,3] is not run as...
stackexchange_codegolf
Every programmer knows that brackets []{}()<> are really fun. To exacerbate this fun, groups of interwoven brackets can be transformed into cute and fuzzy diagrams. Let's say that you have a string that contains balanced brackets, like [{][<(]})>(()). Step one is to rotate the string 45 degrees clockwise. (In Mathema...
stackexchange_codegolf
Your task: generate a Koch snowflake to the nth depth. You do not need to make a complete Koch snowflake, just one side of the starting triangle. Wikipedia on Koch flakes: https://en.wikipedia.org/wiki/Koch_snowflake. Rules: The program must generate one side of the Koch snowflake to the nth depth. Output must be ASCI...
stackexchange_codegolf
Challenge Imagine a hexagonal grid as shown below. Let's call such a grid has size \$n\$ if it has \$n\$ dots on one side. The following is one of size 3: - - - - - - - - - - - - - - - - - - - Then, pick as many dots as possible on the grid so that no two dots are adjacent. For size 3, the maximum is 7 dots: -...
stackexchange_codegolf
Challenge HP is doing research in mathematics . After doing lots of research, she struck in a problem . She found four numbers n,a, b and c .Now, She wants to know how many number exists which are less than or equal to n and are divisible by a ,b or c . Input : 4 integers denoting n,a,b and c separated by space Output ...
stackexchange_codegolf
Chained Binary Operations Here's a challenge involving truth tables and binary operations. For this specific challenge, your task is to use the following table of operations: To create a function that takes in two inputs f(p,a), where p is the initial truthy/falsy value and a is a list of tuples representing multiple ...
stackexchange_codegolf
We shall soon have a new logo & site design, let us use this last breath of the simple times and golf this ASCII version of the speech bubble beta logo: +-------------------------------------------+ | .---------------------------------. | | .EPEpEpBPEpEGCXCgCgCGJgCgP&PWP&P&P&Y` | | .RSRsRWRSRsRsHoNoNONxNONON...
stackexchange_codegolf
She said s(he) be(lie)ve(d), he said sbeve. Input A non-empty string, s. It's guaranteed that s will have only printable ASCII characters and at least one word (defined as [A-Za-z0-9]+) in parentheses, and all parentheses will be closed respectively. Output A string containing all non-whitespace characters (whitespa...
stackexchange_codegolf
Your task is to write 2 functions/programs. They may share code. The first function must, given a string and a character, output a new string that does not contain that character. The second function must, given the string from the previous function and the excluded character, reconstruct the original string. All input...
stackexchange_codegolf
Inspired by this comment chain... I wanna enklact my way out of this challenge but I can't... @ETHproductions to enklact (v): to implement a lookup table using a subsection consisting of unique elements. Enklacting is a very useful way to compress a lookup table. For example, let's say you had the following list of ...
stackexchange_codegolf
You may have seen Jacob's Ladder in children's science museums. If you're not familiar with what they look like, there are several images and video examples on the Wikimedia Commons. The challenge today is to create an animated ASCII version of the electrical gadget. In the end, it should look something like this: La...
stackexchange_codegolf
Background A matryoshka doll (or Russian nesting doll) is a set of dolls that fit inside of each other. I've accidentally mixed up my collection of matryoshka dolls and I don't remember which one goes inside which. Objective Given a list of unique strings, sort them into nested matryoshka dolls. Each string is an indiv...
stackexchange_codegolf
There's a payment machine for laundry in my building which does a few frustrating things. The ones relevant to this challenge are: It doesn't make change. So if you pay over the amount then you are not getting that over-payment back. It doesn't accept coins smaller than 20c. Meaning the only coins it accepts are 20c...
stackexchange_codegolf
Part of Advent of Code Golf 2021 event. See the linked meta post for details. Related to AoC2017 Day 3, Part 2. You come across an experimental new kind of memory stored on an infinite two-dimensional grid. Each square on the grid is allocated in a spiral pattern starting at a location marked 1 and then counting up wh...
stackexchange_codegolf
Flavortext So...this is awkward. It seems I accidentally turned into a monkey last night after eating one too many banana sundaes. This has made many things inconvenient, especially typing. You see, monkeys only need the following characters: uppercase letters (A-Z), space, comma (,), exclamation mark (!), and question...
stackexchange_codegolf
Inspired by this Implement simple chess bot (with console or GUI) that has following features: [Pseudo-]graphically showing the board; Accepting user moves and making their own moves; Playing by basic chess rules (not doing illegal moves); Making at least minimally reasonable moves (no random moves, a player making ra...
stackexchange_codegolf
You'll be given the name of one of the 20 biggest objects in the Solar System. Your task is to return an approximation of its radius, expressed in kilometers. This is a code-challenge where your score consists of the length of your code (in bytes) multiplied by a penalty ratio \$\ge 1\$, based on your worst approximati...
stackexchange_codegolf
pylint has no lower bound on the scores it will give your code. It uses the following metric to score code, with the maximum score being 10: 10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) With python 3.6, try and write a program that: Outputs "Hello World" when run from the command lin...
stackexchange_codegolf
My high school, and many others implement a type of schedule called a Rotating Block Schedule. This is a way for people to have 8 classes, but on have 6 periods in a school day. There are four days in a block schedule that repeat over and over, and have nothing to do with the actual days of the week. Each are assigned ...
stackexchange_codegolf
Write a program or function which receives as input a string representing a Welsh word (UTF-8 unless otherwise specified by you). The following are all single letters in Welsh: a, b, c, ch, d, dd, e, f, ff, g, ng, h, i, j, l, ll, m, n, o, p, ph, r, rh, s, t, th, u, w, y To quote Wikipedia, While the digraphs ch, dd,...
stackexchange_codegolf
Given 2 brainfuck code snippets A and B, output some brainfuck code C which has the same behavior as running B with the input of As result. Note that C must work for any input that match the following assumptions, as if it were given to A. You can assume: Finite input. both A and B halt. EOF is consistently 0 or consi...
stackexchange_codegolf
Find the max number of Xs you can fit onto a rectangular tic-tac-toe board of length l and height h without ever having 3 consecutive Xs in a row diagonally, horizontally, or vertically. This is a code-golf challenge so shortest code wins! Input A single line containing values l and h, representing the length and heigh...
stackexchange_codegolf
Your task here will be to implement a function1 that forms a permutation on the positive integers (A bijection from the positive integers onto themselves). This means that each positive integer should appear exactly once in the permutation. The catch is your function should have a larger probability of outputting an ...
stackexchange_codegolf
This is the Cops' thread. Robbers' thread is here. Background Boggle is a board game where the players have to find English words on a 4-by-4 board of random alphabets. Words can be constructed by selecting sequentially adjacent cells on the board. ("adjacent" means horizontally, vertically or diagonally adjacent.) A...
stackexchange_codegolf
Consider an array x such as [1 5 3 4] and a number n, for example 2. Write all length-n sliding subarrays: [1 5], [5 3], [3 4]. Let the minimax of the array be defined as the minimum of the maxima of the sliding blocks. So in this case it would be the minimum of 5, 5, 4, which is 4. Challenge Given an array x and a pos...
stackexchange_codegolf
Given an array of integers A, the task is to output another array B of the same length so that B[i] is the maximum over A for every index that is not i. That is \$B[i] = \max_{i' \ne i} A[i']\$. Examples: A = [1, 5, -3, 4, 2]. B = [5, 4, 5, 5, 5] A = [1, 2, 3]. B = [3, 3, 2] A = [-1, -2, -3, -1]. B = [-1, -1, -1, -1] ...
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
Introduction Logic gates! Everyone knows them, everyone loves them (unless you're starting to learn them). Take two booleans, compare them, get a single boolean in return. AND, NAND, OR, NOR, XOR, XNOR. Fun! But, what if you only had the inputs and output, but not the operator? Challenge Given a three digit number, xy...
stackexchange_codegolf
Your challenge is to write a Python program to print all the primes (separated by whitespace) less than a given integer N with an asterisk (*) next to each twin prime in ONE statement. A twin prime is a prime number that is either two more or two less than another prime. All output should be to stdout and input should ...
stackexchange_codegolf
The 3x3 Hexa Prime Square Puzzle Introduction We consider 3x3 squares of hexadecimal digits (from 0 to F) such as: 2 E 3 1 F 3 8 1 5 7 2 7 D D 5 B B 9 We define a 3x3 Hexa Prime Square (HPS3) as such a square for which all hexadecimal numbers read from left to right and from top to bottom are odd primes (i.e....
stackexchange_codegolf
Context It's Valentines Day. The only one you ever loved left you yesterday for this guy she always found "stupid and uninteresting". On your way home, you've been stuck in traffic, listening to old songs on the radio, the rain hitting the windscreen is rocking you. After a while in your car, you find yourself...
stackexchange_codegolf