instruction
stringlengths
34
53.1k
Background The summary of a non-negative integer \$n\$ is the concatenation of all digits that appear in \$n\$ in increasing order, with each digit being preceded by the number of times it appears in \$n\$. Some Examples: n -> summary(n) 1221 -> 2122 (2 ones, 2 twos) 1212 -> 2122 (2 ones, 2 t...
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...
Given an integer n as input, write a function that dynamically allocates n bytes and returns their address. Rules The allocator must be able to dynamically allocate memory at runtime. It doesn't matter where the memory is allocated to or in what form, as long as it's allocated in a valid location which can be read fro...
The objective is to make the smallest SB3 file that can simply be imported into Scratch 3.0 without a "The project file that was selected failed to load" error. Any means can be used, like editing the JSON or better compression. Here's where I am with project.json, the only file inside mine: {"targets":[{"isStage":true...
Background A bijective base \$b\$ numeration, where \$b\$ is a positive integer, is a bijective positional notation that makes use of \$b\$ symbols with associated values of \$1,2,\cdots,b\$. Bijective base 2 representations of positive integers look like this: 1 -> 1 2 -> 2 3 -> 11 4 -> 12 5 -> 21 6 -> 22 7 -> 111 8 -...
This code-golf challenge (and test cases) are inspired by the work of Project Euler users amagri, Cees.Duivenvoorde, and oozk, and Project Euler Problem 751. (And no, this isn't on OEIS). Sandbox A non-decreasing sequence of integers \$a_n\$ can be generated from any positive real value \$\theta\$ by the following proc...
Consider a non-empty binary matrix M and a natural number n. For the purposes of this challenge, M is said to have blockiness n if it can be built using adjacent square blocks of size n, where each block has equal entries; and it cannot be formed using square blocks of any larger size. Intuitively, n can be thought of ...
Yes, I know there is a similar question, but this one specifically concerns any possible words, even with letters left over, while the linked one restricts to a permutation of the input Objective Have you ever had those moments in a Scrabble game where you're staring at your letters, trying to find a good word, and y...
Background J has trains similar to APL's. Given a sequence of verbs (functions), three rightmost verbs are grouped to form a derived verb (a fork) recursively, until one or two verbs remain. If the sequence has odd length, the entire train is a chain of forks. Otherwise, two verbs remain at the end, forming a hook. ...
Challenge Let's have a list L of n elements. The task is to swap every two elements in this list. Constrains the list L has at least two elements size of the list L is a multiple of two (i.e. number of elements is even) Example input: [1,2,3,4,5,6] output: [2,1,4,3,6,5] input: [0,1,0,1] output: [1,0,1,0] Rules ...
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...
I'm designing a new space station for generic super-villain purposes (something something megalaser), but I'm having trouble designing the solar panels. My genius team of scientists can calculate exactly how many square meters of paneling we need to power the station, but the problem is our solar panels only come in sq...
Given a sorted array of unique positive integers \$A\$ \$(A_0<A_1<\cdots<A_{n-1})\$, and an integer \$t\$, where \$A_0\le t\le A_{n-1}\$. Output the value \$i\$ such that: If \$t \in A\$, \$A_i=t\$. If \$t \notin A\$, \$ \left(i-\left\lfloor i\right\rfloor\right)\cdot A_{\left\lceil i\right\rceil} +\left(\left\lceil i...
Consider all arrays of \$\ell\$ non-negative integers in the range \$0,\dots,m\$. Consider all such arrays whose sum is exactly \$s\$. We can list those in lexicographic order and assign an integer to each one which is simply its rank in the list. For example, take \$\ell=7, s=5, m=4\$, the list could look like: (0...
I'm not really sure if this is the right place to ask this. Now, I know I can convert a float to an int with int, but is there some shorter way?
Consider a linear system of equations, in \$n\$ unknowns, expressed as $$A \textbf x = \textbf b$$ where \$A \in M_{n,n}(\mathbb Z)\$ is an \$n \times n\$ matrix of integers, \$\textbf x\$ is a column vector of unknowns \$(x_1, x_2, \dots, x_n)\$ and \$\textbf b = (b_1, b_2, \dots, b_n)\$ is a column vector of integers...
Assume the result of an exam has been published. After 5 minutes, First person knows the result. In next 5 minutes, new 8 persons know the result, and in total 9 know it. Again after 5 minutes, new 27 people know, and total 36 know. In similar fashion, total 100, 225..... people keep knowing it on 5 minute interval. Ch...
I am trying to push my limits of making a python code as short as possible. I left the readability part way behind. I was attempting the K-Goodness String problem from Round A of Google Kick Start 2021. The following was my initial solution: def func(N, K, S): if not S: return 0 y = 0 for i in range(N//2)...
Your input will consist of an 18×18 image in any reasonable format, containing a horizontally and vertically centered 14px Roboto Mono character. This can be any of 94 printable ASCII characters (not including the space). But: you only need to be able to recognize some 80 character subset of your choice. Output should ...
Your task is to write a short program that represents a large (infinite) ordinal, using a well-ordering of the set of positive integers. Your program will take two different positive integers and indicate which one is greater in your chosen well-ordering. The order type of the well-order is the represented ordinal. The...
A digit small number is a positive integer \$n\$ such for any two numbers that multiply to \$n\$, their total number of digits is more than the digits in \$n\$. In otherwords: there are no two positive integers \$a\$ and \$b\$ such that: \$ ab = n \$ and \$ \left\lfloor\log_{10}(a)\right\rfloor+\left\lfloor\log_{10}(b)...
UTF-9 was an April Fool's Day RFC joke specifications for encoding Unicode suitable for 9-bit nonet platforms. Challenge Your task is to implement a program or a function or a subroutine that takes one integer, who represents the codepoint of a character, to return a sequence of integers that represents its correspondi...
Adapted from this StackOverflow question In this challenge you will take a list of lists of integers, e.g. A = [[1,2],[3,4],[5],[]] And an additional single integer (e.g. n = 7). If you were to add n to the front of one of the lists in A there would be as many ways to do that as there are lists in A. In this example ...
You are to take a string representing a piece of brainfuck code and Explanations, containing only printable ASCII characters and newlines ( to ~, ASCII 10 and 32 to 126) as input and output an explanation of that code, formatted to be compliant with Stack Exchange markdown. That is, the explanation must satisfy: Each...
Every phone needs a calculator app. Because of the limited screen real estate, the developer of mine has decided to save some buttons. Instead of having two dedicated bracket buttons - one for open ( and one for close ) - there is just a single bracket button (). It looks something like this: When the button is presse...
What general tips do you have for golfing in Chef? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Chef (e.g. "remove unnecessary whitespace" is not an answer). Please post one tip per answer.
Brainfuck is an esoteric programming language that is Turing Complete, meaning you can't tell whether a given program will halt without running it. It's cell-based and has an infinite tape of cells, values containing an unsigned integer from 0 to 255, but if you give it arbitrary-size cells, just three is enough to mak...
I've been doing quite a few code golf recently and I realised that a lot of times, I have to do something involving list. Most of the times lists are space-separated or comma-separated values in the first argument (argv[2]), and the return value should also be a space/comma-separated string. Are there any tips for conv...
From my CMC. Given a regex and a non-empty printable ASCII text, return one bit per character in the text, indicating the positions of beginnings of non-overlapping matches, and also the positions of beginnings of sequences that are not part of any non-overlapping matches. You can: take the regex as a regex object, st...
UTF-1 is one of the methods to transform ISO/IEC 10646 and Unicode into a sequence of bytes. It was originally for ISO 10646. The UTF-1 encodes every character with variable length of byte sequence, just like UTF-8 does. It was designed to avoid control codes. But it was not designed to avoid duplication of a slash cha...
Consider the \$4\$ divisors of \$6\$: \$1, 2, 3, 6\$. We can calculate the harmonic mean of these numbers as $$\frac 4 {\frac 1 1 + \frac 1 2 + \frac 1 3 + \frac 1 6} = \frac 4 {\frac {12} 6} = \frac 4 2 = 2$$ However, if we take the \$6\$ divisors of \$12\$ (\$1, 2, 3, 4, 6, 12\$) and calculate their harmonic mean, we...
I was pondering today about how many characters it would take in each language to throw an exception, and noticed there wasn't any existing collection of answers, so: The task Throw an exception in the least amount of characters. If your language does not have exceptions, then a panic is valid. A panic constitutes as a...
Infix notation is a method of printing mathematical expressions where each operator sits between its two arguments, such as \$ \left(5 \cdot 4\right) + 3 \$. Prefix notation is a method of printing expressions where operators sit before their arguments. The equivalent of the above is +*543. It's a bit harder to underst...
Task : Wonky numbers are 3-or-more digit numbers that meet one or more of the following criteria: Any digit followed by all zeros: 100, 70000 Same digit throughout the entirety of the number : 1111, 777777777 The digits are in consecutive ascending order : 1234, 1234567890 (for 0 see below) The digits are in consecuti...
So, normally, this is a forbidden loophole to fetch the desired output from an external source. But this challenge is an exception ! In this challenge you will have to fetch data from the internet and output it to the SDTOUT. The task For the purpose of this challenge, you'll be the owner of the imaginary a.pi domain!...
Task Implement a kind of "some users are typing" system, which can be found in Discord and some other chat clients. If 1 user (say, Bubbler) is typing, output Bubbler is typing... If 2 users (say, Bubbler and user) are typing, output Bubbler and user are typing... If 3 or more users are typing (say, Bubbler, randomuse...
Introduction In computer science, a literal is a notation for representing a fixed value in source code. Almost all programming languages have notations for atomic values, some also have notations for elements of enumerated types and compound values. Wikipedia For example 1 usually represent an integer value, "Hello"...
Given an array of integers, count the number of contiguous subarrays with an even sum. You may assume that the array is non-empty, and contains only non-negative integers. This is code-golf, so the shortest code in bytes wins. Test Cases Input -> Output [7] -> 0 [8] -> 1 [3, 5] -> 1 [6, 2] -> 3 [2, 4, 5] -> 3 [7, 4, 0,...
What general tips do you have for golfing in TypeScript's type system? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to TypeScript's type system (e.g. "remove comments" is not an answer). Please post one tip per answer. If you're not familiar with program...
Background Slowsort is an in-place, stable sorting algorithm that has worse-than-polynomial time complexity. The pseudocode for Slowsort looks like this: procedure slowsort(A[], i, j) // Sort array range A[i ... j] in-place. if i ≥ j then return m := floor( (i+j)/2 ) slowsort(A, i, m) ...
Task Continuously print a random character (a-z, A-Z, 0-9) not separated by a newline (\n). Expected output b7gFDRtgFc67h90h8H76f5dD55f7GJ6GRT86hG7TH6T7302f2f4 ... Note: output should be randomised. Requirements/Rules Output must be continuous (i.e. never ending), Output may not comprise of newlines, Output must b...
Inspired by this Puzzling SE question: All distances different on a chess board. Introduction Lets define a sequence \$a(n), n\geqslant 1\$ as how many pawns can you put on a \$n \times n\$ chessboard in such a way that all the distances between two pawns are different. Pawns are placed always in the centre of the squ...
I've recently stumbled upon a Russian site called acmp.ru, in which one of the tasks, HOK, asks us to find the LCM of two positive integers. The full statement, translated to English is as follows: The only line of the input contains two natural numbers A and B separated by a space, not exceeding 46340. In the only l...
Originally from caird coinheringaahing's idea, I (Bubbler) am hosting Advent of Code Golf 2021. On each day from today (Dec 1) until Christmas (Dec 25), a challenge will be posted at UTC midnight, just like an Advent calendar. It is a free-for-all and just-have-fun-by-participation event, no leaderboards and no prizes ...
I'm writing a program that takes a number from input (call it x), loops from 0 to (x - 1) (let's call our iterator y) and prints \$y^x+x\$ for each y. After the loop, it then prints "SUM: N" (without a newline) where the N is the sum of the all of the previously printed values. How can I make the code I already have sh...
What general tips do you have for golfing in BQN? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to BQN (e.g. "remove comments" is not an answer). Please post one tip per answer. At the moment of writing, the official BQN site is the most comprehensive res...
Background I want to display rich, vibrant images on my theoretical fancy custom display, but due to budget constraints, it displays everything in 3-bit colour! Whilst Regular Dithering would work, I don't want to sacrifice resolution, so I would like my images to be dithered through time! Specs Provided an Input Image...
Code Python 3, 245 bytes E=print def F(): B,C,A=1,1,1;yield 0 while True:yield B;B,C,A=B+C+A+1,C+A+1,A+1 C=int(input()) D=0 for A in range(C): E(end='*'*(C-(C-A)+1));B=A while 0<B:E(end=' '+chr(42+B)*B);B-=1 E();D+=1 for A in F(): if D==0:E(end=str(A));break D-=1 Try it online! What it does? Takes a number from...
Given string s of even length as input, randomly capitalize exactly half of the letters. You can assume the input will always be a non-zero, even length You can assume the input will consist of only lowercase letters ([a-z]) Exactly half of the letters should be capitalized in the output Every permutation that has exa...
Part of Advent of Code Golf 2021 event. See the linked meta post for details. The story continues from AoC2015 Day 5, Part 2. Santa needs help figuring out which strings in his text file are naughty or nice. He has already tried two sets of rules, but they're totally ad-hoc, cumbersome, and janky, so he comes up with ...
Introduction I have decided that this Christmas, as a "present" to a friend, I wish to purchase the things described in the classic song "The 12 Days of Christmas". The only problem is, I don't know how to calculate the total price! Your Task Given a list of prices (in order from first to last), calculate the total pri...
A basis of a vector space \$V\$ is a set of vectors \$B\$ such that every vector \$\vec v \in V\$ can be uniquely written as a linear combination of the vectors in \$B\$. In other words, let \$B = \{\vec b_1, \dots, \vec b_n\}\$ be a basis of some vector space \$V\$. For every possible \$\vec v \in V\$, we can say tha...
Part of Advent of Code Golf 2021 event. See the linked meta post for details. Related to AoC2015 Day 10. Here's why I'm posting and not Bubbler The Elves are playing a variation of the game called look-and-say. In plain look-and-say, they take turns making sequences by reading aloud the previous sequence and using tha...
Part of Advent of Code Golf 2021 event. See the linked meta post for details. Related to AoC2015 Day 20, Part 1. Here's why I'm posting instead of Bubbler and why not emanresuA To keep the Elves busy, Santa has them deliver some presents by hand, door-to-door. He sends them down a street with infinite houses numbered ...
Part of Advent of Code Golf 2021 event. See the linked meta post for details. The story continues from AoC2015 Day 24, Part 2. Here's why I'm posting instead of Bubbler To recap: Santa gives you the list of gift packages' weights. The packages must be split into multiple groups so that each group has the same weight, ...
We all know how binary conversion works: the sequence of bits $$ b_1, b_2, ..., b_{n-1}, b_n $$ encodes the number $$ b_1 \times 2^{n-1} + b_2 \times 2^{n-2} + ... + b_{n-1} \times 2^1 + b_n \times 2^0 $$ This gives an unambiguous representation when we limit all bits \$ b_i \$ to be only 0 or 1. ...but what if we allo...
Part of Advent of Code Golf 2021 event. See the linked meta post for details. Related to AoC2016 Day 1, Part 1. You're airdropped near Easter Bunny Headquarters in a city somewhere. "Near", unfortunately, is as close as you can get - the instructions on the Easter Bunny Recruiting Document the Elves intercepted start ...
Inspired by my geography class, Sandboxed Simulate weathering / erosion. Input Input will be given as a string of any 2 characters (or see below) you like in the shape of the rock (here i use spaces and hashes): ### #### ##### ####### ####### ######## Or if your language doesn't support strings, a square matrix ...
Following the theme of strange kitchen appliances, let's talk about my microwave. Introduction My microwave has a keypad that is laid out like this: 30 > 15 1 2 3 4 5 6 7 8 9 +/- 0 S/M I can press the +/- and S/M keys to switch between adding and subtracting minutes or seconds. The microwave starts in a...
Each natural number (including 0) can be written as a sum of distinct powers of integers (with a minimum exponent of 2). Your task is to output the smallest power required to represent \$n\$. For example: 2 = 1^2 + 1^3 // Output 3 9 = 1^2 + 2^3 = 3^2 // Output 2 15 = 2^2 + 2^3 + 1^4 + 1^5 + 1^6 // Output 6 20 = 2^2 + ...
Part of Advent of Code Golf 2021 event. See the linked meta post for details. The story continues from AoC2016 Day 2, Part 2. You finally figure out the bathroom code (on the weird diamond-shaped keypad) and open the bathroom door. And then you see another door behind it, with yet another keypad design: For those who...
Solve an Inglenook Sidings Puzzle Background The Inglenook Sidings Puzzle is a shunting/switching yard puzzle by Alan Wright for model railroading. The rules for the puzzle are as follows: (Source) Form a departing train consisting of 5 out of the 8 wagons sitting in the sidings. The 5 wagons are selected at random. T...
The event scheduler is a recurrent theme in event-driven architectures: something triggers an event that needs to be checked in the future one or more times. I has particular use in trading where you want to correlate one market event with price movements in the future at several time deltas (1ms, 100ms, 1s, 1 min, etc...
Part of Advent of Code Golf 2021 event. See the linked meta post for details. The story continues from AoC2015 Day 3, Part 2. This challenge was kindly contributed by Wheat Wizard (Grain Ghost). Santa is delivering presents to an infinite two-dimensional grid of houses. The delivery begins delivering a present to the ...
Your task Randomly pick and print "Joe Mama" or "Joe Biden" in as little bytes as possible. Rules No trailing lines, spaces, or anything else weird like that No election fraud! Both "Joe Mama" and "Joe Biden" must have equal chaces of winning Prize The winner will get a spot in https://github.com/Sid220/joe-mama-or-j...
Part of Advent of Code Golf 2021 event. See the linked meta post for details. Related to AoC2017 Day 3, Part 2. You come across an experimental new kind of memory stored on an infinite two-dimensional grid. Each square on the grid is allocated in a spiral pattern starting at a location marked 1 and then counting up wh...
Part of Advent of Code Golf 2021 event. See the linked meta post for details. Related to AoC2017 Day 6. A debugger program here is having an issue: it is trying to repair a memory reallocation routine, but it keeps getting stuck in an infinite loop. In this area, there are n memory banks; each memory bank can hold any...
Definition Given some number, x calculate the smallest number i such that 2i≥x. This is not a duplicate of this question. It is slightly different in that an input of 16 should yield an output of 4 whereas 16 returns 5 in the linked question. Input Input will be an unsigned 32-bit integer. Output Output will be an unsi...
Your task is to input a sequence of integers and chunk sort it. You may assume the input list can always be chunked into groups of 1, 2, and 3. Definition Chunk sorting (a term I made up for the purpose of this challenge) is the action of first chunking a sequence into groups of 1, 2, and 3 in a cycle and then sorting ...
Part of Advent of Code Golf 2021 event. See the linked meta post for details. Related to AoC2017 Day 9. Weekends are Bubbler's days off from posting these lol A large stream blocks your path. According to the locals, it's not safe to cross the stream at the moment because it's full of garbage. You look down at the str...
Challenge Draw lines in ASCII corresponding to given inputs: in the first line there are given size of rows and columns of the view and number of separators between each point in the second line is given list of lines separated by space a line contains the position of head and tail coordinates (within the size of colum...
For the context of this challenge, a matched group is a digit \$n\$, followed by \$n\$ more matched groups. In the case of \$n = 0\$, that's the whole matched group. Digits only go up to 9. For example, 3010200 is a valid matched group, as: 3 # 3, capturing three elements... 0 # a 0 (group 1) 1 # a 1 ...
Part of Advent of Code Golf 2021 event. See the linked meta post for details. The story continues from AoC2017 Day 11. Obligatory why me and not Bubbler link After having rescued a child process lost on a hexagonal infinite grid, you hear someone else screaming for help. You turn around, and unsurprisingly, there is a...
Part of Advent of Code Golf 2021 event. See the linked meta post for details. The story continues from AoC2017 Day 14. To recap: The disk is a rectangular grid with \$r\$ rows and \$c\$ columns. Each square in the disk is either free (0) or used (1). So far, you have identified the current status of the disk (a 0-1 ma...
Introduction My gnome friends are writing a programming language and have asked for my help. Due to their size, the gnomes can only handle small superscript numbers instead of big numbers. However, the language they're writing the interpreter in only accepts big numbers! Your Challenge Given an input of a superscript n...
Part of Advent of Code Golf 2021 event. See the linked meta post for details. Related to AoC2017 Day 16. I'm using the wording from my Puzzling SE puzzle based on the same AoC challenge instead of the original AoC one for clarity. \$n\$ people numbered \$1, 2, \cdots, n\$ are standing in line in the order of their cor...
Intro Blur's song Girls & Boys featured the lines girls who are boys who like boys to be girls who do boys like they're girls, who do girls like they're boys in the chorus. These lines have a pretty uniform structure: you have a subject, which is either girls or boys, a relative clause, either who are, who like, or wh...
Part of Advent of Code Golf 2021 event. See the linked meta post for details. The story continues from AoC2015 Day 3, Part 2. This challenge was kindly contributed by Wheat Wizard (Grain Ghost). Santa is delivering presents to an infinite two-dimensional grid of houses each 1 unit apart. The delivery begins delivering...
Definition Given some string return an integer whose digits are the number ocurrences of a-z (case insensitive, in alphabetical order) in that string. Any character with 0 instances is skipped. Characters with 10 or more instances will define 2 or more digits of the returned integer. For example, aaaaaaaaaaaaaaaaaaaaaa...
I was browsing Stack Overflow when I saw this post in Puzzling in the hot network questions and decided to make a challenge out of it (all credit goes to the creator of the challenge). Overview A Chess Number is a number that, when converted to base 18, results in a valid chess coordinate pair, where the first characte...
Your Challenge is to take a binary string as input and get all binary numbers between itself and the reverse of its string representation (the reverse may be less than or greater than the original input). Output must be padded with zeroes to be the same length as the input. The Order in which the values are displayed d...
Your challenge is to, given a positive integer n, count up to each digit of it, giving the effect of converging on it. Basically, count up to the first digit of n by its place value (\$⌊\log_{10}\left(x\right)⌋\$). Then do the same for each subsequent digit, but with the values of the previous digits added. Example imp...
Related to AoC2017 Day 18, Part 2. (Anyone want to add Duet to esolangs?) Duet is an assembly-like language that involves two processes running the same program simultaneously. Each process of Duet operates with 26 registers named a to z, all initialized to zero, except for the register p which contains the process ID...
Write a program that translates an arithmetic expression to a Brainfuck program which evaluates the expression and prints the result in decimal numbers. For example, this arithmetic expression, 2 * (3 + 4) can be translated to Brainfuck as, ++ 2 >+++ 3 >++++ 4 [-<+>]< add <[>[->+>+<<]>[-<+>]<<-]>[-]>>[-<<<+>>>]<<< mul...
The story continues from AoC2017 Day 22, Part 2. The damn virus that was infecting a grid computing cluster now has jumped to a hexagonal computing cluster! In this cluster, the computers are connected in the honeycomb-like shape, and each computer has three neighbors. .. .. .. . .. .. . .. .. .. . .. .. ...
Challenge Given two binary vectors (containing two consistent values of your choice) of length \$n\$ and \$m\$, output a corresponding ascii-art hitomezashi stitching pattern. You are to fill the following pattern, where \$n\$ is the number of A-columns and \$m\$ is the number of B-rows: A A A A A B+B+B+B+B+B A A A A...
In as few bytes as possible in t-sql, return 100 rows containing the phrase 'Have a great Christmas' 92 (I think) to beat :D CREATE TABLE #(m char(99)) GO INSERT # SELECT'Have a great Christmas' GO 100 SELECT * FROM # Previous best effort was: WITH t(m,r)AS(SELECT'Have a great Christmas',1 UNION ALL SELECT m,r+1 FROM ...
Introduction Everyone knows the FizzBuzz sequence. It goes something like this: 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz . . . In case you don't know, if the number is divisible by 3, it's Fizz. If it is divisible by 5, it's Buzz. If it is divisible by both, it's FizzBuzz. If it is not divisible by bo...
Part of Advent of Code Golf 2021 event. See the linked meta post for details. The story continues from AoC2018 Day 3. But you're not Bubbler, you're Lyxal! yeah, I know. After a long period of chaos, the Elves have finally agreed on how to cut the fabric. Unfortunately, the next day they have come up with how to utili...
Output a sequence of all the primes that are of the following form: 123...91011...(n-1)n(n-1)..11109...321. That is, ascending decimal numbers up to some n, followed by a descending tail, all concatenated. Background Recently, Numberphile posted a video about primes that follow this pattern. Output 1 -> 123456789109876...
The input message consists of ASCII characters The encoded output message consists of blocks of 0 A block is separated from another block by a space Two consecutive blocks are used to produce a series of same value bits (only 1s or 0s): After the ACSII character(s) have been converted to binary, go through the string: ...
If you visit Code Golf often, you may have heard of Kolmogorov complexity. It's usually defined as the amount of bytes required to express some string in a programming language. Here the Kolmogorov-complexity of a natural number is defined similarly: the number of bytes required to represent it in a programming languag...
Euler's totient function, \$\varphi(n)\$, counts the number of integers \$1 \le k \le n\$ such that \$\gcd(k, n) = 1\$. For example, \$\varphi(9) = 6\$ as \$1,2,4,5,7,8\$ are all coprime to \$9\$. However, \$\varphi(n)\$ is not injective, meaning that there are distinct integers \$m, n\$ such that \$\varphi(m) = \varph...
To shuffle a string \$s\$, Alice applies the following algorithm: She takes the ASCII code of each character, e.g. "GOLF" → \$[ 71, 79, 76, 70 ]\$ She sorts this list from lowest to highest: \$[ 70, 71, 76, 79 ]\$ She reduces each value modulo the length of the string (4 in this case), leading to the list \$A = [ 2, 3...
Part of Advent of Code Golf 2021 event. See the linked meta post for details. The story continues from AoC2018 Day 7, Part 2. Why I'm pxeger, not Bubbler As soon as you and a few Elves successfully assemble the Sleigh kit, you spot another set of the same kit not so far away. But you noticed that the last Elf is slack...
Challenge Given an input string X, determine if X can be obtained from reshaping a strict prefix of itself (a prefix that is not X itself). Reshaping a string to a length N means repeating the string as many times as needed and then taking the first N characters of it. Examples: The string "abba" returns Truthy becacau...
A reflexicon is a self-descriptive word list that describes its own letter counts. Take for example the one found by Ed Miller in 1985 in English: Sixteen e’s, six f’s, one g, three h’s, nine i’s, nine n’s, five o’s, five r’s, sixteen s’s, five t’s, three u’s, four v’s, one w, four x’s This reflexicon contains exactl...
Grimm's conjecture states that, for any set of consecutive composite numbers \$n+1, n+2, ..., n+k\$, there exist \$k\$ distinct primes \$p_i\$, such that \$p_i\$ divides \$n+i\$ for each \$1 \le i \le k\$. For example, take \$\{24, 25, 26, 27, 28\}\$. We can see that if we take the primes \$2, 5, 13, 3, 7\$, each compo...
Imagine you have a grid where some squares are walls, some are empty, and some are lights that shine for arbitrary distances in the four cardinal directions until they meet walls: ####.#### ##..L.... ####.##.# ####.##L. ##......L In the above grid, the lights cover all the tiles. But in some cases, they may not be: ##...
Part of Advent of Code Golf 2021 event. See the linked meta post for details. Related to AoC2018 Day 8. The license file for an imaginary software system is defined as follows: The entire file is a sequence of non-negative integers. The entire file defines a tree of nodes. Each node in the tree has the following fiel...