instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Given a non-empty string consisting of only lower and upper case alphabetical characters and spaces ([a-zA-Z ]), reduce it to a snippet of the alphabet, starting with the first character. To reduce a string, begin with the first alphabetical character, then remove every character after it that is not the next letter of...
stackexchange_codegolf
The Fibtraction sequence (as I call it) is similar to the Fibonacci sequence except, instead of adding numbers, you subtract them. The first few numbers of this challenge are: 1, 2, -1, 3, -4, 7, -11, 18, -29, 47, -76, 123, -199, 322, -521, 843, -1364... The sequence starts with 1 and 2. Every next number can be calcu...
stackexchange_codegolf
I like anagrams. I like programs that reference their own source code. So this challenge combines them! Input. The input to the program could be anything, including letters, numbers, symbols, you name it. Output. A truthy value if the input's characters can be rearranged to give the source code, and a falsy value if th...
stackexchange_codegolf
This challenge will have you count "creatures" in the tile game Palago. A creature is any closed shape that can be formed by Palago tiles of matching colour in a hexagonal grid. The game Palago consists of tiles like this: These tiles can be rotated \$120^\circ\$, \$240^\circ\$, or not at all and placed anywhere on ...
stackexchange_codegolf
Background Consider an \$n\times n\$ grid, where each cell is either empty (denoted by .) or a wall (denoted by #). We say that two cells are adjacent if they share an edge (a corner is not enough). A path is a sequence of distinct empty cells \$s_0,s_1,\ldots,s_k\$ such that cells \$s_i\$ and \$s_{i+1}\$ are adjacent ...
stackexchange_codegolf
Related Sometimes when I use my microwave, I do a little trolling and enter times such as 2:90 instead of 3:30 because they end up being the same time anyway. The microwave happily accepts this and starts counting down from 2:90, displaying times like 2:86 and 2:69 until it gets back to a stage where it can count down...
stackexchange_codegolf
I was messing around on my 'ol TI-84 CE and made a program that produced this output (it was actually bigger but that is not the point): * * * * * * * * * * * * * * * * * ... I evolved it to take input text and make the triangle waves out of that. The final step was to also take a number to specify th...
stackexchange_codegolf
The other day, our team went to an escape room. One of the puzzles involved a board of six mechanical switches where you had to find the correct combination of on and off in order to unlock a box, somewhat like this: -v-v-v- -v-v-v- Being developers, we decided it would be more efficient to try every single one of 2^6...
stackexchange_codegolf
Given 3 integers, determine the lowest possible base for the first two integers to multiply into the third. If you think of the Answer to the Ultimate Question of Life, The Universe, and Everything, 6 * 9 == 42, is true in Base 13. The inputs can include any numbers whose digits use the characters 0-9, a-z, and A-Z, wh...
stackexchange_codegolf
I wrote this function in 48 bytes and I wonder, is there any way to write this code 2 characters shorter? p=lambda n,c:(n*c)[:n//2]+(n*c)[:n//2+n%2][::-1] The point of the function is to create a palindrome of length n by using all the characters from the string c. Example: n = 3, c = 'ab'. Result is 'aba'. Is there s...
stackexchange_codegolf
Challenge Your goal is to write a function that puts quotes around a sequence of capital letters in a string. So some examples (everything on the left (before function) and right (after function) are STRINGS): Hello the name's John Cena -> "H"ello the name's "J"ohn "C"ena I got BIG OLD truck -> "I" got "BIG" "OLD" truc...
stackexchange_codegolf
You are in a one-floor dungeon. There is a treasure which is protected by locked doors. Doors can be opened by finding the corresponding keys. Your goal is to find the shortest path to the treasure. Input Input will be a two-dimensional grid representing the initial layout of the dungeon. ########### #$ # g# # #...
stackexchange_codegolf
Intro Something I've played around with in recreational mathematics has been construction of a divisor table to visually compare/contrast the prime divisors of a set of numbers. The set of input numbers are across the top as column labels, the prime divisors are on the left as row labels, and a mark indicates where the...
stackexchange_codegolf
Is there any javascript-like language? Something that can be interpreted by browsers?
stackexchange_codegolf
Challenge: Take input of two black and white (monochrome) images and xor each pixel of the first, with each pixel of the second, add them to a new image and output the new image. Some clarifications: Size of pictures does not matter. Extension/Image format doesn't matter. You can make it take input any extension and ou...
stackexchange_codegolf
Given a multidimensional array, find the recursive alternating sum. An alternating sum is simply the sum of an array, where every other item (starting with the second) is negated. For example, the alternating sum of [7, 1, 6, -4, -2] is the sum of [7, -1, 6, 4, -2], or 14. In this challenge, you'll take the alternating...
stackexchange_codegolf
Alienese refers to two "languages" in the show Futurama. In actuality, they are two ciphers of English text with a pictographic alphabet. The first is a simple substitution cipher, but the second is slightly more complex. The second is a type of autokey cipher that follows these steps: Take a word to be encrypted, e.g...
stackexchange_codegolf
This is a successor to a previous challenge. Input An integer \$1 \leq n \leq 5\$. Task Your code should produce all strings that satisfy the following properties: Your string should contain exactly two each of the first \$n\$ letters of the alphabet. It should not contain the same letter twice in a row It must start ...
stackexchange_codegolf
You have been hired as a research assistant, and asked to create a small program that will build rat mazes. The rat box is always 62x22 and has an entrance (a) and exit (A) for the rat, like this (input 1): #######a###################################################### # ...
stackexchange_codegolf
If you are given an array of numbers between 1 and 100 and an integer n, you must remove any instances of an item that appear greater than n times. For example: In : [92, 41, 81, 47, 28, 92, 84, 92, 81], n = 1 Out: [92, 41, 81, 47, 28, 84] The most aesthetic/simple algorithm wins. And since this is a popularity-contes...
stackexchange_codegolf
Produce this square snowflake. XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XX X X X X X X X X X X X X X X XX X XXXX XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX XXXX X XX X X X X X X X X X X X X XX X X XXX XXXX XXXX XXXX ...
stackexchange_codegolf
Stuttering is a problem which many of us might have experienced or at least seen it. Although most of famous speech recognition softwares have serious issues with stuttered speaking, let's imagine a software which understands stuttering, but cannot fix them and only writes them as is. An example written text by such a ...
stackexchange_codegolf
Suppose denominations of banknotes follow the infinity Hyperinflation sequence: \$ $1, $2, $5, $10, $20, $50, $100, $200, $500, $1000, $2000, $5000, \cdots \$. How many banknotes are required, at minimum, to pay a \$$n\$ bill? Consider Alice needs to pay \$ $992 \$ to Bob. It is possible for Alice to use 7 banknotes \$...
stackexchange_codegolf
The title pretty much describes it all. Given as input a \$n \times m\$ matrix and an integer \$i\$ create a complete function/program that returns the matrix \$i\$ times clockwise rotated by \$90^\circ\$. Rules: as matrix you can use any convenient representation you like e.g. a list of lists etc... matrix values can...
stackexchange_codegolf
Oh no! I have a theory test soon and I don't remember the scales yet! Help me remember my major scales by printing the following: 7♯ - C♯ D♯ E♯ F♯ G♯ A♯ B♯ C♯ 6♯ - F♯ G♯ A♯ B C♯ D♯ E♯ F♯ 5♯ - B C♯ D♯ E F♯ G♯ A♯ B 4♯ - E F♯ G♯ A B C♯ D♯ E 3♯ - A B C♯ D E F♯ G♯ A 2♯ - D E F♯ G A B C♯ D 1♯ - G A B C D ...
stackexchange_codegolf
This question is a part of the lean LotM. A ring is a type of structure that takes the rules of addition and multiplication we are familiar with and abstracts them, so we can reason about them. To do this we state a number of expected properties as axioms and see what we can say about systems that follow these axioms....
stackexchange_codegolf
Now that we know how to Square a Number my Way, we need an inverse operation, a way to Square Root a Number my Way. To square a number my way, you simply stack it on top of itself a number of times equal to the number of digits it contains, and then take read off every number that is formed both vertically and horizon...
stackexchange_codegolf
Minesweeper is a popular puzzle game where you must discover which tiles are "mines" without clicking on those tiles. Each tile is either a mine (represented by *) or a clue, i.e. a number from 0 to 8 representing how many of the 8 neighboring tiles are mines. Your task today is to take a board containing the mines and...
stackexchange_codegolf
Part of Advent of Code Golf 2021 event. See the linked meta post for details. Related to AoC2020 Day 20, Part 1. (This day is a dreaded one for many of you, I know :P) Obligatory final "but you're not Bubbler" explanation. As the train carries you to the destination, you've got some spare time. You open the travel boo...
stackexchange_codegolf
There is a 3x3 square block made of 1x1 square blocks, with coins in each 1x1 block, starting from top left block you want to collect all the coins and return to top left block again, if possible provide instructions to achieve this. Rules From block \$(x,y)\$ in one step you can move right(R) to \$(x,y+1)\$ ,left(L) ...
stackexchange_codegolf
Challenge Given a rectangular area arrange a group of rectangles such that they cover the rectangular area entirely. Input An integer denoting the height. An integer denoting the width. The dimensions of the rectangles consisting of the following form: axb,cxd,... where a,b,c, and d are integers - any reasonable for...
stackexchange_codegolf
Related: I double the source, you double the output! When Steve Jobs launched the iPhone 3G, the slogan said Twice as fast, half the price I changed the word fast to long to better represent this challenge. Objective Write a program that outputs a non-zero, even integer. If the source code is doubled, the value of t...
stackexchange_codegolf
Given two positive integer fractions \$x\$ and \$y\$ such that \$x < y\$, give the fraction \$z\$ with the smallest positive integer denominator such that it is between \$x\$ and \$y\$. For example \$x=2/5\$, \$y=4/5\$, the answer is \$1/2\$. Other fractions such as \$3/5\$ are also in between the two, but \$1/2\$ has...
stackexchange_codegolf
Othello/Reversi is a board game in which players take turn placing pieces of a color (dark or light) on the 8x8 board. The possible moves are positions where there are one or more pieces of the opponent's color in a straight (horizontal, vertical, or diagonal) line between that position and a piece of the player's colo...
stackexchange_codegolf
Background Most (halfway decent) text editors allow you to navigate text using the arrow keys. Up and down allow you to navigate lines, while left and right move across a line but also wrap around. Furthermore, if the line is shorter than your cursor's X position, the cursor appears at the end of the line but returns...
stackexchange_codegolf
Given a list of positive integers, write code that finds the length of longest contiguous sub-list that is increasing (not strictly). That is the longest sublist such that each element is greater than or equal to the last. For example if the input was: \$[1,1,2,1,1,4,5,3,2,1,1]\$ The longest increasing sub-list would ...
stackexchange_codegolf
Given an integer n > 2, print or return the smallest non-negative integer k such that a(n, k) = 9, where a(n, k) is defined by: a(n, 0) = n a(n, k+1) = a(n, k) / 2 + 1 if a(n, k) is even the sum of the digits of a(n, k)² (in base 10) if a(n, k) is odd Examples For n = 5, the expected output is k = 4: a(5, 0) = 5 a(...
stackexchange_codegolf
Related Now you have some dice which you may roll several times. You need a uniform random integer between 1 and \$n\$, inclusive. Show a method that rolls the fewest times and behaves as an \$n\$-sided dice. Alternative question: Given a set \$S\$ and \$n\$, pick the fewest elements from \$S\$(each element can be pick...
stackexchange_codegolf
This challenge was inspired by programming an Arduino microcontroller. I have 6 LEDs and 6 buttons connected to various pins on the board. In the code, each button and LED is assigned an ID number (1-6). Pin numbers (ranging from 0-13) corresponding to the ID numbers are looked up using a switch statement. Purely for a...
stackexchange_codegolf
This is a problem that the Hacker Cup team made for the 2018 Facebook Hacker Cup, but we ended up not using it (though Ethan struggles through a variety of other challenges). Normally code size isn't a factor in the Hacker Cup, but we thought this would make for an interesting code golf challenge. We look forward to se...
stackexchange_codegolf
Background You've been given a task to take notes for a meeting. You start typing on your Google Doc, but you don't have enough time during the meeting to look at your keyboard while you type. Fortunately for you, you can type without looking at your keyboard. After the meeting, you realize that everything you typed wa...
stackexchange_codegolf
History There's a room on StackOverflow in Russian where you can see such an interesting discussion: Just because there are not enough real discussing in that room, @Grundy "plays ping-pong" to keep it unfrozen. Task Implement a bot for StackExchange that posts "ping!" to the 115624 room if the previous message was ...
stackexchange_codegolf
Objective Given an unlabelled binary tree, decide whether it is contiguous in indices. Indices This challenge gives one-indexing on binary trees. The exact definition expresses all indices in binary numeral: The root is indexed 1. For every node, to get the index of its left child, replace the most significant 1 by 1...
stackexchange_codegolf
I am looking for tips to code in this golfing language Seriously, and was wondering what some of the ways for golfing this language is. "Remove comments" is not a tip. Actually is also included
stackexchange_codegolf
The sequence discussed in this challenge is a variant of the Descending Dungeons sequence family. Specifically, the sequence generation rules: (A_b = A's base 10 representation read as a base b number, A = A_10) A(0) = 10 A(n) = 10_(11_(12_(...(n+9)_(n+10)))) Your goal is to make a program which accepts a nonnegative ...
stackexchange_codegolf
In Elixir, (linked) lists are in the format [head | tail] where head can be anything and tail is a list of the rest of the list, and [] - the empty list - is the only exception to this. Lists can also be written like [1, 2, 3] which is equivalent to [1 | [2 | [3 | []]]] Your task is to convert a list as described. The ...
stackexchange_codegolf
A positive integer \$x\$ is an \$n\$-perfect number if \$\sigma(x) = nx\$, where \$\sigma(x)\$ is the divisor sum function. For example, \$120\$ is a \$3\$-perfect number because its divisors sum to \$360\$: $$360 = 3\times120 = 1+2+3+4+5+6+8+10+12+15+20+24+30+40+60+120$$ and $$926073336514623897600 = 6\times1543455560...
stackexchange_codegolf
Let's have a function \$f\$ that takes a string and removes all pairs of adjacent identical characters. For example \$f(a\color{red}{bb}ba\color{red}{cc}) = aba\$ Note that when two pairs overlap we only remove one of them. We will call a string perfectly paired if repeated application eventually yields the empty stri...
stackexchange_codegolf
The above image is called a hexa-glyph. Hexa-glyphs are some cool patterns I made up while doodling during my DiffEq class. Here's how you make one: Consider the following set of points, shaped like a regular hexagram. The inner hexagon is what will contain the final glyph, while the outer 6 points form a star and...
stackexchange_codegolf
Notice: This king-of-the-hill challenge has completed. This means that the green checkmark, which has been awarded to C5H8NNaO4 for their entry The Observer will not be moved to any new answer. You may still submit new entries, but there may be delays in new tournaments running as I am not actively checking for new en...
stackexchange_codegolf
Challenge Your challenge is to make a simple program that takes the [input] and formats it as "Hello, [input]!" Input Either a function call variable or STDIN, this is the name. Can contain any character, UTF-8, and can be empty - would result in Hello,!. Also newlines in the input are fine - On a new line -> Hello, O...
stackexchange_codegolf
In graph theory a tree is just any graph with no cycles. But in computer science we often use rooted trees. Rooted trees are like trees except they have one specific node as the "root", and all computation is done from the root. The depth of a rooted tree is the smallest number, \$n\$, such that any node of the tree ...
stackexchange_codegolf
Given the name of an HTTP status code, such as OK or Continue, output or return the corresponding number. Your code is limited to 200 bytes, and the winner is the answer that correctly finds the number for the most status codes. For this challenge, the status codes your program should handle are: 100 Continue 101 Switc...
stackexchange_codegolf
Your task is to generate an emoticon of three characters, the first character being one eye, the second the mouth, and the third another eye. Each eye is a random one of these characters: $'*+-;O^`ox~, and the mouth is a random one of these: ,-._coux. Each eye and the mouth must be on the same general level. These eyes...
stackexchange_codegolf
Summer Klerance, a senior in college, is what her teachers refer to as GBL*. Students in her probability class have been assigned individual problems to work on and turn in as part of their final grade. Summer, as usual, procrastinated much too long, and, having finally looked at her problem, realizes it is considerabl...
stackexchange_codegolf
Given integers N , P > 1 , find the largest integer M such that P ^ M ≤ N. I/O: Input is given as 2 integers N and P. The output will be the integer M. Examples: 4, 5 -> 0 33, 5 -> 2 40, 20 -> 1 242, 3 -> 4 243, 3 -> 5 400, 2 -> 8 1000, 10 -> 3 Notes: The input will always be valid, i.e. it will always be integers g...
stackexchange_codegolf
The challenge This challenge is going to be a classic king of the hill game of RPS. You must write a program that takes two command line arguments, a string of all the moves that you have made, and a string of all the moves that your opponent has made. The program will then return either 'r', 'p' or 's' for rock, paper...
stackexchange_codegolf
Imagine a continuous 2-dimensional path that can only turn left, right, or go straight, cannot intersect itself, and must fill a rectangular grid such as the grid of pixels in an image. We'll call this kind of path a snake. This enlarged example shows a snake path in a 10×4 grid that starts out red and increases in hu...
stackexchange_codegolf
Totally not inspired by Visualize long division with ASCII art ;) Your job is to show long hand addition with ASCII art. You solve longhand addition by adding up the columns right to left, placing the value of the ones place in the result, and carrying the tens place over to the top of the next column. Input Input can ...
stackexchange_codegolf
Solve a Tron Game Tron is a great game, and if you haven't played it the internet has MANY online versions available. A fun challenge is to try to write an AI that plays Tron, which is normally much better than any human, thanks to their frame perfect dodging. Even with their perfect dodging of walls, they still get th...
stackexchange_codegolf
Write a program (or function) (let's call it P1), that when run, outputs another program P2 of the same language and exactly 1 byte longer than P1. Program P2 when run, should output a 3rd program P3 that's 1 byte longer than P2. P3 must output a program P4 that's one byte longer than P3, etc. The same for P5, P6, ...,...
stackexchange_codegolf
The Challenge Implement a function which accepts two integers whose values range from 0 - 255 and returns the sum of those integers mod 256. You may only use bitwise negation (~), bitwise or (|), bit shifting operators (>>,<<), and assignment (=). Things you cannot use include (but are not limited to) Addition, subtra...
stackexchange_codegolf
Just take an input in any way and then print it backward (trailing newlines allowed). For example: Hello World -> dlroW olleH Hi -> iH Yes, it is case sensitive. Shortest code wins
stackexchange_codegolf
Let \$R, C\$ be positive integers and let \$0 < s \leq 1\$. Consider the \$R \times C\$ matrix \$\mathbf M\$ defined as \begin{equation} M(i,j) = \frac{\mathrm{mod}\,(j, i^s)}{R^s}, \quad i = 1, \ldots, R, \quad j = 1, \ldots, C \end{equation} where \$\,\mathrm{mod}\,\$ denotes the modulo operation: for \$a,b > 0\$ not...
stackexchange_codegolf
Given two strings, output a third string that is not equal to either of the two inputs, but has the same length (in characters) as either of the inputs. There is guaranteed to be at least one valid output. Test Cases Test cases are quoted to show they are strings. Outputs are one of many possible. input, input -> outpu...
stackexchange_codegolf
Background In Python, function arguments are defined within the parentheses following the function name in the function definition. There are different ways to present function arguments, and they can be categorised into three types: Positional-only arguments, Positional or keyword arguments, and Keyword-only argument...
stackexchange_codegolf
Given an integer n >= 1 as input, output a sample from the discrete triangular distribution over the integers k, for 1 <= k <= n (1 <= k < n is also acceptable), defined by p(k) ∝ k. E.g. if n = 3, then p(1) = 1/6, p(2) = 2/6, and p(3) = 3/6. Your code should take constant expected time, but you are allowed to ignore o...
stackexchange_codegolf
Given a positive number n, output all distinct multiplicative partitions of n in any convenient format. A multiplicative partition of n is a set of integers, all greater than one, such that their product is n. For example, 20 has the following distinct multiplicative partitions: 2 * 2 * 5 2 * 10 4 * 5 20 Order does no...
stackexchange_codegolf
Title stolen inspired by Greg Hewgill's answer to What's the difference between JavaScript and Java? Introduction Java and JavaScript are commonly used languages among programmers, and are currently the most popular tags on Stack Overflow. Yet aside from similar names, the two have almost nothing in common. In honor of...
stackexchange_codegolf
Your task is to write a computer program or function that takes a list of nonnegative integers of at least length 2 and determines if they are a "zigzag". A sequence is a zigzag if and only if the numbers alternate in being larger and smaller than the number that comes before them. For example \$[1,2,0,3,2]\$ and \$[...
stackexchange_codegolf
Task: Your task is, when given three inputs: a numerator n a denominator d another integer, x Create a program/function that finds the xth digit of the number after the decimal place. Specs: The range of n and d is between 1 and 2^31 - 1, inclusive. The range of x is between 1 and 10,000,000, inclusive. You may ch...
stackexchange_codegolf
Inspired by Is this Flow Free puzzle trivial? by @Bubbler. Lengthy chunks of this challenge are borrowed from there. This may be one step of a solution for the linked challenge, depending on chosen strategy. Challenge Given an array of digits 1-9 and a padding character of your choice, output the border of the shape ma...
stackexchange_codegolf
Given input \$x \in \left\{0,3,6,...,90\right\}\$, output \$\sin\left(x°\right)\$ using integer and \$+ - \times \div ( ) \sqrt{\cdot}\$(square root), e.g. \$\sin(45°)=\sqrt{1\div 2}\$. Flexible output format. You needn't do any simplification to output, aka. it's fine to output \$\sin(0°)=\sqrt{42}-\sqrt{6\sqrt{-9+58}...
stackexchange_codegolf
There are lots of different ways to explain matrix multiplication. I'll stick with a single figure since I believe most people here are familiar with it (and the figure is very descriptive). If you want more detailed information, I suggest you visit the Wikipedia-article, or the explanation on WolframMathWorld. Simple ...
stackexchange_codegolf
Discussion in courtrooms often occurs at a high speed and needs to be accurately transcribed in case the text of the decision is needed in future cases. For this purpose, the stenographers who transcribe court discussions use specially designed keyboards with a small set of buttons, which are pressed in groups to spell...
stackexchange_codegolf
Yesterday, as part of a IQ-style test, I got this interesting question: The time on a 24-hour clock is 11:43. What is the least number of minutes I should wait before the same digits are on the screen again (in any valid 24-hour time order)? The answer's 91 minutes, if you were wondering! This stuck in my mind, and ...
stackexchange_codegolf
Natural numbers ≡ \$\mathbb{N}≡\{0,1,2,...\}\$ The submission can be either a program or a function, both cases will henceforth be referred to as "function". The task is to golf the shortest function \$\mathbb{N}^n→\mathbb{N}\$, i.e. a function that maps \$n\$ natural numbers (with \$n>0\$ being a number of your choosi...
stackexchange_codegolf
Challenge: Given a 2D array (8x8) of characters, is the enemy king in check? The program should return true if and only if the king is currently in check. Standard chess rules apply. Specifications: The game is provided using a 2D array, where blank space means there is not a piece on that square. You may assume that t...
stackexchange_codegolf
As per Luke's request and Peter Taylor's addition to this challenge. Introduction Everyone knows the game tic-tac-toe, but in this challenge, we are going to introduce a little twist. We are only going to use crosses. The first person who places three crosses in a row loses. An interesting fact is that the maximum amou...
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 Cops' thread. For the Robbers' thread, go here In this challenge, you are tasked with running some code that makes it so that your language no longer...
stackexchange_codegolf
Create a function which given a number of lines n, makes a bigA. The horizontal bar of bigA must be at the middle row, or the lower of the two if n is even Assume a monospace font for output Output should be a string (or similar, eg character array) with clear linebreaks to break up the lines, and with correct whites...
stackexchange_codegolf
Goal: Given any natural number k such that k<256, produce an deadfish program that gives the smallest solution possible. Background: Deadfish is a joke esoteric programming language. It has a single unsigned byte of memory, called the accumulator, initialized at 0. There are four commands which form a string. i = accu...
stackexchange_codegolf
You might know Alan Walker from his ever popular song Faded. Now his "followers" are called Walkers and they have a logo, here is a simplified version: \\ \\ //\\ \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ //...
stackexchange_codegolf
Or maybe it's not really a labyrinth, but still. Rules: Input is a two-line string, consisting of *, 1, x and X. That string is a labyrinth to walk through. The lines have the equal length. You could take the input as a string with , (comma) or any convenient separator between these two lines. Or you could take both l...
stackexchange_codegolf
Given a square matrix, output the matrix's eigenvalues. Each eigenvalue should be repeated a number of times equal to its algebraic multiplicity. The eigenvalues of a matrix A are scalar values λ such that, for some column vector v, A*v = λ*v. They are also the solutions to the characteristic polynomial of A: det(A - λ...
stackexchange_codegolf
Programs often list outcome statistics, such as this: 54% of participants received an award 69% of participants got a promotion 85% of participants increased their salary These percentages are the result of dividing a/x, where both a and x are whole numbers, and the result is rounded to the nearest hundredth. Your ta...
stackexchange_codegolf
Objective: Write a program that generates beautiful (?) ASCII-art landscapes and skylines! Your program has just one input: a string composed of any combination/repetition of the chars 0123456789abc. For each input character, output a vertical line composed as follows: . .. ... oooo o...
stackexchange_codegolf
Take a unit circle centered on the origin. In any two neighboring quadrants, mirror the curve of the circle across the lines connecting the circle's x and y intercepts. With the resulting shape, you can tile the plane: I made this image with the awesome 2D physics sandbox Algodoo! Write a program that outputs an image...
stackexchange_codegolf
The following is the rhombus sequence. 1 121 12321 1234321 123454321 12345654321 1234567654321 123456787654321 12345678987654321 Your task is to output this, taking no input and using standard output methods (STDOUT, list of numbers or list of strings, etc.). There's a hitch. You may only use up to one loop - no neste...
stackexchange_codegolf
Rules The program should receive a string/array of words as input. For each word in the string/array, it will reconstruct the word by taking characters in alternating fashion from the front and back of the word. 12345 678 9 -> 15243 687 9. It will then rearrange the words in an alternating fashion between the earliest ...
stackexchange_codegolf
In speedcubing, an Ao5 (Average of 5) is computed for a set of five times by removing the fastest and slowest times, and then computing the mean of the remaining three times. A "rolling ao5" is computed for a sequence of at least five times by computing the ao5 for every set of consecutive five times (some sets will o...
stackexchange_codegolf
Church booleans A Church boolean is a function that returns x for true and y for false where x is the first argument to the function and y is the second argument to the function. Further functions can be composed from these functions which represent the and not or xor and implies logical operations. Challenge Construct...
stackexchange_codegolf
The aim is to create an algorithm to detect that one of the string in a small list of strings contains %s, %d, %f, or %r. All sub-string will start by '%' and be 2 characters longs. Input string will be from 1 to 500 characters with a median of around 20 characters and contain zero to multiple of the possible sub-stri...
stackexchange_codegolf
Background A binary tree is a rooted tree whose every node has at most two children. A labelled binary tree is a binary tree whose every node is labelled with a positive integer; moreover, all labels are distinct. A BST (binary search tree) is a labelled binary tree in which the label of each node is greater than the l...
stackexchange_codegolf
As most of you probably know, (byte-addressable) hardware memories can be divided into two categories - little-endian and big-endian. In little-endian memories the bytes are numbered starting with 0 at the little (least significant) end and in big-endian ones the other way round. Fun fact: These terms are based on Jon...
stackexchange_codegolf
The Māori language has quite simple pronouns. It uses a single word for he/she/they/etc (ia), and the words for "you" and "me" are koe and au respectively. There are also words for groups of exactly two people: tāua - You and me (we, au and koe) māua - Me and them (we, au and ia) rāua - Them (third person plural - two...
stackexchange_codegolf
I have a crank-operated music box that can play a series of four notes. When I turn the crank, it plucks one of four strings, depending on the position of the crank and the direction of the turn. When the crank is turned due north, the box (with its strings numbered 1 through 4) looks like this: 1 | 2 | O 4...
stackexchange_codegolf
This is an exact inverse of the question Convert to Spoken Binary. This introduction is copied from there. Introduction In the video the best way to count, binary is proposed as the best system of counting numbers. Along with this argument is a proposal on how to say numbers in this system. First, we give names to eac...
stackexchange_codegolf
This task is part of the First Periodic Premier Programming Puzzle Push and is intended as demonstration of the new king-of-the-hill challenge-type proposal. The task is the write a program to play the iterated prisoner's dilemma better than other entrants. Look, Vinny. We know your cellmate---what's his name? Yeah Mc...
stackexchange_codegolf
What general tips do you have for golfing in Scala 3? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Scala 3 (e.g. "remove comments" is not an answer). Please post one tip per answer. Also see Tips for golfing in Scala
stackexchange_codegolf