instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Like Brainfuck or JSFuck would be efficient in terms of number of characters needed, but what languages would have the highest amount of information per character? I was thinking of APL and J but there has to be more. My goal with this question is to find a program that would allow a person with theoretically infinite ...
stackexchange_codegolf
Your task is to slowly calculate exponentiation, with the following steps: Given two inputs (in this example, 4 and 8), you must calculate the exponentiation by calculate the equation bit by bit. You would do 4^8, have a greater base value (4) and a smaller exponent (8). You can do this using more exponentiation and di...
stackexchange_codegolf
Playing tetris is fun. Watching an AI play tetris is also fun. Some tetris AIs will always ignore the possibility of maneuvering a piece under an overhang, which makes me sad. It means that the programmer said to himself, "What are all the possible places the tile could be at the top of the board, and from each place,...
stackexchange_codegolf
For the purpose of this challenge, we'll define whitespace as only linefeeds (0x0A) and spaces (0x20). Note that most languages and regex flavours consider many other characters as whitespace as well, both inside and outside the ASCII range so you might not be able to make use of the corresponding built-ins. The Cops' ...
stackexchange_codegolf
In this game of cops and robbers, each cop will make a vault: a program that stores a secret, and requires a key to unlock. The robbers should find a way to get the vault to reveal its secret without knowing the key. Cop rules Cops will write two short segments of code: A vault, which takes a key and secret, then allo...
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
Consider a potentially self-intersecting polygon, defined by a list of vertices in 2D space. E.g. {{0, 0}, {5, 0}, {5, 4}, {1, 4}, {1, 2}, {3, 2}, {3, 3}, {2, 3}, {2, 1}, {4, 1}, {4, 5}, {0, 5}} There are several ways to define the area of such a polygon, but the most interesting one is the even-odd rule. Taking any p...
stackexchange_codegolf
If you've ever tried adding labels to a really dense plot, then you'll realise that sometimes labels will overlap one another, making them hard to read. We're going to do something similar but in 1D. Input will be a sequence of (label, x-coordinate) pairs, and output will be the result of drawing each point and label, ...
stackexchange_codegolf
your challenge is to draw this ASCII art: | | |- - - - | | - - - | | | | | | | |- - -| |- - - | | | | | | | | | | | | | |- - - - |- - - |- - - - - - remember this is code golf meaning you have to answer in the leas...
stackexchange_codegolf
Background There is an interesting question on MathSE about some conjectures that are disproven by extremely large counter-examples. This delightful answer tells the story of a sequence of numbers called Gijswijt's sequence, which is now registered as A090822. The sequence is defined as follows Let \$a_1 = 1\$ and for...
stackexchange_codegolf
An example will easily explain this to you. Suppose an array [1,2,3,4,5] Step 1 1 2 3 4 5 ----+---- Step 2 5/ 4/ 1 2 3 / ----+/ Step 3 5| 4| 1 2 3| ----+| Step 4 5\ 4\ 1 2 3\ ----+-\ Step 5 Take the sum of face-to-face elements 6 6 3 You just successfully folded an array 1 time. 2 times f...
stackexchange_codegolf
Brainfuck is an esoteric programming language that is Turing Complete, meaning you can't tell whether a given program will halt without running it. It's cell-based and has an infinite tape of cells, values containing an unsigned integer from 0 to 255, but if you give it arbitrary-size cells, just three is enough to mak...
stackexchange_codegolf
A while ago, I had a look at the prime factorization of 27000: 27000 = 23 × 33 × 53 There are two special things about that: consecutive-prime: The primes are consecutive: 2 is the 1st prime, 3 is the 2nd prime, 5 is the 3rd prime. constant-exponent: The exponent is the same for every prime (always 3) Mathematicall...
stackexchange_codegolf
256-color Xterm-compatible terminals add 240 colors on top of the usual 16 system colors. Colors 16-231 use 6 levels (0, 95, 135, 175, 215, 255) of red, green, and blue, ordered lexicographically. Colors 232-255 are simply 24 levels of gray (8...238 by 10s). To get a better idea of what I'm talking about, see this tabl...
stackexchange_codegolf
This challenge is based on a video in which Andrew Huang discusses unusual time signatures... https://www.youtube.com/watch?v=JQk-1IXRfew In it, he advises that you can understand time signatures by dividing them into 3's and 2's. So you count to a small number a few times, instead of counting to a large number. Here's...
stackexchange_codegolf
What general tips do you have for golfing in 2 dimensional programming languages? I'm looking for tips which can be applied to code-golf problems and are specific to 2D programming languages, but not specific to any one language (Responses like "remove comments" and "use the M operation" are not answers). Please post ...
stackexchange_codegolf
In Excel, the columns range from A-Z, AA,AB,AZ,BA,..,BZ and so on. They actually each stand for numbers, but rather are encoded as alphabet strings. In this challenge, you will be given a string of alphabets, and you must calculate the column it corresponds to. Some tests: 'A' returns 1 (meaning that it is the first c...
stackexchange_codegolf
Note: this problem was inspired by the Unsolved Mathematical Problems for K-12 youtube video, which also features other interesting puzzles. From the wikipedia article: The no-three-in-line problem asks for the maximum number of points that can be placed in the n × n grid so that no three points are collinear ..... Al...
stackexchange_codegolf
Here's a very simple little problem that I don't believe has been asked before. Challenge Write a program or a function that takes in four positive integers that represents the lengths of movable but unbreakable and unbendable straight fences. Output the area of the largest rectangular yard that can be fully encompasse...
stackexchange_codegolf
Write a function that takes two parameters: a positive integer n and a list of words. Given a cube of n-by-n-by-n units, assign a random letter (A-Z) to each surface unit. (For a 3x3x3 cube, there would be 9 surface units on each face.) Then determine whether it's possible for an ant walking along the surface (with th...
stackexchange_codegolf
This is a sequence question of the usual type, as applied to OEIS sequence A038666. That is, do either of the following: Accept no or any input, and output A038666 until the heat death of the universe. Accept a positive integer as input, and output the \$n\$th term of A038666 or its first \$n\$ terms. (If using \$0\$-...
stackexchange_codegolf
Create the shortest program/function/whatever that splits an inputted string along un-nested commas. A comma is considered nested if it is either within parentheses, brackets, or braces. Input and output Output should be a list or a string joined with linebreaks. The input may contain any characters. All testcases wil...
stackexchange_codegolf
Given a digit x (between 0 to 9, inclusive) and a number n, calculate the sum of the first n terms of the following sequence: \$x,10x+x,100x+10x+x,\dots\$ For example, if x is 6 and n is 2, then the result will be 6+66 meaning 72. There can be trailing whitespace in the output but not leading whitespace.
stackexchange_codegolf
You probably all know the 7-segment display which can display among other things all digits from \$0\dots 9\$: Challenge We only consider the segments \$\texttt{A}\dots\texttt{G}\$, your task is to decode a single digit given which segments are turned on. This can be encoded as an 8-bit integer, here's a table of each...
stackexchange_codegolf
The word BANANA appears exactly once in this word search: B A N A A N B B A B A N A B A N A N A B N N A A N N B A A A N N N A A N N N B A A N N N B A N A N A A B A N A N B A N A N B B A The word search above contains only one occurrence of the word BANANA looking up, down, left, right, or diagonally, but it has lot of...
stackexchange_codegolf
I live in the UK, where it rains. A lot. I also have the unfortunate necessity to need to wear glasses to see, which means that when it rains (as it is now), I can barely see out of them. This challenge is so that you can all experience the same! Task Output ASCII art glasses with a drop of water added each second. Inp...
stackexchange_codegolf
A CSS selector is made up of five elements: The element type (tag name) The id of the element The classes of the element The attributes of the element Operators to chain these element selectors This challenge will only involve the first four--also taking into account operators would make more than one element be gen...
stackexchange_codegolf
Fourward (Introduction) I have an unhealthy obsession with the number 4. I love it so much, in fact, that seeing any other digit is frustrating to me. I therefour wish to create a 'Fourier Transformation': a way to represent any integer value with an expression that uses only the digit 4. Fourmat (Challenge) I wish to ...
stackexchange_codegolf
Your input will consist of an 18×18 image in any reasonable format, containing a horizontally and vertically centered 14px Roboto Mono character. This can be any of 94 printable ASCII characters (not including the space). But: you only need to be able to recognize some 80 character subset of your choice. Output should ...
stackexchange_codegolf
Preamble Integers are always either even or odd. Even integers are divisible by two, odd integers are not. When you add two integers you can infer whether the result will be even or odd based on whether the summands were even or odd: Even + Even = Even Even + Odd = Odd Odd + Even = Odd Odd + Odd = Even Likewise, when...
stackexchange_codegolf
Given a, b, c the length of the three sides of a triangle, say if the triangle is right-angled (i.e. has one angle equal to 90 degrees) or not. Input Three positive integer values in any order Output Either a specific true output (true, 1, yes, ...) or a specific false output (false, 0, no, ...) Example 5, 3, 4 ...
stackexchange_codegolf
(Similar: Through the bases) Normally, our number system is base ten, with the digits 0123456789. However, we can increase or decrease the base count (so hexadecimal uses 0123456789abcdef and octal uses 01234567. Your goal is: given a string, interpret it in all bases 2-36 for which it's valid, compute the total, and e...
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 first Predecessor-completed Ascii Cube (PAC 1) is a simple cube with side length 1 and looks like this: /////\ ///// \ \\\\\ / \\\\\/ The PAC 2 is a geometric shape such that combining it with its predecessor (the PAC 1) completes a side length 2 cube: front back /////////\ /...
stackexchange_codegolf
Sometimes authors will write (s)he as a stand in for she or he and for some reason they don't want to use singular they. This is ok for the nominative but doesn't work so well when you want to write "her or him". You can write h(er)(im) which covers both cases but gives two extra "pronouns" h her him herim In formal...
stackexchange_codegolf
Are there any useful shortcuts that can be used in Java? As shown below, import already adds at least 17 characters to a program. import java.io.*; I understand that the simple solution would be to use another language, but it seems to be a real challenge to shorten Java programs. Tips should be specific to Java...
stackexchange_codegolf
Slope fields or direction fields, are a graphical representation of the solutions to a first-order differential equation of a scalar function. A slope field shows the slope of a differential equation at certain vertical and horizontal intervals on the cartesian plane, and can be used to determine the approximate tangen...
stackexchange_codegolf
Using our familiar mathematical symbols: +, x, parenthesis, and any rational number, it's easy to create expressions that evaluates to some desired number. For example: 1+(2x3)=7, (1+2)+(3x6.5)=22.5 and so on. Boring enough. In this challenge, we'll use a new operator: ±. The use of ± in an expression means you need to...
stackexchange_codegolf
Background You have again x4 been given the task of calculating the number of landmines in a field. But this time, the field is not a number field... it's a field of letters. Our landmine letter operator is sick and requires you to cover for them. They left you the following note: Things work a little differently with...
stackexchange_codegolf
Many digital clocks display the time using simplified digits comprised of only seven different lights that are either on or off: When mirrored horizontally, the digits 018 don't change because they are symmetrical. Also, the digits 2 and 5 get swapped, 2 becoming 5 and vice versa. All the other digits become invalid w...
stackexchange_codegolf
The task Write a program or function that takes a traffic intersection structure and outputs the sequence, in which vehicles will pass. The output should contain at most four lines with the following format #. x->y\n, where # is a sequence number number, followed by the dot ., x and y are characters ["N", "E", "S", "W"...
stackexchange_codegolf
The player has to keep guessing a number from 1 to 10 until they guess the correct number to win the game. If they make an incorrect guess, they're told if their guess was too low or too high. Each line has to render below the previous line for me to accept the solution as the new code for the game (However, you can st...
stackexchange_codegolf
Note: this is heavily inspired by this question. Task: Your task is to generate the nth prime, when each character of your program is repeated n times in place. Let's say your program is: Derp Every character in there is repeated once, so it should output 2. When every character is duplicated in place, like so: DDeerr...
stackexchange_codegolf
As you probably know, there is a war going on in Ukraine. I noticed that it seems nobody has posted a Ukrainian flag challenge yet, so I thought I'd do it myself in support of Ukraine. The Challenge Here is the flag: The flag is divided horizontally across the middle into two equally sized stripes. Stripe colors: (0,...
stackexchange_codegolf
Given a string of 1 and 2 of any length, write some code (doesn't have to be a function anymore, everything will be just fine) that calculates how many steps does it need to shrink the string to a final form, following this criterion: If your string is 112112, this means that you have to print a 1, two 1s and a 2, like...
stackexchange_codegolf
Introduction Sometimes, my boxes are too small to fit anything in it. I need you to make a box expander! So, what makes a box a box in this challenge. OOOO O O O O O O OOOO The corners of the box are always spaces. The box itself can be made out of the same character. That character can be any printable ASC...
stackexchange_codegolf
Background In some possible futures, the world will convert their numerical systems from decimal (base 10 or b10) to some other base (binary b2, octal b8, hexadecimal b16, or even unary b1, in which case we're screwed!). Thus, in preparation for this possible world-changing event, you decide to base-proof all of your p...
stackexchange_codegolf
Your goal is to write a program or function that takes in as input a string representing the path to a file, and outputs a truthy value if that file is not empty and contains no non-null bytes -- i.e., all bits are 0 -- and a falsey value otherwise. I realize it is a very simple problem and I guess I could hack somethi...
stackexchange_codegolf
Given a number n, calculates BB(n) (the maximum number of 1s finally on the tape, among all halting 2-symbol n-state Turing machines with tape of zeros). To solve the problem, you are given an extra (black-box) function H as input, which takes a function in your language (f) and returns a truthy/falsy value indicates w...
stackexchange_codegolf
Context In APL, trains are tacit sequences of monadic/dyadic functions that can be called with one or two arguments. We'll code something to check if a given train follows the correct structure we need in order to have a sound train. Task Given the sequence of function arities in the train, determine if the train is va...
stackexchange_codegolf
Given a distance in meters as an integer \$60\le d \le 260\$, return the number of clubs that may be used according to the following arbitrary chart, where both \$min\$ and \$max\$ are inclusive: club | min | max ----------------+-----+----- Driver | 200 | 260 3-wood | 180 | 235 5-wood ...
stackexchange_codegolf
Suzhou numerals (蘇州碼子; also 花碼) are Chinese decimal numerals: 0 〇 1 〡 一 2 〢 二 3 〣 三 4 〤 5 〥 6 〦 7 〧 8 〨 9 〩 They pretty much work like Arabic numerals, except that when there are consecutive digits belonging to the set {1, 2, 3}, the digits alternate between vertical stroke notation {〡,〢,〣} and horizontal stroke notat...
stackexchange_codegolf
The Sequence Everyone knows the only even prime number is 2. Ho-hum. But, there are certain even numbers n where, when concatenated with n-1, they become a prime number. For starters, 1 isn't in the list, because 10 isn't prime. Similarly with 2 (21), and 3 (32). However, 4 works because 43 is prime, so it's the first ...
stackexchange_codegolf
If you've come here, you probably know what code-golf is, and that's what I'm going to assume. Story (I guess) Keyboards are input devices we use all the time. They existed before mice and touch screen, etc. Their fundamentals have not changed: when you press a key down, a signal is sent to the computer. When you rele...
stackexchange_codegolf
Definitions: A palindrome is a string which reads the same backward or forward (not counting spaces or special characters), such as "madam" or "Sorel Eros". A date is said to be a palindrome when its dd-mm-yyyy format is a palindrome (or any other local representation). Two strings are said to be anagrams when the co...
stackexchange_codegolf
The reverse-then-add (RTA) sequence is a sequence obtained by adding a number to its reverse, and repeating the process on the result. For eg., $$ 5 + 5 = 10 \Rightarrow 10 + 01 = 11 \Rightarrow 11 + 11 = 22 \Rightarrow 22 + 22 = 44 \Rightarrow\text{ }... $$ Thus, 5's RTA sequence contains 10, 11, 22, 44, 88, 176, et...
stackexchange_codegolf
This post is loosely inspired by this mathoverflow post. A Vanisher is any pattern in Conway's Game of life that completely disappears after one step. For example the following pattern is a size 9 Vanisher. An interesting property of Vanishers is that any pattern can be made into a vanishing one by simply adding mo...
stackexchange_codegolf
One day you awake only to find yourself caught in an array. You try to just walk out of there, taking one index at the time, but it seems there are other rules: The array is completely filled with natural numbers. If you find yourself on an index n, you go to the index array[n], except: If you find yourself on an inde...
stackexchange_codegolf
Task Given the page of a book P on stdin, count all occurrences of the digits 0-9 in each member of the range 1 to P. There is no page zero and your program should handle any number less than 1,000,000. Since putting a constraint on how you can do it is difficult to explain there will be a time limit of 3 seconds inste...
stackexchange_codegolf
I have trouble remembering everything I have to do when leveling up a D&D character. For whatever reason, one of the things that gives me trouble is figuring out what their new maximum HP value should be. For this challenge, you will write a program or function to calculate the correct value automatically. Terminology ...
stackexchange_codegolf
The task Given an image as input, your task is to do the following: Resize the image so it is At least 2 times smaller, but still has the same width/height ratio by taking every second (if resized to 2x) pixel in both horizontal and vertical directions and using those in the pixel art image. Example: a 4x4 image [a...
stackexchange_codegolf
Inspired by We had a unit test once which only failed on Sundays, write a program or function that does nothing but throw an error when it is Sunday, and exit gracefully on any other day. Rules: No using input or showing output through the usual IO methods, except to print to STDERR or your language's equivalent. You ...
stackexchange_codegolf
The game shapez.io has a lot of shapes. In my previous challenge, the object was to generate a random code for a shape. Now, your challenge is to render a shape. Specs Shapes Each shape has a unique shortcode, for example: is CrWgRuSp - clockwise from top right, red circle, green wedge, uncolored rectangle, purple sta...
stackexchange_codegolf
You have to take a base-10 number (e.g. 735) and another number for the base to convert to, and convert the base-10 number into the equivalent number in the other base. Rules: You aren't allowed to use any conversion functions built into your language This is code-golf, the shortest answer in bytes wins!
stackexchange_codegolf
Here's an interview question I've seen on a few sites. People claim that an O(n) solution is possible, but I've been racking my brain these last 2 days and I couldn't come up with a solution, nor find one anywhere on the web. Given an array of integers, find two disjoint, contiguous subarrays such that the absolute dif...
stackexchange_codegolf
Given a positive integer n >= 1, output the first n rows of the following structure: # # # ### # # # # # ## ## ##### # # # # # # # # # # ### # ## ## ## # ## ### ### ####### The n-th 1-indexed row is the binary representation of n, mirrored without copying the last character, with # in place of 1 a...
stackexchange_codegolf
Martin Ender's 2D programming language Alice has two different modes depending on what orientation the IP has: orthogonal (Cardinal mode) or diagonal (Ordinal mode). Commands in Alice change their meaning depending on which mode the program is in when they're executed. One especially interesting implementation of this ...
stackexchange_codegolf
Traditionally when you compare two strings you use lexicographical comparison. That can be described by the recursive algorithm: $$ f(x, y)= \left\{\begin{array}[rr] \\ \mathrm{EQ} & \mathrm{if}\,\mid x\mid=0\,\mathrm{and}\,\mid y\mid=0 \\ \mathrm{GT} & \mathrm{if}\,\mid x\mid>0\,\mathrm{and}\,\mid y\mid=0 \\ \mathrm{L...
stackexchange_codegolf
Here is an easy-intermediate challenge for anyone interested! What is that? A thing me and brother do a bit too often is this: One of us has a problem and asks the other to explain how to do certain stuff. The other just says the following carelessly: How to <verb> in <n> easy steps! ...
stackexchange_codegolf
Challenge: Input: A sorted list of positive integers. Output: The amount of integers which are still at the exact same index, after rotating the digits in each integer its index amount of times towards the left and sorting the modified list again. Example: Input: [8,49,73,102,259,762,2782,3383,9217,37846,89487,7471788]...
stackexchange_codegolf
Challenge You are supposed to output the series I recently designed which goes as follows which are pen stroke counts of ascending prime numbers: 2, 3, 2, 4, 3, 5, 6, 5, 7, 7, 7, 10, 4, 6, 7, 4, 4, 4, 7, 6, 8... Example This is an illustration of how this series is formed, first, it takes a prime number from in sequen...
stackexchange_codegolf
Given a string of ASCII characters, output the character that is in the middle. If there is no middle character (when the string has an even length), output the ASCII character whose ordinal is the floored average of the two center characters. If the string is empty, an empty string should be output. Test cases: 12345 ...
stackexchange_codegolf
Inspired by this OEIS entry. Background A saturated domino covering is a placement of dominoes over an area such that the dominoes are completely inside the area, the dominoes entirely cover the given area, the dominoes may overlap, and removal of any domino reveals an uncovered cell (thus failing to satisfy condition...
stackexchange_codegolf
Given a ragged list, we can define an element's depth as the number of arrays above it, or the amount that it is nested. For example, with the list [[1, 2], [3, [4, 5]]] the depth of the 2 is 2, as it is nested within two lists: The base list, and the list [1, 2]. The depth of the 4 is 3 as it is nested within three li...
stackexchange_codegolf
For a 2 dimensional array we will define the elements in either the first row or the last column to be the largest "J-Bracket" of the array. For example in the following array elements in the J-bracket are highlighted: \$ \begin{bmatrix} \color{red}{\underline 1} & \color{red}{\underline 2} & \color{red}{\underline 4}...
stackexchange_codegolf
Each natural number (including 0) can be written as a sum of distinct powers of integers (with a minimum exponent of 2). Your task is to output the smallest power required to represent \$n\$. For example: 2 = 1^2 + 1^3 // Output 3 9 = 1^2 + 2^3 = 3^2 // Output 2 15 = 2^2 + 2^3 + 1^4 + 1^5 + 1^6 // Output 6 20 = 2^2 + ...
stackexchange_codegolf
Here is a challenge: What is the shortest possible compiled program? Writing one line programs are fun, but they often lean on language libraries that get pulled into the final bits. How lean can you get the 'scaffolding' that supports and hooks into the compiled instructions? This seems like an interesting question be...
stackexchange_codegolf
Challenge Inspired by this video. As you may know, a palindrome is a word that is spelled the same forward as it is backward. The word "PULP" is not a palindrome, but when translated into Morse Code (with the spacing between letters removed), "PULP" becomes ".--...-.-...--." which is a palindrome. Your task is to write...
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
Your task is to make a program or function that takes a nonnegative integer (or a different convenient format to represent it) that represents an angle measure in degrees from 0 to 180 (inclusive) as input and outputs every possible time (in hours and minutes; no seconds) on an analog clock where the measure of the sma...
stackexchange_codegolf
There have of course been challenges to render ASCII art fonts here and there. This challenge doesn't add anything to those. In contrary, it subtracts from them for a good reason. If you allow all characters, it's a lot of boring work the task is mainly about clever compression of the font and short extraction This o...
stackexchange_codegolf
So I have the situation where I have one boolean value a and, if that one is true and b<c I want it to end up as true, if a is false and b>c I want it to resolve as true as well. If b=c I want it to be always false, no matter the value b and c are both numbers. My best approach so far is a?b<c:b>c or maybe b^c^a^b<c. I...
stackexchange_codegolf
Disclaimer: The story told within this question is entirely fictional, and invented solely for the purpose of providing an intro. I have a friend who is an architect, and, after explaining the concept of code-golf and this site to him, he said that I should code something actually useful for a change. I asked him ...
stackexchange_codegolf
pannenkoek2012 aims to complete Super Mario 64 with as few presses as possible of the A button, which makes Mario jump. Each "A press" consists of three parts: Pressing the button Holding it for any length of time Releasing it See this video (1:15 - 3:23) for a great explanation that includes the above image. (Howe...
stackexchange_codegolf
This problem is inspired from shinh's problem. Given an input of positive integer \$n\$, output a smiley triangle (see below) with \$n\$ rows. Detailed rules Can be either a function or a full program. Standard I/O rules applied. RULE CLARIFICATION: Output as exactly a string, rather than an array of strings whose it...
stackexchange_codegolf
I recently solved a coding challenge in one of the challenge papers that my IT teacher gave to us. It was a seemingly simple, but fun challenge, so I thought it will make fun golfing. The task Given an input of a 2x2 matrix that contains 4 strictly positive integers (i.e. non-negative and non-zero), like this: $$\begin...
stackexchange_codegolf
Unfortunately one of the greatest comic book writers passed away yesterday afternoon. Lots of Hollywood stars, musicians, actors, and many other people are paying tribute to this awesome writer, so we must do something as well. Challenge Print The Avengers Logo Note: You may use any other character in place of # othe...
stackexchange_codegolf
You're a farmer and your flock of sheep has escaped! Oh no! Round up those sheep by building fences to contain them. As a farmer on a budget you want to use the least amount of fence possible. Luckily for you though, they aren't the smartest sheep in the world and don't bother moving after having escaped. Task Given...
stackexchange_codegolf
This is very similar to this challenge, "Implode the Box". It was a pretty nice challenge and it didn't get many answers, so I'm going to post a similar challenge (strongly) inspired by it. ASCII Boxes look like this: ++ +---+ +------+ +---+ +---+ ++ | | | | | | | | ...
stackexchange_codegolf
Context: We are working on a complex image drawing program to produce mugs, t-shirts, and so on. Here is an example of such function However, we are facing the following problem: Random generated functions are mostly white and black (where black is close to zero and white close to infinity). The idea of this contest i...
stackexchange_codegolf
Take a flag, like this one: ----------------------------- | | | | | | |=============+=============| | | | | | | ----------------------------- And a number input: the "wave length" Say the wave length was 5. Then, every 5 ch...
stackexchange_codegolf
33 is a simple esolang I created. You may have seen me use it in a few questions. You're not going to be writing a full interpreter. The interpreter you will be writing is for a simplified version of 33. This simplified 33 has two numeric registers: the accumulator and the counter. The accumulator holds all the post-ar...
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
A string is considered to be square if the following conditions are met: Each line has the same number of characters The number of characters on each line is equal to the number of lines. Your task is to write a program or function which determines whether or not a given input string is a square. You may require inp...
stackexchange_codegolf
Your task is to write a program that finds the largest radius that N circles can have and still fit inside of a rectangle that is X by Y pixels large. (similar to this wikipedia article) Your program must find the largest possible radius and optimal position of these N circles so that No two circles overlap All of th...
stackexchange_codegolf
Inspired by this question about packing into this format. Occasionally I see a completed crossword and being as I am, I can't be bothered to find out what the solutions to the clues actually were. Input: A 2D string (any format, newline separated, 2d list etc.) Blank squares will be represented with a (space characte...
stackexchange_codegolf
Given an ordered list of same-case letter strings (a-z XOR A-Z) where each string is preceded by 0 or more space ( ) characters, output the same list but with the strings sorted at each level of indentation. Indentation depths under different parents count as distinct lists for sorting purposes. Example If your input i...
stackexchange_codegolf
Introduction This challenge is about producing a code to count the frequency of bigrams in a text. A bigram is two consecutive letters in a text. For instance 'aabbcd' contains the bigrams aa, ab, bb, bc, cd once each. Counting bigram frequencies is super useful in cryptography. In a brute force algorithm, this code ma...
stackexchange_codegolf
Given a non-empty 2D array consisting of 0 and 1, find the number of squares whose 4 corners are all 1. The squares do not need to be "upright". All the rows are guaranteed to have the same length. Reasonable input/output methods are allowed. Testcases: 0001000 1000000 0000000 0000100 0100000 This returns 1. 10101 000...
stackexchange_codegolf
Write a program or function that duplicates letters in a word, so that all the duplicated letters arranged from left to right in the word would form the input array. For example: input: chameleon, [c,a,l,n] output: cchaamelleonn Input The starting word (e.g. chameleon) An array of characters ([c,a,l,n]) or a string t...
stackexchange_codegolf