instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Introduction You're making a robot that can navigate a set of books of varying heights. It can climb books and jump off books, but if the distance is too big it will stop to prevent damage. To figure out the ideal design, you're writing a simulator. Your program will take as input a list of numbers, representing the he...
stackexchange_codegolf
Your challenge is to write a program which will output a non-context-free language. A Context-free Grammar is a series of replacement rules, describing which symbols can be replaced by which other symbols. It defines set of strings, known as a language, which is generated by performing all possible replacement rules on...
stackexchange_codegolf
Imagine for a second that you can compose a tree out of dots. . ... ..... ....... ......... ........... ............. ............... ... ... This tree is 13 dots tall. Now imagine for a second that your filesystem looked like these dots. Your task in this challenge is to make a...
stackexchange_codegolf
The code lock for my garage has 5 buttons, labeled "1 2", "3 4", "5 6", "7 8", and "9 0". To open the garage door, you have to enter the correct 4-digit PIN. As you can see, every button represents two numbers. Thus some PINs, like "1357" and "2367", are essentially identical because they require the same sequence of b...
stackexchange_codegolf
Introduction How to prove that 1 = 2: 1 = 2 2 = 4 (*2) -1 = 1 (-3) 1 = 1 (^2) You can just multiply both sides by 0, but that's cheating. This is just bending the rules a little bit. Your challenge: Write a program/function that, when given two integers, outputs a "proof" that the two are equal. Rules Your program's...
stackexchange_codegolf
It's been a while since I posted here, so here we go another day another challenge. Challenge : Given a number(n) split it into it's prime factors. Input : A positive non-zero integer greater than 2. Output : Decompose the number into it's prime factors and return the number of occurances of each prime in it. Ouput...
stackexchange_codegolf
The happy ending problem (actually a theorem) states that Any set of five points in the plane in general position has a subset of four points that form the vertices of a convex quadrilateral. The problem was so named by Paul Erdős when two mathematicians who first worked on the problem, Ester Klein and George Szekere...
stackexchange_codegolf
Let us take a break from the brain-wrecking questions and answer some of the simpler ones You have recently read something extremely funny, and want to express your laughter to the world! But how can you? Task You have to display the string: Lololololololololololololololololololololololololololololololololololololololo...
stackexchange_codegolf
Note: As per consensus on Meta, challenge-writing questions are on topic here. In light of this "thing to avoid when writing challenges", I started to think about challenges involving random generation of certain kinds of objects. It sometimes happens that I want to post a code-golf challenge that involves randomly g...
stackexchange_codegolf
Given a positive integer n output the sum of the first n decimal digits of the fractional part of πn. Example input and outputs: 1 → 1 2 → 14 3 → 6 4 → 13 5 → 24 50 → 211 500 → 2305 5000 → 22852 Built-in functions computing digits of π or evaluating either power seri...
stackexchange_codegolf
Introduction All the possible moves and their combinations of a Rubik's Cube form a group. A group in general is a set with some binary operation defined on it. It must contain a neutral element with respect to this operator as well as inverses for every element of the set. For instance the integers \$\mathbb Z\$ with ...
stackexchange_codegolf
Philosophers have long pondered the Trolley problem. Unfortunately, no human has solved this problem yet. Luckily, as programmers we can use computers to solve the problem for us! Input Your program will take as input a (finite) directed graph (with at most one edge from x to y, for any x and y), with a designated nod...
stackexchange_codegolf
Introduction I don't see many regex challenges on here, so I would like to offer up this deceptively simple one which can be done in a number of ways using a number of regex flavours. I hope it provides regex enthusiasts with a bit of fun golfing time. Challenge The challenge is to match what I've very loosely dubbed a...
stackexchange_codegolf
Growing up, my first console game system was an Atari 2600 and I will always have a love for some of those games I so enjoyed as a child. Many of the graphics are still memorable, perhaps even iconic. It turns out that these sprites are very simplistic bitmaps, 8 pixels wide with variable height where the binary repre...
stackexchange_codegolf
Consider a stream/file with one integer per line. For example: 123 5 99 Your code should output the sum of these numbers, that is 227. The input format is strictly one integer per line. You cannot, for example, assume the input is on one line as an array of integers. You can take input either from STDIN, in form of a ...
stackexchange_codegolf
In 1.13, Minecraft language files were switched from being a simple multi-line key=value format to JSON. Challenge Write a program converting from the original format returning a JSON string. Input can be taken using any standard input method, output must be json from any standard output method The original format cont...
stackexchange_codegolf
Given a word, decide if it is an ambigram. When rotated: b > q d > p l > l n > u o > o p > d q > b s > s u > n x > x z > z Assume only lowercase letters as input. Test input: this, another, lll, lol, dad, dab, dap, wow, ooi, lollpopdodllol, Ones That Should Return Truthy Values: lll, lol, lollpopdodllol, Note tha...
stackexchange_codegolf
This 128-language quine ouroboros (a program which outputs a program in another language, which outputs a program in yet another language, (125 languages later), which outputs the original program) is pretty impressive. But unfortunately, it has a static number of iterations. Write a program which outputs a program (no...
stackexchange_codegolf
Statement You are given a still of a series of balls falling in a 2D grid. This grid is surrounded by immutable and unbreakable walls so all the action is contained within them. Your task is to determine what the state of the scenario will be after gravity does all it's work. Elements inside grid - Floor, doesn't alt...
stackexchange_codegolf
You have to make something that takes in one input from a default I/O method (as an integer), and prints out the sum of all the permutations of that number (not necessarily unique) For example: 10 would return 11 because 10 can have 2 permutations (10 and 01), and the sum of those two numbers would be 11 202 would have...
stackexchange_codegolf
Given two numbers \$x,y > 2, x≠y \$ output all integers \$m\$ such that $$ x + y \equiv x \cdot y \pmod m $$ $$ x \cdot y > m > 2 $$ Input Two integers Output A list of integers Test cases 3, 4 -> 5 5, 8 -> 3, 9, 27 29, 9 -> 223 26, 4 -> 37, 74 13, 11 -> 7, 17, 119 6258, 571 -> 463, 7703, 3566489
stackexchange_codegolf
Given: a width, a height, and a set of sets of points. Output: An image where each set of points is connected and colored in (like a shape). Each shape must be a different color from all of the other shapes, but the actual color doesn't matter as long as each color is distinct. The shapes must be in order; whether you ...
stackexchange_codegolf
I was intrigued by the design of this graphic from the New York Times, in which each US state is represented by a square in a grid. I wondered whether they placed the squares by hand or actually found an optimal placement of squares (under some definition) to represent the positions of the contiguous states. Your code...
stackexchange_codegolf
The Myriad System is an alternative system for naming large numbers proposed by Donald Knuth in 1981. In this system, numbers up to 999 are named as they are normally, but 1000 is not given a special name and is instead named as "ten hundred"; the next benchmark number being 10000, or "one myriad" (which, of course, co...
stackexchange_codegolf
There have been some tax rate calculator problems here that depend on defined rates (specifically US federal rates), but none that have done it for arbitrary lists. Your task is to build a program or function that will take an arbitrary list of marginal tax brackets and calculate the effective amount of tax paid on a g...
stackexchange_codegolf
Challenge Given a left- or right-stochastic matrix where the limit as x approaches infinity of the matrix to the power of x approaches a matrix with all finite values, return the matrix to which the matrix converges. Basically, you want to keep multiplying the matrix by itself until the result no longer changes. Test C...
stackexchange_codegolf
Task Given a winning Wordle play results (clues), the target ("secret") word and a list of words, output a possible sequence of words leading to such results. The words in the list will be distinct and so should be the output. You may assume that for given inputs a solution exists. If there is more than one, you may ou...
stackexchange_codegolf
Given the spiral of size S and the step N, output the "square" S*S spiral having N asterisks, built from the outer to inner radius clockwise. Test cases (examples) below. Input: 4 3 Output: *** Input: 4 6 Output: **** * * Input: 4 11 Output: **** * * * **** Input: 6 18 Output: ****** * * * * ...
stackexchange_codegolf
Supreme Sum String Given an input string, return the word with the highest sum of each of its unicode characters. Rules The input should be seperated by whitespace The value of each word is based on the sum of each character in the word's UTF-16 code The output should be the first word with the highest value (in case...
stackexchange_codegolf
We'd like to factorize a semiprime \$N\$. The goal of this challenge is to find two small integers \$u\$ and \$v\$ such that \$uvN\$ can be trivially factorized with Fermat's method, thus allowing to easily deduct the factors of \$N\$. The task Given a semiprime \$N\$ and a positive integer \$k\$, we define \$x\$ and \...
stackexchange_codegolf
Heatmaps Consider a rectangular room, on whose ceiling we have a thermal camera pointing downward. In the room, there are some number of heat sources of intensity 1-9, the background temperature being 0. The heat dissipates from each source, dropping by one unit per (non-diagonal) step. For example, the 20x10 room .......
stackexchange_codegolf
Challenge Given an integer greater or equal to 4, n, print a rounded rectangle of as close as possible (with a gap of 1) sides and a perimeter of n characters. Rules n is always 4 or greater, because otherwise the output wouldn't be a square The characters for the perimeter can be any non-whitespace character The rect...
stackexchange_codegolf
Consider an \$n \times n\$ grid and a circle of radius \$r \leq \sqrt{2} n\$ with its center in the top left. In each square there is an integer from the range -3 to 3, inclusive. For a given radius, there is a set of squares in the grid which are not at least half covered by a circle of radius \$r\$ but are at least ...
stackexchange_codegolf
Your task is to write a program that will filter out some characters in a string, so that the remaining spells out (part of) the other string. Let's say we received the string "123456781234567812345678", and the second string is "314159". First, we put a pointer on the second string: 314159 ^ So the pointer is now on ...
stackexchange_codegolf
The rundown Create a program that generates an array of random length with random numbers, then apply a series of rules that alter the array. After the rules have been applied, print the sum of the array unless specified otherwise Array setup The array must be a random length between 5 and 10 inclusive, with random int...
stackexchange_codegolf
In Bloons Tower Defense 6, the strength of different bloons can be measured by their Red Bloon Equivalent (RBE), or the number of single pops it takes to completely defeat the bloon. The RBE for the bloon types are as follows (sourced from the wiki) Bloon RBE red 1 blue 2 green 3 yellow 4 pink 5 black...
stackexchange_codegolf
This challenge is inspired by @LuisMendo's MATL answer to my "binary multiples" challenge. Task Pick a code-golf challenge that is open and that has been posted before this one; let me call it the "linked challenge". The linked challenge must be a challenge whose task involves producing output. Write the shortest code ...
stackexchange_codegolf
Inspired by Braille graphics and Build an analog clock. The goal there is to create a tool that use terminal console to draw and animate a clock by using UTF-8 fonts \U2800: ⠀ to \U28FF: ⣿. 00:[⠀] 01:[⠁] 02:[⠂] 03:[⠃] 04:[⠄] 05:[⠅] 06:[⠆] 07:[⠇] 08:[⠈] 09:[⠉] 0A:[⠊] 0B:[⠋] 0C:[⠌] 0D:[⠍] 0E:[⠎] 0F:[⠏] 10:[⠐] 11:[⠑] 12:...
stackexchange_codegolf
Carry sort is an \$O(n)\$ "sorting" algorithm. Here's how it works. The algorithm moves left to right along a list. As it traverses a list it "carries" a single item, the largest item it has encountered so far. Once it encounters a larger item it picks up that item and drops the item it is already carrying in place. W...
stackexchange_codegolf
Below Python code generates memory leak. Challenge: Fix the memory leak with minimal changes to the code as measured by Levenshtein distance to the original code. You may only change the code before t is initialised. When the del t line is removed the modified program should print I'm still alive! every second. PS: I ...
stackexchange_codegolf
Introduction I've always liked the idea of finding the most possible bang-for-your-buck squeezed out of a tiny chip, like the 6502. Of course, I'll need to start small. Filling the screen on 6502asm.com should be easy enough. Challenge Fill the entire program output screen on 6502asm.com with the color white using the ...
stackexchange_codegolf
The New York Times has a daily online game called Letter Boxed (the link is behind a paywall; the game is also described here), presented on a square as follows: You are given 4 groups of 3 letters (each group corresponds to one side on the picture); no letter appears twice. The aim of the game is to find words made o...
stackexchange_codegolf
Challenge Given an array of positive integers and a threshold, the algorithm should output a set of consecutive-element-groupings (subarrays) such that each group/subarray has a sum greater than the threshold. Rules The solution should honor two additional criteria: be of highest cardinality of the groups (i.e. highes...
stackexchange_codegolf
You are given 3 non negative numbers: \$x\$, \$y\$ and \$z\$, and must minimize the number of digits (non negative) inserted at any place in the numbers \$x\$, \$y\$, or \$z\$ to make $$x + y = z$$ (a clarification: you can add any non negative digit any number of time at any place ) (you can assume that \$x\$, \$y\$, ...
stackexchange_codegolf
Context So the Dutch "Ministerie van Binnenlandse Zaken en Koninkrijksrelaties" (NL) - "Ministry of the Interior and Kingdom Relations" (EN) recently released the source code of their digid-app. They have some goofy code in there, which led to mockery and memes on reddit Source code of the offending method can be found...
stackexchange_codegolf
Challenge: Take a rectangular figure consisting of the two characters # and (whitespace, ASCII-32), and identify which direction the lines are. The options are: 'Vertical', 'Horizontal', 'Left Diagonal' and 'Right Diagonal'. Input: The input will be a figure of size n-by-m where 5 <= m,n <= 20. There will be two space...
stackexchange_codegolf
Your task is simple: output the letter x a random number of times. Every possible length of xs must have a non-zero probability of being output. Of course, there must be some lengths whose probabilities tend to \$ 0 \$, in order for the total probabilities to sum to \$ 1 \$, but all must still be theoretically possible...
stackexchange_codegolf
A simple register calculator This challenge involve a simple register calculator that works in the following way: It has some registers named A,B,C,...,Z, each of them can contain an integer, they are all initialized to 0. It executes instructions of 3 characters: The first character of any instruction is one of +,-,*...
stackexchange_codegolf
Given a permutation of the alphabet and an input string, encrypt the input string by replacing all characters with the one's you've been given. The capitalization should be kept the same and non-letters are not to be changed. [hnvwyajzpuetroifqkxmblgcsd], "Hello, World!" -> "Zytti, Giktw!" As [abcdefghijklmnopqrstuvwx...
stackexchange_codegolf
(Note: this challenge is distinct from my other challenge (Draw a path made from direction changers) because of it's rendering of direction (horizontal or vertical), crossing points and single or double paths.) Let's start with a frame drawn in Ascii characters. For this challenge it will always be 20 characters wide ...
stackexchange_codegolf
Overview In this challenge, you will be given two numbers which are both a small offset larger than a multiple of a medium-size number. You must output a medium-sized number that is almost a divisor of both of the numbers, except for a small offset. The size of the numbers involved will be parameterized by a difficulty...
stackexchange_codegolf
Given a string as input, determine whether it is a noun or not. You will be scored on the 1000 most common English words, by how many you correctly label as a noun or not. The program or function which correctly classifies the most of those words in 50 bytes or less will win. Nouns A noun is a word that represents a th...
stackexchange_codegolf
It is simple. I cannot stand when people use spaces when naming files. It sometimes wrecks console commands and makes the output of ls ugly. The challenge is to write a program (only ascii characters) which renames all files (including directories) in the current directory to versions with spaces removed or replaced b...
stackexchange_codegolf
Plot: Jimmy is missing; we have to find him. We should split up. Plot twist: Jimmy is already dead. But, our cast doesn't know that, so they need to search the whole area anyway. There is an N columns x M rows (1<=M,N<=256) grid of cells, either marked as "S" for the starting point, "." for open space, or "#" for an o...
stackexchange_codegolf
In chemistry class, we were learning about titrations, and attempting one as a lab. We were using phenolphthalein as the indicator for the titration, so on top of grading the lab normally, my teacher held a little contest to see who had the lightest shade of pink, and thus the most accurate transition. Your task is to ...
stackexchange_codegolf
Definitions A perfect square is an integer which can be expressed as the square of another integer. For example, 36 is a perfect square because 6^2 = 36. A squarefree number is an integer which is not divisible by any perfect square, except by 1. For example, 10 is a squarefree number. However, 12 is not a squarefree ...
stackexchange_codegolf
Input: A decimal Output: The input truncated How to truncate them? The integer part of the input will remain the same. The decimal part of the input will be truncated based on the lowest digit in consecutive order. The two step-by-step examples below should clarify what I mean by that: Example 1: Input: 17.46940822 Ste...
stackexchange_codegolf
Given a string containing only letters, output the length of the longest run of consecutive alphabetical letters the word contains, where order does not matter. An example algorithm may sort the word, remove duplicates, and then output the length of the longest run. Test Cases watch -> 1 stars -> 3 antidisestablishment...
stackexchange_codegolf
The Meeker numbers are a 7 digit number in form of \$abcdefg\$, where \$a×b=10c+d\$ and \$d×e=10f+g\$. As an example \$6742612\$ is a meeker number, here \$6×7=10×4+2\$ and \$2×6=10×1+2\$, so it is a meeker number. Additionally, a Meeker number does not have any leading zeros (so \$a \ne 0\$) The Challenge Your program...
stackexchange_codegolf
It turns out that my toaster is a tad broken. It lost WiFi (You know, it's one of those newfangled smart toasters), and its been going bonkers! Since it no longer works, I've been having to hack into my breakfast's source code and run Plate.bread.toastAs(3); every morning. Will you help? My toaster takes one input: the...
stackexchange_codegolf
The goal of this challenge is to implement a digital low-pass filter. You are free to implement any type of digital filter you want, however whatever results produced must pass the validation script below. Here's a general description of what the validation script expects: When an FFT is taken of the filtered signal, ...
stackexchange_codegolf
Introduction - What is a necklace? A necklace is something that OEIS people are obsessed with. The OEIS challenge has like 5 necklace sequences. A binary necklace of length n is a loop with n beads that are either 0 or 1. Two necklaces are the same if one can be rotated to become the other, and two reversible necklaces...
stackexchange_codegolf
Let's say I've got some ASCII art: ___ ,"---". : ; `-.-' | | | | | | _.-\_/-._ _ / | | \ _ / / `---' \ \ / `-----------' \ /,-""-. ,-""-.\ ( i-..-i i-..-i ) |`| |-------| |'| \ `-..-' ,=. `-..-'/ `------...
stackexchange_codegolf
Given a possibly nested, non-empty array of single-digit positive integers (not guaranteed unique), output the ASCII-art representation as a tree, using the box-drawing characters ┌ ┴ ┐ ─ │ ┬ ┼. (These were copied from Code Page 437, but you can use any equivalent representation). Every integer of the array should be a...
stackexchange_codegolf
A couple months ago, we had a discussion on meta about increasing the reputation awarded for upvotes on questions. Here's the basics of our current reputation system for votes:1 A question upvote U is worth 5 reputation. An answer upvote u is worth 10 reputation. A question or answer downvote d is worth -2 reputation....
stackexchange_codegolf
The magic music box (MMB) This explains the motivation for the challenge, feel free to ignore. The magic music box is a word game played by a group of people, where one is the owner of the magic music box and the other people are trying to put words inside the magic music box. Rules for the game with humans: the game g...
stackexchange_codegolf
I feel tired to do "find the pattern" exercise such as 1 2 3 4 (5) 1 2 4 8 (16) 1 2 3 5 8 (13) Please write a program that finds the pattern for me. Here, we define the pattern as a recurrence relation that fits the given input, with the smallest score. If there are multiple answers with the same smallest score, using...
stackexchange_codegolf
Given a string representing a number and the base that number is in, shift each positional value upward, wrapping back to zero if the value cannot increase. You will never be provided invalid input, nor a base larger than 36. For example, you may be provided ['5f6', '16'], which represents the number 1526 in base 16. T...
stackexchange_codegolf
This question is written because "Thing Explainer" is fun to read, and gave me an idea. Write "stuff that makes computer do things" that reads/takes a set of letters, numbers and things like this "#%|? and returns True / 1 if all words are part of this set. If all words are not part of that set, return the words that w...
stackexchange_codegolf
Related but very different. A boustrophedon is a text where every other line of writing is flipped or reversed, with reversed letters. In this challenge, we will just reverse every other line, but leave the actual characters used intact. You may chose which lines to reverse, as long as it is every other one. You may ta...
stackexchange_codegolf
Introduction In Tennis, the server alternates serving on the left side or the right side of the court every point, starting on the right. It is possible to figure out which side to serve on for that point just based on the score; if there have been an even number of points you serve on the right, and after an odd numbe...
stackexchange_codegolf
Introduction A function that adds months to a date (without overflowing ends of months) is implemented in many languages/packages. In Teradata SQL it's ADD_MONTHS, here are some examples: ADD_MONTHS('2021-01-31', 1) => 2021-02-28 ADD_MONTHS('2021-01-30', 1) => 2021-02-28 ADD_MONTHS('2021-02-28', 1) => 2021-03-28 ...
stackexchange_codegolf
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 ...
stackexchange_codegolf
Scratch is a visual programming language. For the sake of counting bytes, Scratch is usually written in scratchblocks2 syntax. Post tips that specifically apply to Scratch or scratchblocks2.
stackexchange_codegolf
Since I saw the first one a few years ago, I always was subjugated by this kind of word clock where the time is actually spelled out by words being lit up or not into a meaningful sentence. The text displayed on that clock is the following. IT IS HALF TEN QUARTER TWENTY FIVE MINUTES TO PAST TWO THREE ONE FOUR FIVE SIX...
stackexchange_codegolf
Introduction: Beckett Grading Service (aka BGS), is a company which encapusulates and grades Trading Card Game (TCG) cards (i.e. sport cards, Magic The Gathering, Pokémon, Yu-Gi-Oh, etc. etc.). The TCG cards that come in for grading will be checked on four categories (which we will later refer to as subgrades): centeri...
stackexchange_codegolf
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 ...
stackexchange_codegolf
Write a program, given an input n, will generate all possible n-tuples using natural numbers. n=1 (1),(2),(3),(4),(5),(6)... n=2 (1,1),(1,2),(2,1),(2,2),(1,3),(3,1),(2,3),(3,2),(3,3)... n=6 (1,1,1,1,1,1) (1,1,1,1,2,1) (1,1,1,2,1,1)... The output may be in any order that does not break any other rules. The program...
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
My teacher always gives me the most complicated set of math problems for homework. Like: pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even. And I want to know in advance how much time to set aside for my homework, but I don't want to have to figure all that out. That's why its your task to program it for me. S...
stackexchange_codegolf
Most tip calculator apps simply take a flat percentage of the meal price. So, for example, if your meal is $23.45, you can leave a 15% tip = $3.52, or a more generous 20% tip = $4.69. Convenient enough for credit card users. But not so if you prefer to leave cash tips, in which case these oddball cent amounts get in ...
stackexchange_codegolf
I recently tried to produce the shortest C code possible to display all its command line arguments (which are stored in argv). I ended with a relatively small piece of code, and I was wondering if there was some trick I'm not aware of. Here's my try (I compile with C17, but any standard before C23 is very likely to com...
stackexchange_codegolf
Box blur is a simple operation for blurring images. To apply box blur, simply replace each pixel with the average of its and the surrounding 8 pixels' values. Consider, for example, the following example, in which each "pixel" has a one-digit value: \begin{array} {|r|r|}\hline 1 & 1 & 1 \\ \hline 1 & 7 & 1 \\ \hline 1 ...
stackexchange_codegolf
Leon's story Leon is a professional sling shooter and he comes to a shooting range everyday to practice. A casual target is not a challenge for him anymore so before shooting he first covers the target of radius 1.0 with k rectangle stickers. He then fires n shots that cannot hit the stickers. What's special about Leo...
stackexchange_codegolf
Background This challenge is about Convolutional neural networks, and its two main building blocks, namely Convolutional layer and Pooling layer. For simplicity, we ignore the "depth" of the images and intermediate tensors, and just look at the width and height. Convolutional layer A convolutional layer works like a ke...
stackexchange_codegolf
The random Fibonacci sequence is defined as follows: $$ f_n = \begin{cases} f_{n-1}+f_{n-2} \text{ with probability } 1/2 \\ f_{n-1}-f_{n-2} \text{ with probability } 1/2 \\ \end{cases} $$ $$ f_1 = f_2 = 1 $$ i.e. whether the next term is the sum or difference of the previous two is chosen at random, independently of ...
stackexchange_codegolf
Some of you may be familiar with the way that a motorcycle shifts. But for those who don't, It looks like this 6 5 4 3 2 N 1 Now I want to know what gear I am in after performing a few up and down shifts. The program should work from neutral. Sample input: V^^ Sample output: 2 As you can see I downshifted once from ...
stackexchange_codegolf
Context As a conlanger, I am interested in creating a uniform, naturalistic language. One of the tricks is to create vocabulary according to certain structures of words. An example from English: In English, we have the word “tap” structured consonant-vowel-consonant. Usually, this means that there are many other words ...
stackexchange_codegolf
A polyomino with \$n\$ cells is a shape consisting of \$n\$ equal squares connected edge to edge. No free polyomino is the rotation, translation or reflection (or a combination of these transformations, i.e. an isometry) of another (they're equal). The sequence of free polyominoes with \$n\$ cells is as follows: 1, 1, ...
stackexchange_codegolf
The Lost Numbers are 4, 8, 15, 16, 23, 42. Your goal is to create an expression to output them all. Your allowed characters are 0123456789, ^+-*/, (), % for modulo and n as the single variable allowed. Modified PEMDAS ()^*/%+- is the precedence and / is normal division (3/2 = 1.5). 0^0 = 1 although division by 0 is und...
stackexchange_codegolf
Characters in strings are sometimes represented as their ASCII hexadecimal codes. Printable characters have two hex digits in their representation. Swapping those digits leads to another character, which will be our output. The table of relevant character codes can be found on Wikipedia. Details Take a string as input...
stackexchange_codegolf
One day you awake only to find yourself caught in an array. You try to just walk out of there, taking one index at the time, but it seems there are other rules: The array is completely filled with natural numbers. If you find yourself on an index n, you go to the index array[n], except: If you find yourself on an inde...
stackexchange_codegolf
Introduction Your job is to write a function or program that detects if a number a is less than a number b. But... You are not allowed to use built-in alternatives for equals, less than, greater than, less than or equal to, greater than or equal to, or not equal to operators. (Writing your own implementation is allowed...
stackexchange_codegolf
There has been a question about yes in the past, but this one is slightly different. You see, despite yes having a rather long size, it is incredibly fast. Running the following command: timeout 1s yes > out yields a file that is 1.9 GB. Compared to this program: int puts();main(){while(1){puts("y");}} which yields a...
stackexchange_codegolf
Context After "Computing a specific coefficient in a product of polynomials", asking you to compute a specific coefficient of polynomial multiplication, I wish to create a "mirror" challenge, asking you to compute a specific coefficient from polynomial division. Polynomial division Let us establish an analogy with inte...
stackexchange_codegolf
On Pomax's Primer on Bézier Curves this "fairly funky image" appears: This is related to the fact that every cubic Bézier curve can be put in a "canonical form" by an affine transformation that maps its first three control points to (0,0), (0,1) and (1,1) respectively. Where the fourth and last control point lies afte...
stackexchange_codegolf
Description You have a list of integers and start counting from the first term to the next and continue from that to the next and so on.. How many times have you counted? For example given [ 2, 5, 3, 8 ] you start at 2 and count to 5 -> 3 4 5 (3 times) then from 5.. 4 3 (2 times) and finally 4 5 6 7 8 (5 times) You co...
stackexchange_codegolf
Definitions A bijection from a set S to a set T is a function from S to T such that one element in T is mapped by exactly one element in S. A bijection within a set S is a bijection from S to S. The natural numbers are the integers which are greater than or equal to 0. A subset of a set S is a set such that every elem...
stackexchange_codegolf
Inspired by this chat mini-challenge. Given a string as input (ASCII printable characters only), output the string with the letters "raining" down. Each letter must be a random number of lines downward (random between 0 and the length of the string, each having non-zero probability), and only one character per column. ...
stackexchange_codegolf
Inspired by Create a binary wall Given a list of positive integers, we can write them out all above each other like so, for [2, 6, 9, 4] as an example: 0010 0110 1001 0100 We can imagine this as a wall: ..#. .##. #..# .#.. However, this is a very weak wall, and it has collapsed! Each 1 (#) falls down until it hits th...
stackexchange_codegolf