instruction_seed stringlengths 292 48.7k | found_ngrams sequencelengths 0 21 |
|---|---|
Write the shortest program in your favourite language to interpret a brainfuck program. The program is read from a file. Input and output are standard input and standard output.
Cell size: 8bit unsigned. Overflow is undefined.
Array size: 30000 bytes (not circled)
Bad commands are not part of the input
Comments begin ... | [] |
The Fibonacci sequence is a sequence of numbers, where every number in the sequence is the sum of the two numbers preceding it. The first two numbers in the sequence are both 1. Here are the first few terms:
1 1 2 3 5 8 13 21 34 55 89 ...
Write the shortest code that either:
Generates the Fibonacci sequence without... | [] |
I am referring to Project Euler #12. Write the solution in any language you want, but consume the least amount of memory while executing. Running time is not measure in this case.
The sequence of triangle numbers is
generated by adding the natural
numbers. So the 7th triangle number
would be 1 + 2 + 3 + 4 + 5 +... | [
[
488,
220,
17,
488,
220,
18,
488,
220,
19,
488,
220,
20,
488
],
[
18,
488,
220,
19,
488,
220,
20,
488,
220,
21,
488,
220,
22
],
[
220,
16,
488,
220,
17,
488,
220,
18,
... |
Task description:
Write a program as short as possible to draw a radial gradient in ASCII art. The size of the output grid is predefined. The center point and the characters to be used for the gradient are provided as input to the program.
The gradient will be 70×25 character cells in size with the following specificat... | [] |
Your task is to tack on a feature to a programming language, either by implementing a very clever library, or by processing the input text and/or tweaking the compilation process.
Ideas:
Add PHP-style presentation interleaving to C (e.g. <?c printf("Hello,"); ?> world!).
Add a null coalescing operator to one of those ... | [] |
Given a 20×20 grid of non-negative integers, find a 3×3 sub-grid where the
product of the sums of the individual lines hits the maximum. Spoken in
formulas:
Given the 3×3 sub-grid
$$\mathfrak{U} = \left(\begin{matrix}
x_{11} & x_{12} & x_{13} \\
x_{21} & x_{22} & x_{23} \\
x_{31} & x_{32} & x_{33}
\end{matrix}\right)$$... | [] |
Write a program rotates some Cartesian coordinates through an angle about the origin (0.0,0.0). The angle and coordinates will be read from a single line of stdin in the following format:
angle x1,y1 x2,y2 x3,y3 ...
eg.
3.14159265358979 1.0,0.0 0.0,1.0 1.0,1.0 0.0,0.0
The results should be printed to stdout in the ... | [] |
The GolfScript language has one serious lack, no float or fixed point handling. Remedy this by creating a function F for converting an integer number, given as a string, to a string representing 1 / 10 000 000 000 of it's value. The function must handle both positive and negative values as well as leading 0s.
The follo... | [] |
In 1939 Juzuk described a way to generate the fourth powers of natural numbers.
Group the natural numbers like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ...
Scratch each second group:
1 4 5 6 11 12 13 14 15 ...
The sum of the n remaining groups is n**4.
Input: none
Task: print the fourth powers upto 1... | [] |
Your task is to write a program, in any language, that adds two floating point numbers together WITHOUT using any fractional or floating point maths. Integer maths is allowed.
Format
The format for the numbers are strings containing 1's and 0's which represent the binary value of a IEEE 754 32-bit float. For example th... | [] |
Create a routine that takes an array of blocks in one numeric base system, and convert them to an array of blocks in another numeric base system. Both the from and to systems are arbitrary and should be accepted as a parameter. The input array can be an arbitrary length (If using a language where array lengths are no... | [] |
There is a well-known theorem that any permutation can be decomposed into a set of cycles. Your job is to write the shortest possible program to do so.
Input:
Two lines. The first contains a number N, the second contains N distinct integers in the range [0,N-1] separated by spaces. These integers represent a permuta... | [] |
Given a square of positive, natural numbers write a program find a horizontal and a vertical path with the sum of numbers along them being maximal. A horizontal path goes from the first column to the last and has to increase its column position by one in each step. A vertical path goes from the first row to the last an... | [] |
The shortest code to pass all possibilities wins.
In mathematics, the persistence of a number measures how many times a certain operation must be applied to its digits until some certain fixed condition is reached. You can determine the additive persistence of a positive integer by adding the digits of the integer and... | [] |
Mr Jones wants to do a round-trip on his bicycle. He wants to visit several cities in arbitrary order, but his route must not cross it self, since he hates to be at the same place twice in his holidays. As he really loves cycling, the length of his route is completely irrelevant, but he dislikes to drive around the lan... | [] |
The shortest code to pass all possibilities wins
Many grid based games have been made that start off with a grid of lights that are switched on. Pressing any of the lights causes that light and the four lights adjacent to it to be toggled. When a light is toggled, it is turned off or turned on, depending on if it was... | [] |
The general SAT (boolean satisfiability) problem is NP-complete. But 2-SAT, where each clause has only 2 variables, is in P. Write a solver for 2-SAT.
Input:
A 2-SAT instance, encoded in CNF as follows. The first line contains V, the number of boolean variables and N, the number of clauses. Then N lines follow, eac... | [] |
PHP has closures, let's play around with them.
I have some arrays similar to, $wannabelist = array (1, 2, 3, 4, 5, 6).
I want to do this: compr( expression($params), $wannabelist, $wannabilist2 ...).
compr() should do the following:
Take all the possible combinations of elements of the arrays given as parameters;
Pass... | [
[
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
]
] |
A happy number is defined by the following process. Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends ... | [] |
You are given a bunch of weights, and your task is to build a small balanced mobile using those weights.
The input is a list of integer weights in the range 1 through 9, inclusive. There may be duplicates.
The output is an ascii picture of a mobile that, when hung, would balance. Perhaps best shown by example:
input
... | [] |
For a given positive integer number N, write a complete program to find the minimal natural M such that the product of digits of M is equal N. N is less than 1,000,000,000. If no M exists, print -1. Your code should not take more than 10 secs for any case.
Sample Inputs
1
3
15
10
123456789
32
432
1296
Sample Outputs
... | [] |
Write the "fastest" program to print an incrementing series of squares from a given input to a given input.
Example input:
-2
7
Example output:
4, 1, 0, 1, 4, 9, 16, 25, 36, 49
When using a "cryptic" language, please post the pseudocode, in addition to your program.
The entries will be judged on the most efficient al... | [] |
Write a program to find the sum of all odd numbers between a given range [a,b]. Input consists of a single line containing two integers a and b separated by a space. 0 ≤ a,b ≤ 1,000,000,000,000. Your program should not take more than 10 secs.
Sample Inputs
1 5
4 8
1 8
0 5
Sample Outputs
9
12
16
9
| [] |
Given two numbers r and n on separate lines, write a program to print n natural numbers starting from 1 onwards, excluding the r-th powers. For example,
If r=2 and n=10, the results would be 2,3,5,6,7,8,10,11,12,13
4 and 9 were excluded because 4 is 2^2 and 9 is 3^2
Sample Input
2
10
Sample Output
2 3 5 6 7 8 10 11 12... | [] |
The square number digit density (SNDD) of a number - invented by myself - is the ratio of the count of square numbers found in consecutive digits to the length of the number. For instance, 169 is a 3-digit number containing 4 square numbers - 1, 9, 16, 169 - and thus has a square number digit density of 4/3, or 1.33. ... | [] |
Interpret a triple of 32-bit integers as a vector of 32 integers modulo 5. Write an addition routine for these vectors.
Example:
def add32((a0,a1,a2),(b0,b1,b2)):
c0 = c1 = c2 = 0
m = 1
for i in range(32):
a = ((a0//m)&1) + 2*((a1//m)&1) + 4*((a2//m)&1)
b = ((b0//m)&1) + 2*((b1//m)&1) + 4... | [] |
In The Art of Computer Programming, Knuth describes an algorithm to compute short addition chains. The algorithm works by computing a tree known as the Power Tree. The tree is rooted at 1, and each level is computed from the previous. Suppose we've computed level k. Then, for each node (n) in level k, and each ance... | [] |
Given a non-negative integer n, enumerate all palindromic numbers (in decimal) between 0 and n (inclusive range). A palindromic number remains the same when its digits are reversed.
The first palindromic numbers (in base 10) are given here:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99, 101,
111, ... | [
[
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... |
Here is a real question somebody asked me. Suppose you have n teams, one terrain.
Each team must play each other team exactly once.
The number of times a team plays two matches in a row should be minimized.
The problem is hard if not optimized. Your program should be able to answer this question for up to 6 teams (at... | [] |
This challenge is to compute the most efficient multiplication order for a product of several matrices.
The size of the matrices is specified on a single line of standard input. You should print to standard output a list of integers indicating the order in which to do the multiplications to minimize the total multipli... | [] |
Challenge
Being someone who plays far too much chess in his spare time, I thought I'd set a code golf challenge inspired by the game of chess (with a software flavour), for those interested.
The challenge is to determine the winner of a game of standard chess given a PGN (Portable Game Notation) file as input -- or in... | [] |
Assume an simple keyboard with this layout:
1 2 3 4 5 6 7 8 9 0
A B C D E F G H I J
K L M N O P Q R S T
U V W X Y Z . , ? !
Peter's keyboard pattern can be generated by starting at the top left of the keyboard, and displays the first three characters and a newline. It shifts over one character and displays the second,... | [] |
The Challenge
Print a nice Christmas tree with it's own star at the top using the shortest code possible. The tree star is an asterisk (*) and the tree body is made out of 0 The tree must be 10 rows high. Every row should be properly indented in the way that the previous row are centered over the next one. Any given ro... | [] |
Given a binary integer inclusively between 0 and 1111111111111111 (i.e. a 16-bit unsigned integer) as input, output the same integer in negabinary.
The input can be in whatever format is most convenient for your language; for example, if it is easier for the program to handle input with 16 digits, like 0000000000000101... | [] |
The PBM (Portable BitMap) format is a very simple ASCII black and white bitmap format.
Here's an example for the letter 'J' (copy-pasted from the wikipedia link):
P1
# This is an example bitmap of the letter "J"
6 10
0 0 0 0 1 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 0 0 1 0
1 0 0 0 1 0
0 1 1 1 0 0
0 0 0 ... | [] |
Note: A couple of answers have arrived. Consider upvoting newer answers too.
Common Lisp from happy5214
C from luser droog
Java from NeatMonster
Javascript from crempp
C from Mike C
C++ from Darius Goad
Postscript from luser droog
C++ from
JoeFish
Javascript from entirelysubjective
C from RichTX
C++ from Dave C
Hask... | [] |
The obvious solution would be to just print them as a string, but is it possible to write a shorter code?
Requirements:
No input should be processed, and the output should be in the form of 2 3 5 7 11 13 ... etc.
No reserved words in the language are used at all
The language should at least allow structured programmin... | [] |
When I saw the title of this closed question, I thought it looked like an interesting code golf challenge. So let me present it as such:
Challenge:
Write a program, expression or subroutine which, given an arithmetical expression in infix notation, like 1 + 2, outputs the same expression in postfix notation, i.e. 1 2 ... | [] |
How could we generate shapes or images using binary?
I got to messing around trying to create something that looked matrix like and got to thinking, wouldn't a great CodeGolf be to see who can make the best shortest code to generate a binary image?
Please advise me of any rules I should add.
Rules:
Create a binary ima... | [] |
The problem is very simple: write a program that accepts a single unsigned integer from the command line, and prints out that many random numbers on the standard output, in ascending order.
For example:
input:
5
output (you can use any type of whitespace):
557
9424
19212
32293
39135
However, you are not allowed to de... | [] |
Given two integers m and n, return the first m digits of sqrt(n), with the decimal point. They will be given with a space in between.
You only have to produce m digits: so if m=5, n=500, then the output will be 22.360, not 22.36067.
Do not use anything that will increase the precision of any operation.
Test Cases:
20 9... | [] |
Given some code in your language as a string, find and display all the variable names.
Examples in pseudocode:
a=2
b=3
for(i, 0->9) do b=b-10
if a=b then write "a equals b"
Returns: a b i
abcdefgh=20000000000000
bcdifhgs="hello"
if abcdefgh=bcdifhgs then da44="hax"
if abcdefgh*2=da44 then write da44
Returns: abcdefgh... | [] |
Overview:
Using you language of choice, implement a complete "half away from 0" rounding function in the shortest amount of code possible.
Rules/Constraints:
Direct, predefined Round-like functions are not allowed.
Floor/Ceiling-type functions are allowed, if your language supports these.
Function shall be able to han... | [] |
Seem like GolfScript wins all of these. So you can't beat them, join them.
Write an Self-Contained Golfscript Interpreter
I'm using the definition of self-contained to mean, a single program:- So no passing the buck to some external program to do the work for you.
Test Cases:
Strings and blocks are represented as li... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
16,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,... |
You can count 0, 1, 2, 3, 4.
But to get from 3 to 4 you have to change 3 bits at once.
Given a number of bits, how can you go through all numbers once,
but change at each step only 1! bit.
Here is an example for 3 bits:
000 100 110 010 011 111 101 001
so the output is:
0 1 3 2 6 7 5 4
Rules:
given a number of bits n... | [] |
Definition1
A Kolakoski sequence is a self-describing infinite sequence {kn} of alternating blocks of 1's and 2's, given by the following rules:
k0 = 1
kn = the length of the (n+1)'th block
The Task
Given a positive integer n, generate the first n elements of the Kolakoski sequence.
Details
Input will be provided ... | [] |
Inspired by the previous question.
Golomb's self-describing sequence g(n) is a sequence where any natural number n is repeated within the sequence g(n) times.
The first few numbers in the sequence are:
n 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
g(n) 1 2 2 3 3 4 4 4 5 5 5 6 6 6 6 7 ... | [] |
(Adapted from Problem C of the first qualifier of the ACM Programming Contest of 2012/2013)
You have several arrays, named \$A_1, A_2, ... , A_n\$, each sorted in ascending order. Every item in the array will be a 32-bit integer.
A sandwich is a set of indices \$j_1, j_2, ... , j_n\$ such that \$A_1[j_1] ≤ A_2[j_2] ≤ .... | [] |
Given
the number of goods N
positive weight of each good weight[N]
positive profit of each good profit[N]
and a positive number W which is the knapsack capacity.
This problem is called “the zero-one knapsack” for choosing the most beneficial goods for the knapsack of limited capacity.
Example:
The number of goods ... | [] |
Last week we had a programming contest in my university and I am very curious about one of the problems , one which only one team (but from another city) was able to solve. Maybe its not that hard, but I cant find any solutions that will take less than a second of execution time. The problem is the following:
Problem
Y... | [] |
A fragmented file is a file which is seperated into several parts on a harddrive, because it can't fit into a certain space.
On all harddrives, there are files called unmovable files, which are unmovable. To simulate real data on a harddrive, the input will also have unmovable files.
You are given several sequences of ... | [
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11
]
] |
The problem is as follows.
Input: An integer n
Output: The smallest prime bigger than n.
The challenge is to give the fastest code possible to do this. I will test the code on values starting at size roughly 10^8 10^200 and doubling in size until it takes more than one minute 10 seconds on my computer.
The winni... | [] |
Over at https://math.stackexchange.com/questions/33094/deleting-any-digit-yields-a-prime-is-there-a-name-for-this the following question is asked. How many primes are there that remain prime after you delete any one of its digits? For example 719 is such a prime as you get 71, 19 and 79. While this question is unresolv... | [] |
You are given a list of numbers L = [17, 5, 9, 17, 59, 14], a bag of operators O = {+:7, -:3, *:5, /:1} and a number N = 569.
Task
Output an equation that uses all numbers in L on the left-hand side and only the number N on the right-hand side. If this is not possible, output False. Example solution:
59*(17-5)-9*17+14... | [] |
Given a string of different characters, and a number n, generate all the ordered combinations with repetition, of length 1 to n, using those characters.
Another way to define it is to see the given characters as "custom" digits in the base (radix) of the number of characters, then the program should generate all the "n... | [] |
Your function takes a natural number and returns the smallest natural number that has exactly that amount of divisors, including itself.
Examples:
f(1) = 1 [1]
f(2) = 2 [1, 2]
f(3) = 4 [1, 2, 4]
f(4) = 6 [1, 2, 3, 6]
f(5) = 16 [1, 2, 4, 8, 16]
f(6) = 12 [1, 2, 3, 4, 6, 12]
...
The function doesn't have to return ... | [] |
Assuming 'lol' with a variavle number of 'o's. Print a the following phrase:
What does 1st, 2nd, 3rd, 4th ... 'o' stand for?
Examples:
lol -> What does 1st 'o' stand for?
loooool -> What does 1st, 2nd, 3rd, 4th, 5th 'o' stand for?
So far I managed to write a 128 characters solution in Perl:
$l=(<>=~tr/o//);print"... | [] |
Consider an expression 2^2^...^2 with n operators ^. Operator ^ means exponentiation ("to the power of"). Assume that it has no default assosiativity, so the expression needs to be fully parenthesized to become unambiguous. The number of ways to parenthesize the expression are given by Catalan numbers C_n=(2n)!/(n+1)!/... | [] |
You know that some decimal numbers can't be expressed as IEEE 754 floating points. You also know that arithmetic with floating points can give results that seem to be wrong:
System.out.print(4.0-3.1); (source)
0.2 + 0.04 = 0.24000000000000002 (source)
While one wrong number with an error that is this small might not ... | [] |
Everyone likes a good puzzle. After all, that's the basis for Code Golf and Code Challenge! What better puzzle exists than the famous Rubik's Cube? Well what else but her slightly larger sister, the Rubik's Revenge!
Rubik's Revenge Background
Released in 1982 following the success of the classic Rubik's Cube invent... | [] |
This is tangentially related to my quest to invent an esoteric programming language.
A table of the binary numbers 0 .. 15 can be used to implement a Universal Binary Function using indexing operations. Given two 1-bit inputs X and Y, all 16 possible functions can be encoded in a 4-bit opcode.
X Y F|0 1 2 3 4 5 6 7 8 ... | [] |
This is the Collatz Conjecture (OEIS A006577):
Start with an integer n > 1.
Repeat the following steps:
If n is even, divide it by 2.
If n is odd, multiply it by 3 and add 1.
It is proven that for all positive integers up to 5 * 260, or about 5764000000000000000, n will eventually become 1.
Your task is to find... | [] |
There is already a problem on here about calculating the total resistance of a resistor diagram. However, that problem deals only with series-parallel diagrams, which are trivially reducible. Here I present the question that includes nontrivial bridges and the like, and uses a slightly more convenient representation.
Y... | [] |
Your task is to build a piece of code that generates an aperiodic sequence of integers, either by outputting one every time it iterates, or by taking an integer n and returning the nth number in that sequence.
Now, the sequence 1, 2, 3, 4, 5, 6, ... is itself aperiodic, so I'm going to introduce a few limitations to th... | [
[
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... |
You must take input in the form of
title|line1|line2|(...)|line[n]
And output an information card. It's hard to explain how to make the card, so here's a quick example:
Input
1234567890|12345|1234567890123|pie|potato|unicorn
Output
/===============\
| 1234567890 |
|===============|
| 12345 |
| 123456789012... | [] |
Statement
The task is to synthesize sound (one note played) of some musical instrument (of your choice) using function in some general purpose programming language (of your choice).
There are two goals:
Quality of the resulting sound. It should resemble the real instrument as fine as possible;
Minimality. Keeping the ... | [] |
In this challenge, you will recieve a comma-separated list of weights as input, such as
1,3,4,7,8,11
And you must output the smallest amount of weights that can add to that set. For example, the output for this set would be
1,3,7
Because you could represent all of those weights with just those three:
1 = 1
3 ... | [] |
Multi palindromic numbers
Finding all number for which at least two** representation are palindromic, with more than one** characters, if in decimal, octal, hexadecimal, binary or in base64.
** have to be editable, see Variables below.
Edited: After lot of reflexion about comment from @DavidCarraher, I found an import... | [] |
You have a French deck of cards that sorted like this: 2 - 10, Princes, Queens, Kings, Aces.
The deck represented with array of numbers from 1 to 52(included)
Now the dealer is shuffling the deck 3 times and inserting a Joker in a random position of the deck.
The joker represented with the number 0
The idea of shufflin... | [] |
Upon receiving month and year in YYYYMM format, generate output of the corresponding calendar month for that year.
For example the input 201312 should generate the following output:
Mo Tu We Th Fr Sa Su
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
Only... | [] |
The 9 Hole Challenge
9 code golfing challenges of varying difficulty.
Penalties for using the same language more than once.
The question will be updated with pars, hole champions and trophy winners.
This comes from a competition I have with some friends, it's not the usual format, but I hope some of you will appreci... | [] |
Imagine a two-dimensional array of boolean values, where the 0s represent squares of grass on a rectangular plot of land and the 1s represent fences.
Write a function that accepts the 2D array as an input and determines whether you can travel from any one area of grass to any other area of grass, using only north/east/... | [] |
Write a function that rotates an integer array by a given number k.
k elements from the end should move to the beginning of array, and all other elements should move to right to make the space.
The rotation should be done in-place.
Algorithm should not run in more than O(n), where n is the size of array.
Also a constan... | [
[
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... |
Here's an interesting problem I thought of the other day, which involves bits of code competing against other bits of code not just in a property that the code has, but by playing a game against those other bits of code.
Your task is to build a program that takes the current state of a Go board, and determines what mov... | [] |
This will be my very first post on stackexchange so bear with me.
Create a program that counts from 0 to 1,000,000,000.
Now the trick is to not print all these characters but to only print how many zeroes are in that number. And keep track of the total amount of zeroes you've encountered. For example
10
Will output;
1... | [] |
This challenge is to write a program or script which counts the sum of all digits within the integers from 1 up to and including a given number.
Input, one positive integer.
Output, the sum of digits in that number and all smaller numbers.
Examples:
Input: 5
Integer Sequence: 1, 2, 3, 4, 5
Sum of Digits: 1 + 2 + 3 + 4... | [
[
488,
220,
21,
488,
220,
22,
488,
220,
23,
488,
220,
24,
488
],
[
18,
488,
220,
19,
488,
220,
20,
488,
220,
21,
488,
220,
22
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19... |
Given a unique, sorted list of integers, create a balanced binary-search tree represented as an array without using recursion.
For example:
func( [1,2,3,5,8,13,21] ) => [5,2,13,1,3,8,21]
Before we start, a hint: we can simplify this problem a ton so that we don't actually have to think about the input integers (or any... | [] |
0000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000
0000001111111111111100000000000000000011111111111111100000000000000000
000000111111111111110000000000000000... | [] |
Your program must output atleast half of its sourcecode in reverse. Any single part of the sourcecode as long as it is one single block of neighbouring characters.
Your program should not take any input (from user, filename, network or anything).
The output has some additional constraints. The character position (fir... | [
[
16,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
20
],
[
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
20,
11
]
] |
Terms
A worm is any list of nonnegative integers, and its rightmost (i.e., last) element is called the head. If the head is not 0, the worm has an active segment consisting of the longest contiguous block of elements that includes the head and has all of its elements at least as large as the head. The reduced active se... | [] |
Your task this time is to implement a variant of the POSIX expand(1) utility which expands tabs to spaces.
Your program is to take a tabstop specification and then read input on standard in and replace tab characters in the input with the appropriate amount of spaces to reach the next tabstop. The result should be wri... | [] |
You are a contractor for a company who designs electrical circuits for the various products they make. One day, the company accidentally gets a huge shipment of one-ohm resistors and absolutely nothing else, and give you the task of putting them to good use in the newest products they're making.
Your task is to build a... | [] |
Write a program that takes a sorted integer array, shuffles all the elements in such a way that for every i there must exist a j such that, one of the following is satisfied:
a[i] < a[j] < a[i+1]
a[i] > a[j] > a[i+1]
i and j are within the bounds of array.
If there are not many distinct elements, you must show an err... | [
[
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... |
A weird number is a number that the sum of proper divisors is greater than the number itself and no subset of proper divisors sum to that number.
Examples:
70 is a weird number because its proper divisors (1, 2, 5, 7, 10, 14, and 35) sum to 74, which is greater than 70, and no combination of these numbers sum to 70.
1... | [] |
Write a function or program that takes in a list and produces a list of the local extremes.
In a list [x_0, x_1, x_2...] a local extreme is an x_i such that x_(i-1) < x_i and x_(i+1) < x_i or x_(i-1) > x_i and x_(i+1) > x_i. Notice that the first and last elements of the list can never be local extremes.
So for some ex... | [] |
The challenge is to find the shortest implementation of the game of life in 3D (example). These are the rules:
Cells (in this case, cubes) with only 1 or less neighbours die, as if by lonliness.
If exactly 5 cells surround an empty cell, they breed and fill it.
If a cell has 8 or more neighbours, it dies from overcrowd... | [] |
Create a Sudoku solution CHECKER
There are oodles of Sudoku SOLVERS here, but I want you to create a solution CHECKER as small as humanly possible (code-golf).
A valid entry will be able to either take a 9x9 array as an argument (passed by reference, serialized on the command line, or however you want to take it) or... | [] |
Create a deterministic program to play nd tic-tac-toe with the other contestants.
Your program should work when n (width) and d (dimension number) are in these ranges:
n∈[3,∞)∩ℕ ie a natural number greater than 2
d∈[2,∞)∩ℕ ie a natural number greater than 1
n = 3; d = 2 (32 ie 3 by 3):
[][][]
[][][]
[][][]
n = 3; ... | [] |
Your challenge is to take input like this (a Hello World program):
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
And output a prompt (which will be "> "):
>
The user can then enter anything at the prompt. Your simple debugger must have these commands:
S - ... | [
[
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
]
] |
I once needed to write a function that calculates the block entropy of a given symbol series for a given block size and was surprised how short the result was. Thus I am challenging you to codegolf such a function. I am not telling you what I did for now (and in which language), but I will in a week or so, if nobody ca... | [] |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 10