instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Aww, man, this expiry date doesn't write the months with letters! I can't tell if it's expiring on March 10th or October 3rd... Wait, no, never mind, the year says 2012. (alley-oops half-used brick of cheese into the trash can like a pro) So let's suppose for a moment that you're too busy to try to reason out when this...
stackexchange_codegolf
The task is simple. Write an interpreter for the language *. Here's a bigger link to the wiki. There are only three valid * programs: * Prints "Hello World"  *  Prints a random number between 0 and 2,147,483,647 *+* Runs forever. The third case must be an infinite loop according to the specifications in this question...
stackexchange_codegolf
A simple regex is either: _ (which matches the empty string) Any lowercase letter a to z (which matches that letter) r*, where r is a regex (which matches r any number of times) (r|s), where r and s are regexes (which matches either r or s) (r+s), where r and s are regexes (which matches r followed by s) Note that du...
stackexchange_codegolf
Sandbox Post Intro The information panels are everywhere. When the technology became cheaper, the paper posters were transformed into luminous signs that show words that appear on one side and come out on the other, like the one on the figure: When one of these signs starts up, it usually starts empty and the text lea...
stackexchange_codegolf
Don't you hate it when you can't remember how to craft something in Minecraft? Well, time to remedy that! Task Your task is to take an input, either as a 1D or 2D list and output what item is a result of the crafting table! Input You may take input as either a string or a list of length 9 or a 2D nested array. If you t...
stackexchange_codegolf
Background K functions have a feature called projection, which is essentially partial application of values to a function. The syntax for projections is a natural extension of the regular function call syntax: f[1;2;3] / call a ternary function f with three arguments 1, 2, 3 f[1;2;] / the third argument is missi...
stackexchange_codegolf
Goal Given a non-negative integer, create a function that returns the starting position of number of largest consecutive 1's in that integer's binary value. When given an input 0, return 0. If the number has multiple streaks of equal length, you must return the position of the last streak. Input An integer greater than...
stackexchange_codegolf
Your network scanning tool is annoyingly picky about input, and immediately crashes if you feed it an IPv4 address that contains improper characters or isn't properly formatted. An IPv4 address is a 32-bit numeric address written as four numbers separated by periods. Each number can be zero to 255. We need to write a...
stackexchange_codegolf
Input A single positive integer \$ 10 \geq n \geq 2\$ Output A list of strings, each of length \$2n\$, satisfying the following properties. Each string will contain each of the first \$n\$ lowercase letters of the alphabet exactly twice. No letter can occur twice consecutively. That is abbcac is not allowed. No two st...
stackexchange_codegolf
If I want to type the string aaa, the least keystrokes I can type it in is 3: a a a. But if I want to type the string aaaaaa, I can do it in 5: a a a ctrl-c ctrl-v, where the ctrl-c refers to copying aaa and the ctrl-v refers to pasting it. Specifically, starting with an empty "buffer" and an empty "clipboard": The ke...
stackexchange_codegolf
Given N integers, output the sum of those integers. Input You may take the integers in any reasonable format, including: stdin arguments an array or list Rules Your code must not include the characters + or -. Standard loopholes apply. Take note of Abusing native number types to trivialize a problem. This is code-...
stackexchange_codegolf
You probably know the game mastermind: The player tries to guess a code of 4 slots, with 8 possible colors - no duplicates this time. Let's call those colors A through H, so possible solutions could be ABCD or BCHD. Each time you place a guess, the game master will respond with two information: how many slots you got r...
stackexchange_codegolf
Given an input n, your program or function must output the smallest positive integer k such that n rounded to the nearest multiple of k is greater than n. Example. Given an input 20, the output value should be 3: The nearest multiple of 1 is 20, which is not greater than 20. The nearest multiple of 2 is 20, which is...
stackexchange_codegolf
The challenge today is to write a program that outputs a known proverb, Where there is a will, there is a way., that means if someone is determined to do something, he will find a way to accomplish it regardless of obstacles. Output It has to be exactly the same, including the space bar and punctuation and excluding th...
stackexchange_codegolf
Given two non-negative integers e.g. 27, 96 their multiplication expression would be 27 x 96 = 2592. If now each digits is replaced with a symbol, such that two digits are replaced with the same symbol if and only if they are equal we could get something like AB x CD = AECA or 0Q x 17 = 0Z10 or !> x @^ = !x@!. (follo...
stackexchange_codegolf
Given n (the number of players), t (the threshold value), and s (the secret), output the n secrets generated by Shamir's Secret Sharing algorithm. The Algorithm For the purposes of this challenge, the computations will be done in GF(251) (the finite field of size 251, otherwise known as the integers mod 251). Ordinaril...
stackexchange_codegolf
No, not that thing in powerpoint You will be given a string, and a 2D array of boolean values. The 2D array will represent a picture. You will be creating art out of it. Let me show you how. The steps to art First, you create a square which fits the 2d array, with the string. Like if the string is 'PPCG', and the pic...
stackexchange_codegolf
This challenge is based off of Helka Homba's question Programming a Pristine World. From that question, the definition of a pristine program is: Let's define a pristine program as a program that does not have any errors itself but will error if you modify it by removing any contiguous substring of N characters, where ...
stackexchange_codegolf
Background A Medusa have released a dangerous Hydra which is revived unless the exact number of heads it have is removed. The knights can remove a certain number of heads with each type of attack, and each attack causes a specific amount of heads to regrow. The knights have hired you to write a program or function that...
stackexchange_codegolf
Introduction Many old chess books use descriptive notation to notate squares on a chessboard, naming the file (column) of the square based on the starting piece positions of White or Black, depending on whose move it is. The ranks (rows) are numbered 1 through 8, with 1 being closest to the player. For example, from Wh...
stackexchange_codegolf
Task You will be given a string in the input consisting only of the characters from a to z, i.e. the input will match the regex /^[a-z]*$/. Your output should be a complete program in the same language, whose source code contains the input, and is a proper quine. Example Your program would receive the input abc and out...
stackexchange_codegolf
Background: Too many illegal immigrants from Blandia are crossing the border to Astan. The emperor of Astan has tasked you with digging a trench to keep them out, and Blandia must pay for the expenses. Since all typists have been furloughed until the trench is arranged, your code must be as short as possible.* Task: Gi...
stackexchange_codegolf
Background A classical logic gate is an idealized electronic device implementing a Boolean function, i.e. one that takes a certain number of Boolean inputs and outputs a Boolean. We only consider two-input logic gates in this challenge. There are \$2^{2 \times 2} = 16\$ distinct two-input logic gates (2×2 input combina...
stackexchange_codegolf
In this challenge, you implement an interpreter for a simple stack-based programming language. Your language must provide the following instructions: push a positive number pop two numbers and push their sum pop two numbers and push their difference (second number - first number) pop a number and push it twice (dup) p...
stackexchange_codegolf
Write a program that accesses Project Gutenberg's KJV Bible, either from a file called pg10.txt in the working directory or in any other way that is typical for the language, takes a Bible verse reference as input, and prints the corresponding verse, with no newlines except optionally one at the end, as output. The sta...
stackexchange_codegolf
Introduction A farmer needs help calculating the least time it will take him to pick his fruit each day. Challenge This farmer has X orchards. Each orchard has Y fruits in it. If the orchard has no fruits, then it will contain the string "none". The farmer has a list, this list contains the fruit he must pick. The f...
stackexchange_codegolf
Write a program to calculate the first 500 digits of the mathematical constant e, meeting the rules below: It cannot include "e", "math.e" or similar e constants, nor may it call a library function to calculate e. It must execute in a reasonable time (under 1 minute) on a modern computer. The digits are to include the...
stackexchange_codegolf
The following picture shows the problem: Write a function that, given an integer as the circle radius, calculates the number of lattice points inside the centered circle (including the boundary). The image shows: f[1] = 5 (blue points) f[2] = 13 (blue + red points) other values for your checking/debugging: f...
stackexchange_codegolf
Swap encoding is an encoding method where you iterate through a string, reversing sections of it between pairs of identical characters. The basic algorithm For each character in the string: Check: Does the string contain the character again, after the instance you found? If so, then modify the string by reversing the s...
stackexchange_codegolf
In the strategy game "Hexplode", players take turns placing tokens on a hexagonal board. Once the number of tokens equals the number of adjacent tiles, that tile hexplodes, and moves all of the tokes on it to the surrounding neighbors. You can play the game online here. I like this game, but sometimes it's hard to know...
stackexchange_codegolf
This small challenge derives from my annoyance at discovering that numpy doesn't have a built in function for it. Input An n by m matrix of integers. Output The maximum value in the matrix and the 2d coordinates of one of its occurrences. The coordinates should be in the order (row_idx, col_idx) if your code is no sho...
stackexchange_codegolf
Robbers thread Cops, Choose two strings of code, one public and one secret. We will call them P and S. You will be writing a program using only repetitions of these strings. For example: if you choose P=helloand S=world, valid programs would be hello, world, helloworld, worldhello, helloworldworldhello, hellohellohello...
stackexchange_codegolf
You are given an integer n as input, and, regardless of the current date, must return the calendar year (Gregorian calendar, other calendars not allowed) taking place n seconds from now. Rules You may not assume that the current year is 2021. In other words, imagine a user testing your solution in five years. Standard...
stackexchange_codegolf
Given a random code written using Brainfuck commands. You program should translate that code into the following ascii art: each Brainfuck command represents as 5x9 array of A and B symbols. All commands are concatenated with 5x3 arrays of A symbols. Symbols A and B you choose yourself. For example, when input is ><+,.[...
stackexchange_codegolf
(This code golf task is related to Code-Golf: Lights Off!. The same puzzle is used, but the task is different.) Introduction "Lights Out" is a puzzle in which you should switch off all lights in a 5x5 grid. However, when you swap a light from on to off, or from off to on, the four adjacent lights will swap as well! Fo...
stackexchange_codegolf
What general tips do you have for golfing in Smalltalk? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Smalltalk (e.g. "remove comments" is not an answer). Smalltalk is a purely object-oriented language created by Alan Kay. The two links are GNU Small...
stackexchange_codegolf
Inspired by a restriction on What do you get when you multiply 6 by 9? (42) By order of the President, we are no longer permitted to use confusing fake numbers (i.e. numbers other than integers from 0 to 99 inclusive), and are instead to use only real numbers, that is, those that are not fake. Unfortunately, most maths...
stackexchange_codegolf
Challenge description On some channels on a popular streaming site twitch.tv a common message people tend to spam in chats to bait people into spamming "LUL" is One more LUL and I'm out LUL is a popular emote used to express that something funny happened on stream. Soon dank memes showed their potential and a parody o...
stackexchange_codegolf
After seeing some impossibly short solutions in this SE, I began to wonder what code someone could come up with to build a pseudo-random number generator. Now given that I am new to programming, I have absolutely no idea what such generator should look like, or what language to write them in. But that did not stop me f...
stackexchange_codegolf
Chris, a cryptic crosswords addict, has a set algorithm for the order in which he solves them. We will use the above image as a guide. Chris always starts off with the first across clue, in this case 1 Across. Chris is a capable crossword enthusiast, so it is assumed that he will always know the answer to the clue he...
stackexchange_codegolf
Challenge Given a number width, number height, hours and minutes print the time using the following format style: ------ - ------ ------ - - ------ ------ ------ ------ ------ | | | | | | | | | | | | | | | | | ------ ------ ------ ------ ------ | ...
stackexchange_codegolf
Generate the contents of an SVG file containing 6 bingo cards. Winner is the one that uses the shortest code. A qualifying answer has an output that can be directly pasted in a blank to get the required image. Rules are as follows. The generated SVG code should comply with SVG version 1.1 described here. The size of t...
stackexchange_codegolf
Final results 1st place goes to Follow! Honourable mentions to The diff predictor (2nd), and Simple Killer, Low Blow and High to Low (joint 3rd). Other winners: (score competition) 1st - Simple Killer Honourable mentions: The diff predictor and Naiive. (wins competition) 1st - Crab Honourable mentions: Follow and High ...
stackexchange_codegolf
Write a code that runs or compiles in as many programming languages as possible and prints a newline separated list of names of previous and current programming languages. Every used language must have 1 character longer name than previous; ex. C#, C++, Ruby, Jelly, Python... Each language must output a list of langua...
stackexchange_codegolf
The Language: Oppification A funny language to speak is created by applying the following process to each word: Place op after each consonant. So Code becomes Copodope. Yes, that's it. For the purpose of this challenge, y is always a consonant. The Challenge: De-oppification Given an oppified word, return the origina...
stackexchange_codegolf
Many languages allow strings to be "added" with +. However this is really concatenation, a true addition would follow the group axioms: It is closed (the addition of any two strings is always a string) It is associative ( \$\forall a b . (a + b) + c = a + (b + c)\$) There is an identity (\$\exists e . \forall a . a...
stackexchange_codegolf
Given N decanters (0 < N < 10) with that can hold C0 ... CN-1 liters (0 < C < 50) and a goal G liters, please determine if it is possible to reach that goal using only the following actions: Fill a decanter Empty a decanter Pour from one decanter to another until the one being poured to is full or the one being poured...
stackexchange_codegolf
Discussion in courtrooms often occurs at a high speed and needs to be accurately transcribed in case the text of the decision is needed in future cases. For this purpose, the stenographers who transcribe court discussions use specially designed keyboards with a small set of buttons, which are pressed in groups to spell...
stackexchange_codegolf
Brainf**k is the most famous esoteric programming language and is the inspiration for hundreds of other esoteric languages. In fact, there are quite a few languages that are so heavily based off of Brainf**k that the only difference is the characters used. Your challenge is to interpret one of these languages. Brainf**...
stackexchange_codegolf
The below pattern will form the basis of this challenge. /\ \/ /\ / \ / \ /\/ \/\ \/\ /\/ \ / \ / \/ /\ \/ Given an input width and height, each >=1, output the above ASCII art pattern repeated that many times, joining (and overlapping) at the small diamond...
stackexchange_codegolf
Challenge Your task is to write a program which, once a second (including immediately when your program is started), prints the elapsed time from the time your program was started. Rules Time must be printed in hh:mm:ss format. (leading zeros for single-digit values) The time stamps must be separated by CR, LF, or CRL...
stackexchange_codegolf
Write a program that takes two lists of strings and generates a javascript regex that fully matches all the strings in the first list and matches none of the strings in the second list. To be specific when for all stings in the first list str.match(/[your-output]/) must produce a match for the full string and for all s...
stackexchange_codegolf
Write a full program to calculate the inverse of a 4-by-4 matrix. Rules The sixteen values of the initial matrix must be hard-coded to variables, as follows: _ _ |a b c d| |e f g h| |i j k l| |m n o p| - - Then print the values of the inverse matrix, row by row, with each number separated by some delimiter...
stackexchange_codegolf
cat goes "Meow" We are all familiar with the concept of a cat program. The user types something in, it is echoed back to the user. Easy. But all cat programs I've seen so far have missed one fact: a cat goes "Meow". So your task is to write a program that copies all STDIN to STDOUT UNLESS the input is cat, in which ca...
stackexchange_codegolf
You are a Computer Science professor teaching the C programming language. One principle you seek to impart to the students is modularity. Unfortunately, past classes have tended not to get the message, submitting assignments with the entire program inside main(). Therefore, for this semester you have issued strict modu...
stackexchange_codegolf
A directed graph G is given with Vertices V and Edges E, representing train stations and unidirectional train routes respectively. Trains of different train numbers move in between pairs of Vertices in a single direction. Vertices of G are connected with one another through trains with allotted train numbers. A hop is ...
stackexchange_codegolf
Thanks to HyperNeutrino for making more test cases Often in chat, someone will ask a question, and multiple people will answer it at the same time. Usually, the person who was beaten to the gun will say "ninja'd", creating even more unnecessary chat. Given a chat log similar to the following: Community: Hi Test: Hi Ran...
stackexchange_codegolf
A venerated pass time of pedants is to point out that pictures of "Rubik's Cubes" (on t-shirts, posters etc.) are not actually solvable. The first thing that should be checked is that the cube is made up of the right pieces. To be solvable a cube needs six colors each with nine squares. The cube also needs each edge ...
stackexchange_codegolf
Given 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
Generative AI is here! It's great for certain things, but it has a few problems. Not only has it broken our Stack Exchange community, it also makes mistakes. For example, when you ask Bing AI if it is sentient, Bing says (credits to GPT Gone Wild) Your job is to print that text exactly. More specifically, Take no inp...
stackexchange_codegolf
(yes, "generating generating" in the title is correct :) ) Context In middle (?) school we are taught about sequences and, in particular, we are taught about linear sequences where the nth term is generated with an expression of the form an + b, where a and b are some coefficients. In this challenge, we will deal with ...
stackexchange_codegolf
(Taken from https://en.wikipedia.org/wiki/File:Tangential_quadrilateral.svg) A tangential quadrilateral (see example above) is a quadrilateral in which a circle can be inscribed. Your task is to find the possible value of d given a, b, and c. Specs a, b, c will all be positive integers. If no possible value of d exis...
stackexchange_codegolf
Background BitCycle is a two-dimensional Turing-complete programming language involves moving bits around a playfield. Because I am too lazy to write BitCycle programs myself, you will be writing a program which outputs BitCycle programs for me! Unfortunately, the storage space on my computer is only about a bit, so yo...
stackexchange_codegolf
Cops thread Robbers, your task is to crack a cops answer. Reveal the character that should be changed and what it should be changed to too. Please notify the cop if you cracked their challenge. The robber winner is the user with the most cracks. I will declare the winner cop and robber a week after this challenge is po...
stackexchange_codegolf
Introduction Suppose you want to compute the tail maxima of a list of numbers, that is, the maximum of each nonempty suffix. One way to do it is to repeatedly choose one number and replace it by a higher number occurring after it, until this is not possible anymore. In this challenge, your task is to perform one step o...
stackexchange_codegolf
Backstory [which is not true] A piano is set up like this: However, on my piano, all of the black keys are broken! I still want to be able to play some chords on my broken piano though. In music, a chord is a group of notes that are played together. To allow for input of chords, I will first define what a semitone is....
stackexchange_codegolf
Setup Take the following 4x4x4 cube along with a 2D view of 3 of its faces, with a common 1x1x1 cube highlighted: The arrows represent the points of view that generated the V1, V2 and V3 faces drawn underneath the big cube. Given an arrangement of some 1x1x1 cubes inside the main cube we can try and identify it with o...
stackexchange_codegolf
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...
stackexchange_codegolf
Introduction The EKG sequence begins with 1 and 2, then the rule is that the next term is the smallest positive integer not already in the sequence and whose common factor with the last term is greater than 1 (they are not coprimes). The first terms are: 1, 2, 4, 6, 3, 9, 12, 8, 10, 5, 15, ... It's called EKG because...
stackexchange_codegolf
Are you tired of languages with built in quining techniques? Your challenge, should you choose to accept it, is to add a built-in quine feature to the language of your choice. Task Given some programming language X, you should define A language X′ that is a subset of X. A quine command string Q. (This is a string of ...
stackexchange_codegolf
Background Network discovery tool Nmap takes a list of TCP/UDP port numbers as input and performs a security audit against the listed ports. The target port listing on the command line includes selected port numbers as strings separated by a comma. To make specifying big amounts of ports more convenient the tool also s...
stackexchange_codegolf
I was seen multiple shortest "Hello World!" program, but this is the longest program. The Rules Each submission must be a full program. This must be non-interpreted language (for example, JavaScript, Python, HTML, etc.) Target OS must be Windows, Mac, Linux or MS-DOS. The challenge Writing a longest Hello World prog...
stackexchange_codegolf
Challenge Consider the rainbow as seven colours, represented by strings as Red Orange Yellow Green Blue Indigo Violet. Your task is to create a program that receives one of these colours as input and outputs next in order rainbow colour. This includes overlapping Violet -> Red Input A string containing one of rainbow c...
stackexchange_codegolf
Task Write a function/full program that will be able to produce two different sequences of integers in [0, ..., 9]. You will take an input seed to decide whether to output your specific sequence or the common one. For that matter, you must choose one non-negative integer, let us call it k. When the input seed is equal ...
stackexchange_codegolf
Bitshift Variations in C Minor by Robert Miles is a Code Golf music piece written in C (with some additional bash commands). It was originally presented in a 2016 Computerphile video Code Golf & the Bitshift Variations. You can listen to clean renderings of it here (by Lucia Ceionia). The original 2016 source code pres...
stackexchange_codegolf
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: ...
stackexchange_codegolf
In the game 2048, you have a grid, and you can move the elements in four directions. They all move in that direction as far as they can. For this challenge, you will be given a padded, square 2D string (either with newlines, or a list of strings), like so: ab cd e f ghij kl mno p q r st u v w x y ...
stackexchange_codegolf
To celebrate Rounded Pi Day, you must take advantage of today's date to make a program that takes in a circle's diameter and outputs its circumference by multiplying the diameter by 3.1416, where 3.1416 must be obtained using today's date. Input 3 Output 9.4248 etc. Does not take the date as input. You do not have to ...
stackexchange_codegolf
My dog ate my calendar, and now my days are all mixed up. I tried putting it back together, but I keep mixing up the days of the week! I need some help putting my calendar back together, with the days in the correct order. And since I need my calendar put together as fast as possible, don't waste my time by sending me ...
stackexchange_codegolf
Background Inspired by I'm a palindrome. Are you?, where it is presented the shocking fact that “()() is not a palindrome, but ())(”, I asked myself what instead is ()() and the answer is simply: it is a string with a vertical symmetry axis! The task Write a program or function that takes a string S (or the appropriate...
stackexchange_codegolf
You are James and four of your friends (Bjarne, Eich, Rossum, Ada) are called for an interview. There are n interviewers, and they can each serve one person at a time, alphabetically. Each round of interview takes 20 min. Let's take n = 2, So, the first round started with Ada and Bjarne, takes 20 min (they're handle...
stackexchange_codegolf
You must make the shortest program to always find the optimal solution to a simplified Frogger game on a 9x9 grid. Course Elements: L - Log (Length: 3-4). When you hop on a log, it carries you with it. V - Vehicle (Length: 1-2) Speed (1-2): On the left hand side of the row will be the speed that elements in the row...
stackexchange_codegolf
In most programming languages, the string Hello, World! can be represented as "Hello, World!". But if you want to represent "Hello, World!" you need to escape the double quotes with backslashes for "\"Hello, World!\"", and to represent that you also need to escape the backslashes resulting in "\"\\\"Hello, World!\\\"\"...
stackexchange_codegolf
Your challenge today is to implement a t9-like functionality. You will implement a function that will only have 2 parameters. You will receive 1 phone number in a string and the content of a text file with a list of words (don't assume a specific newline style). You can use the link https://raw.githubusercontent.com/en...
stackexchange_codegolf
Given a nonnegative integer n, your solution must output a program in your chosen language whose output has n times as many bytes as the outputted program. Rules You must specify the language and encoding of the programs your solution outputs, and you may not choose different languages or encodings for different input...
stackexchange_codegolf
It's 22022 and the Unicode consortium is having a problem. After the writing system of the ⮧⣝Ⅲⴄ⟢⧩⋓⣠ civilization was assigned the last Unicode block, the consortium members have been scrambling to find a new encoding to replace UTF-8. Finally UTF-∞, a proposal by Bob Rike, was adopted. UTF-∞ is backwards compatible wit...
stackexchange_codegolf
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...
stackexchange_codegolf
We all know what a quine is. A quine is a program which prints its own source code. And we also know about the printable ASCII characters. Well... this challenge mixes both. Your mission, should you accept it, is to create an index quine. An index quine is a non-empty program, composed only of the printable ASCII chara...
stackexchange_codegolf
Introduction A hypercube/tesseract is the 4 dimensional equivalent of a normal cube. It's made by taking a cube net, extending it to the 3rd dimension, then – using the 4th dimension – folding it into a hypercube. It's basically a cube, where each side is a cube. To create a hypercube, you need 16 4d vectors (a vector ...
stackexchange_codegolf
There's only one question for machine-language golfing, and it's for the ia32 and amd64 architectures. Here's one for a predecessor of them: the Zilog Z80! The ISA is available here. As usual, if your tip is only applicable to a certain environment/calling convention, please indicate that in your answer. Only one tip ...
stackexchange_codegolf
The input for the continuous knapsack problem is as follows. For each item 1...n we are given a positive weight and profit. Overall we are also given a positive capacity which is the maximum weight we can carry. The goal is to pick items so that the profit is maximized without exceeding the capacity. This is hard if ...
stackexchange_codegolf
4-state barcodes Many postal services (Royal Mail UK, Canada Post, US Mail, etc) use a 4-state barcode to encode information about their mail. Rendered in ASCII, it may look something like this: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A 4-state barcode is a row ...
stackexchange_codegolf
Let's say I'm ten steps away from my destination. I walk there following the old saying, "Two steps forward and one step back". I take two steps forward, one back, until I'm standing exactly on my destination. (This might involve stepping past my destination, and returning to it). How many steps did I walk? Of course, ...
stackexchange_codegolf
Your program will receive an ascii shape consisting of only underscores _, pipes |, spaces and newlines \n, which, together, represent a horizontally-aligned, right-angled shape. Together with this shape, on a new line, you will also receive either a positive or a negative integer, whose absolute value will be either ...
stackexchange_codegolf
In races in which racers go around at least one turn of a curved track, the starting positions for each racer are staggered, so that each racer travels the same distance around the track (otherwise, the racer in the innermost lane would have a huge advantage). Given the lengths of the major and minor axes (or semi-majo...
stackexchange_codegolf
Jelly is a tacit, golf-oriented programming language by our very own Dennis. It’s popping up in answers here more and more often, beating other golf-y languages like Pyth and CJam, both by using its own code page and its powerful chain system to succinctly express programs. Let’s collect some useful tips for golfing in...
stackexchange_codegolf
As the band's roadie, you have to pack the truck. Your program will place the packages so that they fit in the smallest height. A badly packed truck Rules Packages may be rotated through multiples of 90 degrees. Packages may touch but must not overlap. The output is the repacked image (to file or stdout). Your program...
stackexchange_codegolf
Goal Given an string with a train of hashes, calculate its total length and divide by the distance from start to finish. Simulation What are we simulating? According to this paper, the ratio of the length of a river to the distance between start and end is approximately Pi! (This may have been disproved empirically, bu...
stackexchange_codegolf
Description The task of this challenge is to devise a program or function that tracks a given object in an \$n×n\$ space. I/O Your program will be given 3 inputs, which may be taken in any sensible way: n will be the size of the plane's side. (so, for \$n=5\$, your plane will be \$5×5\$). You may assume n will always b...
stackexchange_codegolf
Challenge Write a program that takes as input a day from April 30, 1789 to August 21, 2019 and returns as output who was president of the USA that day. Notes For the list of US presidents, the format of their names, and the period of their presidency, see below: April 30, 1789 - March 4, 1797 George Washington...
stackexchange_codegolf