instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Here's an advanced version of the Count the Liberties challenge. The definitions of the terms liberty and group are the same as the previous challenge, so have a look at the previous one for details, but briefly put, A group is a group of stones that are connected horizontally or vertically. Liberty is the number of e...
stackexchange_codegolf
Your task is to make a program in L that takes n as an input number, output a program p in L that prints its own first n characters. Rules The program p has to be irreducible, See an example below. PAY ATTENTION TO THIS RULE: If a program takes an input as n, the first n characters of the output would be the same as...
stackexchange_codegolf
Draw the ionising-radiation-hazard-symbol in an arbitrary colour on a distinctly coloured background. The specific proportions were published in the June 27th 1974 issue of the Federal Register of the US Government. Details As output, writing to a file (raster and vector formats are permitted) or displaying on the scr...
stackexchange_codegolf
Write a script that outputs A to stdout infinitely. There should be no newlines or separators between the characters. Standard loopholes apply. This is code-golf. The shortest solution in each language wins.
stackexchange_codegolf
Taking in Input Define a function f as follows: IF x < 0: f(x) = -√|x| ELSE: f(x) = √x In your programs/functions, each point (x, y) given as input will correspond to the point (f(x), f(y)). For example, if the points (4, -2) and (-1, 5) are given as input, your program will be dealing with the points (2, -√2)...
stackexchange_codegolf
Introduction: I have loads of different ciphers stored in a document I once compiled as a kid, I picked a few of the ones I thought were best suitable for challenges (not too trivial, and not too hard) and transformed them into challenges. Most of them are still in the sandbox, and I'm not sure yet whether I'll post al...
stackexchange_codegolf
It is easy to describe a finite state machine that recognizes multiples of 9: keep track of the digit sum (mod 9) and add whatever digit is accepted next. Such a FSM has only 9 states, very simple! By the equivalence between FSM-recognizability and regular languages, there is a regular expression for multiples of 9. Ho...
stackexchange_codegolf
Generator functions This gives the context for why this challenge came to life. Feel free to ignore. Generator functions are a nice way of encoding the solution to a problem of combinatorics. You just write some polynomials, multiply them and then your solution is the coefficient of one of the terms. For example, how m...
stackexchange_codegolf
Your task is to make a program in L that takes n as an input number, output a program p in L that prints its own first n characters. Rules The program p has to be irreducible, See an example below. PAY ATTENTION TO THIS RULE: If a program takes an input as n, the first n characters of the output would be the same as...
stackexchange_codegolf
Dart is an object oriented programming language borrowing from both Java and Javascript. What general tips do you have for golfing in Dart? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Dart (e.g. "remove comments" is not an answer). Please post one ti...
stackexchange_codegolf
Let's define a self-contained number as a positive integer, whose digits appear in runs of length equal to themselves only. In other words, any decimal digit d (excluding 0) occurs only in runs of length exactly d. Task You can choose any of the three methods listed below: Given an integer n, output the nth (either 0 ...
stackexchange_codegolf
Given an input string, write a program that outputs the total number of lines and curves it has. The Challenge Take input from STDIN, or any other input method. Output to STDOUT, or any other output method, the total number of lines and curves contained in the string, in that order, based on the below table in the cod...
stackexchange_codegolf
This was originally a pure mathematics question, but I think I've got the best chance for an answer here. The Challenge For concreteness, consider Peano Arithmetic (PA). For some language L of your choosing, construct a computer program of length at most N bits in L such that: If it terminates, it outputs a number th...
stackexchange_codegolf
Introduction: (Source: Wikipedia) When we look at a rainbow it will always have the colors from top to bottom: Red; orange; yellow; green; blue; indigo; violet If we look at these individual rings, the red ring is of course bigger than the violet ring. In addition, it's also possible to have two or even three rainbow ...
stackexchange_codegolf
Lets define a pointer sequence to be any sequence such that a(n) = a((n-1)-(a(n-1))) forall n greater than some finite number. For example if our sequence begun with 3 2 1 Our next term would be 2, because a(n-1) = 1, (n-1)-1 = 1, a(1) = 2 (this example is zero index however it does not matter what index you use the...
stackexchange_codegolf
Definition: a prime power is a natural number that can be expressed in the form pn where p is a prime and n is a natural number. Task: Given a prime power pn > 1, return the prime p. Testcases: input output 9 3 16 2 343 7 2687 2687 59049 3 Scoring: This is code-golf. Shortest answer in bytes wins.
stackexchange_codegolf
Challenge: Given an index integer n, either output the n'th item in this sequence, or output the sequence up to and including index n: 25,25,7,28,29,20,21,22,23,14,35,26,7,28,29,20,16,29,12,15,28,21,14,17,30,13,16,29,12,15,28,21,10,6,12,18,15,11,7,13,19,17,13,9,15,21,18,14,10,16,22,19,15,11,17,23,20,16,12,18,24,21,17,1...
stackexchange_codegolf
The sound of the theremin has been immortalized in The Beach Boys song Good Vibrations. Many also associate its sound with the theme for the original series of Star Trek, though apparently it was a soprano's emulation. This challenge requires you to implement a theremin. Input Take 2 dimensional input from a mouse or...
stackexchange_codegolf
We can write mathematical expressions using the standard math operators (,),+,*,/,- available pretty much universally. We allow the symbols a, b, c, d and integers (e.g. 1, 45, etc.) but will restrict to just these four symbols. (Bonus points if you can handle more.) The goal is to take an expression as input and outpu...
stackexchange_codegolf
Actually not inspired neither by Atbash Self Palindromes nor by Generalized Gematria Calculator. Given a string s of length n, output the Revu'a sequence, which is the first character of s, the first two characters of s, ... the first n–2 characters of s, the first n–1 characters of s, the entire s. The string will onl...
stackexchange_codegolf
Your task is to decompose a number using the format below. This is similar to base conversion, except that instead of listing the digits in the base, you list the values, such that the list adds up to the input. If the given base is \$n\$, then each number in the list must be in the form of \$k\times n^m\$, where \$0\l...
stackexchange_codegolf
Can you recover a sequence of letters from a sequence of dots and dashes? In Morse code, x is represented by -..-, but without the help of spaces, -..---.-... could represent xmas, or dole, or teettteteee, etc. I took the lyrics from "Rudolph, the Red-Nosed Reindeer" to make the following sequence of letters: youknowda...
stackexchange_codegolf
In this task you are given an odd number of white balls and the same number of black balls. The task is to count all the ways of putting the balls into bins so that in each bin there is an odd number of each color. For example, say we have 3 white balls. The different ways are: (wwwbbb) (wb)(wb)(wb) for the two differ...
stackexchange_codegolf
Your task is to take an ASCII art image and output it rotated clockwise by 45 degrees and scaled by a factor of \$\sqrt 2\$. The scaling comes from using a lattice pattern which introduces space between the characters. To explain it visually, a \$3 \times 3\$ block would be processed like so: 123 456 789 becomes 1 ...
stackexchange_codegolf
A fixed-point combinator is a higher order function \$\mathrm{fix}\$ that returns the fixed point of its argument function. If the function \$f\$ has one or more fixed points, then $$\mathrm{fix} f=f(\mathrm{fix} f).$$ The combinator \$Y\$ has such properties. Encoded in lambda calculus: $$Y=\lambda f.(\lambda x.f(x x)...
stackexchange_codegolf
Inspired by this question on AskUbuntu. Your job is extremely simple. Take the PATH environment variable (echo $PATH) and export it such that each entry (separated by the : character) is on its own line. For example, if the PATH is /bin:/usr/bin:/usr/local/bin, your program should output: /bin /usr/bin /usr/local/bin ...
stackexchange_codegolf
Related. Given a printable ASCII string, split it into a list of non-empty strings with a new sub-string beginning every time a character, which has not previously been seen in the same case, occurs. Examples "mississippi" → ["m","i","ssissi","ppi"] "P P & C G" → ["P"," P ","& ","C ","G"] "AAA" → ["AAA"] "Adam" → ["...
stackexchange_codegolf
This is an answer-chaining question, which means that all answers are affected by those before them. The task The n-th answer to this question must run in all languages that are present in answers before it. They need not run in order, but must print the name of the language currently running, reversed. Additional rule...
stackexchange_codegolf
The title pretty much describes it all. Given as input a \$n \times m\$ matrix and an integer \$i\$ create a complete function/program that returns the matrix \$i\$ times clockwise rotated by \$90^\circ\$. Rules: as matrix you can use any convenient representation you like e.g. a list of lists etc... matrix values can...
stackexchange_codegolf
Given a string, like potatocarrot, break it into the smallest number of substrings possible. These substrings can consist either be a single character, or one of a list of words passed as input. For example, if [carrot, potato] was the input, the optimal way to break the string up would be [potato][carrot]. If the list...
stackexchange_codegolf
The first Letters, Get Moving! was very popular, but had limited participation. This one will be easier to solve, but hopefully involve some tricks in golfing. You are given a string of only lowercase letters. For each letter, with position in the alphabet m, move it so it becomes the mth letter from the end. If the va...
stackexchange_codegolf
Modern hardware can perform multiplication very fast in a constant latency of 3~4 cycles. But some tiny chips for embedded environments sometimes lack hardware multiplication, which has to be emulated by a series of instructions. Goal You are given a primitive CPU with a set of basic operations. Your job is to implemen...
stackexchange_codegolf
Part of Advent of Code Golf 2021 event. See the linked meta post for details. The story continues from AoC2015 Day 5, Part 2. Santa needs help figuring out which strings in his text file are naughty or nice. He has already tried two sets of rules, but they're totally ad-hoc, cumbersome, and janky, so he comes up with ...
stackexchange_codegolf
This is a byte sized challenge where you have to convert an input temperature in one of the three units (Celsius, Kelvin and Fahrenheit) to the other two. Input You would be provided with a temperature as a number followed by a unit (separated by space). The temperature can be an integer or a floating point number (23 ...
stackexchange_codegolf
Bounty One of the convincing conjectures, by Loopy Walt is, maxlib(n) = 0, if n = 1 2, if n = 2 6, if n = 3 (2n - 1)⌊n / 3⌋, if n % 3 = 0 (2n - 1)⌊n / 3⌋ + n, if n % 3 = 2 2n⌊n / 3⌋ + 1, otherwise Loopy Walt's post below explains how this conjecture is derive...
stackexchange_codegolf
As a big fan of the Lost TV series, I always got intrigued by the sequence of numbers that repetitively appears on the episodes. These numbers are: \$ 4, 8, 15, 16, 23, 42\$ (A104101) Using any programming language, write a code that outputs these numbers. Scoring: Shortest answer wins The output must not contain any ...
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
Challenge The goal of this challenge is to make a function that takes two paragraphs and output a concatenated result with removing the duplicated overlapped lines due to redundancy (but a single copy of the part of overlapped lines should be kept to avoid information loss). Each input paragraph is with the follows spe...
stackexchange_codegolf
Your task Given a simple regular expression, you have to count how many strings of length n have a match of length n with the given simple regex. This will just be a subset of regexs. Like, no lookaheads or named groups or recursion or whatever weird things regexs have. Simple regular expression For the purposes of thi...
stackexchange_codegolf
Given two numbers in tape location #0 and tape location #1 in Brainfuck, compute their product into another tape location (specify with answer). Optimize for the least amount of time-units used, where the interpretation of any command uses one time-unit. As example, here is a quick C++ program to determine the number o...
stackexchange_codegolf
Intro This is based on an actual problem I recently faced while making a computer game and I thought it would make for a nice round of code-golf. There are seven main spectral classes of star which put out varying amounts of heat. The geology of planets around a star are greatly influenced by the amount of heat receive...
stackexchange_codegolf
You are to make a program that can check the syntax of programs of its same language. For example, if you do it in python, it checks python syntax. Your program will receive a program on standard input, and verify whether or not its syntax is correct. If it is correct, output just "true" on standard output. If not, out...
stackexchange_codegolf
Task Any one of these two: Determine if a given position (an ordered non-empty collection of integers in the range ‒8 to 8, or ‒7 to 7 if you want) is a valid Dimensional Chess position. List all the valid positions in any order. Make sure to describe your input (if not listing all) and output formats. The 2368 vali...
stackexchange_codegolf
Inspired by this answer (emphasis mine): We will play a game. Suppose you have some number x. You start with x and then you can add, subtract, multiply, or divide by any integer, except zero. You can also multiply by x. You can do these things as many times as you want. If the total becomes zero, you win. For example,...
stackexchange_codegolf
Your program is supposed to create a full red screen in MSDOS. The source of the binary (.com file) must be 5 bytes or less. No wild assumptions, the binary must work in MsDos, DosBox, and FreeDos alike. For winning, you have to post x86 assembler code which can be assembled with NASM (FASM) or directly the hex code of...
stackexchange_codegolf
Develop a program to check if a given word is part of a language defined by the following rules: The language has a set of rules. The empty string is considered a valid word in the language. Two words from the language can be concatenated to create a new word in the language. If X is a word in the language, then "A" +...
stackexchange_codegolf
Given a number n, Output an ordered list of 1-based indices falling on either of the diagonals of an n*n square matrix. Example: For an input of 3: The square shall be: 1 2 3 4 5 6 7 8 9 Now we select all the indices represented by \, / or X (# or non-diagonal positions are rejected) \ # / # X # / # \ The output sha...
stackexchange_codegolf
Given two input integers, a >= 4 and b >= 2, output an ASCII square of size a x a. The twist is the square must be constructed of b 3 x 3 squares formed like the following: ### # # ### You can use any ASCII printable character (except whitespace) to construct the smaller squares. I'm using # for visibility and consist...
stackexchange_codegolf
If I need to get the number of diagonal squares in all directions: I do the following formula 2 N − 2 − |x − y| − |x + y − N − 1| The above example has 13 and that's what the formula gives. Now, what if you wanted to get the diagonal squares, but only in one direction? The top right has 4 squares, the top left has 3, ...
stackexchange_codegolf
Fluff After taking a look at deadfish, I decided it sucked, so I came up with a new (and easier) variant of it: imnotdeadfish. As with its predecessor, there are 4 commands and an accumulator which begins at 0: + # increment the accumulator - # decrement the accumulator s # square the accumulator o # output the accumul...
stackexchange_codegolf
For example, in traditional web hexadecimal, a certain base-16 number represents an RGB value. For example, 45A19C equals (69,161,156) in RGB. You'll be converting from that number to RGB value, however, instead you'll be given that number in base-10 rather than base 16. So in the example used above, 45A19C would equa...
stackexchange_codegolf
Rules In this challenge, I'm going to redefine the definition of "quotes" a bit. Quotation marks (AKA quotes) are any identical characters used in pairs in various writing systems to set off direct speech, a quotation, or a phrase. The pair consists of an opening quotation mark and a closing quotation mark, which is t...
stackexchange_codegolf
Task Given a positive integer number and a threshold, split into every possible way without generating any numbers above the threshold. Examples Input: 15008 Threshold: 400 Valid Output: [[1, 5, 0, 0, 8], [15, 0, 0, 8] [1, 50, 0, 8], [150, 0, 8]] Invalid outputs: [[1, 5, 0, 0, 8], [15, 0, 0, 8], [150, 0, 8], [1, 500...
stackexchange_codegolf
Prompt: You are given two sets of XY coordinates along with two angles (all are floats): X1 Y1 A1 X2 Y2 A2. The angles are relative to world coordinates: 0 being straight up or north and going clockwise. Your program or function has to return a set of two floats of the XY coordinates the two angles cross at. Example: ...
stackexchange_codegolf
Introduction In the strategy game Starcraft 2, there are three "races" to choose from: Terran, Zerg, and Protoss. In this challenge we will be focusing on the Protoss and the iconic phrase "You must construct additional pylons!" This message is stated when you run out of supply to build your army. So, to help out the S...
stackexchange_codegolf
Given a ragged list of positive integers find the size of the largest list contained somewhere in it. For example: [1,[1,[8,2,[1,2],5,4,9]],2,[],3] Here the answer is 6 because one of the lists has 6 elements and all other lists have fewer. [1,[1,[8,2,[1,2],5,4,9]],2,[],3] ^ ^ ^ ^ ^ ^ The length doesn't ca...
stackexchange_codegolf
Given an odd integer N (5 <= N <= 51), generate a maze with side length N that follows the following requirements: The maze must be composed of the characters | - and +. It must use the | character as a vertical wall, the - character as a horizontal wall, and if that wall turns, the character + should be used. The wid...
stackexchange_codegolf
Commentscript is a variant on Javascript that I made up for the purpose of this question. Only commented-out code is evaluated. Javascript has two types of comments: // this is a single line comment, which starts with `//` and ends on a newline. /* This is a multiline comment. It starts with /* and ends with */ Examp...
stackexchange_codegolf
In Minecraft, pistons are blocks that can move other blocks. However, they can only move at most twelve blocks, and won't work at all if any obsidian is in the way. Also, slime blocks are sticky and stick to other blocks, except for obsidian. Your challenge Take as input a 5x5 matrix or similar, containing one piston a...
stackexchange_codegolf
Although what is a Pascal's triangle is well-known and we already can generate it, the task is now different: Output \$n\$ first lines of the Pascal's triangle as colored bricks. Color number is computed as maximal power of \$d\$, that divides the needed-to-color element or \$7\$ if power is more than \$7\$. Numbered c...
stackexchange_codegolf
Your task is to create a program that is to mimic Big Ben (Twitter). Task Whenever a new hour has begun (according to your computer's local time or UTC), you have to output BONG repeated hour times (with a space between the words). For example, when it's 3 o' clock, you have to output BONG BONG BONG. The time format fo...
stackexchange_codegolf
I only very recently discovered code golf and just found this part of the Stackexchange network, and naturally after looking at so many clever answers, I feel inferior. Inner me knows I'll get better over time, but inner me is also vain and needs validation. At the same time, I don't take kindly to pandering, so you'd ...
stackexchange_codegolf
Challenge Given a graphical input of a shape, determine how many holes there are in it. Not Duplicate This question was marked as a possible duplicate of Count Islands. I believe this challenge is different from the Count Island challenge because in this one, you have to figure out how to eliminate blocks that touch th...
stackexchange_codegolf
A shape is chiral if no amount of rotation can make it look like it's mirror image. In this puzzle we will be writing chiral computer programs. For this puzzle we will think of a program as a rectangular matrix of characters. As such all solutions to this challenge must be rectangular (that is all lines must be of th...
stackexchange_codegolf
Write a program that outputs its source code in reverse when run, and outputs its source forwards when I reverse the source. If your program is "abcd", when run with no arguments it should output "dcba", and when I run the program "dcba" it should output "abcd." This is a quine challenge, so both your forwards and reve...
stackexchange_codegolf
Background Stick Bomber is a two-player game I just made up. Initially, some sticks are placed in one or more groups, and the sticks in each group are laid out in a straight line. So a configuration with three groups of 3, 5, and 8 sticks each may look like the following. For conciseness, we can call it a (3,5,8) confi...
stackexchange_codegolf
This is alternate of a rip-off of a rip-off of a rip-off of a rip-off of a rip-off of a rip-off. Go upvote those! Your task, if you accept it, is to write a program/function that outputs/returns its input/args. But again, The tricky part is that if I rot-13 your source code, the output must be returned rot-19. Your co...
stackexchange_codegolf
Write a program that outputs its source code in reverse when run, and outputs its source forwards when I reverse the source. If your program is "abcd", when run with no arguments it should output "dcba", and when I run the program "dcba" it should output "abcd." This is a quine challenge, so both your forwards and reve...
stackexchange_codegolf
Introduction In this challenge, I asked you to implement swap encoding. Swap encoding is an encoding method where you iterate through the string, reversing substrings between identical characters. The basic algorithm is: For each character in the string: Check: Does the string contain the character again, after the ins...
stackexchange_codegolf
Your job is to make a sorting algorithm. The catch, you must copy it from Stack Overflow. Your program will take an input array (or equivalency), and output a sorted permutation of the array. Your program must consist solely of copy and pasted code blocks from Stack Overflow. You may not take parts of a code block, n...
stackexchange_codegolf
Let's take a grid of 16x16 printable ASCII characters (code points 0x20 to 0x7E). There are 30-choose-15 paths from the top left to the bottom right corner, making only orthogonal moves, like the following example: ##.............. .#.............. .######......... ......##........ .......##....... ........#....... ......
stackexchange_codegolf
I was browsing Stack Overflow when I saw this post in Puzzling in the hot network questions and decided to make a challenge out of it (all credit goes to the creator of the challenge). Overview A Chess Number is a number that, when converted to base 18, results in a valid chess coordinate pair, where the first characte...
stackexchange_codegolf
Here, x (supplied as input) and n (the result of your computation) are both positive integers. n * x = n shifted. Find n. Here's an example of shifting: 123456789 -> 912345678 abcdefghi -> iabcdefgh (letters = any 0~9 digit) 123 -> 312 Shifting only happens once to the right. Shifting left, e.g. 123456789 -> 234...
stackexchange_codegolf
The positive rational numbers can be shown to be numerable with the following process: Zero has the ordinal 0 Arrange the other numbers in a grid so that row a, column b contains a/b Plot a diagonal zig-zag top right to bottom left Keep a running tally of the unique numbers encountered along the zig-zag Here's a pict...
stackexchange_codegolf
Let \$ A \$ represent the alphabet, such that \$ A_1 = \$ a and \$ A_{26} = \$ z. Let's define that a word \$ W = w_1 w_2 ... w_n \$ (where \$ w_c \in A\$) is in standard order if and only if: \$ w_1 = A_1 \$, and for \$ 2 \le i \le n \$, if \$ w_i = A_x \$ then \$ w_j = A_{x-1} \$ for some \$ j < i \$ and some \$x\$....
stackexchange_codegolf
Task: Given two positive integers, generate a random integer between them (inclusive) and then output all its prime factors. Examples: Input: Random Number: Output: 1,2 2 [2] 12,46 18 [2,9] 142,17 40 [2,2,2,5] Scoring: This is code-golf so the least by...
stackexchange_codegolf
Given an array where each number represent a color. After iterating each item in the array (for each item in the iteration the pointer can also point to the second-item-to-the-right), and the two colors in the iteration is the same, do the following checking: If there is a different color between the pointed colors, th...
stackexchange_codegolf
Related. Given a positive integer \$n\$, output all integers \$b\$ (such that \$1<b<n-1\$) where \$n\$ can be written as the sum of any number of consecutive powers of \$b\$. Example: Let's say \$n=39\$. \$3^1+3^2+3^3\$ \$= 3 + 9 + 27\$ \$= 39\$ This does not work for any other \$b\$, so our output is [3]. Test cases...
stackexchange_codegolf
Background A snake is a path over the cells of a square grid, such that it doesn't touch itself on a side of a unit square. Touching at a corner is allowed. An example snake: ##.#. .#.## ##..# #.### ###.. Some example non-snakes: ###.# #.#.# ##### .#... .#### ### .#. ## ## Challenge Given an empty grid with the two...
stackexchange_codegolf
Spirals are cool , so are numbers, and number spirals are even cooler. But what if I want a specific number, in a specific place using xy coordinates... Challenge Using an infinite spiral moving down first, curling in a counterclockwise manner ex: 6 5 4 7 0 3 8 1 2 9 10 11 Take negative and positive inputs(...
stackexchange_codegolf
Output/print this block of text: 1234567890 2468013579 3691470258 4815926037 5049382716 6172839405 7306295184 8520741963 9753108642 0987654321 Acceptable formats include: Trailing newlines/whitespace List of strings List of lists of characters List of lists of integers However, list of integers is not acceptable bec...
stackexchange_codegolf
We've all done it, well, maybe not, but making your own alien language and numbering system is a staple of especially fantasy writing, but is mostly just a fun activity. The task is simple, take two inputs: An ordered list input of 10 [ten] unique 'numerals' (any printable ASCII character) and interpret them, in order...
stackexchange_codegolf
We've had a lot of quine challenges, but a lot of the quine formats are similar, lets create some variance in our quines. Your task is to create a selection of programs in the same language (at least 2), all of which output their own source code, however, none of these programs can share any characters. For example, if...
stackexchange_codegolf
Task: Given an array of numbers as input (you can choose what subset, such as integers or natural numbers), replace all items with the number of times they appear within the array. As an example, [1, 2, 2, 1, 4, 8, 1] would become [3, 2, 2, 3, 1, 1, 3]. You can take input/produce output as arrays, lists, tuples, or any...
stackexchange_codegolf
The year 2013 had an interesting property: the digits are consecutive when sorted (0123). Let's call this type of number a sortable number: a non-negative integer whose base-10 digits are consecutive after sorting. Unfortunately, this won't happen again until 2031, and after that, not until 2103. Your challenge is to w...
stackexchange_codegolf
Given a positive integer as input, output the smallest positive integer such that appending its digits (in base 10) to the end of the input number will form a prime number. Examples 1 --> 1 2 --> 3 8 --> 3 9 --> 7 11 --> 3 20 --> 11 43 --> 1 134 --> 11 3492 --> 11 3493 --> ...
stackexchange_codegolf
Take a flag, like this one: ----------------------------- | | | | | | |=============+=============| | | | | | | ----------------------------- And a number input: the "wave length" Say the wave length was 5. Then, every 5 ch...
stackexchange_codegolf
What is the shortest sequence of moves that, from the solved state of the cube, creates a pattern that meets the following criteria: 6 colors on each face at most 2 facelets of the same color no adjacent facelets of the same color EDIT: I made up the name of the pattern. I asked this question in 2018 on Mathematics S...
stackexchange_codegolf
Alternatively: Now you're checking with portals! Inspired this challenge I am somewhat of a self-declared Chess Anarchist. That means that when I play chess, en passant is forced (else the brick gets used), double check is mate (and pasta), and all sorts of new pieces and squares are added to the game. One such piece i...
stackexchange_codegolf
Simple challenge: The code must be both valid Lisp and valid Fortran, and must print out "hello world" in both. Note: I've sunk about 5 hours into this at this point, I'm not even sure it's possible at this point... Details: Must be in a single source file. Any version of Fortran and any Lisp are allowed (specify whic...
stackexchange_codegolf
The string abaaba Is a palindrome, meaning it doesn't change when it's reversed. However we can split it in half to make two palindromes aba aba We could also split it up this way: a baab a And all three of those are palindromes. In fact there are only two ways to split the string into smaller strings such that non...
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
Calculate the maximum number of circles of radius r that can fit in a rectangle with width x and height y. Write a function that take r, x and y as input and returns the number of circles that fit in the rectangle.
stackexchange_codegolf
Task You should write a program that when a button is pressed, it outputs a different sound for each key. The keys that you will use are: 1!2"34$5%6^78*9(0qQwWeErtTyYuiIoOpPasSdDfgGhHjJklLzZxcCvVbBnm The notes begin at C and each key above adds one semitone. Lets make it slightly easier for you though. You can choose ...
stackexchange_codegolf
Task Given a matrix, your program/function should output a row-equivalent matrix in checkerboard form ( \$A_{ij}=0\$ if and only if \$i+j\$ is odd). Two matrices are defined to be row-equivalent if and only if one can be obtained from the other by a sequence of elementary row operations (EROs), where each ERO consists ...
stackexchange_codegolf
This question asking us to make a "Cyclic Levenquine" has gone unanswered. So today we will ask a slightly simpler version. In this challenge we will define a K-Levenquine to be a program whose output is Levenshtein distance K from its source. Task Your goal in this challenge is to write a program with some output dif...
stackexchange_codegolf
My job is stacking pebbles into triangular piles. I've only been doing this for a century and it is already pretty boring. The worst part is that I label every pile. I know how to decompose pebbles into piles of maximal size, but I want to minimize the number of piles. Can you help? Task Given an integer, decompose it ...
stackexchange_codegolf
"nimi ale lon toki pona" is a song by YouTuber jan Misali which lists 137 common words in the constructed language Toki Pona. This challenge is not a duplicate of "How high can you count?" or "Alphabet printing challenge" because instead of numbers or single characters, it outputs random (to many programming languages)...
stackexchange_codegolf
Morpion solitaire This is a game that I remember having learnt from my grandparents in my childhood. Initially I didn't know the name. G B has found it to be Join Five (or less ambiguously - Morpion solitaire) with a slightly different starting position. NOTE: it seems that it's kinda known and this problem formulation...
stackexchange_codegolf
I'm working from home and the heat of my laptop on my lap is the only thing keeping me warm. I have a Dell G3 Laptop with an NVidia GEForce GTX CPU. I have tried writing a rust program with 5 threads that calculates and prints the Fibonacci sequence in an infinite unthrottled loop, but that only gave a bit of warmth, a...
stackexchange_codegolf