instruction_seed stringlengths 292 48.7k | found_ngrams listlengths 0 21 |
|---|---|
Turns out there are some distant aliens who know English (and have coincidentally standardized on 8-bit computer architectures). Yet they have never heard of ASCII, nor even alphabetical order.
It is believed that these aliens are picking up information from Earth. Yet they are doing so with digital equipment that re... | [] |
Your job is to simulate a mathematically perfect game of 2048. The idea is to find the theoretical upper limit of how far a 2048 game can go, and find how to get there.
To get an idea of what this looks like, play with this 2x2 clone and try to score 68 points. If you do, you will end up with a 2, 4, 8, and 16 tile. It... | [] |
Your task is to play the roles of both characters in this scene from Inception. In it, Cobb gives Ariadne a challenge:
You have two minutes to design a maze that takes one minute to solve.
Some liberties will be taken on that description. Most importantly, this challenge is not time-based, rather scores are based on ... | [] |
In the highly underrated Steampunk novel The Difference Engine, the equivalent of cinema houses delivered a pixelated moving image displayed by tiles which could be flipped mechanically. The control engine for orchestrating the movement of the these tiles was a large noisy machine controlled by a deck of punched cards.... | [] |
From now on considering the word "fuck" to be non-profane would be a good idea
Make the smallest compiler or an interpreter for the Brainfuck variant, Boolfuck. It has to be executable in Windows, DOS, or a Unix operating system (so Linux, Mac, OpenBSD etc). Boolfuck is very similar to Brainfuck, and a complete definit... | [] |
Your task is to read an image containing a handwritten digit, recognize and print out the digit.
Input: A 28*28 grayscale image, given as a sequence of 784 plain-text numbers from 0 to 255, separated by space. 0 means white and 255 means black.
Output: The recognized digit.
Scoring: I will test your program with 1000 o... | [] |
Alice and Bob like to play a card game, with a deck of cards numbered with consecutive nonnegative integers.
Alice has a very particular way of shuffling the deck, though. First, she takes the top card from the deck and puts it at the bottom of the deck. Then she removes the next card, and starts a pile with it. Then, ... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11
],
[
220,
16,
11,
220,
17,
11,
220,
18,
11,
220... |
Introduction
From Esolangs.org :
Pi is based on the brainfuck language and uses the same instructions as it. Pi works by calculating pi digits and introducing errors in some random digits of them, encoding obfuscated brainfuck instructions.
Instructions are encoded as below:
'>' '<' '+' '-' '.' ',' '[' ']'
0 ... | [] |
Write a program which takes an integer argument and outputs the number of degree n monic polynomials with coefficients that are -1,1 or 0 which have a root which is a root of unity. To make it a little cleaner, only count polynomials with leading coefficient of 1.
You can use any language you like as long as it is fr... | [] |
A nonogram is a two-dimensional logic puzzle that looks something like this (screenshots from the game Pixelo, my favourite nonogram game):
The goal of the game is to figure out what image those numbers are encoding. The rules are simple: A number on a column or row means that somewhere in that column or row, that man... | [] |
Introduction
The Fibonacci Linear Feedback Shift Register (LFSR) is a digital circuit which generates a stream of random-looking bits. It consists of several 1-bit flip-flops in a row, with certain positions designated as 'tapped'. In each iteration, the values in the tapped positions are XORed together (i.e., summed... | [] |
Me thinks there aren't enough easy questions on here that beginners can attempt!
The challenge: Given a random input string of 1's and 0's such as:
10101110101010010100010001010110101001010
Write the shortest code that outputs the bit-wise inverse like so:
01010001010101101011101110101001010110101
| [] |
The challenge: Write a function, that delivers following output: "1 2 3 4 5 4 3 2 1".
Kids stuff? Of course. But here's the point:
You only can use: 1 for loop, 2 int variables.
You must not use: IF terms, another function, ...
Do not hardcode the output
There are also some more restrictions to make this harder:
No ... | [] |
You dudes, the Most Excellent Adventure is a home brew roleplaying game system based on the Bill & Ted Films, plays gnarly air guitar riff.
In this game system, when you draw from your dice pool (you have between 1 and 12 ten-sided dice, with faces labelled 0-9) you need to connect the results as a phone number on you... | [] |
Dark black ink has splattered all over your white sheet of printer paper! The obvious solution is to fold the paper so black and white parts meet and both become grey as the ink diffuses. Then unfold and refold until your paper is all equally grey.
Finding the best way to make these folds is your task in this coding ch... | [] |
Given a number, starting with 1, create new numbers (children) by taking the last digit, n, and concatenating 1 through n+1.
This seems to be a much better explanation of the sequence A071159.
Integers whose decimal expansion start with 1, do not contain zeros and each successive digit to the right is at most one gr... | [] |
The scenario
I drive along a road with my car and it begins to rain. The raindrops are falling on my window randomly and now i ask myself, where is the biggest connected wet area?
The task
To make it easier, the window is split in a matrix of 10*10 squares.
Your job is to find the biggest connected water-drop-area on t... | [] |
The Challenge
For a given set of n integers, write a program which will output its lexicographic index.
The Rules
The input must only be a set of unique non-negative integers separated by spaces.
You should output the lexicographic index (range 0 to n!-1 inclusive) of the permutation.
No permutation libraries or permu... | [] |
This question originates in this reddit thread by reddit user taho_teg but it is expanded to a more general 'puzzle'.
You have a centrifuge with 24 holes for the vials uniformly distributed in a circle around the central axis. If you now have a number of vials and you want to start the centrifuge, you need to make sure... | [] |
Challenge
Find the smallest cover of bases (e.g., moduli) whose sets of quadratic residue can be tested via table-lookup to definitively determine whether or not a given non-negative integer n is a perfect square. The bases must all be less than or equal to the square root of the maximum value of n.
The answer with the... | [] |
The Challenge
The challenge is that I have a standard mechanical push button lock and you need to find out every possible code that could unlock it.
With a standard mechanical push button lock you have all single digit numerals and sometimes a few letters.
With this specific push button lock there are specific rules.
R... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11
]
] |
After @MartinBüttner achieved exactly 10,000 reputation, we now have three full rows of 10k users on the users page! Now, since we're all programmers here, we like to automate things instead of doing them manually. Your challenge is to write a program to automatically congratulate new 10k users.
Specification
Input
The... | [] |
An ant walks along the edges (not faces) of a wireframe cube. Each vertex it encounters presents it with a fork from which two new edges branch off. The ant chooses which way to turn -- left or right. These direction are relative to the ant, who is facing the vertex and is outside the cube. Your goal is to determine, f... | [] |
Write the shortest code to reverse the bit order of a 32-bit integer.
Rules:
Input is assumed to be a valid integer or string equivalent if your language doesn't support numerical values (e.g. Windows Batch).
Output must be a valid integer or string equivalent if your language doesn't support numerical values (e.g. Wi... | [] |
Your challenge is to find the smoothest number over a given range. In other words, find the number whose greatest prime factor is the smallest.
A smooth number is one whose largest prime factor is small. Numbers of this type are useful for the fast Fourier transform algorithm, cryptanalysis, and other applications.
For... | [] |
Prior to the discovery of fingerprints and DNA testing, the British police used an anthropometric system to identify repeat offenders. Certain parts of the bodies of criminals were measured and stored in records -- these parts of the body were assumed to not change in size after adulthood. This system was known as bert... | [] |
Given an integer n (where n < 10001) as input, write a program that will output the first n Ulam numbers. An Ulam number is defined as follows:
U1 = 1, U2 = 2.
For n > 2, Un is the smallest integer which is greater than Un-1 that is the sum of two distinct earlier terms in exactly one way.
For example, U3 is 3 (2+1... | [] |
In Gödel, Escher, Bach, Douglas Hofstadter introduces an integer sequence which is commonly referred to as the figure-figure sequence:
2, 4, 5, 6, 8, 9, 10, 11, 13, 14, 15, 16, 17, 19, 20, 21, 22, 23, 24, 25, ...
You may enjoy working out the definition of the sequence yourself as part of the challenge, but if you can... | [] |
Introduction
This is one of my favorite math puzzles.
Given a digit (say 3) and the number of times to use that digit (say 5), generate 10 expressions which result to 1, 2, 3, 4, 5, 6, 7, 8, 9 and 10 using just +, −, ×, ÷, ^ and √ (root) (brackets are allowed to group operations).
For example:
(3^3 + 3)/(3 + 3) = (33 -... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11
],
[
220,
16,
11,
220,
17,
11,
220,
18,
11,
220... |
Output all numbers in certain range containing certain digits
Task
Take an input of digits through console, prompt, or a file (in the decimal number system). These digits should be separated by spaces.
Take an input of the "maximum" through console, prompt, or a file
If you use a file, the program must output "[Data t... | [] |
Statement of problem
Given a set of unique, consecutive primes (not necessarily including 2), generate the products of all combinations of first powers of these primes — e.g., no repeats — and also 1. For example, given the set { 2, 3, 5, 7 }, you produce { 1, 2, 3, 5, 6, 7, 10, 14, 15, 21, 30, 35, 42, 70, 105, 210 } b... | [] |
Pi is an irrational number, which means that its decimal representation never terminates or repeats itself.
Pi truncated to 41 decimal digits (40 places) is 3.1415926535897932384626433832795028841971.
If we ignore the decimal point and list the digits as a sequence of positive integers, avoiding duplicates, we get 3 1 ... | [] |
Suppose your alarm wakes you up one morning, but you hit snooze so you can sleep for 8 more minutes. When it rings again you grudgingly get up and take a shower, which you estimate takes 15 to 17 minutes. You then brush your teeth for exactly 2 minutes, and get dressed, which takes about 3 to 5 minutes. Finally, you ea... | [] |
Consider the digits of any integral base above one, listed in order. Subdivide them exactly in half repeatedly until every chunk of digits has odd length:
Base Digits Subdivided Digit Chunks
2 01 0 1
3 012 012
4 0123 0 1 2 3
5 01234... | [] |
Introduction
When a room has bare, parallel walls, it can create unpleasant repeating acoustic reflections (echoes). A diffuser is a device mounted on a wall which creates a blocky surface of many different heights. This has the effect of breaking up the reflected sound into many smaller reflections (each with a diff... | [] |
I've created a new language called "EasyFlow." Your task is to simplify writing BrainFlow programs by compiling EasyFlow to BrainFlow. That is, you take an EasyFlow program and output a BrainFlow program which does the same thing. EasyFlow is defined as follows:
The program starts out with a list of variables. A varia... | [] |
Consider these 15 ASCII playing card patterns (ace through Joker, and the back side), where X is a placeholder for the suit symbol: (they look better with less line spacing)
------------- ------------- ------------- ------------- ------------- ------------- ------------- ------------- ------------- -... | [] |
This is intended to be an easy, bite-size code-golf.
The mex (minimal excluded number) of a finite collection of numbers is the smallest non-negative integer 0, 1, 2, 3, 4, ... that does not appear in the collection. In other words, it's the minimum of the complement. The mex operation is central to the analysis of imp... | [] |
Winner
CJam, 74 bytes by Optimizer
Task
Take an input of an integer n through the console or a file.
Find the sum of the nth prime, square, triangular number, and cube. Add to that the factorial of the first decimal place of the square root of n and the xth Fibonacci number, where x is the first digit of the square of... | [] |
Introduction
You have the misfortune of being stuck in a runaway car on an obstacle course. All of the car's features are non-responsive, save for the steering system, which is damaged. It can drive straight, or it can turn right. Can the car be guided to safety?
Mechanics
Your car begins in the upper-left corner of... | [] |
Your job is to find the location (read index) of a given element X in an array gone through the following transformation process:
Take a fully sorted integer array of size N (N is known implicitly)
Take any random number of mutually exclusive even index pairs (as in that no index appears in more than 1 pair) from the ... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11
]
] |
The task is to draw a regular polygon of n sides using only a compass and an unmarked ruler.
Input (n) is one of the following 10 numbers: 3, 4, 5, 6, 8, 10, 12, 15, 16, 17.
Method: Because you only have a ruler and compass you can only draw points, lines and circles.
A line can only be drawn:
through two existing poi... | [] |
Note: although this is tagged as Python, other languages are permitted
Challenge
What you have to do is write the shortest functions to perform the same actions as the following Python 2 built in functions:
Range
>>> range(1, 10, 1)
[1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> range(1, 10, 2)
[1, 3, 5, 7, 9]
>>> range(10, 5, -1)
[1... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11
]
] |
Inspired by https://puzzling.stackexchange.com/q/626
In your adventures you arrive at a series of 7 bridges you have to cross. Underneath each bridge lives a troll. In order to cross the bridge, you must first give the troll a number of cakes as a percentage of the number of cakes you are carrying. Because these are k... | [] |
Bulgarian Solitaire is a single-player game made popular by Martin Gardner in his mathematical column in Scientific American.
You have N identical cards, split into piles. You take a card from each pile and form a new pile with the removed cards. You repeat this process until you reach a state you've already seen and s... | [] |
In one of the more iconic xkcd strips, Randall Munroe visualised the timelines of several films in narrative charts:
(Click for larger version.)
Source: xkcd No. 657.
Given a specification of the timeline of a movie (or some other narrative), you are to generate such a chart. This is a popularity contest, so the answe... | [] |
Emulate the Professor's typing
Background
Unfortunately, the Professor is not able to use his keyboard properly: whenever he is meant to use the Shift key, he presses Caps Lock once before typing, and doesn't bother to correct himself. If there are two or more keys in a row that require Shift, he presses Caps Lock befo... | [] |
So a colleaque came with this problem lately and I want to challange you to solve the problem in the code-golf style, shortest solution in any language wins.
The Problem:
Given is a random set of values, where the values themselfs are
not the concern, but the amount (which is random as well)of values.
To keep the post... | [] |
From Erich Friedman's Math Magic, (problem #2 on that page) your challenge is to find the edge elimination number of a connected graph.
A single edge elimination is the removal of an edge from a graph, without disconnecting the graph, except for creating lone vertices. For instance, in the graph below, the two leftmos... | [] |
The goal of this challenge is to write a program which takes a string (of any length) as input and displays anagrams (see these examples of anagrams) of this string, made by taking words in a dictionary (either individually or in pairs), but the anagrams don't need to be perfect.
An anagram is the result of a rearrange... | [] |
I've got a tough one for you!
My girlfriend recently came across a new show on MTV (USA). It's a terrible show, and everyone on it is trashy, but the "game" is pretty interesting. From Wikipedia:
Are You The One? follows 20 people who are living together in Hawaii to find their perfect match. If the 10 men and 10 wo... | [] |
Consider a randomized list of the integers 1 to N. You want to sort it using only the following actions:
Swap the first and last list elements. (S)
Pop off the first element and append it to the end of the list. (P)
This is always possible because any list can be sorted with enough swaps of adjacent elements. Using S... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11
]
] |
Sometimes when you press a key on a keyboard, the letter doesn't always display on screen. Whether this is because of a dodgy connection or otherwise, you have decided to write a script to control the probability of a letter displaying on screen when the corresponding key is pressed.
One day, you decide to buy a monke... | [] |
Introduction
Pi is
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089...
Let's treat each digit as an instruction as to how to get to the next digit.
The first digit is 3.
Counting three digits after the first digit, we arrive at 1.
One digit after this 1 is a 5.
Five digits after that ... | [] |
Challenge: implement calculation of a Delacorte Number in any language. Shortest code wins.
For a given square matrix of distinct integers 1..n² (possible side length n at least between 3 and 27), its Delacorte Number is the sum of the products gcd(a, b) × distance²(a, b) for each distinct pair of integers {a, b}.
The... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11
],
[
220,
16,
11,
220,
17,
11,
220,
18,
11,
220... |
Your job is to write a program (or two separate programs) in any language that:
Can take a completed Sudoku board as input (in any logical format) and compress it into a string of characters
Can take the compressed string as input and decompress it to get the exact same completed Sudoku board (output in any logical fo... | [] |
You are given integers N and M, 1 <= N,M <= 10^6 and indexes i and j. Your job is to find the integer at position [i][j]. The sequence looks like this (for N=M=5, i=1, j=3 the result is 23):
1 2 3 4 5
16 17 18 19 6
15 24 25 20 7
14 23 22 21 8
13 12 11 10 9
Shortest code wins. Good luck!
| [] |
Sequences
You are given four number sequences, numbered 1 through 4.
OEIS The location of 0's when the natural numbers are listed in binary. Here's an example of how to calculate the sequence:
0,1,10,11,100,101,110,111
^ ^ ^^ ^ ^
0 3 78 10 14
The start of the sequence goes like this: 0, 3, 7, ... | [] |
One of the games of the French TV show Des chiffres et des lettres, called Le compte est bon ('The total is right'), consists of the following :
You get a number A between 101 and 999 as well as six numbers E1,..,E6 chosen randomly, with possible repetitions, from {1,2,3,4,5,6,7,8,9,10,25,50,75,100}
The goal is to get ... | [] |
Your job is to convert decimals back into the sum of the square roots of integers. The result has to have an accuracy of at least 6 significant decimal digits.
Input:
A number indicating the number of square roots and a decimal indicating the number to approximate.
Example input:
2 3.414213562373095
Output:
Integers s... | [] |
Your goal is to implement Möbius inversion, a linear operation on a sequence of numbers that is used in combinatorics and number theory. Fewest bytes wins.
What is Möbius inversion?
Given a (finite) integer sequence f_1, f_2, ..., f_N, we can compute its divisor-partial-sum g, whose nth element g_n is the sum of all te... | [] |
Format
The format is a 64 bit value x representing a IEEE-754 double-precision binary floating-point number (a.k.a "a double"). x is assumed to represent a real number (not a NaN or Infinity).
Goal
The goal is to print/output the shortest string containing a decimal representation for which x is the closest IEEE 754 re... | [] |
Background
Consider a (closed) chain of rods, each of which has integer length. How many distinct hole-free polyominoes can you form with a given chain? Or in other words, how many different non-self-intersecting polygons with axis-aligned sides can you form with a given chain?
Let's look at an example. Consider a part... | [] |
What better problem for PCG.SE than to implement PCG, A Better Random Number Generator? This new paper claims to present a fast, hard-to-predict, small, statistically optimal random number generator.
Its minimal C implementation is just about nine lines:
// *Really* minimal PCG32 code / (c) 2014 M.E. O'Neill / pcg-rand... | [] |
Challenge
Your task in this question is to write a program or a named function which takes a positive integer n (greater than 0) as input via STDIN, ARGV or function arguments and outputs an array via STDOUT or function returned value.
Sounds simple enough ? Now here are the rules
The array will only contain integers ... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220
]
] |
Your goal is to display ASCII art of a formation in ten-pin bowling where only some of the pins remain. Fewest bytes wins.
The tens pins are in a triangular formation:
O O O O
O O O
O O
O
Pins are labelled from 1 to 10 as:
7 8 9 10
4 5 6
2 3
1
Drawing pins as O and missing pins as ., the formation 1 3 5 6... | [] |
Input
A list of nonnegative integers.
Output
The largest nonnegative integer h such that at least h of the numbers in the list are greater than or equal to h.
Test Cases
[0,0,0,0] -> 0
[12,312,33,12] -> 4
[1,2,3,4,5,6,7] -> 4
[22,33,1,2,4] -> 3
[1000,2,2,2] -> 2
[23,42,12,92,39,46,23,56,31,12,43,23,54,23,56,73,35,73,42... | [] |
Task
Print 0 if an n*m maze cannot be solved
Print 1 if an n*m maze can be solved (in 1 or more ways)
(so I'm not asking for paths but if it's possible to solve!!!)
Example
Input array(2d):
[[0,0,0,0,0,0,1],[0,0,0,0,0,1,0],[0,0,0,0,1,0,0],[1,0,0,0,0,0,0]]
XXXXXXXXX
XS XX
X X X
X X X
XX FX
XXXXXXXXX
... | [] |
In this challenge, your task is to construct an undirected graph from a sequence of directives. There is one directive for each nonnegative integer, and each transforms a given graph into a new one.
Directive 0: Add a new disconnected node.
Directive 1: Add a new node, and connect it to every existing node.
Directive ... | [] |
The game BattleBlock Theater occasionally contains a puzzle which is a generalised version of Lights Out. You've got three adjacent blocks, each of which indicates a level between 1 and 4 inclusive with bars, e.g.:
|
||||
||
If you touch a block, then that block as well as any adjacent block will increment its level (... | [] |
This is a loose continuation of my earlier challenge on constructing graphs.
Background
An eccentric artist has hired you to estimate the structural integrity of his sculptures. He creates his works of art by taking a bunch of cube-shaped magnets, and dropping them one by one into a huge pile. To better analyze his met... | [] |
This challenge was inspired by a question on Mathematica.SE.
Say you've got a nested list/array of some arbitrary structure (the lists at each level don't necessarily have the same length). For simplicity, we'll assume that the nodes are non-negative integers or empty arrays. As an example
[[[1, 3], 2], [1, 4], 12, [[0... | [] |
In the game of Freecell, you are tasked with building four foundation piles in suit from ace to king, on a layout where you build downward in alternating colours. However, you can only build one card at a time, so you are given four "free cells" each of which can contain one card to help you move entire sequences. The ... | [] |
Background
In this challenge, a partition of a set S means a collection of nonempty subsets of S, which are mutually disjoint and whose union is S. We say that a partition p is finer than another partition q (and q is coarser than p), if it can be obtained from q by splitting some of its sets into smaller pieces. The j... | [] |
Consider an array of bits, say
1 1 1 0 0 0 0 1 0 0 1 0 1 1 1 1 1 0 1 0
We call a contiguous subarray of length ≥ 5 a phase if at least 85% of the bits are the same and the first/last bits are both equal to the majority bit. Furthermore, we call a phase maximal if it is not a strict subarray of some other phase.
Here a... | [] |
I want to try a new form of code golf here. Similar to bonuses, not all parts of the challenge have to be completed, but each answer has to implement a subset of certain size (and there is a core that every answer has to implement). So besides the golfing this challenge also involves choosing a set of features that go ... | [] |
Input
Your input in this challenge is a list of integer pairs. They represent the southwest corners of unit squares on the plane, and the list represents their union as a subset of the plane. For example, the list
[(0,0),(1,0),(0,1),(1,1),(2,1),(1,2),(2,2)]
represents the red-colored set in this picture:
Output
Yor o... | [] |
All those questions that are duplicates... Ignored and marginalized by society. It is just not... right. We have to do something. There surely must be love for them too.
They feel appreciated if a piece of code outputs a link to a duplicate question. But the duplicate questions are not so easily impressed. They are swe... | [] |
Your program or function should output all the 36 4-perfect numbers in increasing order separated by newlines.
An n positive integer is a k-perfect number (multiply perfect number) if the sum of its divisors including itself (i.e. the sigma function of n) equals k*n.
For example 120 is a 3-perfect number because 1 + 2... | [
[
488,
220,
17,
488,
220,
18,
488,
220,
19,
488,
220,
20,
488
],
[
220,
18,
488,
220,
19,
488,
220,
20,
488,
220,
21,
488,
220
],
[
16,
488,
220,
17,
488,
220,
18,
488,
... |
Introduction
I want to find the substring with the most 1's in a sequence of 0's and 1's.
Input
Your program has two inputs, the sequence and the substring length.
The sequence is any number of 0's and 1's:
01001010101101111011101001010100010101101010101010101101101010010110110110
The substring length is any positive ... | [] |
This code-golf challenge is based on the following puzzle:
You have an odd number of tokens whose weights are known whole numbers, and they don't all have the same weight. Show that there's a token you can remove so that the remaining tokens can't be split into two equal-size sets that have the same total weight.
Her... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11
]
] |
In this pixelated font of uppercase letters of the alphabet, all the characters are 5 units wide and 5 tall.
███ ████ ███ ████ █████ █████ ████ █ █ █████ █ █ █ █ █ █
█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ██ ██
█████ ████ █ █ █ ████ ████ █ ██ █████ █ ... | [] |
This is based on xkcd #153.
Make a program or named function which takes 2 parameters, each of which is a string or a list or array of bytes or characters. The second parameter will only contain characters drawn from lrfu (or the equivalent ASCII bytes). It should be interpreted as a series of instructions to be perfor... | [] |
Background
This is a continuation of my earlier challenge, where the task was to compute the shape of a sculpture obtained by dropping magnets into a huge pile.
Good news: the eccentric artist liked your work, and has another project for you. He still works with magnetic sculptures, but has decided to expand his art st... | [] |
In statistics, sometimes it's useful to know whether two data samples come from the same underlying distribution. One way to do this is to use the two-sample Kolmogorov-Smirnov test.
Your task will be to write a program that reads in two unsorted nonnegative integer arrays and calculates the main statistic used in the ... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
Here is a simple, bite-sized (byte-sized?) code golf: given a non-empty list of positive integers less than 10, print a block-diagonal matrix, where the list specifies the size of the blocks, in order. The blocks must consist of positive integers less than 10. So if you're given as input
[5 1 1 2 3 1]
Your output coul... | [] |
The Hamming(7,4) code goes back to 1950. Back then Richard Hamming worked as a mathematician at Bell Labs. Every Friday Hamming set the calculating machines to perform a series of calculation, and collected the results on the following Monday. Using parity checks, these machines were able to detect errors during the co... | [] |
Scenario:
Imagine a situation where you wish to share a unique alphanumeric code. Perhaps it is a one-time-use coupon code you hand write on business cards, or some other scenario where it is desirable to have a code where mis-keying the entry is unlikely to produce valid result and the another valid code is not readil... | [
[
425,
11,
356,
11,
422,
11,
468,
11,
434,
11,
479,
11,
472
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11
],
[
11,
356,
11,
422,
11,
468,
11,
434,
11,
... |
Story:
Lucy asked George what his Lucky Number was. After some contemplation, George replied that he had several Lucky Numbers. After some brief confusion, Lucy asked George what his first n Lucky Numbers are. George then asked you, his buddy, to write him a program to do the work for him.
The Challenge:
You will write... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11
]
] |
Background
A Davenport-Schinzel sequence has two positive integer parameters d and n. We will denote the set of all Davenport-Schinzel sequences for given parameters by DS(d,n).
Consider all sequences of the natural numbers 1 to n, inclusive, which satisfy:
No two consecutive numbers in the sequence are identical.
The... | [] |
One of the key parts of PNG's compression algorithm is the Paeth transformation, which transforms the image in a way that makes it compress better (usually). In this challenge, your task is to write a program to compute a Paeth transformation. The operation of a Paeth transformation is described below.
The Paeth Transf... | [] |
I have $15 in my pocket. Likewise, I am in a store which doesn't give change. While browsing, I spot an item that costs $10 (tax included). Can I buy that item without losing any money?
In this case, the answer is yes. No matter how my $15 is divided up (one 10 and one 5, or three 5s, or something else), I will alw... | [] |
... Ah sorry, no popcorn here, just POPCNT.
Write the shortest program or function which takes in a number n and output all integers from 0 to 2n - 1, in ascending order of number of 1 bits in the binary representation of the numbers (popcount). No duplicates allowed.
The order of numbers with the same popcount is impl... | [] |
Introduction
I want to build a ladder.
For this, I have scavenged from the junkyard two long boards with holes in them, and I want to place the steps into these holes.
However, the holes are not evenly placed, so the steps will be a little wonky, and I find it hard to estimate the amount of rod I need for them.
Your jo... | [] |
Here's a pixelated 5 by 7 font for the digits 0 through 9:
.███.
█...█
█...█
█...█
█...█
█...█
.███.
..█..
███..
..█..
..█..
..█..
..█..
█████
.███.
█...█
....█
...█.
..█..
.█...
█████
.███.
█...█
....█
..██.
....█
█...█
.███.
█..█.
█..█.
█..█.
█████
...█.
...█.
...█.
█████
█....
█....
.███.
....█
█...█
.███.
.██... | [] |
The Shotgun numbers are a sequence with a rather simple definition but some interesting structure. Start with the natural numbers:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, ...
Now take all numbers at indices divisible by 2, group them into pairs, and swap the numbers in each pair:
1, 2, 3... | [
[
11,
220,
16,
17,
11,
220,
16,
19,
11,
220,
16,
21,
11
],
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
... |
You should write a program or function which outputs or returns the sum of the digits in base b representation of the first n natural power of a in ascending order.
Example for a = 2, b = 3 and n = 4
The base10 numbers are 2^0, 2^1, 2^2 and 2^3.
Their base3 representations are 1, 2, 11, 22.
The digit sums are 1, 2, 2,... | [] |
99 (pronounced "ninety-nine") is a brand new Esoteric programming language (not to be confused with 99, note the italics). Your task in this challenge is to write an interpreter for 99 that is as short as possible. The submission with the fewest bytes wins. Tiebreaker goes to the submission posted first.
Since this que... | [] |
Given a number N, output a NxN right angled triangle, where each row i is filled with numbers up to i.
Example
n = 0
(no output)
n = 4
1
1 2
1 2 3
1 2 3 4
n = 10
1
1 2
1 2 3
.
.
.
1 2 3 4 5 6 7 8 9 10
(no alignment needed)
n = N
1
1 2
1 2 3
.
.
.
1 2 3 4 .... N
There is no trailing space at the end of each line.
Lea... | [] |
Write a function or complete program that takes a positive number n and performs n steps of an iterative algorithm for calculating π that has quadratic convergence (i.e. it approximately doubles the number of accurate digits at every iteration) then returns or prints out 2n correct digits (including the beginning 3). O... | [] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.