instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
I was playing around with cellular automaton and I found one that had some interesting behavior. Here's how it works: It reads a binary string from left to right, if it encounters a 1 followed by 2 other values it will append a 0 to the result and continue reading. If it encounters a 0 (or there are less than 3 value...
stackexchange_codegolf
The new site header has some bits of source code from various questions as the background. Here are the first 3 lines: --<-<<+[+[<+>--->->->-<<<]>]<<--.<++++++.<<-..<<.<+.>>.>>.<<<.+++.>>.>>-.<<<+. Hello, World! IT'S SHOWTIME TALK TO THE HAND "Hello, World!" YOU HAVE BEEN TERMINATED "9!dlroW ,olleH"ck,@ 72a101a+7aa+3a4...
stackexchange_codegolf
A twin of this. FizzBuzz is where a range of positive integers is taken, and numbers divisible by 3 are replaced with "Fizz", divisible by 5 with "Buzz" and divisible by 15 with "FizzBuzz". For example, FizzBuzz from 1 to 10 is 1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz. Your challenge is to, given a list of Fizzes, B...
stackexchange_codegolf
Introduction: Pete likes doing word search puzzles. Despite that, he has trouble searching for words vertically, (anti-)diagonally, or reversed. Because of that, he'll always search for the words left-to-right, and rotates the entire puzzle in increments of 45 degrees clockwise. In addition to that, he'll also always s...
stackexchange_codegolf
This challenge is a riff on Dion's challenge "Is this a rectangle?". The goal of this challenge is to write a program to decide whether or not some collection of tuples of integers represents a hypercube of some dimension. Background A hypercube is a generalization of a square. A \$0\$-cube is a single point. A \$1\$...
stackexchange_codegolf
Sometimes I feel like the conversation is going down the wrong path and take it upon myself to steer it in another direction. And this conversation is going wrong real fast, so I need to change the subject in as few characters as possible.1 Task Given a list of sentences, return the sentences ordered such that each sen...
stackexchange_codegolf
You are given a string and two characters. You have to print the string between these characters from the string. Input Input will first contain a string (not empty or null). In the next line, there will be two characters separated by a space. Challenge Return the string between the two characters Example Hello! What's...
stackexchange_codegolf
Let's take a grid of 16x16 printable ASCII characters (code points 0x20 to 0x7E). There are 30-choose-15 paths from the top left to the bottom right corner, making only orthogonal moves, like the following example: ##.............. .#.............. .######......... ......##........ .......##....... ........#....... ......
stackexchange_codegolf
There was a previous perceptron question but it was closed. Also it required a lot of extra stuff that's not normally part of the perception algorithm like I know it. This question will be much simpler The Perceptron is a extremely basic classification algorithm. While it still has some limited use it's been mostly ove...
stackexchange_codegolf
Based on this question from Code Review. Given precisely three positive integers, return the product of all of the distinct inputs. If none of the inputs are distinct, return 1. That is, implement the function: \$ f(a,b,c) = \cases{1 & $a = b = c $ \\ a & $ b = c $ \\ b & $ a = c $ \\ c & $ a = b $ \\ a b c & otherwise...
stackexchange_codegolf
Your task is to modify the original Plan 9 cat tool for UNIX, in order to make it a fully turing complete language interpreter. You may make use of ANSI escape codes and the backspace character (\x08) to aid in this. You must submit: A modified version of the Plan 9 cat tool A hexdump of the turing machine that can be...
stackexchange_codegolf
A certain well-known cable company has a somewhat clumsy 'Search for Program' feature that works through the remote. It takes muchly much button pushing; so, being an admirer of economy of motion, I thought I'd seek out a programmer's help to minimize the number of finger movements I have to make. The Craptastic Search...
stackexchange_codegolf
You just recently got a new phone, but you don't quite like the way it vibrates, you've decided you want to create your own vibration patterns. So, you've written a program where you used the keywords long, short and pause to make your phone vibrate according to these keywords. Task Create a small program that accepts ...
stackexchange_codegolf
Input A single hex 6-digit colour code, capital letter, without #. Can also be a 24-bit integer if you prefer. Output The closest HTML color name (e.g red, or dark-salmon, as defined as https://www.w3schools.com/colors/colors_names.asp or see below). Distance is defined by summing the difference in red, green and blue ...
stackexchange_codegolf
What general tips do you have for golfing in Bash? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Bash (e.g. "remove comments" is not an answer). Please post one tip per answer.
stackexchange_codegolf
Given \$n, m\ge 1\$. There are \$n\$ balls. Do \$m\$ moves, each choose a ball (maybe also the first one), and exchange with the one currently on the first place. At the end, the order of balls should be the same as the initial state. You can either output all possibilities, or a random one provided all possibilities h...
stackexchange_codegolf
Given a non-negative integer N, output the smallest odd positive integer that is a strong pseudoprime to all of the first N prime bases. This is OEIS sequence A014233. Test Cases (one-indexed) 1 2047 2 1373653 3 25326001 4 3215031751 5 2152302898747 6 3474749660383 7 3415500717...
stackexchange_codegolf
Given a string representing a number and the base that number is in, shift each positional value upward, wrapping back to zero if the value cannot increase. You will never be provided invalid input, nor a base larger than 36. For example, you may be provided ['5f6', '16'], which represents the number 1526 in base 16. T...
stackexchange_codegolf
The Task The task is easy: given an Alpha-2 country code, output the Alpha-3 equivalent. The input may be in any case you choose, and the output in any consistent case of your choosing. Here are the codes: [["AF", "AFG"], ["AX", "ALA"], ["AL", "ALB"], ["DZ", "DZA"], ["AS", "ASM"], ["AD", "AND"], ["AO", "AGO"], ["AI", "...
stackexchange_codegolf
Guidelines Task Given two non-negative integers, find the sum of both numbers... to the power of 4. Examples 2, 3 -> 97 (2^4 + 3^4 = 97) 14, 6 -> 39712 (14^4 + 6^4 = 39712) 0, 25 -> 390625 (0^4 + 25^4 = 390625) Rules You will only ever receive two non-negative integers as input (bonus points if you get it to work wi...
stackexchange_codegolf
In this challenge you will take a an ascii art image of a highway like so | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | And you need to put rain across its lanes like so |\\\|\\\| |\\|\\| |\\\\\\\| |\\\\\| |\\\|\\\| |\\...
stackexchange_codegolf
You are to post an answer you posted that exploited a loophole in the challengers question. Bonus points if it caused them to rewrite the question. For example, one challenge was to write a program that such that if a random character is removed, it still works, and your score is how many characters it fails on. Some o...
stackexchange_codegolf
Given a positive integer n, do the following (and output every stage): start with a list containing n copies of n. do the following n times: at the ith step, gradually decrement the ith entry of the list until it reaches i So, for example, if the given n is 4, then you start with [4,4,4,4], and then at the first step...
stackexchange_codegolf
For today's challenge you have to take an input, and if your source code is reversed, then the input should be printed doubled. Let's say your source code is ABC and its input is xyz. If I write CBA instead and run it, the output must be any of be xyzxyz or xyz xyz or xyz xyz For any numerical input you should not mu...
stackexchange_codegolf
Give credit to whom credit is due. Objective Given an integer N > 0, out the smallest integers A, B, and C so that: All of A, B, and C are strictly greater than N; 2 divides A; 3 divides B; and 4 divides C. This is a code-golf, so the shortest answer in bytes wins. Test cases N => A, B, C 1 => 2, 3, 4 4 => 6, 6, 8 43...
stackexchange_codegolf
Task Given two positive integers, output the number of carries needed to add them together in long addition in base 10. Examples ¹¹¹ <-- carries 999 + 1 ---- 1000 Three carries are needed. ¹ 348 + 91 ---- 439 One carry is needed. Testcases 999, 1 -> 3 398, 91 -> 1 348, 51 -> 0 348, 52 -> 2 5, 15 -> 1 9...
stackexchange_codegolf
Inspired by this Youtube Video from Tom Scott. Write a program or function that prints the current amount of views this question has. That's it. Your program may only access the stack exchange api, any other websites are disallowed. Output An integer with the exact amount of views this question has at the moment. Outpu...
stackexchange_codegolf
I encountered some silly code from a game and I figured this would actually turn into a fun golfing problem, so: Given any ASCII string in the limited char range specified below. Append as few characters as possible such that, given: i = 1 sum = 0 for char in string sum += char.intval * i++ end for sum % 1000 == 0 W...
stackexchange_codegolf
Special Independence Day (USA) themed challenge for you today. You must write a program that prints this ascii-art representation of The American Flag. 0 |--------------------------------------------------------- | * * * * * * #################################| | * * * * * ...
stackexchange_codegolf
Inspired by this comment... Thanks to users Step Hen, Wheat-Wizard, and Dennis for helping my solidify the specification of this challenge before posting it! This is the Robber's thread! For the Cops' thread, go here In this challenge, you are tasked with running some code that makes it so that your language no longer...
stackexchange_codegolf
Your program should print the following: **Language, XXX bytes** ``` CODE ``` or its equivalent. XXX should be substituted by the actual number of bytes your program takes, and CODE should be substituted by the source code of your program. Language should be substituted by the actual language your program is in. Your...
stackexchange_codegolf
In this challenge you will take two lists as input and you will zip them. The zip can be defined with this recursive expression: \$ \mathrm{zip}(a,b) = \begin{cases} \left[\,\,\right] & a = \left[\,\,\right] \\ [a_0]\mid\mid\mathrm{zip}(b, t) & a = [a_0] \mid\mid t \end{cases} \$ or this Haskell program if you would l...
stackexchange_codegolf
You are given a string of terrain, with molehills and mountains: /\ / \ _/\__ / \ ___/ \_/ \_ ____/\___/ \___ Your job is to replace every molehill in the string with an equivalent mountain centered in the same col...
stackexchange_codegolf
Background As you probably learned in biology class, DNA and RNA are composed of strands of nucleotides; each nucleotide consists of a chemical called a base together with a sugar and a phosphate group. The information stored in the DNA or RNA is coded as a sequence of bases. DNA uses the bases A, C, G, and T (standing...
stackexchange_codegolf
John, a knight wants to kill a dragon to escape the castle! The dragon has A heads and B tails. He knows, that: if you cut off one tail, two new tails grow if you cut off two tails, one new head grows if you cut off one head, one new tail grows if you cut off two heads, nothing grows To defeat the dragon, John needs ...
stackexchange_codegolf
Spirals are cool , so are numbers, and number spirals are even cooler. But what if I want a specific number, in a specific place using xy coordinates... Challenge Using an infinite spiral moving down first, curling in a counterclockwise manner ex: 6 5 4 7 0 3 8 1 2 9 10 11 Take negative and positive inputs(...
stackexchange_codegolf
GHC command line errors can be horrible, lets make them as bad as possible. To disincentivize very long programs use the following formula to calculate your "score". (# of bytes of GHC output) / 2^(8 + # of bytes of code) Template Haskell is banned as there is probably a TH configuration where you can replicate an err...
stackexchange_codegolf
You're with your best bud, Jim, at the amusement park and as your favorite ride comes into view, you and Jim exchange glances. Naturally you race to get in line. Unfortunately he wins because you're a golfer and he plays a real sport (sorry friends). In fact, you're so far behind that you and Jim are separated by x peo...
stackexchange_codegolf
Given a set of vectors all of the same positive finite dimension, output a falsey value if they are linearly dependent and a truthy value if they are linearly independent. A set of vectors v1, v2, ... is linearly dependent if for some scalars a1, a2, ... not all equal to 0, a1v1 + a2v2 + ... = 0. (0 is the zero vector...
stackexchange_codegolf
You are given a polynomial function, in the following format: \$x = (c_0 * y^0) + (c_1 * y^1) + (c_2 * y^2) + ... + (c_n * y^n)\$ where \$c_n\$ stands for the coefficient of the \$n^{th}\$ power of \$y\$ You have to plot the equation on a \$10 * 10\$ ASCII matrix. The value must be floored to an integer before plotting...
stackexchange_codegolf
What's great about golfing is not having to deal with errors. Except this time you won't get off so lightly! I need to do some arithmetic with certain limitations, and I wan't to know what goes wrong if anything. Challenge Given a list of signed integer values [n1..n11], give the following result or the first error tha...
stackexchange_codegolf
Consider a positive integer N written in base b. A sequence is generated from this number by finding the largest digit d in the expansion of N and writing N in base d+1, repeating until the base the number is written in can be decreased no further. For example, the sequence generated by 346 (10) in starting base 16 has...
stackexchange_codegolf
Imagine you place a knight chess piece on a phone dial pad. This chess piece moves from keys to keys in an uppercase "L" shape: two steps horizontally followed by one vertically, or one step horizontally then two vertically: +-+ |1| 2 3 +-+ `-------v | +-+ 4 | 5 |6| | +-+ | ...
stackexchange_codegolf
The year 2013 had an interesting property: the digits are consecutive when sorted (0123). Let's call this type of number a sortable number: a non-negative integer whose base-10 digits are consecutive after sorting. Unfortunately, this won't happen again until 2031, and after that, not until 2103. Your challenge is to w...
stackexchange_codegolf
A quote from MO.SE answer: Although it is well known that Conway was able to quickly calculate the day of the week of any given date, it is less well known that one part of the algorithm is easy to remember and useful in practice: In any given year, the following dates all fall on the same day of the week: 4/4, 6/6, 8...
stackexchange_codegolf
This is perhaps one of the classical coding challenges that got some resonance in 1986, when columnist Jon Bentley asked Donald Knuth to write a program that would find k most frequent words in a file. Knuth implemented a fast solution using hash tries in an 8-pages-long program to illustrate his literate programming t...
stackexchange_codegolf
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. There's a good news and a bad news. Good news: you got a Christmas present from Santa. (Already?! Christmas is two weeks away!) Bad news: the present is locked with a laser lock. And a note next to it says: Only the ones who can prope...
stackexchange_codegolf
Calculate the maximum number of circles of radius r that can fit in a rectangle with width x and height y. Write a function that take r, x and y as input and returns the number of circles that fit in the rectangle.
stackexchange_codegolf
Based on my SO question, but more specifically: Find a RegEx such that, given a text where paragraphs end with an empty line (or $ at the very end), match the up to twenty last characters of a paragraph excluding the \r or $ but no more than three complete "words" including the "separators" in between and the punctuati...
stackexchange_codegolf
Background (feel free to skip) Ordinals are the abstract representation of well-orders. A well-order of a set is a total order, which basically means that every element in the set can be compared against any other element in the set, and one of them is either smaller or larger. Also there are no cycles. The crucial dif...
stackexchange_codegolf
Playing the game of memory against a machine is highly unfair, because they play almost as good as small children. So let's make the machine play alone, but in a fair way: Input: 1...26 pairs of lowercase letters in random order like zz or gttg or abcdefghiabcdefghi. You can trust each letter appears exactly twice and...
stackexchange_codegolf
Let's start by defining a reflection of a character in a string: Given a string with distinct lowercase alphabetical letters with no spaces such as abcdefg, define a reflection of a letter in the string c as moving it (without changing the order of any other letter) to a new place in the string such that the num...
stackexchange_codegolf
Whilst trying (and failing) have persuade my infant son to eat his dinner, I tried singing to him. Mid way through this song I realised the formulaic structure might lend itself well to code golfing! The task is to write a program or function which accepts no input and produces the following text: There's a hole in the...
stackexchange_codegolf
Given a decimal integer n as input, output the smallest (in terms of absolute value) decimal integer m such that the absolute value of n-m is a binary integer (composed only of 1s and 0s). n and m can be any integer, positive or negative. Example Let n = 702. The closest binary integer is 1000 = |702 - (-298)|, so m = ...
stackexchange_codegolf
This is taken from this question (with permission ofcourse). I'll quote: Create a function which takes a string, and it should return true or false based on whether the input consists of only a repeated character sequence. The length of given string is always greater than 1 and the character sequence must have a...
stackexchange_codegolf
Your code-golf challenge is to find all occurences of a word in the 3d matrix. There is no restriction on I/O format. In the samples below, the word is presented, then a blank line, then the 2-dimensional layers from top to bottom, and the output, for each line, consists of a coordinate and a direction (x, then y, then...
stackexchange_codegolf
Take as input two strings \$A\$ and \$B\$. Output a string \$C\$ that is \$A\$ but with two characters swapped such that the Levenshtein distance \$d(C,B)\$ is as small as possible. You must swap two characters and you cannot swap a character with itself, although you may swap two identical characters in different po...
stackexchange_codegolf
Write a program or function that, when given n, will print a spiral n characters long made up of the Latin alphabet ABCDEFGHIJKLMNOPQRSTUVWXYZ repeated as needed. This spiral should run through the alphabet only forwards. Related to Alphabet Spiral, though the spiral runs through the alphabet forwards and backwards, an...
stackexchange_codegolf
Or Fix American Kennel Club's database As covered by the recent video by Matt Parker, the American Kennel Club permits thirty-seven (37) dogs of each breed to be assigned the same name (source), because of a database restriction for Roman numeral length. Given an integer, your task is to output the length of its Roman ...
stackexchange_codegolf
Let's define a self-contained number as a positive integer, whose digits appear in runs of length equal to themselves only. In other words, any decimal digit d (excluding 0) occurs only in runs of length exactly d. Task You can choose any of the three methods listed below: Given an integer n, output the nth (either 0 ...
stackexchange_codegolf
A company is arranged in a heirarchical structure, with a layer of workers at the bottom. Each worker is managed by a manager. Consequently, each manager is managed by another manager until there is a company "boss". Each manager is restricted to managing, at most, x workers. For a company of size y calculate the numbe...
stackexchange_codegolf
A string of characters repeats if it contains two consecutive substrings that are equivalent. For example, 2034384538452 repeats as it contains 3845 twice, consecutively. Therefore, your challenge is to decide whether a string contains a repeating substring. You may take the input as a string or an array of characters....
stackexchange_codegolf
Challenge Statement The goal of this challenge is to build the 5 state Infinite Time Turing Machine that takes the longest to halt. Since Infinite Time Turing Machines can run for infinite time your score will be a "transfinite ordinal". That's the challenge statement, but if you don't what all this means or want to d...
stackexchange_codegolf
Matrix challenges are popular. There's an issue of how to provide test cases. A common method is the row-wise array-of-arrays representation, such as: [[1,2],[3,4],[5,6]] -> a 3 by 2 matrix This is good with vertical space, but there's always the task of converting the test cases into something your language can use, ...
stackexchange_codegolf
Description In this challenge, you need to write a function that takes in a list of strings and returns the smallest string based on their ASCII value. You should assume that the input list contains only lowercase alphabetical strings. Test Cases ["a", "b", "c"] => "a" ["hello", "world", "code"] => "code" ["aaa", "aa",...
stackexchange_codegolf
The plus-minus sequence The plus-minus sequence is one that starts with two seeds, a(0) and b(0). Each iteration of this sequence is the addition and subtraction of the previous two members of the sequence. That is, a(N) = a(N-1) + b(N-1) and b(N) = a(N-1) - b(N-1). Objective Produce the plus-minus sequence, in infinit...
stackexchange_codegolf
Write a program or function which takes a string of text as input and outputs the number of non-alphabetical characters in it (standard I/O rules apply). A non-alphabetical character is any character not appearing in this string: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ In terms of ASCII character codes, t...
stackexchange_codegolf
You probably all know the fibonacci sequence: fibonacci(n)=fibonacci(n-1)+fibonacci(n-2) fibonacci(0)=0 fibonacci(1)=1 Your task is as simple as it could be: Given integer N compute fibonacci(n) but here is the twist: Also do negative N Wait. What? fibonacci(1)=fibonacci(0)+fibonacci(-1) so fibonacci(-1)=1 and f...
stackexchange_codegolf
Inspired by this chat mini-challenge. Given a string as input (ASCII printable characters only), output the string with the letters "raining" down. Each letter must be a random number of lines downward (random between 0 and the length of the string, each having non-zero probability), and only one character per column. ...
stackexchange_codegolf
In this challenge you will receive a list of positive integers \$W\$ called a word, and a square symmetric matrix \$M\$. Your task is to determine if the word can be turned into the empty list by applying a series of valid moves. The valid moves are: If two consecutive values in the list are equal you may remove them ...
stackexchange_codegolf
The task Most Casio calculators featured a variable M, which has 3 operators related to it: M, M+, and M- M, as you can expect, returns the value stored in the variable. M+ takes the number on the left and add it to M. M- does the same thing as M+, but subtract instead. To make the challenge just a bit more difficult, ...
stackexchange_codegolf
Objective Given a nonempty unordered list of positive integers, decide whether they can be added, negated, or multiplied to yield a single zero. Each given number must be used exactly once. There is a taboo. Do not multiply zero to anything. Adding zero to anything is OK. Examples Truthy List, Solution [1,1], 1-1 [1,1,...
stackexchange_codegolf
Intro This is based on an actual problem I recently faced while making a computer game and I thought it would make for a nice round of code-golf. There are seven main spectral classes of star which put out varying amounts of heat. The geology of planets around a star are greatly influenced by the amount of heat receive...
stackexchange_codegolf
Implement this recurrence relation as a function or program that inputs and outputs a non-negative integer: F(0) = 0 F(N) = the smallest integer greater than F(N-1) such that the sum and/or product of its base-10 digits is N N is your program's input and F(N) its output. To be clear, the sum of the digits in a number...
stackexchange_codegolf
Game of Game of Life Conway's Game of Life is a 0-player game. But that's okay! We can make it a multi-player game. This game is played on the smallest square grid that will accommodate a 6x6 square for each player (12x12 for 2-4 players, 18x18 for 5-9 players, etc). This grid is actually a torus, so it wraps in bot...
stackexchange_codegolf
Having a function f that takes arguments x1, x2, …, xn                                                – ie.  f : X1 × X2 × … × Xn → Y – currying redefines f as a function taking a single argument a1 which maps to yet another function. This technique is useful for partial application, for example with a curried pow func...
stackexchange_codegolf
For this problem you are given an \$n \times n\$ matrix of integers. The task is to find a pentagon in the matrix with maximum sum. The pentagon must include part (or all) of the x and y axes as two of its sides starting from the top left cell. All the sides except one must be horizontal or vertical. The remaining si...
stackexchange_codegolf
Challenge Given a positive integer \$N \ge 3\$, generate an alternating series of \$N\$ random numbers within the range \$[1, N]\$, such that their sum equals \$N\$. Expressed mathematically as $$N = \sum_{i=1}^{N} (-1)^{i-1} a_i$$ where \$a_i \in [1,N]\$ are random terms. Input \$N\$ Output A string representing the ...
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
You are writing a screen scraper application monitoring a text-only chat window. Text is added at the bottom of the window. The application takes screenshot of the chat window. If a change has occurred since last screenshot (new_screenshot != old_screenshot), the screenshot is saved. After X time, all images are merg...
stackexchange_codegolf
Related. Given a number \$n\$, Euler's totient function, \$\varphi(n)\$ is the number of integers up to \$n\$ which are coprime to \$n\$. That is, no number bigger than \$1\$ divides both of them. For example, \$\varphi(6) = 2\$, because the only relevant numbers are \$1, 5\$. This is OEIS A000010. We can now define th...
stackexchange_codegolf
Given a range and a list thereof, while keeping the existing intervals in the list unchanged, split the additional range into sub-intervals and add them to the list, such that all the ranges in the final list are disjoint and contain all numbers present in the input ranges. The goal is to create an insertInterval(inte...
stackexchange_codegolf
We already have a base conversion question, but not one with negative bases (nope, this doesn't count). (Corresponding wiki article.) You will receive a number (may be negative) and a base (must be negative), and your task is to convert the number into the base. The base will only be from -10 to -2. Specs You may rece...
stackexchange_codegolf
Write a program that prints the RGB color of a given pixel on the screen. The program should read a line from stdin in the format x,y, where x and y are unsigned integers. The pixel (0,0) is the top left pixel in the screen. The program should then output a line to stdout in the format RRR,GGG,BBB, which represents the...
stackexchange_codegolf
Now that I'm thoroughly addicted to Code Golf, it's probably about time that I try to pick up a few golfing languages. Given that I play almost exclusively in JavaScript, Japt seems like the logical language to start with. I'll be diving into the documentation at the next opportunity I get but, in the meantime, please ...
stackexchange_codegolf
Consider a triangle ABC where each side has integer length (an integral triangle). Define a median of ABC to be a line segment from a vertex to the midpoint of the opposing side. In the figure below, the red line segments represent the medians. Note that any given triangle has three medians. Let n be some positive int...
stackexchange_codegolf
Challenge Taken with permission from my University Code Challenge Contest The dependence we have on mobile phones makes us charge them every night up to the maximum level of the battery, so we do not run the risk of running out of power by the middle of the next day. There are even people who, when they see a free out...
stackexchange_codegolf
Generative AI is here! It's great for certain things, but it has a few problems. Not only has it broken our Stack Exchange community, it also makes mistakes. For example, when you ask Bing AI if it is sentient, Bing says (credits to GPT Gone Wild) Your job is to print that text exactly. More specifically, Take no inp...
stackexchange_codegolf
Every phone needs a calculator app. Because of the limited screen real estate, the developer of mine has decided to save some buttons. Instead of having two dedicated bracket buttons - one for open ( and one for close ) - there is just a single bracket button (). It looks something like this: When the button is presse...
stackexchange_codegolf
My job is stacking pebbles into triangular piles. I've only been doing this for a century and it is already pretty boring. The worst part is that I label every pile. I know how to decompose pebbles into piles of maximal size, but I want to minimize the number of piles. Can you help? Task Given an integer, decompose it ...
stackexchange_codegolf
Summary We already have a challenge for the minimal number of characters for Turing completeness. But what about the minimal maximum byte? Challenge For a language of your choice, find a subset of characters that allows your language to be Turing complete with the minimal maximum byte value. Example If your language is...
stackexchange_codegolf
Introduction Your job is to write a function or program that detects if a number a is less than a number b. But... You are not allowed to use built-in alternatives for equals, less than, greater than, less than or equal to, greater than or equal to, or not equal to operators. (Writing your own implementation is allowed...
stackexchange_codegolf
Inspired by Nicola Sap's Challenge Goal Your challenge is to simply produce π with 232-1 digits. However today's twist, like the title implies, is to produce it without using any numbers or any π constants in your source-code. Input/Output Your program will not be provided usable input. It can output in any reasonable ...
stackexchange_codegolf
Given a positive input \$n > 0\$, output the amout of two types based on their rarity. The two types are called \$A\$ and \$B\$, we know the followings: \$n\$ is a limited input and the maximum is \$nmax\$ At the start \$B\$ is twice as rare as \$A\$ As the presence of \$A\$ increade the rarity of \$B\$ decreases When...
stackexchange_codegolf
A Shift matrix is a binary matrix with one superdiagonal or subdiagonal formed by only ones, everything else is a zero. A superdiagonal/subdiagonal is a diagonal parallel to the main diagonal, which is not the main diagonal, i.e. all entries \$a_{ij}\$ where \$i=j+k\$ and \$k \neq 0\$. The main diagonal is defined to b...
stackexchange_codegolf
A store is having a big sale. If your price reaches $199 or more, you can reduce it by $100. You can buy each product only once. Here's an example list of products: (in order to simplify, the names of the products are represented by letters) +------+-------+ | name | price | +------+-------+ | A | 26.9 | | B | 2...
stackexchange_codegolf
Background The Italian definite article (corresponding to English the) has seven different forms: l', il, lo, gli, i, la, le. Which one to use depends on three variables: Gender: masculine / feminine. Number: singular / plural. Initial letter of the subsequent word: vowel / consonant type A / consonant type B. Vowel...
stackexchange_codegolf
Thanks to FryAmTheEggman for the idea for this second version. Version 1 here. Not-so-simple challenge: given a number of cards, build the biggest house of cards you can with that number of cards, according to the following building order: /\ /\ /\ /\/\ ...
stackexchange_codegolf
Introduction I don't see many regex challenges on here, so I would like to offer up this deceptively simple one which can be done in a number of ways using a number of regex flavours. I hope it provides regex enthusiasts with a bit of fun golfing time. Challenge The challenge is to match what I've very loosely dubbed a...
stackexchange_codegolf
Your Task: Print "Hello, World!" using a palindrome. Simple, right? Nope. You have one restriction: you may not use comments. "Comments" include Normal // or # comments Adding extraneous characters to a string literal Triple-quoted string comments Creating a string literal to hide characters You may not use a pre-de...
stackexchange_codegolf