instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
From Wikipedia, Gabriel's Horn is a particular geometric figure that has infinite surface area but finite volume. I discovered this definition in this Vsauce's video (starting at 0:22) where I took the inspiration for this problem. You begin with a cake (a cuboid) of dimension \$x \times y \times z\$. In your first sli...
stackexchange_codegolf
A recent SO question asks for a convenient one-liner to generate a list of numbers and their negative counterparts in Python. Given two integers \$1≤a≤b\$, generate all the integers \$x\$ such that \$a≤|x|≤b\$. The result may be printed or returned in any order or structure, as putting the result into a list and sortin...
stackexchange_codegolf
It's my friend's birthday soon and since he is a programmer and ASCII art lover, I thought I'd make him some ASCII cake! Sadly, I keep forgetting his current age, so I would like to have a program for my ASCII oven, that bakes a cake with a specified number of candles, so I don't have to do it myself again if I am wron...
stackexchange_codegolf
Given a non-empty string (or an integer, or a list/array if you prefer) composed exclusively of digits in the range [1-9], your task is to write a function (or a whole program) that applies a "Match-3 type of rule" from left to right and outputs the resulting string, like this : [parameter] "12223" -> [returned value] ...
stackexchange_codegolf
I am working on a code to print all semimagic squares [1] of a given size. I am working with the following definition: An \$n\times n\$ consists of numbers \$1,2,\cdots, n^2\$. All numbers must be distinct. Sum of each row and each column is equal. According to Ripatti A. (2018) [1]: \$n\$ number of semimagic squ...
stackexchange_codegolf
Not a new one: Input N, being n, 0 ≤ n ≤ 5. Output N times "Hello World." Example: Input 3 Output Hello World. Hello World. Hello World. These 2 are my best solutions: First public class Out { public static void main(String[] a) throws Exception { java.io.OutputStream o = System.out; ...
stackexchange_codegolf
I like golfing in tinylisp: (d M(q((x)(i x(i(disp x)0(M x))0 But I also like posting explanations with nicely formatted code: (d M (q ((x) (i x (i (disp x) 0 (M x)) 0)))) Can you help me generate the ungolfed code for my explanations? The task Given a line of tinylisp code, return or output the same cod...
stackexchange_codegolf
In chess, the Fool's Mate is the fastest possible way to reach checkmate. It is reached with Black's second move. In chess notation, one possible sequence of moves that achieves Fool's Mate is 1.f3 e6 2.g4 Qh4#. This is not the only possible way to achieve this checkmate (in the same number of moves). There are three ...
stackexchange_codegolf
Lonely primes (as I call them) are primes, where given a number grid with width w ≥ 3, are primes which do not have any other primes adjacent to them orthogonally or diagonally. For example, if we take this grid where w = 12 (primes highlighted in bold): 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17...
stackexchange_codegolf
OEIS sequence A020872 counts the number of restricted forests on the Möbius ladder Mn. The Challenge The challenge is to write a program that takes an integer as an input n > 1 and returns A020872(n), the number of restricted forests on the Möbius ladder Mn. This is code-golf, so shortest code wins. (An ulterior motiv...
stackexchange_codegolf
Write a program or function that takes in a quadratic equation and prints its factorized roots. The input can be taken in from any reasonable source, such as a function parameter, stdin, or a command line argument. Edit: This is not intended to be a duplicate of other quadratic equation questions. While others simply p...
stackexchange_codegolf
Much like this challenge, write a program or function that takes no input and prints or returns the string Hello, Earth! with an optional trailing newline. The catch is that your program must be an even number of characters long, and each two character chunk of your program must consist of identical characters. For ex...
stackexchange_codegolf
Robbers thread In this cops-and-robbers challenge, your task is to write a program h that outputs "Hello Shue!". Next, you have to choose a string i and also write a Shue program p, so that p(i)=h. Your score is len(p)+len(i). Your answer will contain the language of h, i and your score (please write the score as len(p...
stackexchange_codegolf
Originally posted (and deleted) by @Tlink, which was most likely inspired from this StackOverflow question. Since it was a shame it got deleted, because it seemed like a good challenge in general, I figured I'd repost it with proper formatting and rules. (I've tried contacting @Tlink and get his/her permission to post ...
stackexchange_codegolf
Your challenge today is to output a given term of a sequence enumerating all of the integers. The sequence is as follows: If we have a 0-indexed function generating the sequence f(n) and ceil(x) is the ceiling function, then f(0) = 0; abs(f(n)) = ceil(n/2); sign(f(n)) is positive when n and ceil(n/2) are either both ev...
stackexchange_codegolf
This problem is based on, A337517, the most recent OEIS sequence with the keyword "nice". \$a(n)\$ is the number of distinct resistances that can be produced from a circuit with exactly \$n\$ unit resistors. The sequence begins 1, 2, 4, 9, 23, 57, 151, 427, 1263, 3823, 11724, 36048, 110953, 342079. The goal of this c...
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
Background Your friend, a linguist, has recorded and analyzed some simple conversation snippets in various languages. Being quite absent-minded, they have forgotten which language each snippet was in. You must help them by creating a program that analyzes the sentence structures and rules out impossible cases. Input Yo...
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
Background I have a ladder leaning on a wall, and a remote-controlled robot that can climb it. I can send three different commands to the robot: UP: the robot takes one step upwards. If it was on the highest step, it trips over, falls down and explodes. DOWN: the robot takes one step downwards. If it was on the lowest...
stackexchange_codegolf
Years ago I read the "Best of Ruby Quiz" book by James Edward Gray II (also available online by now). For problem 2 in the book (which is problem 14 on his original RubyQuiz site), he mentions a golfed solution in under 300 bytes, even though he is not a big fan of golfing. So I did wonder if I could beat that and mayb...
stackexchange_codegolf
Write a program (in a first language A) that interprets a "99 Bottles of Beer" program and a FizzBuzz program (both in a second language B) on its standard input. The output should go to standard output; you may implement the interpreter as a function in languages lacking standardized I/O interfaces. Constraints The 99...
stackexchange_codegolf
The Challenge: Draw a rectangle of ASCII boxes: [] The Rules: Takes a width and a height input You can assume both of these are numbers Must produce a string with newline characters, \n Examples: 2, 2: [][] [][] 2, 3: [][] [][] [][] Fewest Bytes wins.
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
This challenge is related Challenge Your task is to write as many programs/snippets as you can, where each one outputs/prints/ returns an alphabet. The first program must output the letter A or a, the second one B or b and so on. You can not reuse any characters between the programs (Except Whitespace, it can be reused...
stackexchange_codegolf
Recently I had the pleasure of writing a Haskell program that could detect if the NegativeLiterals extension was engaged. I came up with the following: data B=B{u::Integer} instance Num B where{fromInteger=B;negate _=B 1} main=print$1==u(-1) Try it online! This will print True normally and False otherwise. Now I had ...
stackexchange_codegolf
I'm a lazy but efficient person, as many of you probably are as well. So, whenever I'm doing something I want to do it with minimal effort. Which is why I'm asking you to solve this problem for me. What I have here is a document of sorts. On every line of this document is a single word or short phrase. The document is ...
stackexchange_codegolf
Background A binary Hankel matrix is a matrix with constant skew-diagonals (positive sloping diagonals) containing only 0s and 1s. E.g. a 5x5 binary Hankel matrix looks like a b c d e b c d e f c d e f g d e f g h e f g h i where a, b, c, d, e, f, g, h, i are either 0 or 1. Let's define a matrix M as Hankelable if the...
stackexchange_codegolf
Given an ASCII art with simple closed paths using | and - (pipes and dashes), output a random point inside the boundary. Eg. given: ---- ---- | |- --- => |12|- --- | | | | |345| |6| ----- --- ----- --- Any point 1-6 should have an equal probability of being printed. Specs T...
stackexchange_codegolf
This is a problem on Luogu OJ. I decided to post it here because on Luogu OJ, many people, including me and my friend, are interested about how to solve this problem within the fewest characters. Your task is to output the following ASCII-art: ************ ####....#. #..###.....
stackexchange_codegolf
Using the word “conemon” print each character 2 times more than the last. The first letter, “c”, should be printed 10 times, the second 12 and so on. Each repeated-letter-string should be printed on a new line. So the end-result becomes: cccccccccc oooooooooooo nnnnnnnnnnnnnn eeeeeeeeeeeeeeee mmmmmmmmmmmmmmmmmm ooooooo...
stackexchange_codegolf
The task is a rather simple quine challenge with a twist, you must output your source code in the shape of a pyramid. The shape of a pyramid is defined below: 1 234 56789 ABCDEFG HIJKLMNOP QRSTUVWXYZa bcdefghijklmn ......etc...... The main limitation of this challenge is that your quine mus...
stackexchange_codegolf
Heavily based on this closed challenge. Codidact post, Sandbox Description A Sumac sequence starts with two non-zero integers \$t_1\$ and \$t_2.\$ The next term, \$t_3 = t_1 - t_2\$ More generally, \$t_n = t_{n-2} - t_{n-1}\$ The sequence ends when \$t_n ≤ 0\$. All values in the sequence must be positive. Challenge Gi...
stackexchange_codegolf
While at work I spotted a nice and simple challenge. The job was to stock products in cargo units with a certain capability. Since an order can have various batches, coming in sequence from the production, we usually make a list of the pieces of those batches distributed in each cargo to make sure nothing is lost durin...
stackexchange_codegolf
This is a relatively simple question. I'm trying to golf a Snake game I've written, and I'm trying to work out if there's a way to golf the following conditional assignments which control x and y coordinates of the snake ensuring a wrap around of the play area: if (P<0) { P = T-1; } if (P>T-1) { P = 0; } if (Q<0) {...
stackexchange_codegolf
This one is pretty simple. Write the shortest program you can, while generating the most output. To make it fun, programs that produce infinite output will be disqualified. The winner is the program with the largest output size/code size ratio. The results are based on what works on my computer, which is a Mac running ...
stackexchange_codegolf
The Tabula Recta (sometimes called a 'Vigenere Table'), was created by Johannes Trithemius, and has been used in several ciphers, including all variants of Bellaso's Vigenere cipher and the Trithemius cipher. It looks like this: ABCDEFGHIJKLMNOPQRSTUVWXYZ BCDEFGHIJKLMNOPQRSTUVWXYZA CDEFGHIJKLMNOPQRSTUVWXYZAB DEFGHIJKLM...
stackexchange_codegolf
Use any programming language to display numbers divisible by 1000000 that are greater than 1 and less than 10000000. Each number should be displayed in new line. Your program should display exactly: 1000000 2000000 3000000 4000000 5000000 6000000 7000000 8000000 9000000
stackexchange_codegolf
Challenge Create the image of a progress pride flag. Output Dimensions Rules Your program must create the image and not just load it from a website The colours can be just your language's default if it is very difficult / impossible to load RGB values, else they should be: red: (255,0,0), orange: (255,140,0), yello...
stackexchange_codegolf
Write a function (using as few bytes as possible) that takes a bi-dimensional array of any number of columns and rows in which: 0 represents empty block, 1 represents snake block. The function must return the number of possible paths the snake traveled. Example 1: Input: [ [1,1,1,1,1], [0,0,0,0,1], [0,0,0,0,1...
stackexchange_codegolf
Your task is to create a program or function that creates a paste on sprunge.us. Your program/function must receive the text to sprunge from your language's usual input mechanism, such as standard in; or in the case of a function, it can be a string or whatever makes the most sense to you. Your program will POST the te...
stackexchange_codegolf
A traveler needs to stay for n days in a hotel outside town. He is out of cash and his credit card is expired. But he has a gold chain with n links. The rule in this hotel is that residents should pay their rent every morning. The traveler comes to an agreement with the manager to pay one link of the golden chain for e...
stackexchange_codegolf
This is the inverse of "Encode the date in Christmas Eve format." Write a program that takes as input the string Christmas, possibly followed by Eve between 1 and 365 times, and outputs the date encoded in YYYY-MM-DD format, or any format from which the year, month, and date can be easily obtained. Assume that the "Ch...
stackexchange_codegolf
Objective Given a date, spell it out in Romanized Japanese. I/O Format The input format is flexible. The output format is <month spelling> <day spelling>; note the space. You can freely mix cases in output. You may output trailing newline. Mapping Months Month Spelling January Ichigatsu February Nigatsu Mar...
stackexchange_codegolf
Introduction: I'm a twisty puzzles collector. Here you can see my current collection of ± 300 puzzles. I think everyone knows the regular Rubik's Cube (3x3x3 Cube), which is a NxNxN Cube. There are also Cuboids (block-shaped puzzles), which come in different forms, perhaps better explained by SuperAntionioVivaldi here:...
stackexchange_codegolf
Given \$A = (a_1,\dots,a_k)\ k\ge2 \$ a sequence of positive integers, in which all elements are different. Starting from \$i=2\$, while \$a_i\in A:\$ (until the last element) If \$d=|a_i-a_{i-1}|\$ is not already in \$A\$, append \$d\$ to \$A\$ Increase \$i\$ Output the completed sequence. This is code-golf Example ...
stackexchange_codegolf
In this challenge, you'll print out the SBCS of Jelly, a popular golfing language. Its code page looks like this: _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F 0_ ¡ ¢ £ ¤ ¥ ¦ © ¬ ® µ ½ ¿ € Æ Ç Ð 1_ Ñ × Ø Œ Þ ß æ ç ð ı ȷ ñ ÷ ø œ þ 2_   ! " # $ % & ' ( ) * + , - . / 3_ 0 1 2 3 4 5 6 7 8 9 : ; < = > ? 4...
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
Very related You're given a piece of ASCII art representing a piece of land, like so: /‾\ __/ ‾\_ \_/‾\ \ Since an overline (‾) is not ASCII, you can use a ~ or - instead. Your challenge is to determine if it is connected by the lines of the characters. For example, the above can be traced ...
stackexchange_codegolf
Alice, Bob, Carol, Dave, and Eve are going out for a nice game of golf and need your help to decide in what order they will play. Your program will input some statements, which are defined as a condition, and then one or more optional logical boolean operators followed by another condition. (That's [Condition]([Logical...
stackexchange_codegolf
Introduction Don't you hate it when someone uploads an album you like to YouTube, but the description only contains a track listing? Like this: 1. Everything in Its Right Place - 4:11 2. Kid A - 4:44 3. The National Anthem - 5:50 4. How to Disappear Completely - 5:55 5. Treefingers - 3:42 6. Optimistic - 5:16 7. In Lim...
stackexchange_codegolf
Write a program or function that takes in a string and outputs a count of each modern English alphabet letter in the string, case-insensitive. Input: A string consisting of printable ASCII characters (code points 32-126). Output: A list of pairs, where each pair consists of a letter and its count in the string. The lis...
stackexchange_codegolf
In Python it is often necessary to use str.replace(a,b), however .replace is rather long and feels unnecessary. So is there a shorter alternative to str.replace. Alternatively is there a similar trick to how you can use r=range for golfing for str.replace? Example code for golfing m=input() f="hello" print m.replace('t...
stackexchange_codegolf
Challenge In this challenge, the input will be an ordered set of numbers and the program should be able to tell if the set of numbers is an Arithmetic Sequence. Input The input will be a list separated by ,(comma) or , (comma+space). The minimum length of the list should be 3 elements. Output The Output can be a Boo...
stackexchange_codegolf
Introduction On 30 May 2020, NASA and SpaceX launched a crewed rocket to the international space station on the SpaceX Demo 2 mission. This is the first time humans have been launched into orbit from American soil since the retiring of the Space Shuttle in 2011, and the first time ever that a private company has launch...
stackexchange_codegolf
You are the treasurer and you have received information that a counterfeit coin has entered the treasury. All you know is that the counterfeit coin is lighter than the original. Knowing how many coins you have in total and using only a balance scale, you need to determine the minimum number of weighings to determine wh...
stackexchange_codegolf
Now that we're graduating, it's time to tally up the number of times someone suggested that PPCG was graduating, even before the annoucement! (see here) Your program will receive a list of chat messages. Each message has three pieces of data: the user (e.g. Geobits), the timestamp (e.g. Aug 19 '15 2:41 PM), and the mes...
stackexchange_codegolf
Consider the following alphabetically sorted list of words: balderdash ballet balloonfish balloonist ballot brooding broom All of the words start with b, and the first 5 start with bal. If we just look at the first 2 words: balderdash ballet we could write instead: balderdash +let where the ' ' is used where a wor...
stackexchange_codegolf
Upon the rumor that Codegolf will have a Rock-Paper-Scissors tournament you look into the topic of square-free words. A word made of the letters R, P, S is square-free if it does not contain a sequence that repeats twice. That is to say, the word can not be written as a x x b where a and b are words of any length and ...
stackexchange_codegolf
I'm designing a new space station for generic super-villain purposes (something something megalaser), but I'm having trouble designing the solar panels. My genius team of scientists can calculate exactly how many square meters of paneling we need to power the station, but the problem is our solar panels only come in sq...
stackexchange_codegolf
plorcly borglar is a "mod" created by jan Misali for the constructed language toki pona that makes words sound funny. It involves substituting the 14 toki pona letters for funnier versions plus 2 extra rules. The substitutions are: toki pona letter plorcly borglar letter m bl n gl p b t pl k cl s scr...
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
The input will be two five letter words. They don't actually have to be dictionary words, just any five letters each, all lowercase or all uppercase, your choice. Only A-Z will appear in the input words and they will always be 5 characters in length. Your program is to score them both as though they were poker hands an...
stackexchange_codegolf
How do I remove all duplicates from list and order it based on count? s = ["foo", "this", "lem", "foo", "lem"] s = ["foo", "ebh", "wosv", "wosv", "ebh", "4whcu"] #should return >>> ["foo", "lem", "this"] >>> ["ebh", "wosv", "foo", "4whcu"] Rules: Must be shorter than the below code in terms of byte size. Order must b...
stackexchange_codegolf
Your task is to find two missing characters in a Columbo episode title. Input One of the 69 Columbo episode titles (as listed below), with exactly two characters replaced with *. Example: "Ran*om for a *ead Man" Output You may either return the full episode title, or just the two missing characters in any reasonable f...
stackexchange_codegolf
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
There is a great story to tell about regular hexagons found for example in honeycombs. But this busy bee needs your help in telling him which point is inside or outside his honeypot. So, given a regular hexagon as pictured below, centered at the origin and with edge size l, determine if a set of coordinates (x,y) are i...
stackexchange_codegolf
For this challenge, submissions should be a program or function shaped like a right triangle, which produces a right triangle of the same size. What is a right triangle? For this challenge, a right triangle consists of 1 or more lines, each containing a number of characters (assume all non-newline characters are the sa...
stackexchange_codegolf
Originally sandboxed by @xnor Left-or-right is a very simple language @xnor made up. Its expressions are made of arrows < (left), > (right), and parentheses. The goal is to evaluate an expression to either < or >. An expression A<B picks the left item A, while A>B picks the right one B. Think of < and > as arrows point...
stackexchange_codegolf
Task Given an integer matrix M and a modulus m, find an inverse of M modulo m. If the matrix M is not invertible modulo m, the behaviour is left unspecified. Matrix inverse If M is a square matrix, its inverse exists if and only if its determinant is not 0. Similarly, when we are talking about matrices modulo m, the in...
stackexchange_codegolf
I got to wondering yesterday if I could write a program to comb through a given word search and output the answers. It was actually surprisingly easy. Now I wonder just how small we can get. Rules Your first input is a string or collection of n lines, each of which is n characters long Your second input is a list of ...
stackexchange_codegolf
Can the Tune be Played? Explanation A broken musical keyboard has keys labelled with positive integers. It is broken in two ways: It takes a long time to process key presses: after pressing the key labelled with the number \$n\$, there is a gap of \$n\$ seconds before the \$n\$th note is heard. So, for example, the \$...
stackexchange_codegolf
I'm (still) trying to make another submission to the Largest Number Printable question, and I've got the following bit of code: f=->a{b,c,d=a;b ?a==b ?~-a:a==a-[c-c]?[[b,c,f[d]],~-c,b]:b:$n} h=[],$n=?~.ord,[] h=f[h]until h==p($n+=$n)-$n Ungolfed: f=->{b,c,d=a if b if a==b # a is not an array return a-1 elsif a...
stackexchange_codegolf
Task Create a program or a function that is valid in multiple programming languages, and when compiled/interpreted as a different language outputs "Hello, World!" in a different natural language. For example, a valid solution might output Hello World! (English) when compiled and run as C, Hallo Welt! (German) when comp...
stackexchange_codegolf
Part of Advent of Code Golf 2021 event. See the linked meta post for details. Related to AoC2017 Day 3, Part 2. You come across an experimental new kind of memory stored on an infinite two-dimensional grid. Each square on the grid is allocated in a spiral pattern starting at a location marked 1 and then counting up wh...
stackexchange_codegolf
Introduction: In my recent Strikethrough the Word Search List challenge I mentioned the following: When I do the word-search puzzles, I (almost) always go over the words in order, and strike them through one by one. In some cases I do them in reversed order as a change of pace, although that doesn't matter too much r...
stackexchange_codegolf
The Great Pyramid of Giza, the largest pyramid in Egypt, is not only the oldest of the Seven Wonders of the Ancient World, but it is also the only one to remain largely intact. The Egyptian Pyramids can take up to 20 years to build and are so big that Al-Aziz Uthman, son of the great Saladin who crushed the Crusaders, ...
stackexchange_codegolf
Write a program that either accepts input via stdin or from the command line. It will then unscramble the words, printing out the unscrambled version of each word.You get a text file containing every word (most of them) in the English dictionary to use. (Here is the file: Word List, and you can either use it from the w...
stackexchange_codegolf
Given an array of integers, count the number of contiguous subarrays with an even sum. You may assume that the array is non-empty, and contains only non-negative integers. This is code-golf, so the shortest code in bytes wins. Test Cases Input -> Output [7] -> 0 [8] -> 1 [3, 5] -> 1 [6, 2] -> 3 [2, 4, 5] -> 3 [7, 4, 0,...
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
I'm attempting to solve a programming golf style programming puzzle. I need to write an 18 character phrase in Chef in less than 32 "lines" of code. In this case, a line counts as an ingredient or an instruction. The most straightforward way of doing this is to declare an ingredient for each character and put each ingr...
stackexchange_codegolf
Introduction A circle-tangent polynomial is a polynomial of degree \$N\ge3\$ or above that is tangent to the unit circle from inside at all of its N-1 intersection points. The two tails that exits the circle are considered tangent at their intersection points from inside as well. You may consider such polynomials are w...
stackexchange_codegolf
Well, although this challenge turned out to be a huge success, it also turned out to be very trivial to solve. Therefore, for those of looking for more of a challenge, I created a sequel to this challenge in which you must now count the number of unique rectangles. Check it out! Now, for those of you looking to solve ...
stackexchange_codegolf
Given an input sentence consisting of one or more words [a-z]+ and zero or more spaces , output an ASCII-art histogram (bar graph) of the letter distribution of the input sentence. The histogram must be laid out horizontally, i.e. with the letter key along the bottom in alphabetical order from left to right, with a Y-a...
stackexchange_codegolf
Too bad! I had such a beautiful equation, but I lost all my =+-*, so there is nothing left but a chain of digits, looking like a number: 7512. But was it 7+5=12 or 7-5=1*2 or 7=5*1+2 or 7=5+1*2? Or are there even more valid possibilities? Your task: For a given positive integer number, return the number of true equatio...
stackexchange_codegolf
Intro The Switching sequence is defined like so: Start with n people standing in a circle (6 for this example). 1 2 6 3 5 4 Starting from person 1, the person that is to the left of the "chosen" person is removed. 1 6 3 5 4 The removed person can "switch" the removal method up: If the removed person is ...
stackexchange_codegolf
Write a program or function that takes input and outputs/returns a full program (in the same language) that outputs said input. Note that the input may contain any printable ASCII character or newline (AKA 0x20-0x7f and 0x0a). However, the input will not have trailing whitespace nor preceding whitespace, nor will it be...
stackexchange_codegolf
Cubically is too tedious to manually write any code in. Your challenge is to translate ASCII text into Cubically source code. Cubically This is just a quick run-down of Cubically; the repository has a more complete guide and details. Cubically is an esolang I wrote a while ago, designed to be painful to use. It contain...
stackexchange_codegolf
The task is simple, divide, get the quotient and the remainder, and if the remainder isn't 1 or 0, do the same thing (quotient divmod remainder) until the remainder is 1 or 0, then get the remainder. If the last input number is 1 or 0, output it. If the input is [15, 4], then the output would be 0, because the divmod o...
stackexchange_codegolf
We have lots of horizontal axis for numbers, but I honestly think they're kind of boring. Your task today is to build me a portion of a diagonal axis between two distinct non-negative integers given as input. How to build a diagonal axis? Let's take an example, with the input 0, 5. Our axis should look like this: 0 ...
stackexchange_codegolf
This is a cops-and-robbers challenge. The robbers' thread is here. An interesting question to think about is the following: If I have a sequence of numbers how many of them do I have to provide before it is clear what sequence I am talking about? For example if I want to talk about the positive integers in order star...
stackexchange_codegolf
Write a function or program that given a list of non negative integers, arranges them such that they form the largest possible number. INPUT [50, 2, 1, 9] OUTPUT 95021 INPUT 0 OUTPUT 0 INPUT (Interesting one) [7, 76] OUTPUT 776 RULES standard loopholes apply. Depending on your language you can use int(32) / in...
stackexchange_codegolf
Challenge Implement the 1-indexed sequence A054049, which starts like this: 1, 2, 3, 6, 13, 5, 9, 377, 21, 11, 89, 14, 8, 233, 16, 987, 18, 2584, 20, 6765, 55, 23, 28657, 25, 75025, 27, 196418, 29, 514229, 31, 1346269, 33, 3524578, ... This sequence is the lexicographically smallest sequence of positive integers, so t...
stackexchange_codegolf
This challenge is inspired by one of my other challenges: Pointlessly make your way down the alphabet That challenge asked you to take a string of text, and for each letter produce a sequence of letters moving down the alphabet to 'a'. For this challenge I'd like to decode the output of that challenge (minus the line b...
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
Originally sandboxed by @xnor Left-or-right is a very simple language @xnor made up. Its expressions are made of arrows < (left), > (right), and parentheses. The goal is to evaluate an expression to either < or >. An expression A<B picks the left item A, while A>B picks the right one B. Think of < and > as arrows point...
stackexchange_codegolf
Intro Given a whole number \$< 100,\$ extend/shorten the english representation of the number to have as many characters as it's value. Sandbox Rules Take the number \$n\$, and get it in words from this dictionary. You may take this dictionary in any way you prefer. (a list, read from link, command line arg, STDIN, va...
stackexchange_codegolf
Consider you have a hash function \$\mathcal{H}\$ which takes strings of length \$2n\$ and returns strings of length \$n\$ and has the nice property that it is collision resistant, i.e. it is hard to find two different strings \$s \neq s'\$ with the same hash \$\mathcal{H}(s) = \mathcal{H}(s')\$. You would now like to ...
stackexchange_codegolf
This is a code-challenge with a custom scoring system, where the lowest score wins. Introduction Many smartphones allow to enter text by swiping your finger across the 2D virtual keyboard. This technology is usually combined with a prediction algorithm that outputs a list of guessed words, sorted from most likely to le...
stackexchange_codegolf
Barbrack Your task is to write a program or function that takes a non-negative integer (in decimal or any other convenient base for your language), and output a number in the numbering system Barbrack. What's that? Barbrack is a numbering system I made up that can represent non-negative integers. Zero is represented wi...
stackexchange_codegolf