instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
(Just open 50 tabs in Google Chrome :D (just kidding, no you can't)) Shortest code for infinite disk I/O any language, C# example: using System.IO; namespace FileApp { static class Program { public static void Main() { do { File.WriteAllText("a", "a"); File.Delet...
stackexchange_codegolf
Consider depicting a simple, open, two-dimensional curve on a W wide by H high grid of text where X represents part of the curve and . represents empty space and no other characters are used. Every grid space has 8 neighboring grid spaces, its Moore neighborhood. Grid spaces beyond the borders are considered empty. A g...
stackexchange_codegolf
Given an \$m \times n\$ matrix of integers A, there exist a \$m \times m\$ matrix P, an \$m \times n\$ matrix D, and an \$n \times n\$ matrix Q such that: \$A = P D Q\$. P and Q are unimodular matrices (i.e. matrices which are invertible and whose inverses are also integer matrices); D is diagonal; each diagonal entry...
stackexchange_codegolf
Your task Given a numerical string or integer \$\ge 0\$ (which may have leading zeros), convert it to letters using the below rules. Rules Loop through the digits: If the digit is 0 or 1, combine it with the next digit and output that letter of the alphabet (0-indexed). If the digit is 2, combine with the next digit O...
stackexchange_codegolf
Introduction Some time ago, I need to write function which split string in some specific way. At the first look, task looks trivial, but it was not so easy - especially when I want to decrease code size. Challenge As example we have following input string (it can be arbitrary) Lorem ipsum dolor sit amet consectetur ad...
stackexchange_codegolf
We all know of, or at least have heard of, brainfuck, one of the most famous and influential esoteric languages. While these days most implementations use an infinite tape, the original compiler by Urban Müller had a tape of 30000 cells. A little known fact* is that there is actually a special value at the end of the t...
stackexchange_codegolf
Task Given one non-whitespace printable character, make a 3x3 square representation of that input. For example, if the input is #, then the output is: ### # # ### Rules The output format is strict, although a trailing newline is allowed. It means that the space in the middle is required, and also that the two newline...
stackexchange_codegolf
I like the Hilbert Curve. Your task for this challenge is to take an image (strictly a square image where all the sides are a power of two pixels wide) and unravel it line by line in a zig-zagging fashion and ravel it back up in a pseudo-Hilbert curve. Unraveling To unravel you will start with the pixel in the upper l...
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
Challenge Make the shortest program to determine if the figures in the input will fit into the space in the input. Requirements The input will be in the format of this example: Input: +----+ -- +--+ | +----+ | | | | +--+ | | +---------+ Output: +----+ |+--++----+ || |-- | |+--+ | ...
stackexchange_codegolf
Quell is a single-player grid-based puzzle game. Pearls are scattered across a 2D map and the aim is to collect them all by rolling a drop of water over them. For this challenge we will only consider basic maps containing the drop, pearls, walls, and empty spaces. (The full game includes a variety of additional objects...
stackexchange_codegolf
Introduction Our goal is to efficiently find the maximum of a large amount of (redundant) data. We define the outer product of vectors \$A\$ and \$B\$ as a matrix containing the products of all entries of \$A\$ with each entry of \$B\$. (see outer Product) $$ A\otimes B := A\cdot B^T = \left(\begin{array}{rrr} A(1)\cdo...
stackexchange_codegolf
We say two positive integers are anagrams of each other if the digits in one of them (in decimal representation) can be rearranged to form the other. Leading zeros don't count. For example, 110020222 is an anagram of 212102020, but not of 221100011; neither is 22002211 even though it can be written as 022002211. Intere...
stackexchange_codegolf
A polyquine is both quine and polyglot.1 You are to write a quine which is valid in at least two different languages. This is code golf, so the shortest answer (in bytes) wins. 1 I made that up. Or rather, Geobits did. Apparently, he wasn't the first one either, though. Rules for Quines Only true quines are accepted. T...
stackexchange_codegolf
Inspired by this tweet where a user stated the following: it's insane how much code would be cleaned up if JS got pipes and pattern matching i often do this since it's the best way to make use of TS inference and pattern matching would make it less hacky const result = (() => { if (scenario1) { return { t...
stackexchange_codegolf
The abs() function in most languages does one thing: give the positive version of the input. Most of the times this is done using something similar to int abs (int i) { return i < 0 ? -i : i; } I was wondering if there is any way to do this with less bytes. Note that this doesn't have to be more efficient, just sm...
stackexchange_codegolf
When babies open their mouths, they're not just spewing gibberish. They're actually talking in a highly advanced, adult-proof cipher... The Baby-talk Cipher When a baby talks, it could look something like gogooa gagooook aagaaoooy Each single-space separated section represents a character (so the example above represen...
stackexchange_codegolf
Feb. 6 was a real weekday. Because it lies in the 6th week of the year. So a real weekday is a day with a a day number that equals the week number. But not all country have the same counting of weeks. in Germany a week starts with Monday and ends on Saturday in the US they start on Sunday. Write a program that checks a...
stackexchange_codegolf
The title is an homage of the Natural Number Game, which is a nice interactive tutorial into proving certain properties of natural numbers in Lean. Given that the previous two were slightly too involved (either mathematically or technically) for newcomers to Lean (i.e. the vast majority of CGCC community), I decided to...
stackexchange_codegolf
Here is the (quite scary) Five little ducks song(it is not long): Five little ducks went out one day, over the hills and up away. Mother Duck said, "Quack Quack Quack Quack", but only four little ducks came back. Four little ducks went out one day, over the hills and up away. Mother Duck said, "Quack Quack Quack Quack...
stackexchange_codegolf
SE will be down/read only today 2017-05-04 at 00:00 UTC until 00:20 UTC. Your challenge is to output a truthy value if SE is down/read only and a falsy value if SE is not. You may not have any input, and you must use date builtins to determine if SE is down/read only (no actually querying the SE api!) Example output: 1...
stackexchange_codegolf
An old test for programmers, taken from here (Note: in italian). Along a road (denoted by '_'), there is a Magical Piper (denoted by 'P') and several mice (represented by the two characters 'o' and '~', that denote respectively the head and the tail of the small rodents). Write a program that prints how many mice are g...
stackexchange_codegolf
Challenge Given an integer greater or equal to 4, n, print a rounded rectangle of as close as possible (with a gap of 1) sides and a perimeter of n characters. Rules n is always 4 or greater, because otherwise the output wouldn't be a square The characters for the perimeter can be any non-whitespace character The rect...
stackexchange_codegolf
Sandbox Your challenge is to write a program that when first run, will do one of the actions below at random with equal chances of both: A cat program A standard cat program: read everything from STDIN and put it on STDOUT (or your language's closest equivalent). Do nothing and halt This shouldn't output anything....
stackexchange_codegolf
Introduction I have an even number of bottles, all of different sizes. Unfortunately, I only know the size of the smallest bottle: 300ml. I also know the following: Half of the bottles are twice the size of the other half, meaning that the smallest small bottle and the smallest large bottle are in a ratio of 2:1. The...
stackexchange_codegolf
Explanation ¡Hola! For those of you who don't take Spanish, a verb is conjugated based on the person who does the action. Here's a chart: English Spanish I Yo You Tú He Él She Ella You (formal) Uste...
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
Let's say I have a .env file with the following contents: CF_WORKERS_ACCOUNT_ID=abcdef34632114 CF_WORKERS_API_TOKEN=abcdef34632114def3463def3463 FAB_DEV_ZONE_ID=434932843272439874329 I'm doing a screencast, and I want to quickly cat .env to show what's in the file, without broadcasting the exact values, since they're ...
stackexchange_codegolf
Your task is to determine whether two numbers are easy to multiply. This means that their base-10 long multiplication doesn't have any carrying (regrouping) between place values, looking at both the multiplication steps and the addition step. This happens when each pair of digits being multiplied gives 9 or less and th...
stackexchange_codegolf
This sequence is defined as Starts with 1, 2, 3 The next element of the sequence is the first number greater than the previous three that is co-prime with each of the previous 3 elements in the sequence. In other words, if the previous 3 elements are a, b, c, then the next is the first integer n>c such that gcd(a,n)=...
stackexchange_codegolf
Challenge Given two numbers, output their quotient. In other words, integer divide one number by another. Both divisor/dividend will be under 10001. Division must be performed using integer division, rounding down. Here are some example inputs and outputs: 5 1 5 -4 2 -2 4 -2 -2 6 ...
stackexchange_codegolf
Figuring out whether a given number is prime, while not very complicated, is kind of hard. But making a guess doesn't need to be. Seeing whether a number is a multiple of 2 or 5 is easy - you can just look at the last digit. Multiples of 3 isn't much harder, just add up the digits and see if you end up with a multiple ...
stackexchange_codegolf
Paterson's worms are a kind of cellular automaton that exist on an infinite triangular grid and, every step, they turn in some direction and move one unit. Their defining properties are that they can never go over the same spot twice, and whenever they encounter the same surroundings, they make the same decision. A wor...
stackexchange_codegolf
Your challenge is to write a program that outputs the color of a given square from the chessboard. This is how a chessboard looks: You can see that the square a1 is dark, and h1 is a light square. Your program needs to output dark or light, when given a square. Some examples: STDIN: b1 STDOUT: light STDIN: g6 STDOU...
stackexchange_codegolf
Given a list of strings, output a single string formed by taking a character from each string at each position, sorting them by ASCII ordinal, and appending them in order to the output string. In other words, for n input strings, the first n characters of the output will be the first characters of each of the inputs so...
stackexchange_codegolf
The goal of this challenge is to write a program or function that returns the least amount of strikes needed to complete a given course. Input The layout of the course can be passed in any suitable way and format you prefer. (read from the console, passed as an input parameter, read from a file or any other, multilin...
stackexchange_codegolf
In this challenge, players need to tamper with a time bomb as late as possible without getting blasted in the face. Mechanics Let N be the number of bots plus one. Each round, each bot receives the following arguments: numbers played by all bots last round in ascending order. number of points it received last round. N...
stackexchange_codegolf
Generator functions This gives the context for why this challenge came to life. Feel free to ignore. Generator functions are a nice way of encoding the solution to a problem of combinatorics. You just write some polynomials, multiply them and then your solution is the coefficient of one of the terms. For example, how m...
stackexchange_codegolf
Your task is to create a random sequence of moves, which can be used to scramble a Rubik's Cube. Such a scramble is made up of exactly 25 moves. Each move consist of of the letters UDRLFB optionally followed by one of the suffixes '2. This notation is called the Singmaster notation. UDRLFB represents one of the 6 faces...
stackexchange_codegolf
Background For my code-golf submissions in C, I need a processing tool. Like in many other languages, whitespace is mostly irrelevant in C source (but not always!) -- still makes the code much more comprehensible for humans. A fully golfed C program that doesn't contain a single redundant whitespace often is barely rea...
stackexchange_codegolf
In Australian Football, goals are worth 6 points and behinds are worth 1 point. Scores may include the number of goals and behinds, as well as the total score. Given the number of goals and behinds for two different teams, determine which team won the game. Take four integers g1, b1, g2, b2 as input, and output two dis...
stackexchange_codegolf
In this challenge, your task is to input a rectangle ASCII pattern (You may assume only printable characters need to be handled, and you may assume a trailing newline or not), C4_4 symmetrify, and output it. Here, C4_4 symmetric means symmetric under 90-degree rotation around a corner of the corner character. The corre...
stackexchange_codegolf
Challenge: Given two integers \$a\$ and \$b\$, with lengths \$A=length(a), B=length(b)\$, output an ASCII-art of the \$a^{th}\$ root of \$b\$, including the answer rounded to \$A\$ amount of decimal places. The size of the ASCII-art root also depends on \$A\$ and \$B\$. Example: \$a=123\$, \$b=1234\$ ____ 123 /123...
stackexchange_codegolf
You have played \$N\$ matches in some game where each match can only result in one of the two outcomes: win or loss. Currently, you have \$W\$ wins. You want to have a win percentage of \$P\$ or more, playing as few matches as possible. Output the minimum win streak that you need. Assume the current win streak is at \$...
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
Input An integer k composed of 1 and 2, with at least 3 digits and at most 200 digits. Output Another integer k' obtained by removing at most one (could be none) digit from k, such that k' is composite, and then another integer p for a non-trivial (that is, not 1 or k') factor of k'. Test Cases 121212 -> 121212 10101 1...
stackexchange_codegolf
Code-Golf caddy Eddie Brackets was getting tired of quine challenges, which appeared to be much too easy for the grand poobahs. He has this idea to spice up things and is sending quines to the car crusher. Challenge: Write a quine that prints itself "squeezed" for output purposes into an n x n square followed by that s...
stackexchange_codegolf
Input: A positive integer n consisting of digits in the range 0-9. Challenge: If d is the highest digit in the integer, assume the base of the number is d+1. E.g. if the integer is 1256 then you shall assume it's in base-7, if it's 10110 then you shall assume it's base-2 (binary), and if it's 159 then it's decimal. Now...
stackexchange_codegolf
Your task is to write a program or function which, given two nonzero integers x and y, returns a truthy value if the image at coordinates x east and y north of xkcd's click and drag comic is mostly white and a falsey value otherwise. Specifications The image should be retrieved from imgs.xkcd.com/clickdrag/[y]n[x]e.pn...
stackexchange_codegolf
We all know that if you google the word "google" it will break the internet. Your task is to create a function that accepts one string and returns its length, in the fewest possible Unicode characters. However, if the given string is google (lowercase), it will cause an error. For example, g('bing') will return 4 but g...
stackexchange_codegolf
AWG (American Wire Gauge) is a common way of specifying wire sizes. Your task in this challenge is to convert from a given gauge to the diameter of the wire in inches. The size in inches for the gauges from 4/0 to 40 are shown in the table below: Gauge to inches table | AWG | Diameter (Inches) | |-----|----------------...
stackexchange_codegolf
Take three inputs, a string of text, T; a string of characters to replace, F; and a string of characters to replace them with, R. For each substring of T with the same (case insensitive) characters as F, replace them with the characters in R. However, keep the same case as the original text. If there are more character...
stackexchange_codegolf
Code-Golf caddy Eddie Brackets was getting tired of quine challenges, which appeared to be much too easy for the grand poobahs. He has this idea to spice up things and is sending quines to the car crusher. Challenge: Write a quine that prints itself "squeezed" for output purposes into an n x n square followed by that s...
stackexchange_codegolf
In response to here. Unlike the previous one, this focuses on code-golf and a new logo, no longer consisting of 6 sticks and the graying-effect as the position of the sticks go deeper. Make the Stack Overflow logo using the following criteria: The tray: Make a gray tray shaped like a bracket facing upwards using th...
stackexchange_codegolf
Challenge Premise I've got multiple pretty numbers all in a row. Each is a decimal digit. 0s are weakly attracted to 0s, 1s are attracted to 1s a little more strongly and so on until 9. I don't know why — it must be something I ate. As a result, a sort of two-way sideways sedimentation occurs until the higher values ar...
stackexchange_codegolf
Introduction Windows 95 used a very simple algorithm for verifying license keys. The scheme of an OEM license key always looked like this: xxxyy-OEM-NNNNNNN-zzzzz The day can be anything within 001-366, and the year cannot be lower than 95 or above 03. xxx represents the day of the year the key was printed on (for exa...
stackexchange_codegolf
Given two strings as input, return the result of XORing the code-points of one string against the code points of the other. For each character in the first input string, take the code-point (e.g. for A, this is 65) and XOR the value against the corresponding index in the second string and output the character at the co...
stackexchange_codegolf
Background Supplementary reading 1, Supplementary reading 2 Linear lambda calculus is a limited form of lambda calculus, where every bound variable must be used exactly once. For example, \a b c d e -> a b (d c) e is a valid term in linear lambda calculus. When embedded as a logic system, this enforces each input to be...
stackexchange_codegolf
You step into the restroom, and notice that the toilet paper has missing! It occurs to you that someone had stolen it. Strangely enough, the first thing you would like to know is the amount of toilet paper the thief stole. Task You are given three integers \$ I \$, \$ R \$, and \$ G \$, the details of the toilet paper,...
stackexchange_codegolf
Introduction Recently, me and a couple of my friends decided to play some cards, and one of them suggested the game 'Irish Snap', which was the inspiration for this challenge. However, I later learnt that the game has a lot of different rules that you can play with, some of which are listed here. The rules that are in...
stackexchange_codegolf
According to TIO there are two types of programming languages: Practical (seen in many corporate environments as a development standard). Recreational (if seen in a corporate environment, you're probably fired). Your Task Mix together one language from each of these realms to achieve the simple goal of calculating th...
stackexchange_codegolf
I am trying to write a solution to the following problem using as few characters as possible (to meme my friend and introduce him to golfing). Can any improvements be done to my code? So the problem requires us to write a function called navigate in Python 3.6 (language of the judge, sorry, no walruses) that takes two ...
stackexchange_codegolf
You are to write a program which generates random integers between \$0\$ and \$99\$ inclusive, outputting each integer in turn, until \$0\$ is generated. You may choose which single-order random distribution (uniform, binomial, Poisson etc.) you use so long as each integer has a non-zero chance of being generated and i...
stackexchange_codegolf
This includes tips for all related derivatives, as coding in these langs often primarily consists of writing the function in the lambda calculus and then compiling it down at the end. Among others, this includes tips for: Standard combinator calculi SKI system BCKW system Esolang combinator calculi Iota/Jot/Zot La...
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
For this challenge, a slice of a string is defined as an upper and lower index that can "cut" a piece of a string. All characters from the string in the range [start, end) (or [start, end] if you don't speak practlang) are part of that slice. If the upper index exceeds the string's length, the overflow is ignored. For ...
stackexchange_codegolf
Flavortext So...this is awkward. It seems I accidentally turned into a monkey last night after eating one too many banana sundaes. This has made many things inconvenient, especially typing. You see, monkeys only need the following characters: uppercase letters (A-Z), space, comma (,), exclamation mark (!), and question...
stackexchange_codegolf
We're going rootin' tootin' cow-poke shootin! This is a simple contest, first program to draw their pistol wins. How it works: I require 2 things from you, an executable, and a command to be run from a bash terminal. The executable needs to do one thing: wait until it receives 'draw!' from STDIN, and then print 'bang!...
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
Your should write a program or function that takes a 4-character string as input and outputs a value indicating if the string is an English word or not. You are allowed to make mistakes in 15% of the provided testcases. Input details: Input is a 4-character string containing only the lowercase English letters (a-z). Ou...
stackexchange_codegolf
Given an integer array of at least two elements, output the Matrix-Vector (defined below) of the array. To compute the Matrix-Vector, first rotate through the size-n input array to create a matrix of size n x n, with the first element of the array following the main diagonal. This forms the matrix portion. For the vect...
stackexchange_codegolf
A standard ruler of length n has distance marks at positions 0, 1, ..., n (in whichever units). A sparse ruler has a subset of those marks. A ruler can measure the distance k if it has marks at positions p and q with p−q=k. The challenge Given a positive integer n, output the minimum number of marks required in a spars...
stackexchange_codegolf
Write a program that accesses Project Gutenberg's KJV Bible, either from a file called pg10.txt in the working directory or in any other way that is typical for the language, takes a Bible verse reference as input, and prints the corresponding verse, with no newlines except optionally one at the end, as output. The sta...
stackexchange_codegolf
Most Unicode characters have full names, for example ” is "RIGHT DOUBLE QUOTATION MARK". You can find a useful reference here, just type in the character you want to find the full name of and look in the DESCRIPTION column. Your challenge is to write a program or function that outputs itself as a string of these. You c...
stackexchange_codegolf
Context We're at war! You need to transfer an important message to your general to inform them from an imminent assault. The thing is, your enemy knows a lot about cryptography : you will need to be more creative in order to encode your message... Task Create a program that accepts an ascii message as input, and output...
stackexchange_codegolf
I'm always forgetting Pokemon type matchups. This is a challenge to print the pokemon type chart! Attacking Type No Fi Fl Po Gr Ro Bu Gh St Fr Wa Gr El Ps Ic Dr Da Fa Normal 1.0 2.0 1.0 1.0 1.0 1.0 1.0 0...
stackexchange_codegolf
(based on this post and the ensuing discussion on chat -- also, much thanks to Dennis for TIO!) The Challenge Choose a language that's currently available on the TryItOnline site, for example PowerShell. Write code in that language on that page, that doesn't take any input, such that when the Run button is clicked, the...
stackexchange_codegolf
Lets Play Kick The Can! Although Moogie is the current winner, if anyone can take his crown they are encouraged to do so Kick the can is a children's game. Involving one defender, and multiple attackers. Today it is no longer such a game! Your job is to write a bot that plays it, to win, king-of-the-hill style! https:/...
stackexchange_codegolf
Given a list of positive integers, give the longest contiguous sublist which contains at most 1 pair of identical items. In the case of a tie return any of the solutions. This is code-golf so the goal is to minimize your source code with answers being scored in bytes. Test cases [] -> [] [1,2,3] -> [1,2,3] [1,2,2,3] -...
stackexchange_codegolf
We've recently reached the threshold of 10,000 questions on PPCG. Hooray! Let's celebrate this with a simple challenge. Input Two integers \$A\$ and \$B\$, both in \$[1..9999]\$, such that \$A+B<10000\$. Task Your task is to add one single digit to one of these integers or one single digit to both of them such that \$A...
stackexchange_codegolf
A venerated pass time of pedants is to point out that pictures of "Rubik's Cubes" (on t-shirts, posters etc.) are not actually solvable. The first thing that should be checked is that the cube is made up of the right pieces. To be solvable a cube needs six colors each with nine squares. The cube also needs each edge ...
stackexchange_codegolf
Given a matrix, sum its values up/down or left/right to form an X, fold it up, and return the list. I describe the algorithm here: Algorithm Your input will be a odd-sized square matrix of integers within your language's reasonable numerical capacity. Let's take the following matrix as an example: 1 2 3 2 1 0 3 2 3 0 4...
stackexchange_codegolf
I found another sequence not yet in the OEIS The binary expansion sequence is defines as follows, assuming 0 indexing: The even numbers of the sequence are how often 0 has appeared in the binary expansion of all previous items in the sequence The odd elements are the same, but for 1s. If you choose to 1-index, revers...
stackexchange_codegolf
A ragged matrix, is a matrix that has a different number of elements in each row. Your challenge is to write a program in any favorable language to find the indices of all occurrences of target in the ragged matrix. Input: A list of ragged lists (can be empty) of positive integers and a target range e.g. 26-56. The tar...
stackexchange_codegolf
Fast and Golfiest Robbers Thread Welcome to the first season of Fast and Golfiest, a cops-and-robbers challenge! I designed this challenge to encourage competitive coding for efficiency (fastest algorithm) to become more popular on the site. The rules are simple. The cops choose problems from LeetCode, a competitive co...
stackexchange_codegolf
Imagine you are given an array/string containing \$5\$ letters of the English alphabet, with each letter having any value from A to Z (inclusive). Every day, each letter will perform a job, which can affect itself or other letters in the array. The letter's job is determined by the letter itself. Most letters are, due ...
stackexchange_codegolf
Background From Wikipedia: An Egyptian fraction is the sum of distinct unit fractions. That is, each fraction in the expression has a numerator equal to 1 and a denominator that is a positive integer, and all the denominators differ from each other. The value of an expression of this type is a positive rational number ...
stackexchange_codegolf
What general tips do you have for golfing in MathGolf? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to MathGolf (for tips which can be applied to loads of programming languages, look at the general tips).
stackexchange_codegolf
Santa needs some help determining how many elves he will need to help him deliver gifts to each house. Coal is considerably heavier than presents, so santa will need three elves for every naughty person in the house. Only two elves are needed to help santa carry presents. On santa's map, a house is represented by a *, ...
stackexchange_codegolf
Take as input an integer in any reasonable format. Then, output all the proper sub-strings of the base-10 digits of that integer that are powers of two, in any reasonable format. Test cases 10230 -> [1, 2] 13248 -> [32, 1, 2, 4, 8] 333 -> [] 331 -> [1] 32 -> [2] # As 32 is not a proper sub-string, since it is the whole...
stackexchange_codegolf
As you might know there is a mathematical fun-fact that if you add all natural numbers you end up with... -1/12 (see Wikipedia here). Of course this is very strange result and can not be obtained by just adding one number followed by another, but some special mathematical tricks. However your task is to write a program...
stackexchange_codegolf
Well, last time I asked for an arithmetic sequence, now comes the geometric sequence Challenge In this challenge, the input will be an unordered set of numbers and the program should be able to tell if the set of numbers is a Geometric Sequence. Input The input will be a set separated by ,(comma). Output The Output ...
stackexchange_codegolf
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. As we all know, Santa comes down the chimney to deliver presents to good kids. But chimneys are normally full of smoke, and the Elves are worried about Santa's health. So they decide to blow the smoke out using an electronic air blower...
stackexchange_codegolf
A simple golf to start the week! You're given three arrays: the base array B, the value array V and the index array I. You should produce another array where the values from V are inserted into B at the indices specified by I. Here is an example: Base: [5, 1, 4, 1, 3] Values: [0, 0, 7] Indices: [5, 0, 3] The indic...
stackexchange_codegolf
Given a drawing of the letter shoot system, where an existing piece of pipe is marked with a *, and an empty spot is marked with a ., your task is to compile a lexicographically sorted list of index tuples [entry row, entry column, exit row, exit column], where each index is 0-based. Entry and exit points are always on...
stackexchange_codegolf
Problem source: https://oj.vnoi.info/problem/backtrack_j We have these two shapes: #. ## and .# ## Let's call the first shape the L and the second shape the flipped L. On a 4x4 board, there are 16 cells. Each cell can be either free or occupied. In all the illustrations, # represents an occupied cell and . represents...
stackexchange_codegolf
Introduction Our goal is to efficiently find the maximum of a large amount of (redundant) data. We define the outer product of vectors \$A\$ and \$B\$ as a matrix containing the products of all entries of \$A\$ with each entry of \$B\$. (see outer Product) $$ A\otimes B := A\cdot B^T = \left(\begin{array}{rrr} A(1)\cdo...
stackexchange_codegolf
(Note: this challenge is distinct from my other challenge (Draw a path made from direction changers) because of it's rendering of direction (horizontal or vertical), crossing points and single or double paths.) Let's start with a frame drawn in Ascii characters. For this challenge it will always be 20 characters wide ...
stackexchange_codegolf
This is a rip-off of a rip-off of a rip-off of a rip-off of a rip-off. Go upvote those! Your task, if you accept it, is to write a program/function that outputs/returns its input/args. The tricky part is that if I make your source code palindrome via duplicating reversed source code after the original code, the output...
stackexchange_codegolf
Given a list of unique strings that are anagrams of each other, output an anagram of those words that is different from each word in the list. The strings will be alphanumeric, and there is guaranteed to be a valid anagram. The program or function can, but doesn't have to be non-deterministic, meaning given the same in...
stackexchange_codegolf