instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
In this challenge, Turing machines operate on a zero-initialized binary tape that is infinite in both directions. You are given an integer \$N\$, where \$1 \le N \le 20000\$. Your program has to output a Turing machine that takes exactly \$N\$ steps to halt, including the final step. Alternatively, you can write a prog...
stackexchange_codegolf
Background You awake on the ground. Above you is a giant stepped pyramid-like structure. Based on your ancient history lessons, you recognize it as a ziggurat. You have been transported by Dr. Sargostein back into ancient Mesopotamia to play a game. In this King of the Hill Ziggurat challenge, you will write a bot that...
stackexchange_codegolf
In R print(x, digits=n) does something a little complicated. It always shows all the digits to the left of the decimal point and then, if there are any digits to the right it rounds the whole number so that at most n digits are shown. However, leading 0s are not counted. Here are examples to show how the function work...
stackexchange_codegolf
A set is sum-free if no two (not necessarily distinct) elements when added together are part of the set itself. For example, {1, 5, 7} is sum-free, because all members are odd, and two odd numbers when added together are always even. On the other hand, {2, 4, 9, 13} is not sum-free, as either 2 + 2 = 4 or 4 + 9 = 13 ad...
stackexchange_codegolf
Related Goats are great. Everybody loves goats. And they also, for some reason, are an excellent complex ascii art for many languages to have built-ins for. Because of this, I personally feel a catalogue to document just how easily a language can print goats is greatly needed. The Challenge Given an integer input via a...
stackexchange_codegolf
"Talk" is a baroquified accumulator-based language that is created in response to Dennis's quote on talk.tryitonline.net. Waiting for someone to create an esolang called talk. . The "Talk" language has 4 commands: 00 If the accumulator is 0, set the accumulator to 0. 01 If the accumulator is 0, set the accumulator t...
stackexchange_codegolf
My parents have an home theater device. The remote is broken making it incredibly difficult to navigate rightwards in a menu. Most the time it doesn't work but when it does it moves rightwards incredibly quickly. This is obviously frustrating but it is most frustrating when you want to enter a movie title which requi...
stackexchange_codegolf
Given a UTF-16 string, test its endianness. Rules: As long as the input is in UTF-16 without BOM, its type doesn't matter. In C++ on Windows, it can be std::wstring or std::u16string. In Haskell, it can be [Int16] or [Word16]. The endianness is tested by noncharacters. If the input contains a noncharacter, it is in wr...
stackexchange_codegolf
As I'm applying for some jobs whose job advert doesn't state the salary, I imagined a particularly evil interviewer that would give the candidate the possibility to decide their own salary ...by "golfing" it! So it goes simply like that: Without using numbers, write a code that outputs the annual salary you'd like to ...
stackexchange_codegolf
Task Your task is to make the smallest function/program that can, when gives an number N, return/print: the number of possible choices a, b such that \$1 \leq a < b < N\$ and a and b have exactly one common digit in base 10 (there exists a digit, and only one digit, which appears both in a and b, for example 12 and 23,...
stackexchange_codegolf
In: a string without line breaks* Allow the user to edit and submit the line Out: the modified string (optionally with a trailing linebreak) The line editor must at minimum allow the user to: move a visible cursor left and right insert and/or overwrite characters at the cursor position remove characters at the curso...
stackexchange_codegolf
Intro More complex than A square of text since this requires padding and input has unknown data type. Every year, Dyalog Ltd. holds a student competition. The challenge there is to write good APL code. This is a language agnostic code-golf edition of this year's tenth problem. I have explicit permission to post this ch...
stackexchange_codegolf
In as few Unicode characters as possible, print the following (144 characters): 1, 2, 3 o'clock, 4 o'clock rock, 5, 6, 7 o'clock, 8 o'clock rock, 9, 10, 11 o'clock, 12 o'clock rock, We're gonna rock around the clock tonight. You must not use any numbers in your code, except the digit 1.
stackexchange_codegolf
An Séimhiú agus an tUrú In Irish Gaelic (Gaeilge) there are a number of ways that the start of a word can be changed. The most common of these are lenition (an séimhiú) and eclipsis (an t-urú) Lenition involves adding the letter h as the second letter. For example, the word "bean" (woman) would be lenited to "bhean". E...
stackexchange_codegolf
Write a piece of code that takes a string as input, and outputs a piece of code in the same language that, when run, will output the initial input string. It must be able to handle any combination of characters A-Z, a-z, and 0-9. Example in Python: import sys print "print('" + sys.argv[1] + "')" Given the input of te...
stackexchange_codegolf
A narcissistic number is a natural number which is equal to the sum of its digits when each digit is taken to the power of the number digits. For example \$8208 = 8^4 + 2^4 + 0^4 + 8^4\$, so is narcissistic. We'll define a function \$f(x)\$ as the following, for a natural number \$x = d_1d_2\dots d_n\$, where \$d_i\$ i...
stackexchange_codegolf
Lets define the process of crushing an array of numbers. In a crush we read the array left to right. If at a point we encounter two of the same element in a row we remove the first one and double the second one. For example here is the process of crushing the following array [5,2,2,3] ^ [5,2,2,3] ^ [5,2,2,3] ...
stackexchange_codegolf
Given a \$n\$-dimensional vector \$v\$ with real entries, find a closest permutation \$p\$ of \$(1,2,...,n)\$ with respect to the \$l_1\$-distance. Details If it is more convenient, you can use permutations of \$(0,1,...,n-1)\$ instead. If there are multiple closest permutations, you can output any one or alternativel...
stackexchange_codegolf
As in this question, your task – should you choose to accept it – is to calculate the date of Easter Sunday according to the Gregorian Computus (as used in the Catholic Church and most others) when provided with only a year number as input, in as few characters as possible without relying on Easter-specific date functi...
stackexchange_codegolf
Input A single string, which contains no whitespace, as a command-line argument. Output If the string is not a valid algebraic notation pawn promotion, produce no output and exit. If the string is a valid pawn promotion, convert it to ICCF numeric notation and print the result, followed by a newline. A valid algebraic ...
stackexchange_codegolf
Rip-off of a 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 input/argument¹. The tricky part is that if I transpose your source code², the output/result must be transposed too. You may choose which kind of 2D data your so...
stackexchange_codegolf
Write the shortest program to print the non-trivial powers ≤ 2^12 in order non-trivial power means the base and exponent are > 1 Leading whitespace is optional When there are multiple solutions, the order is not important, so 16 = 4^2, 2^4 is ok Sample output: 4 = 2^2 8 = 2^3 9 = 3^2 16 = 2^4, 4^...
stackexchange_codegolf
What? Many programming languages, both practical and esoteric, have functions, methods, etc to convert a given string to a decimal number. This is how the process might work: For each character in the given string. Take the character's ASCII value and subtract it by 48. Multiply the output value by 10. (The output at...
stackexchange_codegolf
Your task is to write a program or function that takes as input a list of positive integers and determines if there are any two integers in the list, that both appear the same number of times. For example the list [1, 2, 3, 2] Has one 1 and one 3 so it satisfies the condition. But the list [3, 2, 2, 1, 2, 3] does not...
stackexchange_codegolf
Chaim Goodman-Strauss, Craig Kaplan, Joseph Myers and David Smith found the following simple (both objectively and subjectively) polygon that tiles the plane, but only aperiodically: Indeed they found a one-parameter family of such aperiodic monotiles or "einsteins". The edges of all tiles in this family meet at 90° o...
stackexchange_codegolf
Let's have a function \$f\$ that takes a string and removes all pairs of adjacent identical characters. For example \$f(a\color{red}{bb}ba\color{red}{cc}) = aba\$ Note that when two pairs overlap we only remove one of them. We will call a string perfectly paired if repeated application eventually yields the empty stri...
stackexchange_codegolf
Disclaimer: No, this is not a joke challenge to reverse a string. Task There is only one operation to support: subtraction (-). You also only have two atoms to support: zero (0) and one (1). Here, the prefix notation -AB is equivalent to the postfix notation AB-, where A and B are expressions. Your task is to (recursiv...
stackexchange_codegolf
I've been a fan of My Little Pony: Friendship Is Magic for a long time, and very early on I created a pony version of myself also called Parcly Taxel (warning: may be too cute to look at). The symbol below is her "cutie mark", which you will be drawing here: Construction All key points of the cutie mark lie on a rotat...
stackexchange_codegolf
Codegolf the hamming code (with distance equals 3)! The sequence looks like this: 0, 7, 25, 30, 42, 45, 51, 52, 75, 76, 82, 85, 97, 102, 120, 127, 385, 390, 408, 415, 427, 428, 434, 437, 458, 461, 467, 468, 480, 487, 505, 510, 642, 645, 667, 668, 680... Task Given n output the first n items in OEIS sequence A075926. Y...
stackexchange_codegolf
Fourward (Introduction) I have an unhealthy obsession with the number 4. I love it so much, in fact, that seeing any other digit is frustrating to me. I therefour wish to create a 'Fourier Transformation': a way to represent any integer value with an expression that uses only the digit 4. Fourmat (Challenge) I wish to ...
stackexchange_codegolf
We've all been told at some point in our lives that dividing by 0 is impossible. And for the most part, that statement is true. But what if there was a way to perform the forbidden operation? Welcome to my newest creation: b-numbers. b-numbers are a little bit like imaginary numbers: the main pronumeral involved repre...
stackexchange_codegolf
Giving a challenge involving a Star Trek reference just after May the 4th may be frowned upon, but here goes. You, Luke, Anakin, Palpatine, Yoda and Han Solo are involved in an insane tournament of Rock, Paper, Scissor, Lizard, Spock. The catch here is that you are only allowed to use a fixed order of moves. If your or...
stackexchange_codegolf
A drug comes in 5mg, 2.5mg, and 1mg sized pills. The drug is taken once a day. The total daily dose will be only one of the following (all in mg): 1, 2, 3, ... 20, 22.5, 25, 27.5, 30, 32.5, 35, 37.5, 40, 42.5, 45, 47.5, 50 In words: any whole number less or equal to 20, then at 2.5mg increments up to 50. Your task is t...
stackexchange_codegolf
This challenge is in honor of the tacky Christmas lights at my in laws' house. The challenge is to create a graphical output showing the decoration in "real time". The video (gif or other format) will have n-by-m vertical and horizontal "lights". 5 <= m,n <= 40. The frame size and resolution may vary dependent on n a...
stackexchange_codegolf
Write a program that, given any 'n' number of strings of 'm' length, returns 'm' number of 'n'-length strings, with this condition: Every new string should contains the letters at the same index of the others strings For example, the first output string must contain the first letter of all the input strings, the second...
stackexchange_codegolf
How can I shorten: p=gets.to_i a=gets b=gets.to_i If my input is an integer, followed by a string, followed by an integer?
stackexchange_codegolf
In this challenge, players need to tamper with a time bomb as late as possible without getting blasted in the face. Mechanics Let N be the number of bots plus one. Each round, each bot receives the following arguments: numbers played by all bots last round in ascending order. number of points it received last round. N...
stackexchange_codegolf
Recreational languages win at code golf too much. This challenge is simple, when using higher level functions. The task is as follows: Given any valid url, which is guaranteed to result in a valid HTML document (for example https://en.wikipedia.org/wiki/Ruby_on_Rails, which has 9 images), count the number of images di...
stackexchange_codegolf
Everyone knows log scales are for quitters. Therefore, you must write a program or function that de-quitifies a bar graph with a log scale given a base. The bar graph input is taken as a single string which is a list of bars, where each bar of the log scale bar graph is separated by the printable (or whitespace) delimi...
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
Given a string, your task is to collapse it into a zigzag-like structure as described below. Folding into a Zigzag We'll take the string "Mississippi" as an example: First, output the longest prefix consisting of unique characters only: Mis When you reach the first duplicate character C, ignore it, and output the lo...
stackexchange_codegolf
Balancing Act A see-saw (supposedly from the French 'ci-ça', meaning 'this-that') forms a third of the holy trinity of playground equipment, along with the similarly ubiquitous slide and swing. A see-saw is in perfect balance if, and only if, the sum of the moments on each side are equivalent. A see-saw can therefore b...
stackexchange_codegolf
Task Given a string s, output a truthy value if the ASCII code of each letter is divisible by the length of s, and a falsey otherwise. Input/Output Input is a nonempty string containing only ASCII [32-126]. Output is a standard truthy/falsey value. Note that you can switch the values, for example returning 0/False if d...
stackexchange_codegolf
Let's make a little stupid program that simulates the meme "Mr. incredible becoming uncanny", but in this case, our little ASCII friend is going to react to our code length. Objective: Create a program that takes anything (preferably a program) as input and outputs this: Pov: <face> you score X on codegolf Where X ...
stackexchange_codegolf
Generate the following soccer team ASCII art with the least number of bytes possible. |.| |.| |.| |.| |.| |.| |.| |.| ]^[ ]^[ ]^[ ]^[ ]^[ ]^[ ]^[ ]^[ /~`-'~\ /~`-'~\ /~`-'~\ /~`-'~\ /~`-'~\ /~`-'~\ /~`-'~\ /~`-'~\ {<| 8 |>}{<| 6...
stackexchange_codegolf
On a toroidal square grid (you can wrap around) where each cell indicates one direction (^ > v <) if we pick a cell and start to walk following these directions, we will eventually get stuck in a loop. We may end up in a different loop, depending on our starting cell. Not all the cells we encounter constitute our term...
stackexchange_codegolf
In my answer, I have this code: s.match(/[AEIOU]/) This seems too verbose to check if a string is one of A, E, I, O, or U. I tried: "AEIOU".includes(s) But that's 1 byte longer. Can I do this in a shorter way?
stackexchange_codegolf
Create a program which prints itself, followed by an additional program. This additional program should print the first program, itself, and then a third program. This continues until the nth program, which prints every program in order up to itself, but fails to print a successor. All programs output by your code shou...
stackexchange_codegolf
A Pythagorean triple consists of three positive integers a, b, and c, such that a2 + b2 = c2. Such a triple is commonly written (a, b, c), and a well-known example is (3, 4, 5). If (a, b, c) is a Pythagorean triple, then so is (ka, kb, kc) for any positive integer k. A primitive Pythagorean triple is one in which a, b...
stackexchange_codegolf
The sci-fi shooter Destiny 2 contains guns which have the ability to regenerate ammunition directly into the magazine if, and only if x (precision) shots are landed (in a fixed amount of time), returning y bullets to the magazine. For example, the perk (ability) "Triple Tap" will return 1 bullet to the magazine if 3 pr...
stackexchange_codegolf
The Jaccard index / similarity coefficient, also known as the Tanimoto index / coefficient, is a statistic used for gauging the similarity and diversity of finite sample sets. It was developed by Grove Karl Gilbert in 1884 for the field of weather forecasting [1] and later independently developed by Paul Jaccard [2] wh...
stackexchange_codegolf
Input A nonnegative integer n, and a nonempty string s containing only alphanumeric characters and underscores _. The first character of s is not _. The underscores of s are interpreted as blank spaces that can be filled with other characters. We define an infinite sequence of "infinite strings" as follows. The string ...
stackexchange_codegolf
Definitions: A triangle is considered a right triangle if one of the inner angles is exactly 90 degrees. A number is considered rational if it can be represented by a ratio of integers, i.e., p/q, where both p and q are integers. A number n is a congruent number if there exists a right triangle of area n where all thr...
stackexchange_codegolf
Let's assume we've got an imaginary assembler. The assembler supports numerical labels. An infinite loop example: :1 jmp 1 Your task is, to write a preprocessor for this assembler supporting named labels (instead of numerical ones; with up to 8 characters in length), so the label name is replaced to it's numerical...
stackexchange_codegolf
Given an n-dimensional array filled with numbers, output which p-dimensional array has the largest sum. Input An n-dimensional array of numbers, or your language's equivalent. You can assume this is a rectangular array, or not. n, the number of dimensions in the array. (doesn't need to be called n) p, the number of di...
stackexchange_codegolf
In this challenge you will write a function that takes a list (ordered set) containing real numbers (the empty list is an exception, as it has nothing) and calculates $$f(x)=\begin{cases}1 & \text{if } |x|=0 \\ x_1+1 & \text{if } |x|=1 \\ \log_{|x|}\sum_{n=1}^{|x|}{|x|}^{x_n} & \text{otherwise} \end{cases}$$ where \$|x...
stackexchange_codegolf
Challenge: Given two inputs, x and y, round x to one less significant figure, then repeat until it has y number of unrounded digits left. (the decimal point does not count as a digit) Input & Output Input can be a combination of strings and integers, e.g. you can have the input as a string and the output as an int, o...
stackexchange_codegolf
Minecraft inventory management is hard. You have 17 diamonds, but you need 7 to craft an enchantment table, a pickaxe, and a sword. Do you pick them up and right click 7 times? Or do you right click once and right click twice and take the 7 left? It's so confusing! for those of you who are now confused, don't worry, I'...
stackexchange_codegolf
My Downgoat avatar has several distinct features These features can however also apply to any other animal. Specification Given an image of an animal (technically can be anything), you must apply the Downgoat properties to it. Border pixels are the outer most pixels of the image. The background color is defined as th...
stackexchange_codegolf
Background I have a bunch of old and grainy black-and-white images. Some of them depict vines climbing on a wall, others don't – your task is to classify them for me. Input and output Your input is a rectangular 2D array of bits A, given in any convenient format. It will not be empty, but it's not guaranteed to contain...
stackexchange_codegolf
Scralphabet A normal bag of Scrabble tiles contains the following letters (? is a blank tile, which can stand for any other letter): AAAAAAAAABBCCDDDDEEEEEEEEEEEEFFGGGHHIIIIIIIIIJKLLLLMMNNNNNNOOOOOOOOPPQRRRRRRSSSSTTTTTTUUUUVVWWXYYZ?? The letters have the following value: {"A": 1,"B": 3,"C": 3,"D": 2,"E": 1,"F": 4,"G":...
stackexchange_codegolf
Problem Given a value n, imagine a mountain landscape inscribed in a reference (0, 0) to (2n, 0). There musn't be white spaces between slopes and also the mountain musn't descend below the x axis. The problem to be solved is: given n (which defines the size of the landscape) and the number k of peaks (k always less tha...
stackexchange_codegolf
Imagine that there are \$n\$ different types of objects \$O_1,O_2,O_3,\ldots,O_n\$ and they each have a conversion factor \$k_1,k_2,k_3,\ldots,k_n\$. You can, for any \$1\le i\le n\$, convert \$k_i\$ amount of \$O_i\$ into \$1\$ of any other type of object. Task Your objective is to output all the possible ending confi...
stackexchange_codegolf
Sometimes it is useful to run a math problem with multiple inputs. The goal of this challenge is to make a program that eases this task. Number-generating expressions You must support 3 types of expression: Single number generator: Very simple, just a literal number Multi-number generator: A tad more complicated. Thee...
stackexchange_codegolf
Based on this challenge and this Math.SE question. Idea originally come from a Numberphile video. The goal is to reproduce the logic of Professor McKee when he builds this prime. Your task is to build the Trinity Hall Prime, at a much lower scale. You are given a single number N greater than 2, representing the length ...
stackexchange_codegolf
from Wikipedia, a number is called B-powersmooth if all prime powers \$p^v\$ that divide the number satisfy \$p^v \leq B\$. B-powersmoothness is important, for example, for Pollard's p-1 factorization algorithm. Task your task is to get two numbers, \$n\$ and \$B\$, and output if \$n\$ is \$B\$-powersmooth. Rules You ...
stackexchange_codegolf
Your task is when given a chemical formula as input, output the total number of atoms in the formula. Input A chemical formula in any reasonable format. Each chemical formula has the following: A leading coefficient, which is a number \$N > 1\$. At least 0 groupings of elements surrounded by parentheses. Groupings ca...
stackexchange_codegolf
The following is an unfolded milk carton: +-----+-\|/-+-----+-\|/-+-+ | | / \ | | / \ | | +-----+/---\+-----+/---\+-+ | | | | | | | | | | | | | | | | | | +-----+-----+-----+-----+-+ \ / \ / \ / \ / \_/ \_/ \_/ \_/ This is a code-golf kolmo...
stackexchange_codegolf
Output the current time of day as Swatch Internet Time. Specifically, output a three-digit (zero-padded) number of ".beats" (1000ths of a day) which represent the current time of day in the Swatch Internet Time time zone of UTC+01:00 ("Biel Meantime"). For example, if the current time in UTC is 23:47, then it is 00:47 ...
stackexchange_codegolf
99 Varieties of Dosa is a popular chain of roadside dosa stalls across South India. This is inspired by a combination of this chain and the classic CodeGolf challenge "99 Bottles of Beer". Recreate the variant of the menu of the popular '99 Varieties of Dosa' listed below. (Note: Despite the name, the list contains 10...
stackexchange_codegolf
Inspired by Flow Fit: Sudoku, a brand-new mobile puzzle game (as of Nov 2019). Background A Latin square is a square grid of side length \$ n \$ filled with \$ n \$ different symbols, where each row and column contains each symbol exactly once. Let's define a row (resp. a column) as a maximally consecutive group of cel...
stackexchange_codegolf
This is a code golf version of a similar question I asked on stack earlier but thought it'd be an interesting puzzle. Given a string of length 10 which represents a base 36 number, increment it by one and return the resulting string. This means the strings will only contain digits from 0 to 9 and letters from a to z. B...
stackexchange_codegolf
Given a date between 2010-01-01 and 2099-12-31 as three integers (please state your order if not [year,month,day]), answer with Tesco's corresponding five-digit Burger Relish Best Before End date number. The format is simply the last two digits of the year, followed immediately by three digits representing the day of ...
stackexchange_codegolf
Inspired by a bug in a solution to this challenge, your challenge is to produce this exact text: ZYXWVUTSRQPONMLKJIHGFEDCBA YXWVUTSRQPONMLKJIHGFEDCBA XWVUTSRQPONMLKJIHGFEDCBA WVUTSRQPONMLKJIHGFEDCBA VUTSRQ...
stackexchange_codegolf
Given a ragged array, find the length of the largest subarray that contains the depth of that subarray. The base array layer has a depth of 0. Here is an example: [1, 2, [3, 4, [2, 5]], 0] Here, the subarray [2, 5] contains its own depth 2 and has a length of 2 as well. But in the outermost subarray is a 0, its depth....
stackexchange_codegolf
Introduction How much of the English alphabet does a given string use? The previous sentence uses 77%. It has 20 unique letters (howmucftenglisapbdvr), and 20/26 ≃ 0.77. Challenge For an input string, return the percentage of letters of the English alphabet present in the string. The answer can be in percentage or in ...
stackexchange_codegolf
Given a random code written using Brainfuck commands. You program should translate that code into the following ascii art: each Brainfuck command represents as 5x9 array of A and B symbols. All commands are concatenated with 5x3 arrays of A symbols. Symbols A and B you choose yourself. For example, when input is ><+,.[...
stackexchange_codegolf
Tired of always wondering how many more Pokémon you need to catch to get those high-tier evolutions? Wonder no more! Now you will write a complete program or function to calculate it for you! The Challenge: As input, your program will receive a list of the costs in candy to evolve a Pokémon to the next tier. (This list...
stackexchange_codegolf
Introduction Briscola is one of Italy's most popular card games. It is a trick-taking card game, like Bridge. Briscola is well known for its bizarre point system. In this challenge, given two cards, you will output whether the first one scores more, less, or the same number of points as the second in Briscola's point s...
stackexchange_codegolf
The Levenshtein distance between two strings is the minimum number of single character insertions, deletions, or substitutions to convert one string into the other one. Given a binary string \$S\$ of length \$n\$, we are a interested in the number of different strings of length \$n\$ which have distance at most \$3\$ ...
stackexchange_codegolf
Challenge: Given an expressions made of additions and multiplications, output an expression that is a sum of products. The output must be equivalent to the input modulo the law of distribution. For example, \$1 + ((2 + 5\times 6) \times(3+4))\$ becomes \$1 + 2 \times 3 + 2 \times 4 + 5\times6\times3 + 5 \times 6 \times...
stackexchange_codegolf
There already is a Brainfuck interpreter question, but it is from 2011 and not up to date with current site standards and vague in places. I have proposed reposting this in chat, and it was well-received. Here goes. Objective Given the Brainfuck code and the program's input as input, run the Brainfuck code. As there ar...
stackexchange_codegolf
This is the cops' thread of a cops-and-robbers challenge. The robbers' thread can be found here In this challenge as a cop you will choose two programming languages A and B, as well as a non-empty string S. You are then going to write 4 programs: A program which outputs exactly S when run in both A and B. A program w...
stackexchange_codegolf
Challenge Print the numbers: 1 22 333 4444 55555 666666 7777777 88888888 999999999 In that order. I/O Takes no input. The numbers can have any delimiters desired (or none). That includes lists, cell arrays, .jpeg, etc.... Example outputs: 122333444455555666666777777788888888999999999 [1,22,333,4444,55555,666666,77777...
stackexchange_codegolf
Define a 1-indexed sequence as follows: A083569(1) = 1 A083569(n) where n is an integer greater than 1, is the smallest integer m not occurring earlier such that m+n is a prime number. Your task is to take in n and return A083569(n). n A083569(n) 1 1 2 3 3 2 4 7 5 6 6 5 7 4 8 9 9 8 10 13 11 12 12 ...
stackexchange_codegolf
You have to print out your username, by only using the characters in your username. Standard loopholes are forbidden This is not code-golf, so shortest does not win Don't modify your username please And each language be used one time
stackexchange_codegolf
Input a list of strings a and a string s for search keyword. Find out all strings in a which contains s as subsequence. And sort them in the following order: Exactly equals to s Starts with s Contains s as substring (continuous subsequence) Contains s as subsequence Detail When two strings belongs to the same sortin...
stackexchange_codegolf
I'm always forgetting Pokemon type matchups. This is a challenge to print the pokemon type chart! Attacking Type No Fi Fl Po Gr Ro Bu Gh St Fr Wa Gr El Ps Ic Dr Da Fa Normal 1.0 2.0 1.0 1.0 1.0 1.0 1.0 0...
stackexchange_codegolf
Given n, k, and p, find the probability that a weighted coin with probability p of heads will flip heads at least k times in a row in n flips, correct to 3 decimal digits after decimal point (changed from 8 because I don't know how to estimate the accuracy of double computation for this (was using arbitrary precision f...
stackexchange_codegolf
There already have been multiple challenges about carryless multiplication, this challenge will work with the same calculation rules. You task is given a quadratic polynomial ax²+bx+c, to find an integer r such that a*r*r+b*r+c is zero, with + meaning exclusive or and * being carryless multiplication (use xor to add up...
stackexchange_codegolf
Task description In number theory, the Carmichael function λ takes a positive integer n and returns the least positive integer k so that the k-th power of each integer coprime to n equals 1 modulo n. Given a positive integer n, your solution must compute λ(n). The shortest code in bytes wins. Your program should theore...
stackexchange_codegolf
This is the robbers' thread. For the cops' thread, go here. Introduction For this Cops/Robbers challenge, the cops will write output-producing programs and interweave them together. It is the robber's job to pick apart the cops' programs to produce the desired outputs. Robber rules Robbers will try to find the differen...
stackexchange_codegolf
Input: A string Output: The rarity of the string, as described below. To find the rarity of a string, follow the steps below. Start with 0. Subtract 3 for each E, A, T, or O in the string. Subtract 2 for each I, N, S, or H in the string. Subtract 1 for each R, D, L, or C in the string. Add 1 for each W, F, G, or Y in ...
stackexchange_codegolf
To shuffle a string \$s\$, Alice applies the following algorithm: She takes the ASCII code of each character, e.g. "GOLF" → \$[ 71, 79, 76, 70 ]\$ She sorts this list from lowest to highest: \$[ 70, 71, 76, 79 ]\$ She reduces each value modulo the length of the string (4 in this case), leading to the list \$A = [ 2, 3...
stackexchange_codegolf
I found this YouTube video with a table on it showing some card suits with ampersands. You might not understand what it is about, but I still want to make a challenge about it. The input is two suits, being one of the following: heart diamond spade club You can do anything for any other input. Then the output is their...
stackexchange_codegolf
We do seem to have a fastest square root challenge, but it's very restrictive. In this challenge, your program (or function) will be given an arbitrarily sized nonnegative integer, which is the square of an integer. Input You may take input in any normally allowed way, including (but not limited to) an arbitrary sized ...
stackexchange_codegolf
The absolute value of a number \$x\$ is normally written as \$|x|\$. The left and right side of the absolute value uses the same symbol, so it is not immediately obvious how to parse nested absolute values e.g. \$||1-2|+|3-|4-5|||\$ Your goal is to parse such an expression containing nested absolute values: The express...
stackexchange_codegolf
You will need to evaluate the definite integral (bounded by \$a\$ and \$b\$) of a certain polynomial function that takes the form of: $$\int_a^b \left( k_n x^n + k_{n-1} x^{n-1} + \cdots + k_2x^2 + k_1x + k_0 \: \right) dx$$ Normally, this can be done using the fundamental theorem of calculus and power rules. For examp...
stackexchange_codegolf
There is a question to basically find the largest sum in an array, such that no two elements are chosen adjacent to each other. The concept is to recursively calculate the sum, while considering and not considering every element, and skipping an element depending on whether the previous element was selected or not. I u...
stackexchange_codegolf
NOTE: The winner of this competition is Jack!!!. No more submissions will be accepted. Here is the chat room for this king-of-the-hill challenge. This is my first one so I'm open to suggestions! Reaper is a game concept developed by the Art of Problem Solving which involves patience and greed. After modifying the game ...
stackexchange_codegolf