instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Background
Stick Bomber is a two-player game I just made up. Initially, some sticks are placed in one or more groups, and the sticks in each group are laid out in a straight line. So a configuration with three groups of 3, 5, and 8 sticks each may look like the following. For conciseness, we can call it a (3,5,8) confi... | stackexchange_codegolf |
Introduction
Time is a really simple concept. Seconds pass, one after the other, all the same. But humans love making it hard. This Stackoverflow question has gathered many answers and even though they are surprisingly long and complex, most of them will still fail for certain inputs. Can you format a number of seconds... | stackexchange_codegolf |
A triangular number is a number that is the sum of n natural numbers from 1 to n. For example 1 + 2 + 3 + 4 = 10 so 10 is a triangular number.
Given a positive integer (0 < n <= 10000) as input (can be taken as an integer, or as a string), return the smallest possible triangular number that can be added to the input to... | stackexchange_codegolf |
Fluff
After taking a look at deadfish, I decided it sucked, so I came up with a new (and easier) variant of it: imnotdeadfish.
As with its predecessor, there are 4 commands and an accumulator which begins at 0:
+ # increment the accumulator
- # decrement the accumulator
s # square the accumulator
o # output the accumul... | stackexchange_codegolf |
Subleq is a programming language with only one instruction. Each instruction contains 3 parameters. Code and data space is the same. How it works:
A B C
A, B and C are signed ints. Instructions are executed in the next way:
*B = *B - *A
if(*B <= 0) goto C;
One post is one tip. Write your tips for Subleq here!
Online ... | stackexchange_codegolf |
A stochastic matrix is a matrix of probabilities used in the context of Markov chains.
A right stochastic matrix is a matrix where each row sums to 1.
A left stochastic matrix is a matrix where each column sums to 1.
A doubly stochastic matrix is a matrix where each row and each column sums to 1.
In this challenge, we ... | stackexchange_codegolf |
Write a program in any language that takes a single natural number n as input and generates a Pyth program that, in turn, produces, using nested lists, the nested set given by S(n), where:
S(0) = ∅
S(n+1) = S(n) ∪ {S(n)}
S(n) giving the set representation of the corresponding ordinal number.
Using the list representa... | stackexchange_codegolf |
You are given four integers: \$e,s,b\in\{0,1\}\$ and \$S\in \{0,1,2,4\}\$, where \$e,s,b,S\$ stand for egg, sausage, bacon and spam respectively.
Your task is to figure out whether the corresponding ingredients match a valid entry in the following menu:
[e]gg | [s]ausage | [b]acon | [S]pam
-------+-----------+--------... | stackexchange_codegolf |
Your task
You must write a program, to print a reverse Fibonacci series, given a number.
Input
A non-negative integer N.
Output
You must output all the Fibonacci numbers from Fk to F0, where k is the smallest non-negative integer such that Fk ≤ N ≤ Fk+1.
Example
IN: 5
OUT: 5 3 2 1 1 0
If input isn't a Fibonacci numbe... | stackexchange_codegolf |
Your task
In your language of choice: create a program that outputs 1
This 1 may either be a string or value equivalent to the number one.
The shifting catch
If you take the unicode codepoint (or whatever codepoint encoding your languages uses if not UTF) for each character in your program, and shift each of those valu... | stackexchange_codegolf |
This challenge is to find the longest chain of English words where the first 3
characters of the next word match the last 3 characters of the last word. You will use
an common dictionary available in Linux distributions which can be downloaded
here:
https://www.dropbox.com/s/8tyzf94ps37tzp7/words?dl=0
which has 99171 E... | stackexchange_codegolf |
Your task is simple: write a program (or function) that takes no input and outputs (or returns) its source code. The catch is that when the program is wrapped in "quotes" (Unicode character 34), it should again output its (now quoted) source code.
Standard rules for quines apply. This is code-golf, so the shortest prog... | stackexchange_codegolf |
Some of your employees have broken capslock keys and you're too cheap to replace them. Help them out by creating the shortest program possible to correct their work! Simply convert each character in a given string from uppercase to lowercase and vice-versa... but there's a twist!
You're also very excited for Christmas!... | stackexchange_codegolf |
It seems we've managed to go all this time without a plain vanilla Number-To-Binary challenge! Whilst this will inevitably be only one element in many languages, it should put a few esolangs through their paces.
I truly looked for this challenge to no avail. If it already exists, comment as such and I'll delete this po... | stackexchange_codegolf |
The Premise:
You are writing a C driver for a screen for use on an embedded system. The screen uses a tortured version of SPI that requires data to be sent LSb (least-significant-bit) first, but MSB (most-significant-byte) first.
A fast way to do this (if you have the memory) is to use the integer value of each byte to... | stackexchange_codegolf |
Your task, is simply to multiply 2 integers given in input, separated by a ",". The catch is, you cannot use the multiplication operator "*", even if it is being used differently, or any loops whatsoever
This is code-golf, so shortest code wins!
Test cases: i dont know if you even need it! lol
1,0 -> 0
5,6 -> 30
3920,5... | stackexchange_codegolf |
Homologous series, any of numerous groups of chemical compounds in each of which the difference between successive members is a simple structural unit.
As an example, Alkane is a homologous group where the chemical compounds are in \$C_nH_{2n+2}\$ format. \$CH_4\$ (Methane) is part of the Alkane group because \$CH_4 \t... | stackexchange_codegolf |
Rules/Objectives:
The program must be executed using ./program-name without shell parameter/arguments.
the program-name may not contain any of characters in /etc/passwd, that is acdepstw
You may not open any other file, including own's source code, only /etc/passwd that should be read.
The program must print the conte... | stackexchange_codegolf |
Your job is to open a browser window of the default browser to http://codegolf.stackexchange.com.
Your code must open the browser itself, and cannot rely on an open one.
This is code-golf, so the shortest answer in bytes wins.
Moderator note: A large number of answers to this challenge use the URLs http://ppcg.lol or... | stackexchange_codegolf |
(Essentially the inverse of Find the needle in the haystack)
Given two tuples, (w, h) and (x, y), generate a haystack composed of a single random printable ASCII character of w width and h height with a needle made of a different random printable ASCII character at (x, y) when measured from the upper-left.
For example,... | stackexchange_codegolf |
For each node in a balanced binary tree, the maximum difference in the heights of the left child subtree and the right child subtree are at most 1.
The height of a binary tree is the distance from the root node to the node child that is farthest from the root.
Below is an example:
2 <-- root: Height 1
... | stackexchange_codegolf |
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 each "double power of two", \$2^{2^n}\$ for each \$n\$.
number = symbol = spoken
============================
2... | stackexchange_codegolf |
Here, x (supplied as input) and n (the result of your computation) are both positive integers. n * x = n shifted. Find n.
Here's an example of shifting:
123456789 -> 912345678
abcdefghi -> iabcdefgh (letters = any 0~9 digit)
123 -> 312
Shifting only happens once to the right. Shifting left, e.g.
123456789 -> 234... | stackexchange_codegolf |
Given the name of a cation and anion, output "S" (soluble) or "I" (insoluble). The table we will be using is from wikipedia: https://en.wikipedia.org/wiki/Solubility_chart. It is copied at the end of the question for future reference.
Input: The cation, followed by the anion, separated by a space. The cation will be on... | stackexchange_codegolf |
Isolated prime definition from Wikipedia:
An isolated prime is a prime number p such that neither p − 2 nor p + 2 is prime. In other words, p is not part of a twin prime pair. For example, 23 is an isolated prime since 21 and 25 are both composite.
Consider strings which consists of character x repeated n times, wher... | stackexchange_codegolf |
ALERT: IN CASE YOU DOUBT, NO PUN ON "QUINE" IS INTENDED
In regulated horse-racing for gambling, bets called Quinella bets exist and in which a person bet on the first two places of a race. In racecourses, usually there is a display which shows the odds of a specific combination as below:
(This picture is a cropped p... | stackexchange_codegolf |
Given a directed graph on the nodes 0, 1, ..n, where each edge has two non-negative integer costs, return the set of all possible Pareto Optimal path costs between node 0 and node n.
These are the costs of paths for which you cannot decrease the first component of the cost without increasing the second component, and c... | stackexchange_codegolf |
Spirals are cool , so are numbers, and number spirals are even cooler. But what if I want a specific number, in a specific place using xy coordinates...
Challenge
Using an infinite spiral moving down first, curling in a counterclockwise manner
ex:
6 5 4
7 0 3
8 1 2
9 10 11
Take negative and positive inputs(... | stackexchange_codegolf |
This challenge is inspired by Fortran's idiosyncratic implicit typing rules. Your task will be to determine the data type of the object GOD according to the implicit typing rules explained below.
Background
Fortran 77 has six data types: CHARACTER, COMPLEX, DOUBLE PRECISION, INTEGER, LOGICAL, and REAL. Any object not e... | stackexchange_codegolf |
We seem to never get tired of alphabet-related challenges...
The recipe
Given
a string of letters S, and
two positive integers M, N,
produce an alphabet soup with the letters of S occupying random positions in a rectangular bowl of size M×N, framed by a non-alphabetic, non-space character to represent the rim of the... | stackexchange_codegolf |
Alternesting, is the act of taking a string and nesting it in alternating brackets. Here is how you alternest a string.
For a string of length N, take the center N characters, and surround them in parenthesis. So if our string was Hello world! (12 characters), we'll end up with
(Hello world!)
Then, take the remaining... | stackexchange_codegolf |
Backstory
Not really real, sshh!
It all started one day when a coworker brought in a homemade loaf of bread for my boss's birthday.
My boss really liked this loaf of bread, and he wanted another. Unfortunately, my coworker has quit, so my boss needs me to give him another loaf.
The problem is, I have no idea how to mak... | stackexchange_codegolf |
In the examples below, A and B will be 2-by-2 matrices, and the matrices are one-indexed.
A Kronecker product has the following properties:
A⊗B = A(1,1)*B A(1,2)*B
A(2,1)*B A(2,2)*B
= A(1,1)*B(1,1) A(1,1)*B(1,2) A(1,2)*B(1,1) A(1,2)*B(1,2)
A(1,1)*B(2,1) A(1,1)*B(2,2) A(1,2)*B(2,1)... | stackexchange_codegolf |
Given an array of integers, count the number of contiguous subarrays with an even sum. You may assume that the array is non-empty, and contains only non-negative integers.
This is code-golf, so the shortest code in bytes wins.
Test Cases
Input -> Output
[7] -> 0
[8] -> 1
[3, 5] -> 1
[6, 2] -> 3
[2, 4, 5] -> 3
[7, 4, 0,... | stackexchange_codegolf |
Introduction
This challenge is about producing a code to count the frequency of bigrams in a text. A bigram is two consecutive letters in a text. For instance 'aabbcd' contains the bigrams aa, ab, bb, bc, cd once each. Counting bigram frequencies is super useful in cryptography. In a brute force algorithm, this code ma... | stackexchange_codegolf |
Objective
From Wikipedia :
A recursive acronym is an acronym that refers to itself in the expression for which it stands.
Your goal is to check if a string is a recursive acronym.
The acronym is the first word
Words are not case sensitive, separated with a single space.
The given string does not contain any p... | stackexchange_codegolf |
"All roads lead to Rome" is a saying that essentially means there are plenty of different ways of achieving an objective.
Task
Your task is to write a program that finds a set of link connections from one Wikipedia page to the Wikipedia page about Rome.
Notice that it is not enough to find the word Rome with a hyperlin... | stackexchange_codegolf |
The Len(language,encoding) family of languages is a variety of Lenguage derivatives. To encode a program into a Len language, you replace every character with its representation in a certain encoding, then turn that into a giant integer.
Your challenge is to write a function or program that encodes your language into a... | stackexchange_codegolf |
Left and right Riemann sums are approximations to definite integrals. Of course, in mathematics we need to be very accurate, so we aim to calculate them with a number of subdivisions that approaches infinity, but that's not needed for the purposes of this challenge. You should instead try to write the shortest program,... | stackexchange_codegolf |
"A picture is worth a thousand words"—so the old saying goes. The average word is about four characters long, so a picture conveys 4kB of information. But how much entropy, rather than information, can a picture convey?
Your task is to generate an image, exactly 4,000 bytes in size, with the highest entropy possible. Y... | stackexchange_codegolf |
Your function must accept two strings and return new string where are UTF-16 code of all symbols is the sum of UTF-16 codes of inputs symbols
If the resulting sum is greater than 65535 (maximum UTF-16 codepoint), take the sum modulo 65536
If there are more symbols in one string then sum with zero, codes of symbols wh... | 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 |
A marquee is a low-tech board that allows customizable letters. For example, here is a marquee:
SALE ON SNEAKERS
However, someone might come along and vandalize it by removing letters to send a different message:
S N AKE
Given two non-empty string inputs, an original message and a new message, determine whethe... | stackexchange_codegolf |
The stock market is all about the speed of knowledge. Unlike previous challenges, the current stock price is not random: it is determined by those playing the game. If you can identify an under-priced stock before anybody else, then you've written yourself a money-making program.
Price refers to the how much people ar... | stackexchange_codegolf |
It's obviously ellipsisessieses.
Inspired by a chat message.
Your challenge
Given a list or space or comma-separated string of words, ellipsisessiesesify them.
To ellipsisessieses-ify a word:
Start with the word.
Add the first letter of the original word to the end.
Add 2 of the last letter of the original word to the... | stackexchange_codegolf |
Write some code...
Write a program that takes no input and outputs an integer n which is a multiple of 3. So n=3k, where k is a positive integer.
Double the last character of your code.
Your code should then output k.
Examples
Here is my program hui#2(21+4)//lm, which outputs 81.
Because of that, hui#2(21+4)//lmm shoul... | stackexchange_codegolf |
A palindrome is a word which is spelled the same backwards and forwards. For example, "racecar" is a palindrome as is "redder". A double palindrome is a palindrome whose halves are also palindromes. For example, "abbabba" is a double palindrome, as the half "abba" is also a palindrome. Similarily, "abaababaaba" is a tr... | stackexchange_codegolf |
Sandbox
The major scale (or Ionian scale) is one of the most commonly used musical scales, especially in Western music. It is one of the diatonic scales. Like many musical scales, it is made up of seven notes: the eighth duplicates the first at double its frequency so that it is called a higher octave of the same note.... | stackexchange_codegolf |
Challenge
You have one string of input bytes, output only the last byte in it.
Rules
Your submission may be a program or function outputting the last byte in the input which
is either a string, stdin or command-line arguments, and
is non-empty.
I was trying to solve this with brainfuck, however all languages are allo... | stackexchange_codegolf |
Objective
Given a nonempty unordered list of positive integers, decide whether they can be added, negated, or multiplied to yield a single zero. Each given number must be used exactly once.
There is a taboo. Do not multiply zero to anything. Adding zero to anything is OK.
Examples
Truthy
List, Solution
[1,1], 1-1
[1,1,... | stackexchange_codegolf |
The challenge is to write an interpreter for the untyped lambda calculus in as few characters as possible. We define the untyped lambda calculus as follows:
Syntax
There are the following three kinds of expressions:
A lambda expression has the form (λ x. e) where x could be any legal variable name and e any legal expr... | stackexchange_codegolf |
Challenge:
To take two points on the plane and figure out the position of the point that's a) on the line that connects them, and b) equally distant from each of the original points.
Example:
(0,0), (3,3) -> (1.5,1.5)
(-1,-1), (1,1) -> (0,0)
(-7,3), (2,-2) -> (-2.5,0.5)
(3, 1), (-5,9) -> (-1,5)
Rules:
The input an... | stackexchange_codegolf |
We often see music videos on Youtube. Many Youtube channels that host music videos are "powered by VEVO". Those can be easily identified by both embedding VEVO at their video thumbnails and appending VEVO to their channel name.
Now write some code to test whether a string given by user is a VEVO user account or not.
Re... | stackexchange_codegolf |
Let's use augmented reality to hunt small creatures hidden in source-code. Write a quine program that outputs its own code source, except for 5 consecutive characters that will be modified and that will display a PCG-mon : (^_^)
The 5 consecutive characters can be positioned anywhere in the source code (from position 0... | stackexchange_codegolf |
Introduction:
I collect twisty puzzles, so I'm quite the fan of rubiks-cube-challenges (even though most are fairly difficult). So, let's try a fairly easy rubiks-cube-challenge for a change.
When an NxNxN Cube gets scrambled during a WCA (World Cubing Association) competition, the cube is always held in the same way b... | stackexchange_codegolf |
For a given number n, output an strictly decreasing array whose sum is n and its lexicographical order is the smallest for any possible outputs
Smallest lexicographical order means that for or sum n=9 the following strictly decreasing arrays are possible: [[9],[8,1],[7,2],[6,3],[5,4],[6,2,1],[5,3,1],[4,3,2]]. Putting t... | stackexchange_codegolf |
Your task, at the moment that you choose to accept it, is to write a program that, when given a string and a PCRE-regex, calculates the minimum Levenshtein distance to another string that matches the regex (fully). All strings, as well as the regexes, should be in the Latin-1 character set.
This is code-golf, so the sh... | stackexchange_codegolf |
Let z be a complex number. z is an nth primitive root of unity if for a certain positive integer n and for any positive integer k < n .
Challenge
Write a full program or function that, given a positive integer n as input, outputs all of the nth primitive roots of unity. You may output them in polar form (e^θi or e^iθ,... | stackexchange_codegolf |
What tricks do you know to make CoffeeScript code shorter?
CoffeeScript is language that compiles into JavaScript ("transpiles" into ES3, to be exact). The golden rule is "It's just JavaScript", meaning there's no runtime overhead. Most of JavaScript Tips & Tricks apply as well.
As a side-effect that also means: develo... | stackexchange_codegolf |
Write a quine that outputs the complement of the source code from the smallest containing power of two. Here's an example:
IN : source
OUT: \r\x11\x0b\x0e\x1d\x1b
The largest code point in the string "source" is the letter u, which is 117. The smallest containing power of 2 would be 128, so all the code points are tak... | stackexchange_codegolf |
Objective
Given a string with single Unicode vulgar fraction, parse it to a rational number.
Valid inputs
A valid input is one of:
¼ U+00BC; one quarter
½ U+00BD; one half
¾ U+00BE; three quarters
⅐ U+2150; one seventh
⅑ U+2151; one ninth
⅒ U+2152; one tenth
⅓ U+2153; one third
⅔ U+2154; two thirds
⅕ U+2155; one fifth... | stackexchange_codegolf |
Challenge
In this challenge, we will use a language that is very similar to Brainfuck but slightly different.
This variant of BF does not have any input and output commands; instead, it simply takes a tape as input and modifies it until it halts. The final state of the tape is considered the output of the program.
The... | stackexchange_codegolf |
Your program is supposed to create a full red screen in MSDOS. The source of the binary (.com file) must be 5 bytes or less. No wild assumptions, the binary must work in MsDos, DosBox, and FreeDos alike. For winning, you have to post x86 assembler code which can be assembled with NASM (FASM) or directly the hex code of... | stackexchange_codegolf |
Challenge
Your goal is to write a function that puts quotes around a sequence of capital letters in a string.
So some examples (everything on the left (before function) and right (after function) are STRINGS):
Hello the name's John Cena -> "H"ello the name's "J"ohn "C"ena
I got BIG OLD truck -> "I" got "BIG" "OLD" truc... | stackexchange_codegolf |
It's a normal truth machine but instead of taking input, it uses the first character of the program. Thus, internal.
The 0 and 1 are plain characters, i.e. ASCII code 0x30 and 0x31 respectively.
Example: 0abcd prints 0 and halts, and 1abcd prints 1 infinitely. Then your submission is abcd, whose score is 4 bytes. The 0... | stackexchange_codegolf |
The task here is pretty simple. You should write a program that takes a string as input and outputs it (that is a cat program).
Additionally when the \$n\$th byte of your program is removed (without replacement) the augmented program should take a string as input and remove the \$n\$th character. If the input to your... | stackexchange_codegolf |
This happy individual is known in folklore as the Easter Bunny.
Colours
It is created using 4 colours:
Light pink
Dark pink
White
Black
(I'm happy for these colours to be approximated in your answer. It does not need to be this precise shade)
Shapes
It is constructed of these shapes:
Two tall ellipses in light pink... | stackexchange_codegolf |
I want to be down with the kids of the 1990's and start speaking this L33T speak of their's.
For any given input I would like the resulting L33T speech as an output.
I don't want to go to far down the rabbit hole so let's start simple.
Consider the following replacements:
B or b = 8
E or e = 3
I or i = 1
S or s = 5
Let... | stackexchange_codegolf |
Not entirely sure if this one or a similar challenge has already been posted, but here it goes anyway.
Write a program that takes a string as input and writes its trucated/summarized output form such that a specific sep (separator) is placed in the middle, removing the necessary characters of the original string so tha... | stackexchange_codegolf |
You are an enterprising dot who wants to increase the land under its control. This is quite simple - travel outside your current land and loop back into your land and everything in that loop is now owned by you. But there is a catch. If some other dot somehow finds your loop and crosses it, you die.
If you haven't alre... | stackexchange_codegolf |
This is a simple challenge: given n in any way practical (Function arg, stdin, file, constant in code) output the internal angles
(NOT the sum of the internal angles, just one) of a regular polygon with n sides. The output can be in degrees, gradians or radians, and can be displayed in any way practical (Function retu... | stackexchange_codegolf |
Fastest code is a scoring method on this site where the goal is to write code that is as fast as possible.
From the tag wiki:
The winner of a fastest-code challenge is determined by the runtime performance of the submissions. For fairness, all submissions should be benchmarked on the same machine, which usually means ... | stackexchange_codegolf |
The challenge
Create a function which takes an array of numbers and subtract from each element the lowest element in the array that has not yet been subtracted from another.
After using the lowest value, It can not be used again.
Numbers in the array are decimal numbers, and not necessarily integers.
Example:
Input: ... | stackexchange_codegolf |
Related, both rope, nail and falling, but reversed and some other differences
Consider a loop of rope hanging on n nails on a row. Given a table showing whether the rope would fall down when each possible set of nails were removed, please provide a possible roping way. You may assume such a solution exist.
Here, "fall ... | stackexchange_codegolf |
In Java/.NET/C/JavaScript/etc. you can use ternary-ifs to shorten if-statements.
For example (in Java):
// there is a String `s` and an int `i`
if(i<0)s="Neg";else if(i>0)s="Pos";else s="Neut";
Can be shortened with a ternary-if to:
s=i<0?"Neg":i>0?"Pos":"Neut";
Challenge:
Input: A regular if-else (possible with nes... | stackexchange_codegolf |
A binary multiple of a positive integer k is a positive integer n such that n is written only with 0s and 1s in base 10 and n is a multiple of k. For example, 111111 is a binary multiple of 3.
It is easy to show that a positive integer has infinitely many binary multiples. See here for a construction proof of one binar... | stackexchange_codegolf |
Unlike most languages, Python evaluates a<b<c as it would be done in mathematics, actually comparing the three numbers, as opposed to comparing the boolean a<b to c. The correct way to write this in C (and many others) would be a<b && b<c.
In this challenge, your task is to expand such comparison chains of arbitrary le... | stackexchange_codegolf |
Introduction
Today we're gonna take care of the bane of first-year linear algebra students: matrix definiteness! Apparently this doesn't yet have a challenge so here we go:
Input
A \$n\times n\$ symmetric Matrix \$A\$ in any convenient format (you may also of course only take the upper or the lower part of the matrix)... | stackexchange_codegolf |
Shift Tac Toe
Shift Tac Toe is a game that combines Tic Tac Toe and Connect 4 together. In this game, you start with a 3 by 3 board, and each row is connected to a slider that you can move left and right. At the start, the sliders all start to the very right(this means that you can't move the slider to the right on the... | stackexchange_codegolf |
inspired by thejonymyster's idea
Rules
This challenge is about finding languages that are very suitable for one task but quite the opposite in the other. The two tasks share a theme, but Task 1 is designed to be number-oriented while 2 is string-oriented. You can participate in three categories:
Numbers: Choose a lang... | stackexchange_codegolf |
Challenge description
Let's take a positive integer n, reverse its digits to get rev(n) and get the absolute value of the difference of these two numbers: |n - rev(n)| (or abs(n - rev(n))).
Example:
n = 5067
rev(n) = 7605
|n - rev(n)| = |5067 - 7605| = |-2538| = 2538
After repeating this operation sufficiently many t... | stackexchange_codegolf |
Standardized testing usually comes with a scan-tron or some type of answer document that records your answer. A computer or human(s) would then check your answers and determine your grade. So here, given a scan-tron and the answer key, determine the score and questions missed if any. A scan-tron is just a document with... | stackexchange_codegolf |
Bi-directional translator
The challenge is to create a translator that can translate a [a-zA-Z ] string into another string according to the mappings below. The translator should also be able to translate translated text back into its normal form (hence bi-directional). Case doesn't have to be maintained and can be eit... | stackexchange_codegolf |
This one is inspired by Calvin's Hobbies recent multiplication table challenge.
Write a function or program that takes an integer N as input and prints or returns a N-by-N unique multiplication spiral. The code must (in theory) work for N between 0 and 1000 (outputting this can be hard though). The output should be equ... | 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 |
Introduction
This site is rapidly building up a huge dataset of code snippets, so let's do something with it!
Here's a data file. It contains 9,066 unique language+snippet pairs for 113 languages, all taken from this site. The format is tab-separated (language-TAB-snippet), with all newlines in the snippets replaced wi... | stackexchange_codegolf |
The Xerox Alto, originally released in 1973, was the first computer to feature the now-familiar angled mouse pointer. The Alto's bitmapped pointer looked like this (redrawn from Fig. 2 here):
Your task in this code-golf challenge is to write a program/function that generates an ASCII art representation of the mouse po... | stackexchange_codegolf |
Background
In this challenge, a base-b representation of an integer n is an expression of n as a sum of powers of b, where each term occurs at most b-1 times. For example, the base-4 representation of 2015 is
4^5 + 3*4^4 + 3*4^3 + 4^2 + 3*4 + 3
Now, the hereditary base-b representation of n is obtained by converting t... | stackexchange_codegolf |
Given a string to encode, and a number of columns (the key), encode the string as follows:
I will be using the example Hello, world! and the key 3
First, write out the number of columns:
1 2 3
Next, write the text starting from the upper left, one character per column, and when you run out of columns, go to the next l... | 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 |
Write a snippet to calculate the mode (most common number) of a list of positive integers.
For example, the mode of
d = [4,3,1,0,6,1,6,4,4,0,3,1,7,7,3,4,1,1,2,8]
is 1, because it occurs the maximum of 5 times.
You may assume that the list is stored in a variable such as d and has a unique mode.
e.g.: Python, 49
max((... | stackexchange_codegolf |
I am trying to write a solution to the following problem using as few characters as possible (to meme my friend and introduce him to golfing). Can any improvements be done to my code?
So the problem requires us to write a function called navigate in Python 3.6 (language of the judge, sorry, no walruses) that takes two ... | stackexchange_codegolf |
Challenge
You find yourself in a bash terminal, and want to do some simple tests
on sqlite3.
So you issue the following command:
echo "CREATE TABLE T (id INT NON NULL PRIMARY KEY)" | sqlite3 test.db
Now you want to insert the first N integers (starting from 0, excluding N) into the table T.
For convenience, you execut... | stackexchange_codegolf |
Your input is a ragged list of possibly empty lists of non-negative integers. For example, [[2,0],[[]],[[[],[1],[]],[]]] is a valid input. This input is a "compressed" ragged list. What this means is that when we have a list of numbers, we interpret those as a list of indices, indexing the output.
For example, if I=[[2... | stackexchange_codegolf |
Modern British number plates (a.k.a. registration marks or license plates) use the format AANNXXX where AA is a "DVLA memory tag" (basically a location code), NN is the age identifier, and XXX is three random letters.
Your task is to, given a date, generate a random valid number plate with a date code matching the supp... | stackexchange_codegolf |
Task
Given a string composed of ASCII printable characters, return how many strings could fit the given pattern with character literals and regex-like ranges.
Pattern string
The pattern string follows this grammar (the | means an option and the * means 0 or more occurrences of whatever was immediately to the left):
pat... | stackexchange_codegolf |
This challenge is partly an algorithms challenge, involves some math and is partly simply a fastest code challenge.
For some positive integer n, consider a uniformly random string of 1s and 0s of length n and call it A. Now also consider a second uniformly chosen random string of length n whose values are -1, 0, or 1... | stackexchange_codegolf |
I came across an interesting tiling of the plane using squashed hexagons in a popular math book. All the six edges of the squashed hexagon are the same length. Two opposite corners are right angles and the rest four corners are 135 degrees each. This shape allows four squashed hexagons be arranged so that they meet at ... | stackexchange_codegolf |
Introduction
According to Rand Al'Thor's post in the Puzzling SE, a close-knit word is any word that contains three alphabetically consecutive letters (in any order).
Words like education, foghorn and cabaret are all considered close-knit words whereas words like learning, klaxon and perform are not close-knit words.
C... | stackexchange_codegolf |
Taking a positive integer n as input, print the sample space of n consecutive coin flips. The coin is fair, with two sides H and T, each with probability 0.5.
For example,
Input - 3
Output -
HHH
HHT
HTH
HTT
THH
THT
TTH
TTT
Rules
Standard loopholes apply
You may print the elements out of order, but all of them should ... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.