instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Several years back, Hot Wheels made a simple flash game called "Formula Fuelers Racers"*. To play the game, you select three ingredients from a fridge to put into your car, which is then raced against the computer's randomly-generated car. It turns out the mechanics of this game are pretty simple. First off, the act...
stackexchange_codegolf
I'm working from home and the heat of my laptop on my lap is the only thing keeping me warm. I have a Dell G3 Laptop with an NVidia GEForce GTX CPU. I have tried writing a rust program with 5 threads that calculates and prints the Fibonacci sequence in an infinite unthrottled loop, but that only gave a bit of warmth, a...
stackexchange_codegolf
This is not the same as m-ss-ng-lette-s Challenge: Given a string with masked characters, generate all possible words, inclusive of non-meaningfull words. Rules: The sequence of the characters in the string does not change. The masked character (*) will be one of an English alphabets [a-z]. There are no line breaks, s...
stackexchange_codegolf
A Latin Square is a square of size n × n containing numbers 1 to n inclusive. Each number occurs once in each row and column. An example of a 3 × 3 Latin Square is: [[1, 2, 3], [3, 1, 2], [2, 3, 1]] Another is: [[3, 1, 2], [2, 3, 1], [1, 2, 3]] Given an integer input n where n > 0, determine how many Latin Square...
stackexchange_codegolf
Backstory Disclaimer: May contain made up information about kangaroos. Kangaroos traverse several stages of development. As they grow older and stronger, they can jump higher and longer, and they can jump more times before they get hungry. In stage 1, the kangaroo is very little and cannot jump at all. Despite this, is...
stackexchange_codegolf
Dice Cricket is a game I was introduced to as a child and have used as a way to pass time for years since. I couldn't find a Wikipedia page so I'll explain the rules below. Dice Cricket Rules Premise Dice Cricket is a game similar to scoring a game of cricket as you watch it but rather than watching and recording the r...
stackexchange_codegolf
Note: this problem was inspired by the Unsolved Mathematical Problems for K-12 youtube video, which also features other interesting puzzles. From the wikipedia article: The no-three-in-line problem asks for the maximum number of points that can be placed in the n × n grid so that no three points are collinear ..... Al...
stackexchange_codegolf
The Euclidean GCD Algorithm is an algorithm that efficiently computes the GCD of two positive integers, by repeatedly subtracting the smaller number from the larger number until they become equal. It can be visualised as such: We start with a MxN grid, where M and N are the numbers. In this example I'll use M=12, N=5: ...
stackexchange_codegolf
Background You have again, again been given the task of calculating the number of landmines in a field. But this time, the field is foggy. You must calculate the landmine score given a list/string of numbers, the landmine number, and the land distance (all are numbers). The landmine number tells you where landmines are...
stackexchange_codegolf
Given \$A = (a_1,\dots,a_k)\ k\ge2 \$ a sequence of positive integers, in which all elements are different. Starting from \$i=2\$, while \$a_i\in A:\$ (until the last element) If \$d=|a_i-a_{i-1}|\$ is not already in \$A\$, append \$d\$ to \$A\$ Increase \$i\$ Output the completed sequence. This is code-golf Example ...
stackexchange_codegolf
Cribbage is an interesting game, because you need a specific board to score your game. A cribbage board looks like this: Notice how the first column is on the left as it goes up, then on the right as it goes down, then back on the left as it goes up again. And here is what a poorly drawn rendered ASCII art of a cribba...
stackexchange_codegolf
Your challenge is to make an infinite loading screen, that looks like this: Or, to be more specific: Take no input. Output Loading..., with a trailing space, but no trailing newline. Infinitely cycle through the chars |, /, - and \: every 0.25 seconds, overwrite the last one with the next in the sequence. You can ov...
stackexchange_codegolf
Befunge is a 2-dimensional programming language, with an instruction pointer (IP). In Befunge-98, the ; character tells the IP to skip characters up until the next ; (Let us call it skipping mode when the IP is skipping characters). Here is an example: "This part is read into the stack" ; this part is not ; @ I would ...
stackexchange_codegolf
Stack Exchange doesn't know how to transpose tables. Let's help. Given a markdown table, transpose it. Input assumptions: There will be at least two rows (including header) and two columns Either all cells have no leading space or all cells have exactly one leading space (you must handle both) If the cells have a lead...
stackexchange_codegolf
In the beginning there was NCSA Mosaic, and Mosaic called itself NCSA_Mosaic/2.0 (Windows 3.1), and Mosaic displayed pictures along with text, and there was much rejoicing. 15 years later... And then Google built Chrome, and Chrome used Webkit, and it was like Safari, and wanted pages built for Safari, and so preten...
stackexchange_codegolf
Challenge Suppose you have a list of numbers, and a target value. Find the set of all combinations of your numbers which add up to the target value, returning them as list indices. Input and Output The input will take a list of numbers (not necessarily unique) and a target summation number. The output will be a set of ...
stackexchange_codegolf
Task Given a non-negative number, check if it's odd or even. In case it's even, output that number. Otherwise, throw any exception/error that your language supports, and stop the program. Example with Python Input: 1 Output: Traceback (most recent call last): File ".code.tio", line 1, in <module> IfYouWantThenThr...
stackexchange_codegolf
Challenge The challenge is to write a program that takes the coefficients of any n-degree polynomial equation as input and returns the integral values of x for which the equation holds true. The coefficients will be provided as input in the order of decreasing or increasing power. You can assume all the coefficients to...
stackexchange_codegolf
For each character in your program, the program with that character removed must produce a number smaller than the program with the next character removed. Your base program isn't required to do anything, and may be invalid. An example submission could be abcd, where bcd outputs 1, acd outputs 4, abd outputs 5, and abc...
stackexchange_codegolf
Question Given the atomic number of an element in the range [1-118] output the group and period, of that element as given by the following Periodic Table Of Elements. For elements in the Lanthanide and Actinide series, (ranges [57-71] and [89-103]), you should instead return L for the Lanthanides and A for the Actinide...
stackexchange_codegolf
You are given as input a greyscale image. Your task is to find a static or looping pattern in Conway's Game of Life that resembles the input image as closely as possible. Your output can be either a still image or a looping animation in some format that can be converted to gif. The output image dimensions should be the...
stackexchange_codegolf
You are to write a program which outputs a single positive integer \$n\$. The integer may have leading zeros and whitespace, and/or trailing whitespace. Then, choose a positive integer \$m > 1\$. When the program is repeated exactly \$m\$ times, it should output \$m \times n\$ (and only \$m\times n\$). When repeated an...
stackexchange_codegolf
Help! My device malfunctions and whenever I try to repeat a String, I get a messy results. Instead of repeating the same string N times, it fills an NxN square with each of its characters, and stacks the squares up. For example, given the String "Test" and the number 2, instead of "TestTest", I get: TT TT ee ee ss ss t...
stackexchange_codegolf
This challenge is based on this Stackoverflow question. With a positive number as input, output it as the sum of each digit multiplied by its power-of-10 representation. Input A number, as an integer, a string or a list of digits/characters. The number will be strictly positive. If you accept the number as a string or...
stackexchange_codegolf
Setup: A block is any rectangular array of squares, specified by its dimensions \$(w,h)\$. A grid is any finite ordered list of blocks. For example, \$\lambda = ((3,2),(3,1),(1,2))\$ defines a grid. Let \$\lambda\$ and \$\mu\$ be two grids with equal area. A tiling of \$\lambda\$ by \$\mu\$ is any rearrangement of the ...
stackexchange_codegolf
When you search something on google, within the results page, the user can see green links, for the first page of results. In the shortest form possible, in bytes, using any language, display those links to stdout in the form of a list. Here is an example, for the first results of the stack exchange query : Input : yo...
stackexchange_codegolf
Your task Given two positive integers \$x\$ and \$d\$ (such that \$d<x\$), output the 5th term of the \$d\$th difference of the sequence \$n^x\$ Example Let's say we are given the inputs \$x=4\$ and \$d=2\$. First, we get the series \$n^4\$: \$0^4 = 0\$ \$1^4 = 1\$ \$2^4 = 16\$ \$3^4 = 81\$ ... These are the first 10...
stackexchange_codegolf
Summary Write a program or function, which doesn't take any input, and outputs all the integer numbers, between -1000 and 1000 in ascending order, to the stdout, one per line, like this: -1000 -999 -998 -997 ... And after that you need to print the time taken to print these numbers, or the time from the start of the p...
stackexchange_codegolf
Monday, October 31st, is Halloween. And it got me thinking -- I wonder what other months have the last day of the month also be a Monday? Input A positive integer in any convenient format representing a year, 10000 > y > 0. The input can be padded with zeros (e.g., 0025 for year 25) if required. Output A list of the...
stackexchange_codegolf
In this challenge you will receive a list of non-negative integers. Each one represents a mushroom with a cap of that radius centered at that location. So a 0 means that it occupies no space at all, a 1 means that its cap only occupies space above it, a 2 means it occupies space above it and one unit to the left and ...
stackexchange_codegolf
Write a program that, given a string of capital letters, output all possible phrases that could have been written originally, using any variant of the Oxford English Dictionary. Input There are two inputs: A string \$s\$ of A-Z capital letters that is a phrase with certain letters removed. Example: THSSANEAMPLE Anoth...
stackexchange_codegolf
This is a cops-and-robbers challenge the Robbers' Thread can be found here Your challenge is to write a program that outputs an anagram of its source code but not the original source code itself. For example the following Python program, print`'print*2``'*2` prints 'print*2``print*2``' which has all of the same chara...
stackexchange_codegolf
Given a string s and a positive integer N, gradually duplicate each character more and more until N duplicates, and then staying at N duplicates until N characters away from the end, then step down again. For example, given abalone and 3: a we start with 1 copy bb then 2 copies aaa then 3 copies, which is our sec...
stackexchange_codegolf
Here is the program to return [[0, 0, 0], [0, 1, 0], [0, 0, 0]] [[0]*3,[0,1,0],[0]*3] Try it online! Can you shorten this code?
stackexchange_codegolf
Challenge Given guitar tablature you must output the song represented by the tab. This may be to the speakers of your computer or to an audio file (.wav, .mp3, .midi, .aiff, etc.). There will also be a second input for timing. The tabs may be input via a file or straight to STDIN. The tab will be in ASCII form. Spec Al...
stackexchange_codegolf
A string can be shifted by a number n by getting the byte value c of each character in the string, calculating (c + n) mod 256, and converting the result back to a character. As an example, shifting "ABC123" by 1 results in "BCD234", shifting by 10 in "KLM;<=", and shifting by 255 in "@AB012". The Task Pick as many num...
stackexchange_codegolf
As TIO can show, every letter of the Latin alphabet is represented when it comes to languages. For every letter there is at least 1 programming language whose name begins with that letter. Your task is to create a polyglot in order to demonstrate that. Your program should be runnable in between 2 and 26 different langu...
stackexchange_codegolf
Text adventure games have a pretty set formula; there's a world composed of a series of rooms / spaces, the player can move around these rooms, and there are some items in the rooms. Items can be picked up by the player, put down, used to access other rooms (e.g. keys), and combined with other items to make new items. ...
stackexchange_codegolf
Given two positive integers p and q, your task is to return the array A created by applying the following algorithm: Start with A = [p, q] and d = 2 For each pair (x, y) of contiguous numbers in A whose sum is divisible by d, insert (x + y) / d between x and y. If at least one matching pair was found, increment d and ...
stackexchange_codegolf
Graham's number \$G\$ is defined in this way: \begin{align*} u(3,n,1) & = 3^n \\ u(3,1,m) & = 3 \\ u(3,n,m) & = u(3,u(3,n-1,m),m-1) \end{align*} Then, \begin{align*} g_1 & = u(3,3,4) \\ g_2 & = u(3,3,g_1) \\ g_3 & = u(3,3,g_2) \\ & \vdots \\ G & = u(3,3,g_{63}) \end{align*} You are given that \$u(3,3,2)=7625597484987\$...
stackexchange_codegolf
The WannaCrypt ransomware has struck and it is attacking networks right, left and center. A network is defined by an m*n binary matrix (a), which has a a[i][j] = 1 if a computer is infected and a[i][j] = 0 if it is not. At the end of each hour, all computers that are a neighbour (which shares a side or a corner with) ...
stackexchange_codegolf
Background I like my old 8-bit 6502 chip. It's even fun to solve some of the challenges here on PPCG in 6502 machine code. But some things that should be simple (like, read in data or output to stdout) are unnecessarily cumbersome to do in machine code. So there's a rough idea in my mind: Invent my own 8-bit virtual ma...
stackexchange_codegolf
Introduction: Although it seems challenges scored by least unique characters have been attempted, there are few which were well-received. I think it's a potentially interesting scoring criterion, as long as different languages aren't competing with each other (as with code golf). Challenge: Create a basic FizzBuzz prog...
stackexchange_codegolf
Task similar to this one. Take a string of ASCII characters and convert it to base-3 equivalents separated by a space. For example: Hello, world! Should be converted to 02200 10202 11000 11000 11010 01122 01012 11102 11010 11020 11000 10201 01020 The output should only contain numbers with the same number of digits. ...
stackexchange_codegolf
This, but via template metaprogramming: template <int n> struct insanity { int[][n] permutations; } Generate all numbers with n digits (0-9) such that each digit is either: Zero The first digit Already present Greater than the maximum digit to the left Don't worry about leading zeros either way. Valid examples: 0123...
stackexchange_codegolf
Given a 24 hour time, e.g. 20:48, output the nearest time where each adjacent pair of digits has an absolute difference of 1, e.g. 21:01. That is, each number in the output must differ from the numbers next to it by 1, and the output must be the closest time, forwards or backwards, for which this is true. Time can be c...
stackexchange_codegolf
So I got kinda bored and was wondering if it was possible to make this code shorter without modifying anything except a file named coin.py... from random import*;c=['heads','tails'];print('u win'if choice(c)==input(' / '.join(c)+': ')else'u lose') The program asks the user for either "heads" or "tails", if the result ...
stackexchange_codegolf
Write a program or function that, given a string, will strip it of zalgo, if any exists. Zalgo For this post, zalgo is defined as any character from the following Unicode ranges: Combining Diacritical Marks (0300–036F) Combining Diacritical Marks Extended (1AB0–1AFF) Combining Diacritical Marks Supplement (1DC0–1DFF) ...
stackexchange_codegolf
Left in sandbox for at least 3 days. I want to verify if this inequality is true: for \$n\geq4\$, if \$a_1,a_2,a_3,\dots,a_n\in R_+\cup\{0\}\$ and \$\sum_{i=1}^na_i=1\$, then \$a_1a_2+a_2a_3+a_3a_4+\dots+a_{n-1}a_n+a_na_1\leq\frac{1}{4}\$. Challenge Write a piece of program which takes an integer n as input. It does th...
stackexchange_codegolf
Preface In the well known carol, The Twelve Days of Christmas, the narrator is presented with several gifts each day. The song is cumulative - in each verse, a new gift is added, with a quantity one higher than the gift before it. One Partridge, Two Turtle Doves, Three French Hens, and so on. At any given verse, N, we ...
stackexchange_codegolf
Challenge Your goal is to write a program which will output the 8 measurements of a rectangle, with only some measurements in the input. Your program should throw an error if it cant be done. Here is what each measurement means: | left | | centerX | | | right | | ...
stackexchange_codegolf
This originally came from Give the best Chaitin incompleteness bound, but I realized that there was a fragment of this problem which still potentially gives a good coding challenge. First Order Logic With Equality First, I will need to fix an encoding of first order formulas ('For all x there exists y such that ...'). ...
stackexchange_codegolf
I hate hashes because they remind me of hashtags, help me find them in the input Input A piece of text This is an #example text, #designed for demo #purposes, #to demonstrate the challenge.# You may add a optional newline character at the end of the input if your program requires this You may assume that there will ...
stackexchange_codegolf
Integers in cosine From trigonometry we know that \$\sin(a) =-\cos(a + \frac{(4*m + 1)\pi}{2})\$ where \$a\$ is an angle and \$m\in\mathbb{Z}\$ (integer). The task For an input of a positive integer \$n\$ calculate the value of the integer \$k\$ with \$n\$ digits that minimizes the difference between \$\sin(a)\$ and \$...
stackexchange_codegolf
Objective Write a full program that works exactly like the flow chart below. Each output, which is an integer, shall be through stdout, followed by a line feed. Each input shall be a line of string fed through stdin, and shall be judged to a predicate you choose for branching. The same predicate must be used for all br...
stackexchange_codegolf
Let's define a simple language that operates on a single 8-bit value. It defines three bitwise operations (code explanation assumes 8-bit value variable): ! Negate the least significant bit (value ^= 1) < Wrapping left-shift (value = value << 1 | value >> 7) > wrapping right-shift (value = value >> 1 | value << 7) In...
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
Sandbox Given two positive integers a and b, return the smallest multiple of b that is greater than or equal to a. Examples Definitions: true = is a multiple of b, false = is not a multiple of b. f(1,3) = 3 because 1 is false, 1+1 is false, but 1+1+1 is true. Therefore 3 is returned. f(5,3) = 6 because 5 is false, but...
stackexchange_codegolf
Background Entombed is an Atari 2600 game released in 1982, with the goal of navigating through a continuous mirrored maze as it scrolls upwards. In recent times, the game has been subject to research — despite the strict hardware limitations of the Atari 2600, it somehow manages to create solvable mazes every time. By...
stackexchange_codegolf
This question is based on a question I asked in Spanish language. Yes, I asked for an algorithm in Spanish Language. :) In Spain, current license plates have this pattern: 1234 XYZ where XYZ are three consonants taken from the full set of Spanish consonants (except the 'Ñ', I think). Sometimes, when traveling with ...
stackexchange_codegolf
Write a function or program that takes as its input a string and prints a truthy value if the string is a pangram (a sequence of letters containing at least one of each letter in the English alphabet) and a falsey value otherwise. Case of letters should be ignored; If the string is abcdefghijklmnopqrstuvwXYZ, then the ...
stackexchange_codegolf
You must fill an array with every number from 0-n inclusive. No numbers should repeat. However they must be in a random order. Rules All standard code-golf rules and standard loopholes are banned The array must be generated pseudo-randomly. Every possible permutation should have a equal probability. Input n in any way ...
stackexchange_codegolf
Hopefully not duplicate, but I did not find one. Challenge The challenge is to write full program, which compiles (without errors), but, when executed, will not finish the execution till the end, because an error appears during the execution. Rules It has to be full program, which is compile-able or interpret-able in ...
stackexchange_codegolf
Not a duplicate of the valid move challenge because that asks for specific pieces. Backstory The other night I was doing a little trolling with ChatGPT and chess. I was trying to get it to call me out for making illegal moves, as a lot of the time, you can feed it whatever nonsense you want. While doing so, I wondered ...
stackexchange_codegolf
A Belphegor number is a number of the form \$(10^{n+3}+666)*10^{n+1}+1\$ (1{n zeroes}666{n zeroes}1) where \$n\$ is an non-negative integer. A Belphegor prime is a Belphegor number that is also prime. The \$n\$ values of the first few Belphegor primes are 0, 13, 42, 506 (A232448) Task Write a program that either: take...
stackexchange_codegolf
Inspired by this challenge. Goal: Given a pre-configured switchboard and a list of indexes, invert the switches at the given indexes. A switchboard is made up of some number of switches (v or ^) wrapped in -'s and arranged into rows of varying length. Here is an example switchboard: -v-^-v- -^-v- -v-^-v- To invert/fli...
stackexchange_codegolf
This is part of a Cops and Robbers challenge. Go here for the cops' part. For the purpose of this challenge, we'll define whitespace as only linefeeds (0x0A) and spaces (0x20). Note that most languages and regex flavours consider many other characters as whitespace as well, both inside and outside the ASCII range so yo...
stackexchange_codegolf
Challenge Generate \$n-1\$ consecutive composite numbers using this prime gap formula $$n!+2,n!+3,...,n!+n$$ Input An integer \$n\$ such that \$3 \leq n \leq 50 \$. Output Sequence of \$n-1\$ consecutive composite numbers. Example Input 3 Output 8 9 Rules Output should be in integer format. Test Cases For \$n > 20\...
stackexchange_codegolf
Write a function or program that given a list of non negative integers, arranges them such that they form the largest possible number. INPUT [50, 2, 1, 9] OUTPUT 95021 INPUT 0 OUTPUT 0 INPUT (Interesting one) [7, 76] OUTPUT 776 RULES standard loopholes apply. Depending on your language you can use int(32) / in...
stackexchange_codegolf
Introduction In this challenge, you are given as input the ASCII representation of the net (unfolded surface) of a rectangular cuboid (3D box). The format is this: ....+--+....... ....|##|....... ....|##|....... ....|##|....... +---+--+---+--+ |###|##|###|##| +---+--+---+--+ ....|##|....... ....|##|....... ....|##|.......
stackexchange_codegolf
The Task Your task is to create a program or a function that, given a sentence, outputs it translated to the Farfallino language. 'Y' is treated as a consonant. The usual rules for farfallino alphabet are based on the substitution of each vowel with a 3 letter sequence where the vowel itself is repeated with an interce...
stackexchange_codegolf
Introduction Long story short: a few days ago I accidentally started knitting a sock and the pretty logical structure of the plain stitches lead me to the idea: Why don't we just ASCII-knit a sock? Input The input is an even integer N in the range [2,30]. Output The output is a sock, obviously. Structure Because we wil...
stackexchange_codegolf
OH GODS NO!! You can't leave us here with Doorknob! It'll be nethack everywhere! - 1d ago by Geobits Well, couldn't disappoint... Introduction (you can skip this section if you don't care about exposition and/or if you have Tab Explosion Syndrome) One of the characteristic mechanics of Nethack (and Rogue, and similar...
stackexchange_codegolf
Introduction: In general we usually speak of four dimensions: three space dimensions for x, y, and z; and one time dimension. For the sake of this challenge however, we'll split the time dimension into three as well: past, present, and future. Input: Two input-lists. One containing integer x,y,z coordinates, and one co...
stackexchange_codegolf
Note This is the decryption challenge. The encryption challenge can be found here. Challenge The challenge is to decrypt a given string, using the rules as specified below. The string will only contain lowercase alphabets, digits, and/or blank spaces. If you want to know how the input string has been encrypted, refer t...
stackexchange_codegolf
Challenge Given a string of any length which contains only digits from 0 to 9, replace each consecutive run of the digit 0 with its length. Test Cases 1234500362000440 → 1234523623441 123450036200044 → 123452362344 000000000000 → 12 0123456789 → 1123456789 1234567890 → 1234567891 123456789 → 123456789 010203004050 → 1...
stackexchange_codegolf
A few days ago I made a puzzle about moving people on an airplane. Now I am interested in the general version of this puzzle and the shortest code golf for it. I will briefly summarise the puzzle here. A small airplane went through some heavy turbulence and all its N passengers ended up sitting in reverse order, ie., p...
stackexchange_codegolf
This is an answer-chaining challenge where every part of your answer should aim to be unique from every other answer. This question will work in the following way: I will post the first answer. The next answer will stem from that, and all other answers will originate from it. In this answer I will include a program an...
stackexchange_codegolf
Given a non-negative integer skyline height list, answer how many uninterrupted 1-unit-high horizontal brush strokes are needed to cover it. [1,3,2,1,2,1,5,3,3,4,2], visualised as: 5 5 4 3 5334 32 2 53342 13212153342 needs nine brush strokes: 1 2 3 4 5555 66 7 88888 9999...
stackexchange_codegolf
Given a list of countries in alphabetical order, put them in the same order as they are given in the song "Yakko's World". Specifically, you are given the following list of countries* exactly: Abu Dhabi, Afghanistan, Albania, Algeria, Algiers, Angola, Argentina, Australia, Austria, Bahamas, Bahrain, Bangladesh, Barbado...
stackexchange_codegolf
This challenge is related to some of the MATL language's features, as part of the May 2018 Language of the Month event. Introduction In MATL, many two-input functions work element-wise with broadcast. This means the following: Element-wise (or vectorized): the function takes as inputs two arrays with matching sizes. ...
stackexchange_codegolf
While at work I spotted a nice and simple challenge. The job was to stock products in cargo units with a certain capability. Since an order can have various batches, coming in sequence from the production, we usually make a list of the pieces of those batches distributed in each cargo to make sure nothing is lost durin...
stackexchange_codegolf
Challenge Create a function or program that, when given an integer size, does the following: If size is equal to 1, output H H HHH H H If size is greater than 1, output X X XXX X X where X is the output of the program/function for size - 1 (If you prefer, you may have the base case correspond to 0, so long as you spe...
stackexchange_codegolf
Your task is to implement integer sequence A130826: an is the smallest positive integer such that an - n is an entire multiple of 3 and twice the number of divisors of (an - n) / 3 gives the nth term in the first differences of the sequence produced by the Flavius Josephus sieve. Lost yet? Well, it's actually quite e...
stackexchange_codegolf
Your task is to find how many distinct Blackjack sequences can be found in an ordered list of 12 cards. A Blackjack sequence is defined as a sequence of consecutive cards whose sum of points is exactly 21. Points are counted according to the following table: Symbol | Name | Points Symbol | Name | Points -------+-...
stackexchange_codegolf
A field in mathematics is a set of numbers, with addition and multiplication operations defined on it, such that they satisfy certain axioms (described in Wikipedia; see also below). A finite field can have pn elements, where p is a prime number, and n is a natural number. In this challenge, let's take p = 2 and n = 8,...
stackexchange_codegolf
This is the cops' challenge. To post a robber, go here. In this challenge, cops will invent a (likely simple) programming language, and write an interpreter, transpiler, or compiler that allows you to run it. Robbers will write a program in this language that manages to inject arbitrary code into the interpreter, trans...
stackexchange_codegolf
Given a \$n\$-dimensional vector \$v\$ with real entries, find a closest permutation \$p\$ of \$(1,2,...,n)\$ with respect to the \$l_1\$-distance. Details If it is more convenient, you can use permutations of \$(0,1,...,n-1)\$ instead. If there are multiple closest permutations, you can output any one or alternativel...
stackexchange_codegolf
This is based off this challenge. Given an input string, check whether the string is blurry. What's a blurry string? A blurry string is a string that's contained in the set of all blurrified pure-ASCII strings. Take a non-blurrified pure-ASCII string abc as an example. You repeat every character of this twice: aabbcc ...
stackexchange_codegolf
There is a site called "Return True to Win" with interesting tasks for Javascript programmers. The goal is to find arguments to a given function that force it to return true. The following is one of the tasks: function total(x) { return (x < x) && (x == x) && (x > x); } The users must find snippets for the value of ...
stackexchange_codegolf
The city defines a dog as any living entity with four legs and a tail. So raccoons, bears, mountain lions, mice, these are all just different sizes of dog. Given an ASCII-art image of an animal, determine if that animal is a dog. Rules An animal is a dog if it has four legs and a tail. The foot of a leg starts with one...
stackexchange_codegolf
A recent SO question asks for a convenient one-liner to generate a list of numbers and their negative counterparts in Python. Given two integers \$1≤a≤b\$, generate all the integers \$x\$ such that \$a≤|x|≤b\$. The result may be printed or returned in any order or structure, as putting the result into a list and sortin...
stackexchange_codegolf
Challenge Given a sequence of non-negative integers, create a function that output a descendant pyramid where the children are the sum of both parent numbers. The result is outputted as an string using tab \t. Note: trailing tabs on each line are not required 1\t\t2\t\t3\n\t3\t\t5\t\n\t\t8\t\t results in 1 2 ...
stackexchange_codegolf
Question Santa must get to every house in the world to deliver gifts, can you make a program that will calculate the shortest path that Santa could take, and still visit all the cities listed? Specifications The program should accept Santa's starting point as input. That could either be a city or a pair of coordinates....
stackexchange_codegolf
Let's consider a list \$L\$ (initially empty) and a pointer \$p\$ into this list (initialized to \$0\$). Given a pair of integers \$(m,n)\$, with \$m\ge 0\$ and \$n>0\$: We set all uninitialized values in \$L\$ up to \$p+m+n\$ (excluded) to \$0\$. We advance the pointer by adding \$m\$ to \$p\$. We create a vector \$[...
stackexchange_codegolf
Given two numbers in tape location #0 and tape location #1 in Brainfuck, compute their product into another tape location (specify with answer). Optimize for the least amount of time-units used, where the interpretation of any command uses one time-unit. As example, here is a quick C++ program to determine the number o...
stackexchange_codegolf
Background There is an interesting question on MathSE about some conjectures that are disproven by extremely large counter-examples. This delightful answer tells the story of a sequence of numbers called Gijswijt's sequence, which is now registered as A090822. The sequence is defined as follows Let \$a_1 = 1\$ and for...
stackexchange_codegolf
Premise: For those in networking, you've most likely sent a ping to or from some device to make sure everything's properly connected. Cisco, a popular company in networking[citation needed], has a command for it in their IOS that looks like this: (Image source) Your challenge is to graphically recreate a portion of t...
stackexchange_codegolf
Curling is a sport where two teams aim to place stones as close to the centre of a target as possible. The winner of a curling end is the team whose stone is closest to the centre – they score as many points as the number of their stones closer to the centre than any of their opponents. Task Given two lists of pairs of...
stackexchange_codegolf
Write a program using the fewest bytes of source code which given a list of strings finds all elements which are still in the list when any character is deleted. For example, given a list of all English words boats would be output because oats, bats, bots, boas, boat are all English words and thus would be in the list....
stackexchange_codegolf