instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Task Given \$n\$, output position of the last odd digit in the decimal representation of \$2^n\$ (counting from the end). Rules There are no odd digits for \$n=1,2,3,6,11\$ \$(2, 4, 8, 64, 2048)\$ - you may output anything that is not a positive integer for them (no need to be consistent). You choose whether to handle...
stackexchange_codegolf
Backstory Meet my friend Jimmy: /o\ Jimmy is a little character who likes to stand on platforms. Here's Jimmy safely standing on a platform: /o\ ------------- Now, Jimmy has a good sense of balance, so he can safely stand with one leg off of the platform, like so: /o\ ------------------- Although i...
stackexchange_codegolf
For this challenge you will print the coordinates and color of each piece at the start of a game of checkers. Enter the x and y (comma seperated) for every square (indexed 0-7) on a checkerboard, followed by a "r" or "b" (for red or black) where the top of the board (closer to y=0) is red and the bottom is black. newl...
stackexchange_codegolf
Holy wars have been fought over spaces vs. tabs. (And of course spaces, being objectively superior, won.) —Alex A. Some people still refuse to accept that which is clearly supreme. You've just received a file using the incorrect, bad, and inferior form of whitespace, and now the contents of the file are tainted and...
stackexchange_codegolf
Consider a n x n multiplication table and replace each item with its remainder of division by n. For example, here is a 6x6 table and its "modulo 6" structure: (The last column and row are ignored since both are null) 1 2 3 4 5 6 | 1 2 3 4 5 2 4 6 8 10 12 | 2 4 0 2 4 3 6 9 12 15 18 | 3 0 3 0 3...
stackexchange_codegolf
In North America, most electrical outlets/receptacles follow standards set by NEMA. For this challenge, you'll be given a few properties of a device you need to plug in, and your program (or function) should return all of the outlets that would be compatible. For this challenge, an outlet has three properties: voltage,...
stackexchange_codegolf
The Challenge: Just as the title says, your challenge is to use the printable ASCII characters to create a program that prints out a random polygon in the terminal based on the number of sides, n provided by the user, where n is an integer in the range 3 -> 10 including 3 and 10, in as few bytes as possible. For exampl...
stackexchange_codegolf
Two points pand q in a topological space can be separated if there are open sets U and V such that: p is an element of U and q is an element of V U and V do not have any elements in common Your task is given a topology (a set of open sets) and two points p and q (p!=q) to output sets U and V satisfying the above cond...
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
Inspired by this stack of little statues that are currently on my desk at work, given to me by my colleagues from Sri Lanka when they visited The Netherlands: This is split into two different challenges due to popular demand: Part 1) Determine the amount of statues Part 2) Can the statues be stacked? (this challenge) ...
stackexchange_codegolf
Given an integer n >= 2, output the largest exponent in its prime factorization. This is OEIS sequence A051903. Example Let n = 144. Its prime factorization is 2^4 * 3^2. The largest exponent is 4. Test Cases 2 -> 1 3 -> 1 4 -> 2 5 -> 1 6 -> 1 7 -> 1 8 -> 3 9 -> 2 10 -> 1 11 -> 1 12 -> 2 144 -> 4 200 -> 3 500 -> 3 1024...
stackexchange_codegolf
This challenge was originally sandboxed by Magic Octopus Urn; I adopted and posted it with his permission. This is the cops' thread. The robbers' thread is here. The challenge Step One: Write a piece of code (function or full program) which checks for primality. Step Two: Remove pieces of your code by replacing charac...
stackexchange_codegolf
You are Desmond Hume. For the last 3 years, you and your partner, Kelvin, have been slave to a computer that requires a very specific sequence to be entered into it every 108 minutes to save the world. 4 8 15 16 23 42 Your partner died 40 days ago (due to an unfortunate accident involving Kelvin's head and a big rock)...
stackexchange_codegolf
Your job is to write a program that takes a number N as input and outputs all 2-by-N mazes that are solvable. Output format can be in the form of any two distinct values representing wall and empty - I use x and . here but you can use anything. You can have a matrix, array, string, ascii art, whatever is convenient, an...
stackexchange_codegolf
Challenge Given an image of the Moon as input, output the phase of the Moon. Phases of the Moon Your program will be supplied one of these images in png format and you must output the phase exactly as given: new moon hexdump waxing crescent hexdump first quarter hexdump waxing gibbous hexdump full moon hexdump...
stackexchange_codegolf
If you sort a string you'll typically get something like: ':Iaaceeefggghiiiiklllllmnnooooprrssstttttuuyyyy Yes, that was the first sentence sorted. As you can see, there are a lot of repeated characters, aa, eee, ttttt, 9 spaces and so on. If we add 128 to the ASCII-value of the first duplicate, 256 to the se...
stackexchange_codegolf
McCarthy's 1959 LISP In early 1959, John McCarthy wrote a groundbreaking paper defining just nine primitive functions that when put together still form the basis for all LISP-like languages today. The paper is available digitized here: http://www-formal.stanford.edu/jmc/recursive.pdf Your job is to fully implement a p...
stackexchange_codegolf
This blog post about generating random CSS color codes in JavaScript have multiple solutions for generating a random color in JavaScript. The shortest I can find is this: '#'+(Math.random()*0xffffff).toString(16).slice(-6) If you are not familiar with CSS color code read documentations here. Can we do better? What abo...
stackexchange_codegolf
Given an \$n\times m\$ matrix \$A\$ and two integers \$w,h\$, output a matrix of \$w\times h\$ called \$B\$, such that $$B_{i,j} = \int_{i-1}^i\mathbb dx\int_{j-1}^j A_{\left\lceil \frac xw\cdot n\right\rceil,\left\lceil \frac yh\cdot m\right\rceil}\mathbb dy\text{ (1-index),}$$ $$B_{i,j} = \int_i^{i+1}\mathbb dx\int_j...
stackexchange_codegolf
Given latitude/longitude of two points on the Moon (lat1, lon1) and (lat2, lon2), compute the distance between the two points in kilometers, by using any formula that gives the same result as the haversine formula. Input Four integer values lat1, lon1, lat2, lon2 in degree (angle) or four decimal values ϕ1, λ1, ϕ2, λ2...
stackexchange_codegolf
related What's assignable to what? In this challenge you will be given two types, A and B and determine if A is assignable to B, B is assignable to A, or neither. The Type System (I will use t to represent any type) Basic Types Basic types are represented by a single capital letter, such as X. They are basically class...
stackexchange_codegolf
In this task, you will write a program/function that takes a Normalized Malbolge program and outputs the resulting Malbolge program. (This is a secret tool that all Malbolge programmers are using!) Input A data structure that (somehow) represents a Normalized Malbolge program. Output A data structure that represents th...
stackexchange_codegolf
(The \$\mathbb{Q}\$ in the title means rational numbers.) Background Conway base 13 function is an example of a strongly Darboux function, a function that takes every real number on any open interval \$(a,b)\$. In other words, for any given real numbers \$a, b, y\$, you can find a value \$x\$ between \$a\$ and \$b\$ su...
stackexchange_codegolf
(Inspired by this challenge.) Let's say we have a string ABBCBA. We can say that there is a rise between A and B, for B follows A; we can say that there is a run between B and B, for nothing changes; and finally we can say there is a fall between C and B. We can draw a graph like this: A B B C B ...
stackexchange_codegolf
You may know the game The Six Degrees of Kevin Bacon, based on the conjecture that every actor in Hollywood can be connected to Kevin Bacon by no more than 6 "co-star" relations, so Kevin Bacon is supposedly the "best-connected" node in that graph. Your task will be to find the Kevin Bacon of a graph. We will use posit...
stackexchange_codegolf
The computational parity of an integer is defined as 1 if the integer has an odd number of set bits, and 0 otherwise. (src). Input You will receive one nonnegative integer that you will take the parity of. Optionally, you may take the size of the integer in bytes or bits as an argument, but you must specify this in yo...
stackexchange_codegolf
Your task is to take an array of numbers and a real number and return the value at that point in the array. Arrays start at \$\pi\$ and are counted in \$\pi\$ intervals. Thing is, we're actually going to interpolate between elements given the "index". As an example: Index: 1π 2π 3π 4π 5π 6π Array: [ 1.1, 1...
stackexchange_codegolf
Challenge Given a string of any length, write it as a triangle, spiraling out from the center. For example, abcdefghijklmnop becomes: g fah edcbi ponmlkj Or more explicitly: If you like, you can spiral counter-clockwise instead: g haf ibcde jklmnop Or add spaces uniformly: g f a h ...
stackexchange_codegolf
If a string T of length K appears K or more times in a string S, then it is potentially communistic. For example, 10 in 10/10 is potentially communistic, for it appears 2 times and is of length 2. Note that these substrings cannot overlap. A communistic transformation is one that takes this string T and moves each cha...
stackexchange_codegolf
We want to go on a night hike with the youth group, but of course not everyone has their torch, even though we told them we planned to split up. What options are there for group formation if n teens have m torches with them, but each group needs at least one torch? Example: Three teens with torches (X) and two without ...
stackexchange_codegolf
I was looking at my previous challenge and thought I could make a better version, but I didn't want to modify that one, so here it is! Challenge Given an input n, print an ASCII art cake n layers tall, viewed from the side, with two candles on top, using box drawing characters. First layer is thinner than the other...
stackexchange_codegolf
Inspired by Create a binary wall Given a list of positive integers, we can write them out all above each other like so, for [2, 6, 9, 4] as an example: 0010 0110 1001 0100 We can imagine this as a wall: ..#. .##. #..# .#.. However, this is a very weak wall, and it has collapsed! Each 1 (#) falls down until it hits th...
stackexchange_codegolf
Tic-Tac-Latin! This is a true story, so names have been altered. My latin teacher, Mr. Latin, created his own proprietary (no joke) tic tac toe variant. Let's call it tic-tac-latin. The game is simple, it is essentially tic tac toe played on a four by four grid. Formal rule declaration A line is either a row, column o...
stackexchange_codegolf
In the beginning there was NCSA Mosaic, and Mosaic called itself NCSA_Mosaic/2.0 (Windows 3.1), and Mosaic displayed pictures along with text, and there was much rejoicing. 15 years later... And then Google built Chrome, and Chrome used Webkit, and it was like Safari, and wanted pages built for Safari, and so preten...
stackexchange_codegolf
I recently saw this language in a challenge and it's awesome. Does anyone have some tips for code-golfing in it? Your tips should be at least somewhat specific to MarioLANG. Please post one tip per answer.
stackexchange_codegolf
The crazy mathematician owns a wide collection of numbers, and therefore the space he has left is quite limited. To save some, he must fold his integers, but unfortunately he is really lazy. Your task, if you wish to help him, is to create a function / program that folds a given positive integer for our number maniac. ...
stackexchange_codegolf
You should write a program or function which receives no input and outputs a stream of digits. The stream should contain at least once every positive integer number which does not contain the digit sequence 42. E.g. The string 1231 contains the integers 1 12 123 1231 2 23 231 3 31 (and 1 again) The stream should not c...
stackexchange_codegolf
Based on this game. Description : Based on Wikipedia's description. The 24 Game is an arithmetical card game in which the objective is to find a way to manipulate four integers so that the end result is 24. For example, for the card with the numbers 4, 7, 8, 8, a possible solution is : \begin{equation} ( 7 − ( 8 ÷ 8 ) ...
stackexchange_codegolf
Background Tetris Grand Master 3 has a hidden grading system based on the shape of the stack at the end of the game, which is called Secret ">" Stacking Challenge. It consists of entirely filling the lowest rows except for the zigzag pattern which starts at the left bottom cell and spans the entire width: # .######### ...
stackexchange_codegolf
Your goal is to alternate uppercase and lowercase letters, while ignoring non-alphaneumeric characters. Input => Output abc => aBc OR AbC a c => A c OR a C abc123abc => AbC123aBc OR aBc123AbC Shortest answer wins.
stackexchange_codegolf
Given an input string and a wrapping string, find the location of the first input string char in the wrapping string and replace it with the wrapping string char 1 step to the right of that, find the second char in the wrapping string and replace it with the char 2 steps to the right, find the third and replace it with...
stackexchange_codegolf
Given a number n and an upper limit l list the numbers that can be created by multiplying two or more numbers consisting of only sevens of length n or less that are less than l. A161145 is close to this challenge, however, you will NOT be including the 7, 77, 777, 7777, 77777, etc.. Examples n=anything, l<49 would resu...
stackexchange_codegolf
This challenge is based on a problem described in D. Parnas, On the criteria to be used in decomposing systems into modules, and elaborated upon in J. Morris, Real Programming in Functional Languages. Write a program or function which takes a list of book titles from stdin or as an argument, in a reasonable, convenient...
stackexchange_codegolf
Inspired by digital roots, the prime factoral root of a number is the number that emerges when you take the prime factors of a number, add them together, and repeat the process on the resulting number, continuing until you end up with a prime number (which has itself as its only prime factor, and is thus its own prime ...
stackexchange_codegolf
This is a code golf challenge. Just like the title says, write a program to covert a string of ascii characters into binary. For example: "Hello World!" should turn into 1001000 1100101 1101100 1101100 1101111 100000 1010111 1101111 1110010 1101100 1100100 100001. Note: I am particularly interested in a pyth implemen...
stackexchange_codegolf
Blackjack, also known as twenty-one, is a comparing card game between yourself and a dealer, where each player in turn competes against the dealer, but players do not play against each other. Play goes as follows, the dealer deals you a card. The dealer then deals them-self a card, face down. The dealer then deals yo...
stackexchange_codegolf
The Challenge: For an input of one letter X (upper or lower case from A to Z) and one digit N (0-9) print the corresponding letter X made of N * X. The letter has to be from this list: AAA BBBB CCCC DDDD EEEEE FFFFF GGG H H A A B B C D D E F ...
stackexchange_codegolf
For the question Find the highest unique digit , here is my answer : 9A,sqfe=W%X#- At the end I am essentially trying to achieve a lastIndexOf. I do that by reversing my array, using indexOf, and subtracting from 9. This adds 4 (9 W % -) extra bytes to get from indexOf to lastIndexOf. Furthermore, if I didn't know my...
stackexchange_codegolf
Inspired by this listing from the Commodore 64 User's Guide: 10 PRINT "{CLR/HOME}" 20 POKE 53280,7 : POKE 53281,13 30 X = 1 : Y = 1 40 DX = 1 : DY = 1 50 POKE 1024 + X + 40 * Y, 81 60 FOR T = 1 TO 10 : NEXT 70 POKE 1024 + X + 40 * Y, 32 80 X = X + DX 90 IF X <= 0 OR X >= 39 THEN DX = -DX 100 Y = Y + DY 110 IF Y <= 0 OR...
stackexchange_codegolf
Write the shortest possible code which converts tabs to spaces in the input. Tab size should be supplied as a parameter or be hardcoded in the code in a single place. Spaces on output should point to the right column, e.g. (\t represents a tab character): a\tb aa\tb aaa\tb aaaa\tb should become (for tab size 4): a b...
stackexchange_codegolf
The trumpet is a valved aerophone instrument, usually pitched in B♭. The sound is made when the player vibrates their lips to displace air inside the instrument. That vibration is acquired by setting one's mouth in a specific way, called the embouchure. Different embouchures, with tighter or looser lips, produce differ...
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
The idea here is to produce an almost repeating pattern. That is, the sequence being constructed changes at the last moment to avoid a repetition of some subsequence. Subsequences of the type AA and ABA are to be avoided (where B is no longer than A). Examples: I'll go ahead and start by listing all of the small exampl...
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
A Hilbert Curve is a type of space-filling curve, and it basically maps a line to a plane. Each point in the line corresponds to just one point in the plane, and each point in the plane corresponds to just one point on the line. Shown are iterations 0 through 4 of the Hilbert Curve: Iterations 0 up to 4: The objec...
stackexchange_codegolf
What general tips do you have for golfing in TI-BASIC for the TI-83/84+ series calculators? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to TI-BASIC (e.g. "remove comments" is not an answer). Please post one tip per answer.
stackexchange_codegolf
The famous game of Qwirkle has simple but intricate rules (See part 2 of this question for a summary of the rules!) The Challenge You are somehow (text input, function parameter, whatever) given a board of a Qwirkle game, like a snapshot from any current timeframe within a game. This board can be anything from complet...
stackexchange_codegolf
Your task is to write a RoboZZle interpreter. If you're not familiar with the game, please watch the video at robozzle.com or read my description below. A robot lives on a rectangular grid of squares coloured red, green, blue, or black. Black squares are inaccessible. The others are accessible and some of them contain ...
stackexchange_codegolf
Given a list of strings, find the smallest square matrix that contains each of the initial strings. The strings may appear horizontally, vertically or diagonally and forwards or backwards like in this question Word Search Puzzle. Words should be placed in the square, with at least one word in each direction (horizonta...
stackexchange_codegolf
There are 18 primes with distinct prime digits (A124674). Namely, they are: \$2, 3, 5, 7, 23, 37, 53, 73, 257, 523, 2357, 2753, 3257, 3527, 5237, 5273, 7253, 7523\$ Your task is to output this sequence. Rules sequence rules apply. This means valid solutions may use any of the following formats: Given some index \$n\$...
stackexchange_codegolf
The task is simple: given a 32 bit integer, convert it to its floating point value as defined by the IEEE 754 (32-bit) standard. To put it another way, interpret the integer as the bit-pattern of an IEEE binary32 single-precision float and output the numeric value it represents. IEEE 754 single precision Here is a conv...
stackexchange_codegolf
A skyline is an array of positive integers where each integer represents how tall a building is. For example, if we had the array [1,3,4,2,5,3,3] this would be the skyline in ascii art: # # # ## ### ###### ####### A maximal rectangle is a rectangle that cannot be extended in any direction while being contained...
stackexchange_codegolf
Background The Collatz Conjecture is quite well-known. Take any natural number. Triple and increment if odd; cut in half if even. Repeat, and it will reach 1 eventually. This famous conjecture, however, is only that, for it is yet unproven. Little-known to the world, that was not Lothar Collatz's first attempt at fame....
stackexchange_codegolf
This challenge is for the largest finite number you can get BrainFuck programs of given lengths to contain in memory. We must use one of the BF versions that uses big integers for the cells rather than byte values as not to be capped at 255. Do not use negative positions and values in memory. Do not use the BF instruct...
stackexchange_codegolf
Scala isn't a very commonly used language around here. Most of those who know it like it[citation needed], but some go :\ when they encounter its user-defined operators, saying they're too complicated. However, they're governed by a very simple set of rules, outlined here. Their precedence depends on the first characte...
stackexchange_codegolf
Your Challenge: For a golf Course Of Inputted 'n' length to hole where: 'n' is a whole number and a multiple of 5 between 150 and 500 and 1 integer in code = 1 metre You must calculate the least amount of swings it can be completed in using a combination of clubs and ranges. Here is a visual representation of what t...
stackexchange_codegolf
This is the cops' thread. See the robbers' thread here. In this cops and robbers challenge, the cops will be tasked with writing an algorithm that computes some function of their choice, while the robbers will try to come up with their algorithm. The catch is, the 'algorithm' must be a single closed-form mathematical e...
stackexchange_codegolf
Given an integer k and either a block of text, or a 2d array that the inner arrays may have unequal lengths (that resembles a block of text), rotate every character or element in the k-th column up or down to the next position that exists. Example Rotate the 20th column of the following text (1-based): A line with more...
stackexchange_codegolf
A family of sets is called laminar if for any two sets \$A\$ and \$B\$ in the family one of the following is true: \$ A \subseteq B \$ \$ A \supseteq B \$ \$ A \cap B = \emptyset \$ Or less mathematical: A laminar set is a list of lists that satisfies the following condition: If two elements of the top level list hav...
stackexchange_codegolf
Let \$Z\$ be either the integers, the positive integers, or the non-zero integers; pick whatever's convenient. Give two functions \$f\$ and \$g\$, each \$Z \to Z\$, such that: \$f(g(a)) = g(f(a))\$, for infinitely many integers \$a\$, and \$f(g(b)) \ne g(f(b))\$, for infinitely many integers \$b\$. Rules Many of the ...
stackexchange_codegolf
Every so often I have a function of type a -> b and a function of type b -> b -> c and I would like a function of type a -> a -> c. For example if I wanted to check the second element of each two tuples were equal snd :: (a , b) -> b (==) :: Eq a => a -> a -> Bool And I want something of type Eq b => (a, b) -> (c, b)...
stackexchange_codegolf
Background K functions have a feature called projection, which is essentially partial application of values to a function. The syntax for projections is a natural extension of the regular function call syntax: f[1;2;3] / call a ternary function f with three arguments 1, 2, 3 f[1;2;] / the third argument is missi...
stackexchange_codegolf
You are given an array A of length N and an array B of length N-1. You need to output array where items alternates: A[0], B[0], A[1], B[1], ..., B[N-2], A[N-1] Restrictions: N>0 Type of items is not specified, but code should work at least for unsigned integers. Sample input: A = [1,2,3,4] B = [7,8,9] Sample output:...
stackexchange_codegolf
Part of Advent of Code Golf 2021 event. See the linked meta post for details. Related to AoC2017 Day 9. Weekends are Bubbler's days off from posting these lol A large stream blocks your path. According to the locals, it's not safe to cross the stream at the moment because it's full of garbage. You look down at the str...
stackexchange_codegolf
Background A triangular grid is a grid formed by tiling the plane regularly with equilateral triangles of side length 1. The picture below is an example of a triangular grid. A triangular lattice point is a vertex of a triangle forming the triangular grid. The origin is a fixed point on the plane, which is one of the ...
stackexchange_codegolf
It is common to need to make a page selection interface. It typically looks like this: prev 1 ... 3 4 [5] 6 7 ... 173 next Which means there are totally 173 pages, and you are on the 5th page currently. This challenge requires you take the total number of pages and the current page number as input, and output a string...
stackexchange_codegolf
You have N lists A = [5, 6, 10, 15] B = [3, 0, 7, 4] C = [49, 59, 29] D = [19, 29, 39] E = [9, 15, 3, 10] You have to combine them such that: Two lists which have a common elements they should be next to each other. In this case answer is: A,E,B,C,D [5, 6, 10, 15, 9, 3, 0, 7, 4, 49, 59, 29, 19, 39] E comes after A a...
stackexchange_codegolf
This is an Irregular Webcomic! themed task.* Death is a rather extensive orginization, and, although Head Death has had no trouble telling his employees apart, certain other entities connected to the orginization have had trouble keeping track of them all. Thus, your task here is to, given the title of one of the var...
stackexchange_codegolf
Make a Number Expression is related : actually, it is also about Aheui. But it just made number expression, but this made real Aheui code. Aheui is esolang written in only Korean character. Because of its nature, Aheui can't use Arabic numbers. But, of course, there is way to generate number. Brief introduction to Ahe...
stackexchange_codegolf
Background The Python code ((((((((n%35)^11)*195)|53)&181)+n)%168)*n)+83 produces 74 distinct primes for \$0 \le n \le 73\$. This code also works in Java. The operators are as follows: + is addition * is multiplication % is modulus & is bitwise AND | is bitwise OR ^ is bitwise XOR The produced primes are: 83, 97, 11...
stackexchange_codegolf
Challenge : Inspired by Alphabet Position Finder Given an string and one of two possible mathematical operator (+ or -) as input, your task is to return the operation of each alphabet position from the string. Example : Input: "Hello World", "+" => "Hello World" = [8, 5, 12, 12, 15, 23, 15, 18, 12, 4] (converted to the...
stackexchange_codegolf
The string tut-tutut-tut-tuttut-tut can be constructed with overlapping or concatenated instances of the word tut-tut: tut-tutut-tut-tuttut-tut tut-tut tut-tut tut-tut tut-tut The string tut-tututut-tutut-tut cannot: tut-tututut-tutut-tut tut-tut^ |tut-tut | tut-tut ...
stackexchange_codegolf
Output a random triple \$(x,y,z)\$ of real numbers such that \$x+y+z=\frac{3}{2}\$ Each of \$x,y,z\$, taken alone, is uniformly distributed from \$0\$ to \$1\$. Please explain in your answer what distribution your code produces and why it meets these conditions. In particular, please include a demonstration that with...
stackexchange_codegolf
...will you help me immortalize it? I've had this pillow a few years now, and apparently it's time to get rid of it. Can you please write a function or program, that I can bring with me and use to recreate this pillow whenever I want to reminisce a bit. It must work with no input arguments. The output should look exa...
stackexchange_codegolf
The Challenge Given the two uppercase hexadecimal strings (both 6 characters long, XXXXXX and YYYYYY) representing RGB values (ranging from 000000 to FFFFFF inclusive), and a positive non-zero integer N, display a linear transition of the N+2 colors generated from XXXXXX to YYYYYY that would result in a color gradient....
stackexchange_codegolf
The autokey cipher is closely related to the Vigenère cipher (both were invented by Blaise de Vigenère). Decryption involves the encrypted message and the key. For simplicity, let us assume all characters in the message and key are lowercase letters (no spaces, numbers or symbols etc.). How to decrypt the cipher Conve...
stackexchange_codegolf
Background Jelly's arithmetic atoms vectorize automatically. In fact, x + y is well-defined whenever x and y are numbers or ragged arrays of numbers. Jelly's source code implements this behavior using a generic vectorizer, but for this challenge, we'll only consider addition of integers and nested integer arrays. Defin...
stackexchange_codegolf
Or, "Swap the first and last letters of each word" Your challenge is to, given a string of alphabetical ASCII characters as well as one other character to use as a delimiter (to separate each word), swap the first and last letters of each word. If there is a one-character word, leave it alone. The examples/testcases us...
stackexchange_codegolf
You have come across an old Indian manuscript, one that describes mounds of buried treasure. The manuscript also tells you the location of the treasure, except that some crucial numbers have been encoded indirectly into the text. You figure out that the text uses a 'Kaadi' system, a restricted subset of the more common...
stackexchange_codegolf
It is ancient knowledge that every non-negative integer can be rewritten as the sum of four squared integers. For example the number 1 can be expressed as \$0^2+0^2+0^2+1^2\$. Or, in general, for any non-negative integer \$n\$, there exist integers \$a,b,c,d\$ such that $$n = a^2+b^2+c^2+d^2$$ Joseph-Louis Lagrange pro...
stackexchange_codegolf
This challenge is related to some of the MATL language's features, as part of the May 2018 Language of the Month event. Associated challenge: Function clipboard: paste. Introduction MATL has several clipboards, where you can store values (copy) to be retrieved later (paste). Some clipboards are automatic, which means...
stackexchange_codegolf
If you have any tips regarding golfing in Sesos, a language made by Dennis, and nobody else has covered them yet, please post them here! Only one tip is allowed per answer. Your tip should be at least somewhat specific to Sesos itself, and not just brainfuck. If your tip is relevant to brainfuck in general, you should ...
stackexchange_codegolf
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. Oh no, Santa spilled wine all over his great book. Now most of the letters are illegible. How will Santa now know who is groovy and who is unspeakable? Challenge There was once a sequence of words, like this: groovy groovy groovy unspe...
stackexchange_codegolf
The edit (or Levenshtein) distance between two strings is the minimal number of single character insertions, deletions and substitutions needed to transform one string into the other. The challenge is to write code to output all strings with edit distance exactly k from a fixed string of length 10, where k is a variabl...
stackexchange_codegolf
We've all seen the famous painting of Marilyn Monroe created by Andy Warhol. Let's try to replicate that effect with the usual suspects. Your task is to write a program/programs that do as many as possible of the following tasks: With one image as the input, generate four color palettes from that image and print a 4x...
stackexchange_codegolf
Challenge Write a complete program that prints out the time it took to execute a certain part of itself. That part must include a process whose total number of operations (and therefore execution time) is dependent on a user-substituted numeric value - this can be denoted in any way in your code (uppercase N for exampl...
stackexchange_codegolf
Black Box is a board game, Your task is to reveal all clues. What is black box Black box is a board game with hidden atoms, Your task is given input, All atoms, reveal all clues. I/O Input The atoms can be any 1-char that is not newline (Used for separator) Like this. O.... ...O. ..O.. ..... ....O Output When the code...
stackexchange_codegolf
Here's a simple challenge, so hopefully lots of languages will be able to participate. Given a positive integer \$n\$, output \$A076039(n)\$ from the OEIS. That is, start with \$a(1)=1\$. Then for \$n>1\$: $$a(n)=\left\{ \begin{array}{ll} n\cdot a(n-1), & \text{if } n>a(n-1) \\ \lfloor a(n-1)/n \rfloor, & \text{otherw...
stackexchange_codegolf
A screen consists of some LED segments like such: The screen can be split into several(maybe one) component. Each component is a segment like above, with varying lengths. These components can be used to display any amount, including 0, of digits, as long as the component is large enough. Every digit except 1 needs two...
stackexchange_codegolf
Back to the basics! You're in you comp sci class again, except wiser and golfier. You have the tools, you have the power… but do you have the skill? Probably. Crash Course for the non-Computer Scientist (skip if you don't need it) A string is symbolically represented by an arbitrary letter (usually, for our purposes, w...
stackexchange_codegolf