instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
In the alternating Fibonacci sequence, you first start with 1 and 1 as usual.
However, instead of always adding the last two values to get the next number, you alternate starting with adding, and every other time you subtract instead.
The sequence starts like this:
1
1
2 # 1 + 1
-1 # 1 - 2
1 # 2 + -1
-2 # -1 ... | stackexchange_codegolf |
The Jaccard index / similarity coefficient, also known as the Tanimoto index / coefficient, is a statistic used for gauging the similarity and diversity of finite sample sets. It was developed by Grove Karl Gilbert in 1884 for the field of weather forecasting [1] and later independently developed by Paul Jaccard [2] wh... | stackexchange_codegolf |
Purpose
The idea is to provide the code necessary to map a 32-bit integer to/from a pronouncable word of 9 characters maximum. That could be useful, for example, to make a serial number easier to remember, or type in a form.
Both the method for translating an integer to the corresponding word and for translating back a... | stackexchange_codegolf |
Write a program fragment so that, when repeated N times it prints the Nth Fibonacci number. For example, if your program is print(x) then:
print(x) should print 1
print(x)print(x) should print 1
print(x)print(x)print(x) should print 2
print(x)print(x)print(x)print(x) should print 3
print(x)print(x)print(x)print(x)prin... | stackexchange_codegolf |
Task
Given an integer matrix M and a modulus m, find an inverse of M modulo m. If the matrix M is not invertible modulo m, the behaviour is left unspecified.
Matrix inverse
If M is a square matrix, its inverse exists if and only if its determinant is not 0. Similarly, when we are talking about matrices modulo m, the in... | stackexchange_codegolf |
Your goal in this code golf is to compile all the Stack Exchange sites' favicons.
Getting the Domains
The domains you will be using will be:
*.stackexchange.com
stackexchange.com
stackoverflow.com
superuser.com
serverfault.com
askubuntu.com
mathoverflow.net
stackapps.com
stackauth.com
Everything but stackexchange.co... | stackexchange_codegolf |
A Kaprekar number is an n-digit number k that, when the first n or n-1 digits of k^2 are added to the second n the digits of N^2, the result is N.
Examples:
9^2 = 81. 8+1 = 9.
45^2 = 2025. 20+25 = 45.
297^2 = 88,209. 88+209 = 297
The Kaprekar sequence begins at 1.
Write a program that calculates and outputs the firs... | stackexchange_codegolf |
In most programming languages, arithmetic is written with infix notation -- i.e. the operator is put in between the operands -- e.g. 1+2. In contrast, with Polish notation (a.k.a prefix notation), the operator comes before the operands -- e.g. +1 2. As long as the number of operands for each operator is fixed, this mea... | stackexchange_codegolf |
The Illuminati commands you (with their mind control) to output the following string:
^
/_\
/_|_\
/_|_|_\
/_|/o\|_\
/_|_\_/_|_\
/_|_|_|_|_|_\
/_|_|_|_|_|_|_\
/_|_|_|_|_|_|_|_\
/_|_|_|_|_|_|_|_|_\
Rules:
Trailing spaces are allowed for each line.
Leading spaces in each line... | stackexchange_codegolf |
Input a scientific notation number (base 10), output scientific notation in base 16 (as defined below).
Details
In scientific notation, all non-zero numbers are written in the form
$$ m \times 10^n $$
Where \$ n \$ is an integer, and \$ m \$ is a real number, \$ 1 \leq |m| < 10 \$.
Consider scientific notation in base ... | stackexchange_codegolf |
Given two integers, compute the two numbers that come from the blending the bits of the binary numbers of equal length(same number of digits, a number with less digits has zeros added), one after the other, like such:
2 1
10 01
1 0
1001
0 1
0110
some examples:
Input
Binary
Conversion
Output
... | stackexchange_codegolf |
My user id is 106959
How to check if the number is Fmbalbuena number?
First Step: Check if the number of digits is a multiple of 3: 6 = 3 * 2
Second step: Split the digits into even thirds: 106959 -> 10 69 59
Third step: Subtract the first set of digits from the second modulo 10: 6 - 1 = 5, 9 - 0 = 9
Last step: Check t... | stackexchange_codegolf |
Output the infinite list of pairs of integers (a, b), where both \$ a > 1 \$ and \$ b > 1 \$, ordered by the value of \$ a^b \$. When there are multiple pairs where \$ a^b \$ is equal, they should be ordered lexicographically.
For example, \$ 2^4 = 4^2 = 16 \$, but (2, 4) should come before (4, 2), because it is lexico... | stackexchange_codegolf |
The challenge
Implement the C equivalent of the pow() function (exponentiation) for natural numbers, in a language of your choosing, using only addition, subtraction (which includes negation and comparisons), bit-shifting, boolean operations on signed and/or unsigned integers, and of course looping.
(Note that this is ... | 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.
Background
Flow Free is a series of puzzle games whose objective is to connect all the same-colored pairs of dot... | stackexchange_codegolf |
Program the shortest code that will calculate the average BPM (Beats per Minute) using 8 data points of time passed. This is my first post, and I haven't seen a question similar to this. Since I am a fan of rhythm games, it would be nice to have a small handy tool to calculate BPM using your own keyboard and your own s... | stackexchange_codegolf |
Challenge
The goal is to output Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo.
Context. (Maybe another interesting challenge could be printing all of the other examples? This would probably use similar logic but involve either a function or just a for loop.)
Rule(s)
You cannot output anything other t... | stackexchange_codegolf |
Given a non-negative integer n, print the result of P(P(...P({}))), where the number of P's is n (P is the power set function).
0 => {}
1 => P({})
2 => P(P({}))
3 => P(P(P({})))
n => P(f(n-1))
input result
0 {}
1 {{}}
2 {{},{{}}}
3 {{},{{}},{{{}}},{{},{{}}}}
...
The result should only contai... | stackexchange_codegolf |
Inspired by this question.
Challenge
Let L be a list of n distinct elements. Let P be the set of all (unordered) pairs of positions in P. Let R be a result of applying a pair-swap operation on L by every pair in P in any order.
Example:
L = [1, 7, 8]
P = {(1, 2), (0, 1), (0, 2)}
L = [1, 7, 8] -> [1, 8, 7] -> [8, 1, 7] ... | stackexchange_codegolf |
Taylor series are a very useful tool in calculating values of analytic functions that cannot be expressed in terms of elementary functions, using only information about that function at a single point.
In this challenge, you won't be actually doing any math with them, but merely making string representations of taylor ... | stackexchange_codegolf |
The boardgame Terra Mystica has some very interesting mechanics for one of the primary resources, power. Instead of gaining and spending units of power from a bank, each player starts the game with exactly 12 units of power which are distributed over three "bowls", which are labelled I, II and III. Gaining and spending... | stackexchange_codegolf |
The inverse of this question.
Your challenge is to, given a piece of ASCII art generated by the above question and its enlargement factor, shrink it down to its original size.
The enlargement process
Or look at this
ASCII art within a limited character set can be enlarged to a certain (odd) size by replacing certain c... | stackexchange_codegolf |
A pangram is a string that contains every letter a-z of the English alphabet, case-insensitive. (It's OK if the pangram contains more than one copy of a letter, or if it contains non-letter characters in addition to the letters.)
Write a program or function whose input is a list of strings, and which outputs one or mor... | stackexchange_codegolf |
In this challenge you will write code to take a list of positive integers and output all maximal linear sublists.
A sublist is is a list which can be created by deleting values from the the input list. Sublists have more structure than just lists. They in a way "remember" which values are deleted.
Similarly we say tha... | stackexchange_codegolf |
Most Android smartphones allow the user to use a swipe pattern to open their phone:
Certain patterns are legitimate, and others are impossible. Given an input swipe pattern, return a truthy or falsy indicating if the given input pattern is legal or not.
Input
The grid is labelled row-wise 1 through 9:
1 2 3
4 5 ... | stackexchange_codegolf |
In this exercise, you have to analyze records of temperature to find the closest to zero.
Write a program that prints the temperature closest to 0 among input data.
Input
N, the number of temperatures to analyse (optional). This will be nonzero.
The N temperatures expressed as integers ranging from -273 to 5526.
Outp... | stackexchange_codegolf |
Assumption
A cigarette can be made by combining four cigarette butts. Cigarette butts last infinitely until smoked.
Explanation
Say you have 31 butts. That means, you can make 7 cigarettes from 28 butts and have 3 left over.
Now, these 7 cigarettes will yield 7 butts when you're done smoking them. That means you have 3... | stackexchange_codegolf |
Select any word from https://websites.umich.edu/~jlawler/wordlist with length greater than 1. For each letter on that word, remove it and check if any rearrangement of the remaining letters is present in the wordlist. If it is, this rearrangement is a child anagram of the original word.
For example, theism:
removing t... | stackexchange_codegolf |
Most of you have probably heard of the famous Turtle Graphics program, initially made popular by Logo. This challenge is to implement a Turtle Graphics program in your language of choice.
Rules:
The floor must be a diagonal with dimensions input by the user through std-in in the form x/y, representing the x and y len... | stackexchange_codegolf |
Introduction
Skat is a traditional German card game for 3 players. The deck consists of 32 cards: Ace, King, Queen, Jack, 10, 9, 8, 7 in all 4 suits (Clubs, Spades, Hearts, Diamonds).
In every round there one player plays solo while the other two play against him.
At the start of a round each player is dealt 10 cards, ... | stackexchange_codegolf |
I only very recently discovered code golf and just found this part of the Stackexchange network, and naturally after looking at so many clever answers, I feel inferior. Inner me knows I'll get better over time, but inner me is also vain and needs validation.
At the same time, I don't take kindly to pandering, so you'd ... | stackexchange_codegolf |
In the 1990s, COBOL computer engineers worked out a way to extend six-digit date fields by converting them to YYYDDD where YYY is the year - 1900 and DDD is the day of the year [001 to 366]. This scheme could extend the maximum date to 2899-12-31.
In the year 2898, the engineers started panicking because their 900 yea... | stackexchange_codegolf |
Input:
A string (or the closest thing to that in your language)
Output:
The same string but converted to sentence case
Rules:
For this challenge, sentence case can be considered "The first letter of each sentence is capitalized. The rest are lowercase." (i.e. proper nouns do not have to be capitalized)
If the input do... | stackexchange_codegolf |
Problem
Given an input a where a is a truthy/falsy value output the exact impossible cube below if truthy and the exact normal cube below if falsey.
Input truthy:
___________________________________
/ _______________________________ /|
/ / _____________________________/ / |
/ / /| | ... | stackexchange_codegolf |
A shape's volume is the measure of how much three-dimensional space that shape occupies.
Challenge
Given six integers: [L,W,H] as length, width and height of one container and [l,w,h] as length, width and height of some random item.
You will need to calculate how many items would fit completely if the item was a liquid... | stackexchange_codegolf |
The Challenge
Given a valid regex, output a regex that that matches the same set of strings, but reversed.
The Task
This challenge uses the most basic regex operations: ^, $, ?, +, *, [], {}, |. There's no such thing as capture groups or any of that complicated stuff. Special characters can be escaped.
Sample Input/O... | stackexchange_codegolf |
Overview
Your goal is to implement RC4 encryption. RC4 encryption, invented by Ron Rivest (of RSA fame), was designed to be secure, yet simple enough to be implemented from memory by military soldiers on the battlefield. Today, there are several attacks on RC4, but it's still used in many places today.
Your program s... | stackexchange_codegolf |
Given a unix timestamp as an input, give a datetime string, in a format like so: "YYMMDD.HHmm"
Rules
The input is a number (integer) of a millisecond-precise UNIX epoch time (milliseconds since 1970 January 1st 00:00:00.000 UTC).
The values must be padded with zeroes if they are 1 character instead of 2. (e.g.: for "D... | stackexchange_codegolf |
Challenge
Given a positive integer \$n\$, count the number of \$n\times n\$ binary matrices (i.e. whose entries are \$0\$ or \$1\$) with exactly two \$1\$'s in each rows and two \$1\$'s in each column.
Here are a few examples of valid matrices for \$n=4\$:
1100 1100 1100
1100 0011 01... | stackexchange_codegolf |
In this challenge, your input is a string of lower-case letters like this:
insertspacesbetweenwords
and a dictionary like the that from my other challenge. You may assume that the dictionary file contains only lower-case letters and line-feed characters. Furthermore, the last character in the dictionary file is a line... | stackexchange_codegolf |
In Emoji Math, a user created module for the video game Keep Talking And Nobody Explodes, numbers are written as strings of emoticons, where each emoticon represents a base 10 digit.
Below is the conversion table between digits and emoticons.
Digit | Emoticon
0 | :)
1 | =(
2 | (:
3 | )= ... | stackexchange_codegolf |
Specification
For this challenge you will:
Take an array of positive integers.
For each overlapping pair in the array, calculate the difference of it's integers. If the difference is a common divisor of the integers (they are both divisible by their difference), swap their positions in the array. The values of the nex... | stackexchange_codegolf |
Inspired by the fact that a few related challenges to this could be answered by Vyxal in 0 Bytes using a special flag combination.
Given only one input integer \$n\$, calculate \$f(n,n)\$ where
$$ f(x,y)=
\begin{cases}
x & \text{if } y=0 \\
f(\left(\sum_{k=1}^xk\right),\text{ }y-1) & \text{otherwise}
\end{cases}
$$
If ... | stackexchange_codegolf |
This is the Cop post. The Robber post is here.
Your task is to take an integer input N and output the Nth digit in the sequence OEIS A002942.
The sequence consists of the square numbers written backwards:
1, 4, 9, 61, 52, 63, 94, 46, 18, 1, 121, 441, ...
Note that leading zeros are trimmed away (100 becomes 1, not 00... | stackexchange_codegolf |
Create a program that can be run in 4 different languages such that:
One language prints "Hello World!"
One language outputs its own source code
One language outputs 99 bottles of beer on the wall, that is:
99 bottles of beer on the wall
99 bottles of beer
Take one down, pass it around
98 bottles of beer on the wall
... | stackexchange_codegolf |
The Task
Given a natural number as input, your task is to output a truthy or falsey value based on whether the input is a factorial of any natural number. You can assume that the input number will always be in the range of numbers supported by your language, but you must not abuse native number types to trivialize the ... | stackexchange_codegolf |
Introduction
In this game, players use their armies to fight other players' armies, capture territories, and become the last man standing. Each turn, players receive a base number of armies to use at their disposal. By capturing territories in certain regions, however, players can increase this number to give them a po... | stackexchange_codegolf |
Background:
Standard operation math like basic addition and multiplication in the real world work like these:
12 + 123 = 135
and
12 * 123 = 1476
That's not interesting and boring! Many schools are already interpreting this as practice, practice, practice of formal algorithms. That implies a pretty rigid and boring ma... | stackexchange_codegolf |
A matrix can be thought of as the altitudes of a surface in 3D space.
Consider the 8 neighbours (orthogonal and diagonal) of a cell as a cyclic sequence in clockwise (or anticlockwise) order. Some neighbours may be higher than the original cell, some lower, and some levelled at the same height as the original cell. We ... | stackexchange_codegolf |
The keypad on my office phone has the following layout:
[1] [2] [3]
/.@ ABC DEF
[4] [5] [6]
GHI JKL MNO
[7] [8] [9]
PQRS TUV WXYZ
[*] [0] [#]
+ _
Task:
Write a program that, given an input string, returns a list of instructions that my fingers need to follow in order the type/dial the message/number... | stackexchange_codegolf |
A well known song by the Irish rock band U2 starts with the singer Bono saying "1, 2, 3, 14" in Spanish ("uno, dos, tres, catorce").
There are various theories as to the significance of those numbers. Apparently the official explanation is "we drank too much that night". But there's a more interesting hypothesis: Bono ... | 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 |
As you probably know, there have been multiple lovely Jimmy challenges recently popping up. In these challenges, you were challenged with our beloved friend's acrobatics skills. Now we've got a different challenge for you. Today you will be identifying different types of Jimmys!
Explanation
There are three varieties o... | stackexchange_codegolf |
Part of Advent of Code Golf 2021 event. See the linked meta post for details.
Related to AoC2020 Day 11, Part 2.
You enter the waiting area for a ferry, and you see a bunch of people sitting at a bunch of seats. The seats form a grid like this (. is a floor, L is an empty seat and # is an occupied seat):
LL.#L
#.L.L
L... | stackexchange_codegolf |
Background
In France, and probably in the rest of the European Union, any food available for sale must list the ingredients that compose it on its packaging, in weight percentage descending order. However, the exact percentage doesn't have to be indicated, unless the ingredient is highlighted by the text or an image on... | stackexchange_codegolf |
Description
While support is getting better and better for people to write in various scripts around the world using unicode, and now you can even write in emojis as well, unfortunately most fonts[citation needed] are still missing Latin characters based on the double acute accent, which is required to write properly i... | stackexchange_codegolf |
Background
Boggle is a board game where the players have to find English words on a 4-by-4 board of random alphabets. Words can be constructed by selecting sequentially adjacent cells on the board. ("adjacent" means horizontally, vertically or diagonally adjacent.) Also, same cell can't be used more than once in a word... | stackexchange_codegolf |
Okay, the challenge is that you have to write a regex that matches half of all strings.
Some rules to clarify:
For ANY string length(>0), if I permute all strings(of that length), exactly half of them should be matched. Put more lightly, if I generate a random string of that length it should have a 50% chance of being ... | stackexchange_codegolf |
Task
Given two strictly positive integers n and d as input, determine whether n is evenly divisible by d, i.e., if there exists an integer q such that n = qd.
You may write a program or a function and use any of the our standard methods of receiving input and providing output.
The output should be a truthy or a falsy v... | stackexchange_codegolf |
For cops' post, Cheapo Enigma machine (Cops)
A robber's submission consists of a program/function that accepts the output of a cop's code and returns the input for all the outputs provided by that cop's code. (In other words, you must write the inverse function)
You cannot use built-ins that have the sole purpose of ha... | stackexchange_codegolf |
Arturo is a bytecode-compiled/interpreted, garbage-collected general-purpose language filling a role similar to JavaScript, Python and Ruby. It is centered around the concept of blocks, which hold code just as easily as data. It uses fixed-arity prefix syntax and emphasizes the procedural and functional paradigms.
What... | stackexchange_codegolf |
Given a positive integer n > 1 determine how many numbers can be made by adding integers greater than 1 whose product is n. For example if n = 24 we can express n as a product in the following ways
24 = 24 -> 24 = 24
24 = 12 * 2 -> 12 + 2 = 14
24 = 6 * 2 * 2 -> 6 + 2 + 2 ... | stackexchange_codegolf |
Meta discussion: Is "(The other day) I met a bear" a duplicate?
Your challenge is to output this text:
The other day,
The other day,
I met a bear,
I met a bear,
A great big bear,
A great big bear,
Oh way out there.
Oh way out there.
The other day,
I met a bear,
A great big bear,
Oh way out there.
He looked at me,
H... | stackexchange_codegolf |
Write a cat program, a quine, and a Hello World in the same language such that when two specific programs of the three are concatenated in a certain order, you get the third program. It does not matter which program is the first, second, and third are as long as all three types are represented once each.
e.g. if \$A\$ ... | stackexchange_codegolf |
For robbers' post, Cheapo Enigma machine (Robbers)
A cop's submission will consist of a program/function that accepts a single byte of data and return a single byte of data. Every possible input must produce a unique output. (In the other words, your function must be bijective)
Robbers will attempt to create the invers... | stackexchange_codegolf |
<< Prev Next >>
Santa was able to remanufacture all of the presents that the elves stole overnight! Now he has to send them to the assembly line for packaging. He usually has a camera to supervise the assembly line both to make sure the elves are doing a good job and because assembly line pictures look nice on advertis... | stackexchange_codegolf |
inputs / outputs
your program/function/routine/... will be a predicate on two tuple sequences; call it relation ≡. for the purpose of simplicity we use natural numbers:
the input will be two list of pairs of numbers from ℕ (including 0); call them Xs and Ys
the output will be a "truthy" value
specification
≡ checks t... | stackexchange_codegolf |
Given a rectangular board of cells with some number of holes in it, determine whether it is possible to complete a "holey knight's tour" (That is, a path that visits every non-hole cell exactly once using only chess knight moves, not returning to the starting cell) that starts on the top-left cell.
For the sake of comp... | stackexchange_codegolf |
Today is Purim on which one custom is to give out triangle-shaped cookies with filling called hamantaschen (singular: hamantasch). Another custom is to drink heavily.
I'm not the most perfect baker.... I have so many irregularly-sized hamantaschen to give out and so many friends to give them to! If I sent you a pictur... | stackexchange_codegolf |
Take the string abcdfghjk. To overwrite it, starting from f, with the string wxyz, you would continue along the original, replacing each character with the one from the replacement string. The result would be abcdwxyzk.
Now, consider a string which would be too long to fit, like lmnopqrs. Starting at f you would get ab... | stackexchange_codegolf |
Background
There's a terrible problem in my console - the quotes never get included inside the arguments! So, when given this argument:
["abc","def","ghi","jkl"]
it says that the argument is like this:
[abc,def,ghi,jkl]
It would be very nice if you can fix this problem!
Challenge
Add double-quotes (") in order to sur... | stackexchange_codegolf |
Since programming is predicted to become natural linguisized by the unstoppable advances in LLM technology, perhaps we can code golf LLMs themselves.
Produce the shortest question that is not an arithmetic problem (we know it sucks at multiplication problems) that produces an obvious falsehood from ChatGPT with screens... | stackexchange_codegolf |
Objective Given an input of text that does not contain characters [ or ], perform the following actions:
For every instance of Amen with at least one capital letter (so all instances of Amen excluding amen), output that same Amen (retain capitalization).
For every instance of /all the people said[?: ]/i (that's a Regu... | stackexchange_codegolf |
A simple FizzBuzz using strings.
Given
1 word or phrase (string)
2 unique characters
Output
The word or phrase with each occurrence of the first character replaced with fizz and each of the second character replaced with buzz
Rules
The first letter in both Fizz and Buzz must remain capitalized
For the rest of the wo... | stackexchange_codegolf |
Problem Description
Imagine you're a turtle on a grid. You're given two numbers f and b, and you're facing east. You perform a march across the grid, counting each of the cells you encounter, according to the following rules:
By default, you write the count to the cell you're in, then walk forward.
If the count is di... | stackexchange_codegolf |
In the face of some regrettable rules that turned the original into a glorified sorting task, I am posting a more challenging variant. Shout out to Luis Mendo for the suggestion of how to improve the original challenge.
You've inherited a server that runs several apps which all output to the same log.
Your task is to ... | stackexchange_codegolf |
Challenge
You just entered a room. Here's how it looks (you are the X):
|\ /|
| \/ |
| X |
| |
|----|
You challenge yourself to see if you can reach where you started by following the walls. You go right until you find a wall. Then, you turn clockwise until you are facing parallel to the wall.
For example, if you... | stackexchange_codegolf |
The Interview: The Front Nine
This is the first of a series of challenges inspired by programming job interview questions.
You walk into the office where your potential future boss sits. "Come on in and sit down", he says. You nervously sit down, making sure your snappy yet professional attire is free of wrinkles. He a... | stackexchange_codegolf |
Problem:
In your choice of language, write the shortest function that returns the floor of the square root of an unsigned 64-bit integer.
Test cases:
Your function must work correctly for all inputs, but here are a few which help illustrate the idea:
INPUT ⟶ OUTPUT
0 ⟶ 0
... | stackexchange_codegolf |
Goal: create a self-referencing tuple satisfying x == (x,) in any version of Python. Standard libraries, matplotlib, numpy, pandas only.
Answers meeting this extra condition are prioritised (which may be impossible): this tuple should also be insertable into a dict or set.
If the extra condition is impossible, apart fr... | 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 |
The optimal matrix (for the rather narrow scope of this challenge) is obtained by "zipping" the elements from the corresponding rows and columns of a square matrix and getting the maximum of each pair.
For instance, given the following matrix:
4 5 6
1 7 2
7 3 0
You can combine it with its transpose to get: [[[4,5,6],[... | stackexchange_codegolf |
Task
Your task is to convert strings like this:
abc^d+ef^g + hijk^l - M^NO^P (Ag^+)
To strings like this:
d g l N P +
abc +ef + hijk - M O (Ag )
Which is an approximation to abcd+efg + hijkl - MNOP (Ag+)
In words, raise the characters directly next to carets to the upper line, one character for on... | stackexchange_codegolf |
Challenge
You are given an array \$a\$ of integers. With a move you can increase or decrease an element of the array by 1. Your task is to equalize the array, that is make all the elements of the array equal by performing some moves. But that's not enough! You also want to make as few moves as possible.
Input
A non-em... | stackexchange_codegolf |
According to this page, the best strategy to guess English hangman words is to calculate the odds of each letter in a word list that meet our conditions. But, as I'm really lazy, I don't really want to compute every word in the dictionary by myself. But, as I know that you are always here to help me, I'm sure you will ... | stackexchange_codegolf |
Given an input, output that input followed by a newline endlessly.
Input will be a string consisting only of printable ASCII characters (0x20-0x7E) and newlines (0x0A).
If input is length 0, endlessly output newlines.
This is code-golf so fewest bytes in each language wins!
| stackexchange_codegolf |
An example will easily explain this to you. Suppose an array [1,2,3,4,5]
Step 1
1 2 3 4 5
----+----
Step 2
5/
4/
1 2 3 /
----+/
Step 3
5|
4|
1 2 3|
----+|
Step 4
5\
4\
1 2 3\
----+-\
Step 5 Take the sum of face-to-face elements
6 6 3
You just successfully folded an array 1 time. 2 times f... | stackexchange_codegolf |
A staircase number is a positive integer x such that its nth digit (one indexed starting with the least significant digit) is equal to x % (n + 1). Thats a bit of a mouthful so lets look at an example. Take 7211311, if we take the modular residues of 7211311 on the range 2-8 we get the following:
7211311 % 2 = 1
7211... | stackexchange_codegolf |
So you want to create a haiku, but you're not sure if it follows the syllable rules for a haiku.
I couldn't be bothered to write a proper blurb like I usually do, so you'll have to make do with this. Let's get stuck right in.
Finding a haiku out in the wild
For the purposes of this challenge, we will be checking if the... | stackexchange_codegolf |
Your goal is to write a full program or function that takes 5 positive integers and a string with an image filename as input [X1,Y1], [X2,Y2], N, image.jpg in any reasonable format, where:
First couple [X1,Y1] are the top left X,Y coordinates (<=20) of the blue rectangle area in the example picture (16,11).
Second c... | stackexchange_codegolf |
I'm sure most of us have heard of zip bombs and similar decompression bomb tricks, where a maliciously crafted input creates a massively disproportionate output. We even had a question on here to do that to a compiler at one point.
Well, it occurs to me that Markdown is a compression format of sorts, replacing bulky H... | stackexchange_codegolf |
Gematria is an ancient Jewish method to determine a numeric value of a letter sequence, using a fixed value for each letter. Gematria is originally applied to Hebrew letters, but for the context of this challenge, we'll use Latin script instead. There are many ways to implement Gematria in Latin script, but let's defin... | stackexchange_codegolf |
It's laundry day, and you have lots of clothes that need to be washed. Wanting to have as much time left over for code golf as possible, you hope to optimize how quickly you wash and dry them all.
You have three types of appliances:
Washing machines: Take dirty clothes and turn them into wet clothes
Dryers: Take wet c... | stackexchange_codegolf |
You work for a social media platform, and are told to create a program in a language of your choice that will automatically flag certain post titles as "spam".
Your program must take the title as a string as input and output a truthy value if the title is spam, and a falsey value if not.
To qualify as non-spam, a title... | stackexchange_codegolf |
Given an infinite arithmetically-progressive¹ sequence, compute the minimum length of a prefix with a product divisible by 2^8.
Sample cases & reference implementation
Here is a reference implementation that I wrote in Io.
1, 1 -> 10
2, 4 -> 8
3, 5 -> 10
2, 6 -> 5
7, 5 -> 6
4, 1 -> 9
10, 9 -> 7
256, 9 -> 1... | stackexchange_codegolf |
Background
Bathroom Etiquette, when pertaining to the available urinals, states that the next urinal to be filled in should be the one that minimizes the total discomfort. The total discomfort equation is given by the following set of equations:
dist(x,y) = linear distance between person x and person y in Urinal Units... | stackexchange_codegolf |
Say I have a list such as [3, 0, 4, 2, 1], and I use selection sort to sort it, I could visualize it like this:
3,0,4,2,1
|-|
0,3,4,2,1
|-----|
0,1,4,2,3
|-|
0,1,2,4,3
|-|
0,1,2,3,4
This challenge is about visualizing sorting like this.
Input
Your input will be a list of positive integers, in any format yo... | stackexchange_codegolf |
Marshall Lochbaum's online BQN REPL has an interesting(and aesthetically pleasing) method of displaying arrays. Your task is to implement a version with simpler rules.
[2,[3],4,[[[6,[5],7]]]]
becomes:
┌─
· 2 ┌· 4 ┌·
· 3 · ┌·
┘ ... | stackexchange_codegolf |
In this game of cops and robbers, each cop will make a vault: a program that stores a secret, and requires a key to unlock. The robbers should find a way to get the vault to reveal its secret without knowing the key.
Cop rules
Cops will write two short segments of code:
A vault, which takes a key and secret, then allo... | stackexchange_codegolf |
Idea
From a given word dictionary (containing only plain letters, i.e: no accent or other special chars), with a given fixed word length, find every same when a given number letters are missing.
For sample: un--ed could match: united, untied or unused
Using my dictionnary: /usr/share/dict/american-english, searching f... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.