instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Background Conway's Soldiers is a version of peg solitaire played on an infinite checkerboard. The board is initially full of pegs below an infinite horizontal line, and empty above it. Following the ordinary peg solitaire rules (move a peg by jumping over another one horizontally or vertically, removing the one that w...
stackexchange_codegolf
Objective Given a positive integer, spell it out in the conlang I made. Specification Let \$n\$ be the inputted integer. \$n\$ shall be spelled out in the following specification. The entire spelling is case sensitive. With the decimal expansion of \$n\$, let d be the least significant nonzero digit of \$n\$. First, d ...
stackexchange_codegolf
Your task, is simply to multiply 2 integers given in input, separated by a ",". The catch is, you cannot use the multiplication operator "*", even if it is being used differently, or any loops whatsoever This is code-golf, so shortest code wins! Test cases: i dont know if you even need it! lol 1,0 -> 0 5,6 -> 30 3920,5...
stackexchange_codegolf
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. Inspired by https://xkcd.com/835 In the midst of his mid-life crisis, Santa has impulsively purchased a Sports Sleigh™ for present delivery this year. The only problem is that this sleigh has a specially designed Infinite Present Trunk...
stackexchange_codegolf
Just for fun, I wanted to see how little lines I could solve this problem in, using python. I managed to condense my code into 9 lines. size = int(input("Size: ")) a = [x for x in range(size-2, -1, -1)] if size % 2 == 0 else [x for x in range(size-2, 0, -1)] b, counter = a[::-1], 0 print("\n"+"\\"+"#"*size+"/") #top f...
stackexchange_codegolf
In the spirit of Solve the Halting Problem for Befinge, let's define another 2D language called Modilar SNISP. Modilar SNISP has the following six instructions: \ directs the instruction pointer as follows: if approached from the top, go right; if approached from the right, go up; if approached from the bottom, go l...
stackexchange_codegolf
Problem Build an octal calculator that can do the following operations: Add (+) Subtract (-) Multiply (*) Divide (/) Check is prime Counting in octal is like this with decimal (Octal) (Decimal) 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 10 8 11 9 and so on.....
stackexchange_codegolf
Your job is to write a program that takes a number N as input and outputs all 2-by-N mazes that are solvable. Output format can be in the form of any two distinct values representing wall and empty - I use x and . here but you can use anything. You can have a matrix, array, string, ascii art, whatever is convenient, an...
stackexchange_codegolf
Thanks @NathanMerrill for allowing me to post this! The following is entirely his wording from this sandbox post (deleted): We define a "Fresh" substring as a substring that is different from any other substring that starts earlier. For example, if I take the string "abababc" and split it: ["ab","ab","a","bc"], the fi...
stackexchange_codegolf
Challenge You are supposed to output the series I recently designed which goes as follows which are pen stroke counts of ascending prime numbers: 2, 3, 2, 4, 3, 5, 6, 5, 7, 7, 7, 10, 4, 6, 7, 4, 4, 4, 7, 6, 8... Example This is an illustration of how this series is formed, first, it takes a prime number from in sequen...
stackexchange_codegolf
In the description of this challenge, the following board will be used as a reference for positions: ABC DEF GHI For instance, in a game of ordinary tic-tac-toe, B E A C G D F H I describes the following: -X- -X- XX- XXO XXO XXO XXO XXO XXO --- -O- -O- -O- -O- OO- OOX OOX OOX --- --- ...
stackexchange_codegolf
Yet another blatant rip-off of a 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 string input/argument. The tricky part is that if I reverse your source code, the output must be reversed too. For simplicity, you can assume that the inpu...
stackexchange_codegolf
We define the function g as g(n) = n XOR (n * 2) for any integer n > 0. Given x > 0, find the smallest integer y > 0 such that gk(y) = x for some k > 0. Example x = 549 549 = 483 XOR (483 * 2) (as binary: 1000100101 = 111100011 XOR 1111000110) 483 = 161 XOR (161 * 2) (as binary: 111100011 = 10100001 XOR 101...
stackexchange_codegolf
What is the smallest possible runnable Mach-O executable on x86_64? The program can do nothing (not even returning a return code), but must be a valid executable (must run without errors). My try: GNU Assembler (null.s): .text .globl _main _main: retq Compilation & Linking: as -o null.o null.s ld -e _main -macosx...
stackexchange_codegolf
Given an integer \$ n \ge 2 \$, you need to calculate \$ \lfloor n \log_2(n) \rfloor \$, assuming all integers in your language are unbounded. However, you may not ignore floating-point errors - for example, in python lambda n:int(n*math.log2(n)) is an invalid solution, because for example for n=10**15, int(n*math.log2...
stackexchange_codegolf
The goal of this challenge is to extend the On-Line Encyclopedia of Integer Sequences (OEIS) sequence A038375. Maximal number of spanning paths in tournament on n nodes. A tournament on \$n\$ vertices is a directed graph where for each pair of vertices \$(v_i, v_j)\$ there is either a directed edge \$v_i \rightarrow ...
stackexchange_codegolf
A big part of radio communication is the NATO Phonetic Alphabet, which encodes letters as words to make them easier to understand over comms. Your job, if you wish to accept it, is to print them one by one. You must print this exact string to stdout: A: Alfa B: Bravo C: Charlie D: Delta E: Echo F: Foxtrot G: Golf H: Ho...
stackexchange_codegolf
Challenge Write a program or function that takes in 4 non-negative integers, A, B, C, and D, that represent two fractions, A/B and C/D, where B and D are non-zero and A <= B and C <= D. Output an ASCII art depiction of the fractions made of |x- characters on two lines as follows: The lines will always be the same, min...
stackexchange_codegolf
Challenge Design a compression algorithm specialized for compressing ASCII mazes. You will need to create both a compression algorithm and a decompression algorithm. Your score will be based on the size of your compressed mazes. Mazes These mazes are made primarily of the characters (floors), +, -, |, and # (walls), a...
stackexchange_codegolf
In this task you will take as input a non-negative integer \$n\$, and output the number of pairs of non-negative integers \$a,b\$ such that both are palindromes*, \$a \leq b\$, and \$a+b = n\$. For example if \$n\$ is \$22\$ then the valid pairs are \$ \begin{array}{c|c} a & b \\ \hline 0 & 22 \\ 11 & 11 \\ \end{arra...
stackexchange_codegolf
Introduction "Yarr!! We had a laddie who called himself a "programmer" make a map t' our hidden treasure! But 'tis written wit' weird numbers 'n letters! "E5, N2, E3"... what does it even mean? Madness! Can't even scribe a proper treasure map, t' useless cretin. Fix it fer us! We'll gift ye a share o' t' treasure!" Cha...
stackexchange_codegolf
Challenge: Input: Two integer parameters a and b (where a<b and the difference is at least 2) Output: Output or return this text, where a and b are filled in: (a,b) = ]a,b[ = {a<x<b} = {a<x&&x<b} = a+1..b-1 [a,b) = [a,b[ = {a<=x<b} = {a<=x&&x<b} = a..b-1 (a,b] = ]a,b] = {a<x<=b} = {a<x&&x<=b} = a+1..b [a,b] = [...
stackexchange_codegolf
CODE GOLF & Coding Challenges: In today's challenge, you'll be asked to print the following very special AND tricky AND satisfying Prime Number...! Are you golfers ready? 67796869327179767032383267111100105110103326710497108108101110103101115583273110321161111009712139115329910497108108101110103101443212111111739108108...
stackexchange_codegolf
The Lisp language has a family of functions car, cdr, cadr, etc for accessing arrays. For each one, an a defines taking the first item of an array, and a d defines taking the rest. For example, running cadr on [[1,3,4],5,7] will return [3,4] as the a gets the first item ([1,3,4]) and the d removes the first item. We've...
stackexchange_codegolf
Given a number x, find the sum of all primes up to that number. The input will always be a positive number, bigger than 2. An upper limit isn't defined, so data types can be ignored. Use whichever you want. This is a code-golf, so the shortest code in bytes wins. Example for 5: 2 + 3 + 5 = 10 Test cases: Input Ou...
stackexchange_codegolf
Four-In-A-Row AI Tournament Today, we will be playing a Four-In-A-Row tournament. However, it is not us humans playing... instead, we must have our computers battle instead! This challenge is completely in C#. Rules Basic Game Rules If you have never played, there are simple rules. 2 players take turns putting pieces i...
stackexchange_codegolf
Sandbox Inspired by a Codingame challenge I tried (and failed at) about a month ago. Given a binary tree of words, say: HELLO / \ WORLD EATING / / \ ARCH IDAHO GUARD / DOOZY / ...
stackexchange_codegolf
We'll call the consecutive distance rating of an integer sequence the sum of the distances between consecutive integers. Consider 2 9 3 6 8 1. 2 9 3 6 8 1 <----5----> <-2-> <--3--> \$2\$ and \$1\$ are consecutive integers, and their distance apart in the sequence is \$5\$. \$2\$ and \$3\$ are consecutive integers, a...
stackexchange_codegolf
Introduction Kerning means adjusting the spacing between the letters of a text. As an example, consider the word Top written with the following three glyphs: ##### ..... ..... ..#.. ..... ..... ..#.. ..##. .###. ..#.. .#..# .#..# ..#.. .#..# .#..# ..#.. ..##. .###. ..... ..... .#... ..... ..... .#... We could just fil...
stackexchange_codegolf
Given a string n, create a pyramid of the string split into pieces relative to the current row. The first row contains the string unmodified. The second row contains the string separated into halves by a pipe. The third row separates it by thirds... And so on. The length of each substring, where l is the length of st...
stackexchange_codegolf
If you cannot see this post, you can use this image Your task is to create a markdown parser that outputs Unicode. It should support , , , and ̲̲̲̲̲̲̲̲̲. Every alphabetical character should be converted into Math Sans. This includes the characters before an underline character. Underlines: Add a ̲ character (code point...
stackexchange_codegolf
I just discovered this site and this is my first question, I hope I'm doing it correctly. The challenge is the following, you must write a code that prints all the prime numbers of \$n\$ digits. Since this problem is computationally complicated, I think that one way to simplify it is to give a number \$m\$ that will be...
stackexchange_codegolf
In this challenge, you must parse a list of lists, into a simpler list format. This challenge is based on my sadflak parser. In my sadflak parser, it has all the () removed, replaced with the sum of the ()s at the start of the list, to make the program run faster. To parse into a Sad-List, you have to do this (python i...
stackexchange_codegolf
Within the recesses of Unicode characters, there exists a Unicode block of (currently) 63 characters named "Number Forms", which consists of characters that have numerical values such as the roman numeral Ⅻ, vulgar fractions like ⅑ or ↉, or weird ones like ↊ (10) or ↈ (100000). Your task is to write a program or functi...
stackexchange_codegolf
Note: When I refer to a bridge, I mean it in the non-mathematical sense Introduction You are on a network of islands which are connected by wooden bridges and you want to see if you can burn every bridge in the island network. However, you can only burn a bridge once you've walked over it. Once a bridge has been burned...
stackexchange_codegolf
Introduction In this challenge your task is to generate the ISBN-10 code for books given its ISBN-13 code, assuming that such a code exists. Such an ISBN-13 code consists of several parts separated by -: 978-GG-PPPP-TTT-C The letters G (group), P (publisher), T (title) and C (checksum) all stand for one digit. For the...
stackexchange_codegolf
This challenge is based on a video in which Andrew Huang discusses unusual time signatures... https://www.youtube.com/watch?v=JQk-1IXRfew In it, he advises that you can understand time signatures by dividing them into 3's and 2's. So you count to a small number a few times, instead of counting to a large number. Here's...
stackexchange_codegolf
Input a scientific notation number (base 10), output scientific notation in base 16 (as defined below). Details In scientific notation, all non-zero numbers are written in the form $$ m \times 10^n $$ Where \$ n \$ is an integer, and \$ m \$ is a real number, \$ 1 \leq |m| < 10 \$. Consider scientific notation in base ...
stackexchange_codegolf
Challenge: Input: A sorted list of positive integers. Output: The amount of integers which are still at the exact same index, after rotating the digits in each integer its index amount of times towards the left and sorting the modified list again. Example: Input: [8,49,73,102,259,762,2782,3383,9217,37846,89487,7471788]...
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
Using the shortest JS (ES5) code possible, as measured in number of characters, gather all the ids on a page for foobar elements into a comma-delimited string. For example: <div> <foobar id="456"></foobar> <foobar id="aaa"></foobar> <foobar id="987"></foobar> <div> Should give "456,aaa,987" You cannot use ES6 o...
stackexchange_codegolf
What are some tips on how to shorten this code even further? The code is meant to compute the parallel resistance of an electric circuit. Using scanf float r;main(){float a;scanf("%f",&a);r+=1/a;printf("%f",1/r);main();} Using command-line arguments #include<stdlib.h> float r;main(c,v)char**v;{for(int i=1;i<c;)r+=1/at...
stackexchange_codegolf
As a celebration of good old Notepad, we are going to treat carriage returns and line feeds as what they originally meant, rather than what they are (ab-)used for today. Given a string consisting of printable ASCII plus line feeds (␊; LF; esc \n; hex 0A; dec 10) and carriage returns (␍; CR; esc \r; hex 0D; dec 13), cau...
stackexchange_codegolf
Challenge: Your job is to create a simple interpreter for a simple golfing language. Input: Input will be in the form of string separated by spaces. You can replace space separation with what you want Output: Output the result (a number or a string) obtained after performing all operations. If there are more than on...
stackexchange_codegolf
This is my 12th question, so I thought of this idea. Goal: Output 12, with any preceding or trailing whitespace permitted In as many languages as possible (where different versions or flags count as the same language) Without using any numbers The criteria for a valid programming language are the same as those of The ...
stackexchange_codegolf
Given a decimal integer n as input, output the smallest (in terms of absolute value) decimal integer m such that the absolute value of n-m is a binary integer (composed only of 1s and 0s). n and m can be any integer, positive or negative. Example Let n = 702. The closest binary integer is 1000 = |702 - (-298)|, so m = ...
stackexchange_codegolf
Your regex will receive a string of the form !XX! #<extra> where X is any hexadecimal digit (0-9 and A-F capital letters only), and <extra> is a character sequence to your choosing. (perhaps something like 0123456789ABCDEF0 could be useful?) You may use any regex flavour. Scoring will be calculated as: find regex len...
stackexchange_codegolf
Unsurprisingly, fibonacci primes are primes that are also Fibonacci numbers. There are currently 34 known Fibonacci primes and an additional 15 probable Fibonacci primes. For the purpose of this challenge, the Fibonacci numbers are the sequence \$F_n\$ defined as \$F_1 = 1\$, \$F_2 = 1\$, and \$F_n = F_{n-1} + F_{n-2}\...
stackexchange_codegolf
The Cantor function is continuous everywhere and constant almost everywhere, but has an average slope of 1: The function can be found recursively: \$f_0(x)=x\$ \$f_{n+1}(x)=\left\{\begin{matrix}\frac{1}{2}f_n(3x)&x\in[0,\frac{1}{3})\\ \frac{1}{2}&x\in[\frac{1}{3},\frac{2}{3})\\ \frac{1}{2}+\frac{1}{2}f_n(3x-2)&x\in[\f...
stackexchange_codegolf
May this challenge serve as (another) tribute to Stan Lee, who passed away aged 95. Stan Lee has left us an invaluable legacy and a peculiar catch word: Excelsior. So here's a small challenge based on what he said it was its meaning: Finally, what does “Excelsior” mean? “Upward and onward to greater glory!” That’s wh...
stackexchange_codegolf
Some numbers, such as \$14241\$, are palindromes in base 10: if you write the digits in reverse order, you get the same number. Some numbers are the sum of 2 palindromes; for example, \$110=88+22\$, or \$2380=939+1441\$. For other numbers, 2 palindromes are not enough; for example, 21 cannot be written as the sum of 2 ...
stackexchange_codegolf
You are given a list, L, with the length N. L contains N random positive integer values. You are only able to select from the outer edges of the list (left/right), and after each selection every value in the remaining list increase by a factor of the current selection. The goal is to maximize the total sum of the selec...
stackexchange_codegolf
Assumption A cigarette can be made by combining four cigarette butts. Cigarette butts last infinitely until smoked. Explanation Say you have 31 butts. That means, you can make 7 cigarettes from 28 butts and have 3 left over. Now, these 7 cigarettes will yield 7 butts when you're done smoking them. That means you have 3...
stackexchange_codegolf
This is a cross-post of a problem I posted to anarchy golf: http://golf.shinh.org/p.rb?tails Given two integers \$ n \$ and \$ k \$ \$ (0 \le k \le n) \$, count the number of combinations of \$ n \$ coin tosses with at least \$ k \$ tails in a row. For example, if \$ n = 3 \$ and \$ k = 2 \$, the answer is \$ 3 \$: HHH...
stackexchange_codegolf
Because of this, you need a better way of working out if a phrase is an acronym of a word. You also think it would be worthwhile to see if the phrase and word in question are recursive acronyms. Your task: Given a word and then a phrase separated by a line, output if the phrase is an acronym and then if it is a recursi...
stackexchange_codegolf
This: is a Glider. In Conway's Game of Life, the glider is a famous pattern that rapidly traverses across the board. For today's challenge, we are going to draw an ASCII art Game of Life Board, and place a glider on it. The board we are starting with is this: |_|_|_|_|_|_|_|_|_|_| |_|_|_|_|_|_|_|_|_|_| |_|_|_|_|_|_|_|...
stackexchange_codegolf
Task: Input will consist of some text, with nested [] separating some of it into nested groups: abc[d[fgijk]nopq]rst[u[v[[w]]]xy[[[z]]]] Your task is to remove all brackets, and everything wrapped in an odd number of brackets. For example, a[b]c would remove the [], and the b inside of it. a[[b]]c, however, would only...
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
Challenge Generate \$n-1\$ consecutive composite numbers using this prime gap formula $$n!+2,n!+3,...,n!+n$$ Input An integer \$n\$ such that \$3 \leq n \leq 50 \$. Output Sequence of \$n-1\$ consecutive composite numbers. Example Input 3 Output 8 9 Rules Output should be in integer format. Test Cases For \$n > 20\...
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
Cop's thread here In this cops-and-robbers challenge cops will think of a positive integer. They will then write a program or function that outputs one value when provided the number as input and another value for all other positive integer inputs. Cops will then reveal the program in an answer keeping the number a...
stackexchange_codegolf
Multiplicative Persistence Multiply all the digits in a number Repeat until you have a single digit left As explained by Numberphile: Numberphile "What's special about 277777788888899?" Numberphile "Multiplicative Persistence (extra footage)" Example 277777788888899 → 2x7x7x7x7x7x7x8x8x8x8x8x8x9x9 = 4996238671872 ...
stackexchange_codegolf
Define the function f(n) for a positive integer n as follows: n / 2, if n is even 3 * n + 1, if n is odd If you repeatedly apply this function to any n greater than 0, the result always seems to converge to 1 (though nobody's been able to prove that yet). This property is known as the Collatz Conjecture. Define an in...
stackexchange_codegolf
What is the shortest selector (by character count) to select ALL html elements on a web page, without using asterisk (*)? Some examples are the following: a,:not(a) /*9 chars*/ :nth-child(n) /*12 chars*/ :link,:not(:link) /*17 chars*/
stackexchange_codegolf
Your task is to make a bidirectional compressor. It takes a list of bytes as input and returns a list of bytes as output. It has the property than whenever it is iterated twice it returns the original input. In other words, if f is your program as a function, then f(f(x))=x for all x. Now, since this is a "compressor",...
stackexchange_codegolf
Usually, it is said that "Doing X without Y" can be a trap to beginners writing challenges (source). However, I am cocky and think that I can definitely make an X without any Ys. Randomly. Oh yes, this will be good. Challenge: Given an odd integer n greater than or equal to 1, output an ex of side length n made of rand...
stackexchange_codegolf
Since Euclid, we have known that there are infinitely many primes. The argument is by contradiction: If there are only finitely many, let's say \$p_1,p_2,...,p_n\$, then surely \$m:=p_1\cdot p_2\cdot...\cdot p_n+1\$ is not divisible by any of these primes, so its prime factorization must yield a new prime that was not ...
stackexchange_codegolf
Given a strictly positive integer, N, produce an output satisfying the following: Produce an array of length N. Every string (i.e. "word") in the array is of length N. Every letter in the word is unique. Every first letter of the words are unique between each other. The remaining items of each word are equal to each o...
stackexchange_codegolf
Challenge Display Inky the ghost from Pac-Man using only ANSI escape codes. Here's a text representation of the image B B B B B C C C C B B B B B B B B C C C C C C C C B B B B B C C C C C C C C C C B B B C W W C C C C W W C C C B B W W W W C C W W W W C C B B E E W W C C E E W W C C B C E E W W C C E E W W C C C C C W...
stackexchange_codegolf
Background In JIS X 0208 a 94 by 94 map (kuten (区点)) is defined to encode Chinese characters (kanji), phonetic moras (kana) and other symbols. Along with this standard there are 3 different encodings that maintain 1-1 correspondences with the map, namely JIS, Shift_JIS and EUC. These encodings take 2 bytes for each cha...
stackexchange_codegolf
Given an integer, output a truthy value if it is the same upside-down (rotated 180°) or a falsy value otherwise. 0, 1, and 8 have rotational symmetry. 6 becomes 9 and vice versa. Sequence of numbers producing truthy results: OEIS A000787 0, 1, 8, 11, 69, 88, 96, 101, 111, 181, 609, 619, 689, 808, 818, 888, 906, 916, 98...
stackexchange_codegolf
Can you imagine solving the New York Times crossword puzzle without any clues? Maybe not with all of the creativity and new words and phrases appearing in modern crosswords, but with a fixed word list there's some hope. In this challenge, you create a crossword puzzle grid in which this is theoretically possible. The...
stackexchange_codegolf
Definition For any \$a\equiv1\ (\text{mod }8)\$ and \$n\ge3\$, there are exactly 4 roots to the equation \$x^2\equiv a\ (\text{mod }2^n)\$. Now, let \$x_k(a)\$ be the smallest root to the equation \$x^2\equiv a\ (\text{mod }2^k)\$, then $$\{x_3(a),x_4(a),x_5(a),x_6(a),\cdots\}$$ is a smallest square root sequence (SSRS...
stackexchange_codegolf
This is a code golf. The smallest amount of bytes wins! :) What you need to do You're on Deep Space Nine, a Cardassian outpost taken over by the Federation, in the year 2374. The Borg, a superior race, have collapsed your shields and assimilated half of your crew. However, you have important classified information on y...
stackexchange_codegolf
Challenge Sandbox post Given a positive integer (K) Output a uniformly-random integer (Y) between [0, K). If Y > 0 Assume K = Y and repeat the process until Y = 0. Rules Input must be printed at first Output format as you wish Your program must finish. 0 must be the final output, Optionally an empty line instead 0
stackexchange_codegolf
In this challenge, you'll take an answer as input, and print the answer before it. If the answer passed as input is the first answer, print your own submission's source. You'll be passed any answer in the chain up to and including your own answer, but none after it in the chain. For example, if the first submission is ...
stackexchange_codegolf
Challenge Challenge is writing a program that takes a positive numbers a and a nonzero number b and outputs a^b (a raised to the power b). You can only use + - * / abs() as mathematical functions/operators. These can only be applied to scalar values, but not to whole lists or arrays. Examples: 1.234 ^ 5.678 = 3.29980...
stackexchange_codegolf
Hexcells is a game based off of Minesweeper played on hexagons. (Full disclosure: I have nothing to do with Hexcells. In fact I don't really like the game.) Most of Hexcells rules can be pretty easily expressed in Generalized Minesweeper (Minesweeper played on an arbitrary graph). The one that is most difficult is th...
stackexchange_codegolf
I noticed that in Microsoft Word, single quotations are either ‘ or ’, but not in Notepad. Your task today is: given a string q, convert all the ' characters (only) to ‘ or ’, according to these rules, and then output it: If the character before the quote is a space, and after it comes a character, it becomes ‘ If the...
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
Over is a higher-order function in multiple languages such as APL (⍥). It takes 2 functions and 2 values as arguments, applies the first function to both values, then applies the second to their result. For example, using ⍥ to represent Over: 1 ²⍥+ 2 We would first calculate ² of each argument: 1² = 1 and 2² = 4. We t...
stackexchange_codegolf
Your task is to create a program that, when run, returns itself as output (this is known as a quine). However, this quine must, when it is copied n times, returns the quine, but with each of its characters duplicated in place n times, where n is a positive integer. If your original program is Derp: Derp -> Derp (must r...
stackexchange_codegolf
Husk is a quite new golfing language, created by PPCG users Leo and Zgarb. It has begun being more and more competitive, often staying close or even beating languages known to be very terse, such as Jelly and 05AB1E. Let's list some of the golfing techniques that are somewhat specific to Husk. As always, please post on...
stackexchange_codegolf
Task: You are an amazing programmer and Stackoverflow-answerer, and you decide to answer every question with a bounty on Stackoverflow. You are so good, that you manage to get all the bounties in all the questions. While you wait for the rep to come flooding in, you write a program that goes and find out what the total...
stackexchange_codegolf
Task Write a function or program that takes n as a parameter and prints the first n self-divisors. Definition of Self-divisor A positive integer is called a “self-divisor” if every decimal digit of the number is a divisor of the number, that is, the number is evenly divisible by each and every one of its digits. Exampl...
stackexchange_codegolf
UPDATE: The gist-files are updated (including new submissions) as the Controller.java did not catch Exceptions (only errors). It does now catch errors and exceptions and also prints them. This challenge consists of two threads, this is the cat thread, the catcher thread can be found here. The controller can be download...
stackexchange_codegolf
Task similar to this one. Take a string of ASCII characters and convert it to base-3 equivalents separated by a space. For example: Hello, world! Should be converted to 02200 10202 11000 11000 11010 01122 01012 11102 11010 11020 11000 10201 01020 The output should only contain numbers with the same number of digits. ...
stackexchange_codegolf
Inspired by Is it double speak?, I devised a harder challenge. Given a string, determine if the string is n-speak, for any \$n\geq 2\$. N-speak is defined by repeating each letter \$n\$ times. With \$n = 4\$, the string Hello is transformed to HHHHeeeelllllllloooo. Your goal is to figure out if the input is a valid out...
stackexchange_codegolf
Let's say I have a condition expression x and that I want to check if it is TRUE or FALSE depending on the value of a boolean y: y ? x : !x Is there a way to express it without repeating x expression? Something like how we can get a number or its opposite depending on a bool, without repeating the number in the expres...
stackexchange_codegolf
Perhaps something like this is here already, but I couldn't find it. It is not the same as Aligning Lines!. Example: Input: 98.6 $2,750.17 -$23 -86 3,120,487.19 Output: 98.6 $2,750.17 -$23 -86 3,120,487.19 Note that .6 isn't right-padded to .60 or .6 . Input: A list/array of strings (or lines fr...
stackexchange_codegolf
In this challenge, the goal is to find the values of some variables after a number of assignments are done. An example input: a = 5 b = 4 c = a = b a = 2 b = a This would result in: a = 2 b = 2 c = 4 Each statement will be one of the following: A variable name ([a-z_]+) A numeric value ([0-9]+) An assignment operati...
stackexchange_codegolf
This challenge is inspired by xkcd: Challenge: You'll simulate the copying a large file (1 Gigabyte). The transfer rate will vary between 10 kB/second to 100 MB/second. Your task is to output the time remaining of the file transfer. The output should look like: Time remaining: 03:12 (meaning it's 3 minutes and 12 s...
stackexchange_codegolf
In Chess, a Knight on grid \$(x, y)\$ may move to \$(x-2, y-1)\$, \$(x-2, y+1)\$, \$(x-1, y-2)\$, \$(x-1, y+2)\$, \$(x+1, y-2)\$, \$(x+1, y+2)\$, \$(x+2, y-1)\$ or \$(x+2, y+1)\$ in one step. Imagine an infinite chessboard with only a Knight on \$(0, 0)\$: How many steps is required for moving a Knight from \$(0, 0)\$...
stackexchange_codegolf
"Buzzing" Bill is a well respected beaver. He is the hardest working in his home dam. He was a strong beaver and was able to lift more logs than anyone at the dam. Unfortunately Buzzing Bill's career came to an end in a tragic accident. Being such a prominent figure in his town, the Beaver newspaper wanted to write a ...
stackexchange_codegolf
If we have a list of integers we can "squish" one of them by: decrementing it replacing adjacent values with its new value For example in this list: [1,2,8,3,6] If we squish the 8 we get: [1,7,7,7,6] The question is: Given a starting array, what is the largest we can make its sum by repeatedly squishing values? For...
stackexchange_codegolf
For this challenge a "binary tree" is a rooted tree where each node has 0 children (leaf) or 2. The children of a node are unordered, meaning that while you might draw the tree with left and right children there isn't a distinction between them and mirroring the tree or a sub-tree does not produce a new tree. In this...
stackexchange_codegolf
Sandbox Adapted from exercise 8 of 100 little Keg exercises String manipulation is a very important part of any programming language. Consequently, that is what this challenge is about. The Challenge I want you to write a program that: Takes a series of characters as input and, Then takes another input (integer/letter...
stackexchange_codegolf
Given a non-empty string (or an integer, or a list/array if you prefer) composed exclusively of digits in the range [1-9], your task is to write a function (or a whole program) that applies a "Match-3 type of rule" from left to right and outputs the resulting string, like this : [parameter] "12223" -> [returned value] ...
stackexchange_codegolf
Inspired by certain puzzles on Flow Free: Warps. Background We all know that L-triominos can't tile the 3x3 board, and P-pentominos can't tile the 5x5 board. But the situation changes if we allow the board to wrap around in both dimensions: L-triominos can tile 3x3 toroidal grid The 3rd tile wraps around through all fo...
stackexchange_codegolf
There was a previous perceptron question but it was closed. Also it required a lot of extra stuff that's not normally part of the perception algorithm like I know it. This question will be much simpler The Perceptron is a extremely basic classification algorithm. While it still has some limited use it's been mostly ove...
stackexchange_codegolf