instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Input A single-character string containing an uppercase or a lowercase letter from the English alphabet. Alternatively, you may handle only uppercase or only lowercase letters as input. Output This 3x3 typeface of the input letter (source), with two distinct, printable ASCII characters of your choice (excluding tabs a...
stackexchange_codegolf
I'm new to code golf challenges. My problem came up in Advent of Code 2020 Day 8 The input is an array of arrays. In part two of the problem one needs to run several trials to produce a result by changing an element in the input array. My current code is this (comments added to explain what's going on): p input.each_wi...
stackexchange_codegolf
Given an integer \$n \geq 2\$, print a triangle of height \$n\$ of (triangles of height \$n\$ of asterisks), as in this SO question. For \$n=2\$, print: * *** * * * ********* For \$n=3\$, print: * *** ***** * * * *** *** *** *************** * * ...
stackexchange_codegolf
The Secretary Problem is a famous problem described as thus: You need a new secretary You have N applicants that you can interview one at a time You are able to score each applicant after the interview. Your scoring system will never give two applicants the same score After you interview an applicant, you must give a...
stackexchange_codegolf
Input An integer n and a pair of distinct integer valued (x, y) coordinates on the boundary of the grid. The coordinates are indexed from 1. For example, n=10 and (1,2), (10, 7). The points will always be on different sides of the grid and neither of them will be \$(1, 1)\$. Output The number of integer points in an n...
stackexchange_codegolf
Given a string as argument, output the length of the longest(s) non-overlapping repeated substring(s) or zero if there is no such string. You can assume the input string is not empty. Examples abcdefabc : the substring abc is repeated at positions 1 and 7, so the program should output 3 abcabcabcabcab : abcabc or bcabc...
stackexchange_codegolf
Task Given an integer \$n\in[0,10^{12})\$ in any convenient format, return the number of strokes needed to write that character in simplified Chinese. Background Chinese numerals are expressed in base 10 with a system of digits and places, with an important distinction that digits are in groups of four, rather than thr...
stackexchange_codegolf
Challenge Given a tic-tac-toe board in any format, determine if it is valid or not. If a board can be the result of a tic-tac-toe game, then it is valid. For example, this board is valid:X O X O X O X O XOn the contrary, this board is invalid: X X X X X O O O O Input A full (9/9) tic tac toe board (the outcome, not th...
stackexchange_codegolf
The goal is to create a generator generator [...] generator generator comprehension. The generator must be created via generator comprehension. The following expression must be valid for any number of nestings: next(next(next(next(next(generator))))). The winner is whoever achieves this with the fewest number of byte...
stackexchange_codegolf
Given a list of integers, such as {1, 4, 2, 8, 10}, TI-Basic's ΔList will determine the difference between every overlapping pair of items. In the given example, it would be {3, -2, 6, 2}. Task: Take a list of integers as input, in any reasonable way. All overlapping pairs {x, y} should become y - x, and the resulting ...
stackexchange_codegolf
The Fibonacci polynomials are a polynomial sequence defined as: \$F_0(x) = 0\$ \$F_1(x) = 1\$ \$F_n(x) = x F_{n-1}(x) + F_{n-2}(x)\$ The first few Fibonacci polynomials are: \$F_0(x) = 0\$ \$F_1(x) = 1\$ \$F_2(x) = x\$ \$F_3(x) = x^2 + 1\$ \$F_4(x) = x^3 + 2x\$ \$F_5(x) = x^4 + 3x^2 + 1\$ When you evaluate the Fibo...
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
When given a a list of values and a positive integer n, your code should output the cartesian product of the list with itself n times. For example, in pseudocode your function could be similar to: for x1 in list: for x2 in list: for x3 in list: ... for xn in list: pri...
stackexchange_codegolf
I made this because, although we have a bunch of other questions involving smiley faces, there is nothing for just printing an ASCII smiley face with as little code as possible. Anyway, print this exactly (Trailing spaces allowed): ********** ****************** ********************** ******* ****** ***...
stackexchange_codegolf
You are given a \$3\times3\$ square matrix where each cell is any digit between \$0\$ and \$9\$ except \$7\$. Your task is to figure out the minimum number of digits that must be replaced with \$7\$'s so that the sums of the digits in each row and each column are the same. NB: There is no constraint whatsoever on the d...
stackexchange_codegolf
Challenge Premise I've got multiple pretty numbers all in a row. Each is a decimal digit. 0s are weakly attracted to 0s, 1s are attracted to 1s a little more strongly and so on until 9. I don't know why — it must be something I ate. As a result, a sort of two-way sideways sedimentation occurs until the higher values ar...
stackexchange_codegolf
In chess, the queen piece can move arbitrarily far in each cardinal and intercardinal direction. What does this mean? Well, I'll show you with an ASCII drawing: \..|../ .\.|./. ..\|/.. ---Q--- ../|\.. ./.|.\. /..|..\ It means the queen (notated as Q) can move along these lines (notated as \, |, /, and -), and cannot r...
stackexchange_codegolf
In a puzzle in an old book of mine, a game is defined in which two players choose sequences of coin flips that they believe will appear first when a coin is repeatedly flipped. (It was actually odd and even dice rolls, but this little detail doesn't matter in terms of problem equivalence.) It is noted that if player 1 ...
stackexchange_codegolf
Overview Your goal is to implement RC4 encryption. RC4 encryption, invented by Ron Rivest (of RSA fame), was designed to be secure, yet simple enough to be implemented from memory by military soldiers on the battlefield. Today, there are several attacks on RC4, but it's still used in many places today. Your program s...
stackexchange_codegolf
kolmogorov-complexity is one of the tags on this site, representing challenges that test how much code is needed to output a given fixed result (usually a piece of text). The info page for this tag lists the string 4c1j5b2p0cv4w1x8rx2y39umgw5q85s7uraqbjfd as an example of a string with a high Kolmogorov complexity, sta...
stackexchange_codegolf
(This is a variation on Print a Negative of your Code, which I enjoyed a lot! Thanks to Martin Büttner♦ - almost all of this text is his.) Let's consider the symbols to be the following printable ASCII characters (note that space is included): !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ And the alphanumerics to be these: 012345...
stackexchange_codegolf
I have a coding problem that goes like this: Given a positive integer \$N\$, return a list of all possible pairs of positive integers \$(x,y)\$ such that $$\frac1x+\frac1y=\frac1N$$ I already solved the problem using Python, but I was wondering how I can code golf it. The following is my attempt at golfing (I try to ...
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
This is the first in a series, the second is Two roads diverged in a yellow wood (part 2) This challenge is inspired by Robert Frost's famous poem, "The Road Not Taken": Two roads diverged in a yellow wood, And sorry I could not travel both And be one traveler, long I stood And looked down one as far as I could ...
stackexchange_codegolf
Write a program that counts and prints the number of characters in it's own source code to standard output. The number must be generated from counting the characters. This Ruby solution would not be allowed: puts 6 because it is not calculated. Spaces, tabs, new lines, etc should be counted. The program must be small...
stackexchange_codegolf
I was wondering if it was possible to make this code even shorter than it already was. f=lambda x:f(x-1)+f(x-2) if x>1 else 1 [print(f(i))for i in range(20)] Expected output: 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 Good luck, "golfers" (I'm assuming thats what you guys are called) Note: spe...
stackexchange_codegolf
The challenge, should you accept it, is to determine how much you win in the Bingo Golf Flax Lottery. Based on but not equal to the BingoFlax lottery The input is two lists of numbers (positive non-zero integers). The first list always contains 24 potentially non-unique numbers that make up your board, a 5 x 5 grid of ...
stackexchange_codegolf
The generalised harmonic number of order \$m\$ of \$n\$ is $$H_{n,m} = \sum^n_{k=1} \frac 1 {k^m}$$ In this challenge, we'll be considering the generalised harmonic numbers of order \$2\$: $$H_{n,2} = \sum^n_{k=1} \frac 1 {k^2}$$ This sequence begins \$1, \frac 5 4, \frac {49} {36}, \frac {205} {144}, \dots\$ and conve...
stackexchange_codegolf
What makes the ideal question? Perhaps it is merely the abstraction of a profound thought and the initialization of a dream, a hope, a thought, a (… 5,024.2 characters omitted). Therefore, I propose that we find such a factor to quantify questions. I propose also that this factor be called QF, or the Q-factor. I determ...
stackexchange_codegolf
Introduction The EKG sequence begins with 1 and 2, then the rule is that the next term is the smallest positive integer not already in the sequence and whose common factor with the last term is greater than 1 (they are not coprimes). The first terms are: 1, 2, 4, 6, 3, 9, 12, 8, 10, 5, 15, ... It's called EKG because...
stackexchange_codegolf
Introduction Let's draw some regular hexagons formed by hexagonal tiles, marking the vertices of the tiles with dots. Then we will count the number of dots. size 1: 6 dots . . . . . . size 2: 24 dots . . . . . . . . . . . . . . . . . . . . . . . . size 3: 54 dots . . . . . . ...
stackexchange_codegolf
Cleaning the dishes In this task, you will be given a bar of soap with a width of 1 or more units. You will also be given a plate, which you will have to clean, using the soap as few times as you can. The plate will be at least 1 character. You will have to output a plate with the 'clean' character representing the pla...
stackexchange_codegolf
The goal of this challenge is to determine the angle of a line in a image. Rules on the image: The image background will be white (#FFFFFF) The stroke of the line will be black (#000000) The line will NOT be anti-aliased The image will be 100x100 pixels The line will start at the center of the image The line will sta...
stackexchange_codegolf
As a programmer or computer scientist one might encounter quite a lot of trees - of course not the woody growing-in-the-wrong-direction kind, but the nice, pure mathematical kind: *<- root (also a node) /|\<- edge * * *<- inner node | / \ * * *<- leaf (also a node) | * Naturally over time we all have put tog...
stackexchange_codegolf
Inspired by Nicola Sap's Challenge Goal Your challenge is to simply produce π with 232-1 digits. However today's twist, like the title implies, is to produce it without using any numbers or any π constants in your source-code. Input/Output Your program will not be provided usable input. It can output in any reasonable ...
stackexchange_codegolf
Make me a s'more! I tell you the width, the amount of graham cracker, the amount of chocolate, and the amount of marshmallow. An example: Input: Width: 10 Graham: 3 Chocolate: 2 Marshmallow: 1. Output: GGGGGGGGGG GGGGGGGGGG GGGGGGGGGG CCCCCCCCCC CCCCCCCCCC MMMMMMMMMM GGGGGGGGGG GGGGGGGGGG GGGGGGGGGG Is it that easy? U...
stackexchange_codegolf
Introduction This challenge consists in finding the greatest number removing y digits from the original number n which has x digits. Assuming y=2 n=5263 x=4, the possible numbers removing y=2 digits are: [52, 56, 53, 26, 23, 63] So, the greatest number is 63 which must be the output for this example. Another logic wo...
stackexchange_codegolf
Your task will be to write a Haskell function that takes a list of integers and returns a sorted version of the same list. You are to do this without the use of builtins What are builtins? To keep ourselves from having to navigate edge case hell we are going to limit answers to Haskell (sorry if Haskell is not your fa...
stackexchange_codegolf
For this challenge, a word is defined as a string of letters, separated by spaces. Given a string of words, and an integer i representing an index into that string, output the whole word which contains the character at index i. For example (using 0-based indexing), with the string code golf, and the index 6, the 7th ch...
stackexchange_codegolf
The other day, our team went to an escape room. One of the puzzles involved a board of six mechanical switches where you had to find the correct combination of on and off in order to unlock a box, somewhat like this: -v-v-v- -v-v-v- Being developers, we decided it would be more efficient to try every single one of 2^6...
stackexchange_codegolf
There are many generalizations of Conway's Game of Life. One of them is the isotropic non-totalistic rulespace, in which the state of a cell in the next generation depends not just on its state and the amount of alive cells around it, but also the relative positions of the cells around it. Given an rulestring correspon...
stackexchange_codegolf
Given a number n, find x such that x! = n, where both x and n are positive integers. Assume the input n will always be the factorial of a positive integer, so something like n=23 will not be given as input. Examples: n=1 -> x=1 (0 is not a positive integer), n=24 -> x=4 Shortest code wins.
stackexchange_codegolf
Let's say you've got a table of data: meter_id date 0000 0600 1200 1800 0 030915 10 20 30 40 1 030915 15 7 49 2 where the last four columns are meter readings at different times. You want to output meter_id date time reading 0 030915 0000 10 0 030915 0600 20 etc. Your inpu...
stackexchange_codegolf
Challenge Write \$2 \le n \le 10\$ distinct, valid non-halting full programs in your language of choice. If all of them are concatenated in order, the resulting full program should be a valid halting program, but if any of them are left out, the result should still be a valid non-halting program. More formally, write \...
stackexchange_codegolf
Challenge Statement The goal of this challenge is to build the 5 state Infinite Time Turing Machine that takes the longest to halt. Since Infinite Time Turing Machines can run for infinite time your score will be a "transfinite ordinal". That's the challenge statement, but if you don't what all this means or want to d...
stackexchange_codegolf
This year my age is a prime number, and so is this year. This conjunction will repeat in 10 years and again in 12. If I live to 100, I will lived exactly 11 years in which my age and the year are both prime. My condolences to those of you born in odd-numbered years, who will experience this phenomenon at most once if a...
stackexchange_codegolf
Wren is a small, fast, class-based concurrent scripting language. Does anyone have any tips for this language? Please make sure to post 1 tip per answer, and don't post answers like "remove whitespace".
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
Given no input, output the following: _ | ~-_ | o ~-_ | ~ ~-_ | \~~~~~~ | * \ | \ |~~~~~~~~~~\ Note the backslashes are actually \, which is U+FF3C Trailing whitespace is allowed, however leading whitespace is not. This is code-golf so fewest bytes in each language wins!
stackexchange_codegolf
Given a non-negative integer N, output the smallest odd positive integer that is a strong pseudoprime to all of the first N prime bases. This is OEIS sequence A014233. Test Cases (one-indexed) 1 2047 2 1373653 3 25326001 4 3215031751 5 2152302898747 6 3474749660383 7 3415500717...
stackexchange_codegolf
The Post's Correspondence Problem (PCP) gives you a list of pairs of strings, P_1 ... P_n. Your task is to find a k, and some sequence of k indices such that fst(P_i1) ... fst(P_ik) = snd(P_i1) ... snd(P_ik) We're trying to find some sequence of the pairs where the word we build from the first part is equal to the word...
stackexchange_codegolf
Edit: There will be a bonus of -20 for random masking Hello fellow Whistleblowers and carriers of secret knowledge. I am due to an interview by mail and I - of course - cannot say specific names in full length. But as I want to disclose it in a rather not-so-obvious-way I need your help. I will provide these names in t...
stackexchange_codegolf
Introduction We know that the factorial notation is valid for all natural numbers. However, Euler had extended it for all positive real numbers, as well as for complex numbers by defining a function, which is known as the Gamma Function. It is represented by Γ. Challenge You will be given a non-negative floating point ...
stackexchange_codegolf
Preamble We've already proven we're good at adding two numbers, but many solutions only operate on tiny numbers like 2³²-1, honestly we can do a lot better. The Challenge Given two unsigned, non-negative integers, add them together and return the output. Input may be taken in any convenient format (String, Array of byt...
stackexchange_codegolf
Write a program with the following properties: When run as-is, the program produces no output (i.e. 0 bytes of output). There is a location within the program (of your choice: it could be at the start, end, or somewhere in the middle) with the following property: modifying the program via placing any string there will...
stackexchange_codegolf
Given a positive integer n, randomly output n non negative integers that sum to one hundred. n will be at most 200. The output should be present as a list of integers (not sorted). Your random sample should be uniformly sampled from all lists of n non negative integers that sum to one hundred. Your code should run in a...
stackexchange_codegolf
Gemtext is a very simple markup format used by the alternative web protocol Gemini. Write a Gemtext to HTML converter. From the Wiki: A line of text is a paragraph, to be wrapped by the client. It is is independent from the lines coming before or after it. A list item starts with an asterisk and a space. Again, the r...
stackexchange_codegolf
Challenge Here's a simple one. Write a function or program when given a number in base 10 as input, it will return or print that number's value in Hexadecimal. Examples 15 -> F 1000 -> 3E8 256 -> 100 Rules No built-in Hexadecimal functions whatsoever Letters may be lowercase or uppercase You will only need to worry a...
stackexchange_codegolf
Background The Burrows–Wheeler transform (BWT) is a reversible permutation of the characters of a string that results in large runs of similar characters for certain types of strings such as plain text. It is used, for example, in the bzip2 compression algorithm. The BWT is defined as follows: Given an input string suc...
stackexchange_codegolf
Goal Write a program or function that takes a positive integer n and randomly generate a legal series of pitches (henceforth called a Pitch string) of length n. Input A non-zero, positive integer n <= 100 Output Return a random string, or list of characters, that represent a possible, valid pitch string of length n. Th...
stackexchange_codegolf
Jelly has compressed string literals, using the “...» delimiters. The way these work is by interpreting the ... as a base-250 integer, \$n\$, then repeatedly divmod-ing this integer until it reaches \$0 \newcommand{\d}[2]{ \left( \left\lfloor \frac {#1} {#2} \right\rfloor, #1 \text{ mod } #2 \right) }\$, building up th...
stackexchange_codegolf
Introduction In this challenge, your task is to find generalized subsequences of strings. The subsequences are not necessarily contiguous, and they can also "wrap around" the string, going past its end and starting again from the beginning. You'll want to minimize the number of wraps, though. More formally, let u and v...
stackexchange_codegolf
Write two programs A and B. Program A (the encoder) takes 1024 pairs of integers \$(k,v)\$, where \$0≤k<2^{32}\$ and \$0≤v<1024\$, and all \$k\$ will be different. It will output a single positive integer (likely a few thousand digits long). Program B (the decoder) takes two inputs: the output-integer of program A, a...
stackexchange_codegolf
In this question I asked you to guess an anagram quine based on its output. However it looks like we don't have a question asking to golf an anagram quine yet. So your task will be to make the shortest anagram quine that you can. What is an anagram quine? An anagram quine is a non empty program that prints an anagram...
stackexchange_codegolf
Background Imagine that I'm creating a really long necklace, consisting of only two characters, A and B. You must count the number of occurrences of the substring AB in the string. However, since it's a necklace, you must also consider if the last character and the first character join to make AB. For example, in BBBA,...
stackexchange_codegolf
The Task Write a program or function which, when passed some positive integer n as input, returns Mills' Constant accurate up to n digits. The Definition Mills' Constant worked out to six thousand digits may be located here. Examples Let f be the function described by the challenge. >>> f(1) 1 >>> f(3) 1.31 >>> f(100...
stackexchange_codegolf
Inspired by this comment chain... I wanna enklact my way out of this challenge but I can't... @ETHproductions to enklact (v): to implement a lookup table using a subsection consisting of unique elements. Enklacting is a very useful way to compress a lookup table. For example, let's say you had the following list of ...
stackexchange_codegolf
What general tips do you have for golfing in Befunge? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Befunge (e.g. "remove comments" is not an answer). Please post one tip per answer.
stackexchange_codegolf
Background Polyagony is a family of hypothetical esolangs where the source code is laid out on a specifically shaped board before running it. It's similar to Hexagony, but various uniform tilings can be used instead of a simple hexagon. The shape of the board and the tiling used is defined by the "mode". Mode 3/3,6 is ...
stackexchange_codegolf
The flick input method is a way of inputting Japanese kana on a modern smartphone. It is arranged in a 12-key layout, with the following labels: あかさ たなは まやら 小わ、 When a key is tapped, it produces its respective kana. However, when the key is flicked in one of the four cardinal directions (up, down, left, right) it prod...
stackexchange_codegolf
Inspiration Conway's Game of Life is a well known cellular automaton "played" on an infinite grid, filled with cells that are either alive or dead. Once given an initial state, the board evolves according to rules indefinitely. Those rules are: Any live cell with 2 or 3 living neighbours (the 8 cells immediately aroun...
stackexchange_codegolf
This is the cops' thread, the robbers' thread is here A polyglot is a program, that without modification, can run in multiple languages. Allowed languages Any language that was made before the challenge and isn't made for the purpose of the challenge, it is allowed, though discouraged, to use languages that are easy t...
stackexchange_codegolf
Introduction I stumbled across this (useless) pattern the other day while I was watching TV. I named it "the 9 pattern" because the first number to use it was 9. The gist of it is, you enter a number (let's say x), and then you get back: x x + (x / 3) [let's call this y] two-thirds of y [let's call this z] z + 1 ...
stackexchange_codegolf
A Walsh matrix is a special kind of square matrix with applications in quantum computing (and probably elsewhere, but I only care about quantum computing). Properties of Walsh matrices The dimensions are the same power of 2. Therefore, we can refer to these matrices by two's exponent here, calling themW(0), W(1), W(2)....
stackexchange_codegolf
Your challenge is given an input of a prison layout to work out whether any of the prisoners can escape. Input Input may be in any reasonable format such as a string, array, array of arrays etc. The input will consist of three characters, in this case #, P and space. The input will not necessarily contain all three cha...
stackexchange_codegolf
Magic the gathering has many unique names for colour combinations in decks, as an example when Blue and White appear together in a deck, the deck maye sometimes be named after the Ravnican Guild that features those colours, namely 'Azorius'. There are some exceptions, and oddities though. Below is a list of colour lett...
stackexchange_codegolf
In golf, a knowledgable caddie helps an already good golfer to be even better. In this challenge, you build a "caddie" to help you code golf. In particular, your caddie will compress golfed code in such a way that another program can uncompress and then run the code. A good caddie will compress golfed code to be much s...
stackexchange_codegolf
Given a description of the base state of a recursive ASCII pattern, output an expanded state somewhere along the recursion steps. More specifically: Let the following be an example: ##.. ##.. ..__ ..__ Where # is filled, . is empty, and _ is recursive. This describes a pattern wherein the top left quarter is filled, t...
stackexchange_codegolf
I am trying to write a solution to the following problem using as few characters as possible (to meme my friend and introduce him to golfing). Can any improvements be done to my code? So the problem requires us to write a function called navigate in Python 3.6 (language of the judge, sorry, no walruses) that takes two ...
stackexchange_codegolf
Choi Hong Hi died on the 15th June 2002 at the honorable age of 83. He founded Taekwondo. 15 years after his death, I would like to be a Taekwondo master. This is my time to shine ! Task Given a string you should output a Taekwondo version. Rules You will receive a non-empty string/sentence by any valid input You mus...
stackexchange_codegolf
In this game, you can look inside one box at a time chosen by you. When you do that, you can see how many coins there are in that box. The wizard has one last twist for you. At any point, you can choose to give up on this set of boxes and get him to start the whole process again (with a new random \$x\$). Of course, i...
stackexchange_codegolf
Introduction The sign of a number is either a +, or a - for every non-zero integer. Zero itself is signless (+0 is the same as -0). In the following sequence, we are going to alternate between the positive sign, the zero and the negative sign. The sequence starts with 1, so we write 1 with a positive sign, with zero (t...
stackexchange_codegolf
There are a bunch of different casing conventions, like camelCase, PascalCase, snake_case etc. It's annoying juggling all of these, so instead of choosing one like a sensible person, why not cursedly mix all of them together? Your challenge is to, given a list of words (only containing lowercase letters), convert them ...
stackexchange_codegolf
Background For the purposes of this challenge, we'll define a "perfect nontransitive set" to be a set \$A\$ with some irreflexive, antisymmetric relation \$<\$, such that for all \$a \in A\$ we have that \$|\{x \in A|x<a\}|=|\{x \in A|x>a\}|\$. Okay, now in layperson's terms: \$A\$ is a set of elements with no duplicat...
stackexchange_codegolf
Let's have string multiplication to take a string and a positive number and concatenate that string that many times. In Haskell: 0 * s = "" n * s = s ++ ((n - 1) * s) Your task is to write a program that outputs a number \$n > 0\$. When you double your program (with the described procedure) the new program should ou...
stackexchange_codegolf
Input A bound m <= 4294967295. Output Consider values sampled uniformly at random from integers in the range 0 to m, inclusive. Your output should be the expected (average) number of trailing zeros in the binary representation of the sampled value. Your answer should be exact, for example given as a fraction. Example ...
stackexchange_codegolf
(l, r) defines a line whose left end is at l and the right end is at r, on a 1-dimensional space. Given 2 lines b = (0, bz) and f = (i, i + fz), v = (l, r) is the overlapping part of these lines. When b and f do not overlap (when v cannot have a positive length), v = (0, 0). (input) -> (output) bz, fz, i -> l, r The...
stackexchange_codegolf
Introduction The International System of Units is a system of measuring all around the world, except for a few countries including the US. The SI system (or metric system) is based on powers of ten, listed below (note that this is an incomplete table): femto(f) pico(p) nano(n) micro(μ) milli(m) centi(c) (base unit) hec...
stackexchange_codegolf
A run ascending list is a list such that runs of consecutive equal elements are strictly increasing in length. For example [1,1,2,2,1,1,1] can be split into three runs [[1,1],[2,2],[1,1,1]] with lengths [2,2,3], since two runs are the same length this is not a run ascending list. Similarly [2,2,1,3,3,3] is not run as...
stackexchange_codegolf
Given an email address, the result of a transformation applied to that email address, and a second email address, return the output of the same transformation applied to the second email address. The email addresses will all have the following structure: A string of positive length containing alphanumeric characters an...
stackexchange_codegolf
For example, given 3 sets of parenthesis, you have: ()()() ((())) ()(()) (())() (()()) = 5 possible combinations. Challenge Program must: • Take 1 number as an input • Return one output, the number of possible combinations of parenthesis sets Shortest number of bytes wins
stackexchange_codegolf
Let's say you have a sentence like: this is a very long sentence with several words of no significance It contains only the 26 lowercase letters of the alphabet and spaces. And you have a dictionary, where each word contains any number of the 26 lowercase letters and nothing else: henge renton Then the output should ...
stackexchange_codegolf
I have the code below working. But there must be a better way. file <- "http://s3.amazonaws.com/assets.datacamp.com/production/course_1127/datasets/tmp_file.csv" x <- read.csv(file = file) ts <- xts(x = x, order.by = as.Date(rownames(x), "%m/%d/%Y")) cd=coredata(ts) for (j in 1:length(names(ts))) cd[,j]<-cd[,j]/cd[1,...
stackexchange_codegolf
Sometimes, I will think it is one day of the week (e.g Friday) when in reality, it's earlier in the week (e.g Tuesday). Your challenge is to display the number of days my estimates are off by. Challenge Given a day of the week I think it is, and the day of the week it actually is, output/return the number of days betwe...
stackexchange_codegolf
Inspired by Bake a slice of Pi Challenge Given input 3 <= n <= 100 and 3 <= y <= n, construct an n x n matrix of the decimal portion of pi (14159...), starting in the top left. Then, take the upper-right triangle of size y x y and concatenate it together. Output the resulting number. For example, for input n = 5, y = 3...
stackexchange_codegolf
A Sumac sequence starts with two integers: t1 and t2. The next term, t3, = t1 - t2 More generally, tn = tn-2 - tn-1 The sequence ends when tn < 0. Your challenge: Write a program or function that prints the length of a Sumac sequence, starting with t1 and t2. t1 and t2 are integers within your language's range. Standa...
stackexchange_codegolf
You're driving a car in an infinite city whose blocks are pentagons arranged in the order-4 pentagonal tiling. At each step, you proceed to the next intersection and choose whether to continue left, right, or straight. A sequence of choices that returns you to your initial state (street segment and direction) is called...
stackexchange_codegolf
Every number can be represented using an infinitely long remainder sequence. For example, if we take the number 7, and perform 7mod2, then 7mod3, then 7mod4, and so on, we get 1,1,3,2,1,0,7,7,7,7,..... However, we need the shortest possible remainder subsequence that can still be used to distinguish it from all lower ...
stackexchange_codegolf
What general tips do you have for golfing in 1+? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to 1+ (e.g. "remove unnecessary whitespace" is not an answer). Please post one tip per answer.
stackexchange_codegolf
Introduction Boardgames are a classic play between kids, but there are some kids that feel bored playing a boardgame step by step. Now they want the result to be shown before they put their hands on the board. Challenge Suppose this boardgame: >---#<---X---<X<--#-$ > means the start of the game - means a position w...
stackexchange_codegolf