instruction stringlengths 34 53.1k |
|---|
The Devil's Staircase is a fractal-like function related to the Cantor set.
Your task is to replicate this funky function — in ASCII art!
Input
A single integer n >= 0, indicating the size of the output. Input may be given via STDIN, function argument or command-line argument.
Output
The ASCII-art rendition of the Dev... |
Definitions
Let m and n be positive integers. We say that m is a divisor twist of n if there exists integers 1 < a ≤ b such that n = a*b and m = (a - 1)*(b + 1) + 1. If m can be obtained from n by applying zero or more divisor twists to it, then m is a descendant of n. Note that every number is its own descendant.
For ... |
Heatmaps
Consider a rectangular room, on whose ceiling we have a thermal camera pointing downward. In the room, there are some number of heat sources of intensity 1-9, the background temperature being 0. The heat dissipates from each source, dropping by one unit per (non-diagonal) step. For example, the 20x10 room
....... |
For a given DAG (directed acyclic graph), each of its topological sorts is a permutation of all vertices, where for every edges (u,v) in the DAG, u appears before v in the permutation.
Your task is to calculate the total number of topological sorts of a given DAG.
Rules
You can use any format to represent the graph, l... |
My daughter had the following assignment for her math homework. Imagine six friends living on a line, named E, F, G, H, J and K. Their positions on the line are as indicated (not to scale) below:
Thus, F lives five units from E, and two units from G, and so forth.
Your assignment: craft a program that identifies a pat... |
Years ago I read the "Best of Ruby Quiz" book by James Edward Gray II (also available online by now). For problem 2 in the book (which is problem 14 on his original RubyQuiz site), he mentions a golfed solution in under 300 bytes, even though he is not a big fan of golfing.
So I did wonder if I could beat that and mayb... |
NOTE: This challenge is currently dead, as I'm unable to install the languages needed to run a match. If someone else has the time and interest to do it, I'm not opposed.
See the bottom of the post for a leaderboard.
This is a semi-cooperative king-of-the-hill challenge, where the bots construct paths through a two-dim... |
Counting the amount of triangles in a picture is a task commonly used in brain tests. You are given a picture that contains shapes consisting of triangles. You then must find all possible triangles in the picture.
Task
You are given a list of lines in a format of your choice. You must then output a list of triangles fo... |
Your task, if you choose to accept it, is to write a program/function that accepts an integer \$N\$ as input. The program/function should output/return a list of the first \$N\$ prime numbers. But here's the catch: you are not allowed to use prime characters in your code. A prime character is a character whose Unicode ... |
This challenge is brought to you by real (and tragic) inspiration. Recently, the number row on my keyboard has been a bit sporadic. The keys 1-9 work sometimes--but other times they have no result. As an avid programmer, this is horrible! (See that exclamation point? That's how you know they're working right now.) Not ... |
The English language and most programming languages are written and read from left-to-right, top-to-bottom, but that needn't be the case.
In fact for the block of text
ABC
DEF
I can think of eight related ways it might be read:
Left-to-right, top-to-bottom (LTR-TTB): ABCDEF
Top-to-bottom, left-to-right (TTB-LTR): ADB... |
Sometimes I need to write more documentation than just comments in code. And sometimes, those explanations need screenshots. Sometimes the conditions to get such a screenshot are so weird that I ask a developer to take a screenshot for me. Sometimes the screenshot does not fit my specifications and I have to resize it ... |
Let's assign the numbers 0 through 94 to the 95 printable ASCII characters:
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
Space is 0, ! is 1, and so on until ~ is 94. We'll also assign 95 to tab (\t) and 96 to newline (\n).
Now consider the infinite string whose Nth cha... |
Noel Constant did it without genius and without spies.
His system was so idiotically simple that some people can't understand it, no
matter how often is is explained. The people who can't understand it are people
who have to believe, for their own peace of mind, that tremendous wealth can be
produced only by thr... |
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... |
Rosetta Stone Code Challenges are challenges where you must complete the task in as many languages as possible.
The Challenge
You will be given two numbers, n and s, in a list as input. The n will be a number you have to count up to. n will be any number from 2 to 10000. s will be the number you skip by when counting u... |
There's a board with n squares in a horizontal row.
You start in the leftmost square, and roll a 3-faced dice.
3 possible outcomes for a single roll of the die:
Left: you move 1 step to the left, if possible.
None: you stay where you are
Right: you move 1 step to the right, if possible.
You want to roll the dice exac... |
Today I realised that I often like to define sections in my code like so:
####################
# Helper Functions #
####################
But that it's tedious to do. Assuming I have a line such as this:
# Helper Functions #
What is the shortest set of vim keystrokes to wrap it in a #? Shift does not count as a keystr... |
The major system is a mnemonic device for converting numbers into words so they can be memorized more easily.
It is based on how words sound phonetically, but to keep things simple for the challenge we'll only be concerned with how words are spelled. This means there will be some incorrect conversions, but that's alrig... |
About the Series
First off, you may treat this like any other code golf challenge, and answer it without worrying about the series at all. However, there is a leaderboard across all challenges. You can find the leaderboard along with some more information about the series in the first post.
Although I have a bunch of i... |
Given a list of integers produce a Forward Difference at a specified order/depth.
For the list of integers:
(10, 18, -12, 4, 8, -3, -5, 67, 9, 14)
The Forward Differences at the various orders/depths are:
0 10, 18, -12, 4, 8, -3, -5, 67, 9, 14
1 8, -30, 16, 4, -11, -2, 72, -58, 5
2 ... |
Note: This isn't as much a golfing challenge; it is more so asking for golfing suggestions.
Recently I had a Python assignment for my web development class, in order to check whether we could code. Since I already feel comfortable in Python, I decided to try and golf it, and I was wondering if people could point out th... |
Introduction
In this challenge, your task is to correctly list the cases of two Finnish nouns.
The twist is that you may use one of the listings as a guide to produce the other.
The Nouns
We use the following two declination tables as our data.
They list the cases of two nouns, one case per line in the same order as in... |
Food shortage in the Snakepit
For the first time in 35 years, the snakepit is running out of food. The inhabitant snakes now have to fight each other in order to survive this food shortage. Only one snake can stand at the top of the food chain!
Leaderboard
Not here yet!
Last update on February, 24th
Link to visualizat... |
Since I've been seeing more ><> submissions floating around lately, I thought it might be a good idea to have a tips page.
Please stick to one tip per post, unless they are closely related.
Official Python interpreter
Official Interpreter on TIO
Online interpreter (some bugs present, but good for most cases)
Another O... |
Write a rectangular block of text that when arranged into a Sierpinski carpet, using same-sized blocks of spaces for the empty portions, creates a program that outputs the iteration number of the carpet.
For example, if your text block is
TXT
BLK
then running the program
TXTTXTTXT
BLKBLKBLK
TXT TXT
BLK BLK
TXTTXTT... |
Updated Results
Introduction
To celebrate Monster Hunter 4 Ultimate launch on new 3DS (February 13th), here's a King of the Hill themed on this game.
You are a novice hunter, who'll take part in a tournament consisting of 5 consecutives hunts. At the end of these hunts, hunters will be ranked depending on the damage th... |
I am curious if I am Code Golfing properly. I set the challenge for myself to make a small hashing program into a single statement in Python. I first started off with:
from itertools import permutations
from string import ascii_lowercase
from random import sample
def test():
chars = sample(ascii_lowercase, 9)
... |
Write a quine that consists of real English words separated by single spaces. A "word" is defined as a string containing only lowercase and uppercase letters (/[a-zA-Z]+/ in regex). To be "real" your word must be recognized by the official Scrabble dictionary.
I'm using the Scrabble dictionary since it gives a definiti... |
Input
Two lists A and B of nonnegative integers.
Output
Either 1, 0, or -1, depending on whether A is larger than, equal to, or smaller than B with respect to the twisted lexicographical ordering as defined below.
If you want, you can replace 1, 0 and -1 with any other three constant values.
The twisted lexicographical... |
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... |
Recently, when doing some code-golf challenge, I came up with with two solutions, in 69 and 105 bytes. It's a remarkable coincidence, because:
69 (decimal) = 105 (octal)
69 (hexadecimal) = 105 (decimal)
What other numbers have this property (using different bases)? You should help me answer this question!
Write a pro... |
This king-of-the-hill game is a strategy game in which you must throw around a water balloon and avoid getting splashed by water. The goal is to obtain the most points. You will be given a map of the field and the location of the water balloon. You can either return that you want to hit the water balloon (if you are cl... |
Introduction
In this challenge you will be solving diagonal Burrows-Wheeler transforms. Here is a general overview of what a diagonal Burrows-Wheeler transform is. To encode a message, you first must guarantee that it is odd in length (i.e. 5, 7, 9, etc.). Then you make a grid, n by n, where n is the length of the mess... |
A comment I made in chat and the ensuing conversation inspired me to make this challenge.
Am I the only one referred to by initials around here? We are all about golfing things down. We can have MB and D-nob and ... O.
If I'm known as "CH" then I think everyone else ought to have an initial-based nickname as well.
He... |
... 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... |
For the purposes of this challenge, let's define a cyclic number as an integer that passes the basic part of Midy's Theorem, but not necessarily the extended theorem. This means:
the digits in the second half of the repeating decimal period are [integer is] the 9s complement of the corresponding digits in its first ha... |
This challenge is about writing code to solve the following problem.
Given two strings A and B, your code should output the start and end indices of a substring of A with the following properties.
The substring of A should also match some substring of B with up to one substitution of a single character in the string.
... |
Topping the Charts
You are a record label company. Your goal is to get 4 of your signed bands in the top 4 positions in the charts. However, its recently been noted that bands currently in the charts influence who is going to be in the charts the next day.
In this challenge, each player will control 5 bands (instance... |
Introduction
In this challenge you will be solving date shift ciphers. Here is a general overview of what a date shift cipher is. To encode a message, you first must make a key. A key in a date shift cipher is any date converted into the form of MMDDYYYY (Adding zeros at the beginning of each part to keep the key 8 lon... |
Write a function/program that accepts a string of lower/uppercase letters [A-Za-z] as input, that checks whether the occuring letters are unique and in alphabetical order (ignoring lower and uppercase) or not. The output must be truthy if they are unique and in alphabetical order and falsy if not.
Here some testcases
a... |
We define a Collatz-like sequence s with 4 positive integers:
n starting value
d > 1 divisor
m > 1 multiplier
i increment
(In the original Collatz sequence d = 2 m = 3 and i = 1.)
Given these integers s will be created in the following manner:
s(0) = n
if k > 0 and s(k-1) mod d = 0 then s(k) = s(k-1) / d
if k > 0 an... |
I have bunch of hexagonal rods glued together into an odd sculpture. The rods
are 1 to 99 centimetres (cm) long and 1 square cm in cross-section area. All
rods are glued on a hexagonal face to at least one other rod. The rods are all
aligned at their bottom edge.
After some heavy rain, the sculpture is full of water. H... |
Prelude is an esoteric programming language, which has very few, but unusual, restrictions on what constitutes a valid program. Any block of printable ASCII text ("block" meaning that lines of printable ASCII are separated by newlines - 0x0A) is valid provided that:
Every (vertical) column of text contains at most one... |
Your work is to recreate this piece of art:
_____
|
|
|
|
_____|
|
|
|
|
_____|
|
|... |
This challenge is about writing code to solve the following problem.
Given two strings A and B, your code should output the start and end indices of a substring of A with the following properties.
The substring of A should also match some substring of B.
There should be no longer substring of A that satisfies the firs... |
Given a list of strings, find the smallest square matrix that contains each of the initial strings. The strings may appear horizontally, vertically or diagonally and forwards or backwards like in this question Word Search Puzzle.
Words should be placed in the square, with at least one word in each direction (horizonta... |
Write a program or function that takes in a positive integer N, and prints or returns an N×N ASCII art string whose top half is a semicircle made of ('s and whose bottom half is a downward-pointing triangle made of V's, with spaces used as padding.
In other words, make an ASCII ice cream cone: (output for N = 17)
... |
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... |
Edit
I have posted a 250 lines reference implementation for review at CR, discussing the major class of the code. Download the complete Visual Studio 2013, .NET 4.5 source code (10 kB) from my server.
Story
This is based on a real world puzzle.
A colleague had a very old program. It was announced to be discontinued by ... |
The task is simple: write assembly that computes the order of magnitude of an integer using as few clock cycles as possible.
Order of magnitude is defined as log10, not log2.
The range of valid input is 0 to 1012, inclusive. Behaviour for input outside that range is undefined.
Values should be rounded down to the near... |
Here's a pixelated 5 by 7 font for the digits 0 through 9:
.███.
█...█
█...█
█...█
█...█
█...█
.███.
..█..
███..
..█..
..█..
..█..
..█..
█████
.███.
█...█
....█
...█.
..█..
.█...
█████
.███.
█...█
....█
..██.
....█
█...█
.███.
█..█.
█..█.
█..█.
█████
...█.
...█.
...█.
█████
█....
█....
.███.
....█
█...█
.███.
.██... |
This is Fortnightly Challenge #6. Theme: Language Design
There's a chatroom for this challenge. Come and join us if you want to discuss ideas!
And now for something completely different...
This fortnight, we want to experiment with a new type of challenge. In this challenge, you will be designing a language! Pattern ... |
Input: You will be passed a string containing a single english word. All letters will be lowercase, and there will be no non-alphabetic characters in the string.
Output: You will return an integer from 1 to 7 representing how many syllables you think are in the word.
Scoring: Your program will be run against all of th... |
Once upon a time, I was reading this question/answer on Quora
Are there really programmers with computer science degrees who cannot pass the FizzBuzz test
This code is given as the obvious answer
for i in range(1, 100):
if i % 3 == 0 and i % 5 == 0:
print "FizzBuzz"
elif i % 3 == 0:
print "Fizz"... |
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... |
It's very simple: Your program or function should generate the following text:
Elizabeth obnoxiously quoted (just too rowdy for my peace): "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG," giving me a look.
Fine print
You may write a program or function, which returns the output as a string or printing it to STDOUT (or c... |
This challenge is simply to return a list of lists of integers, similar to the Python range function, except that each successive number must be that deep in lists.
Rules:
Create a program or a non-anonymous function
It should return or print the result
The result should be returned in a list (of lists) or array (of a... |
The Kolmogorov complexity of a string S is the length of the shortest program P, written in some programming language L, whose output is exactly S.
(Yes, the real definition is more formal but this will suffice for the challenge.)
Your task in this challenge is to write the shortest possible "Kolmogorov complexity solv... |
Believe it or not, the Sex Bob-ombs have become a world famous band and are currently on world tour! As their bookkeeper you must oversee their day to day finances and provide regular reports.
Every few weeks you compile a list of their expenses (in whole USD) in the order they were incurred.
For example, the list
378
... |
Write code to evaluate whether a chain of inequalities is true or false. An example input is the string
3<=4!=9>3==3
This is true because each of its components is true:
(3<=4) and (4!=9) and (9>3) and (3==3)
Input:
A string that represents a chain of one or more inequalities. The allowed comparison operators are
== ... |
The International Code of Signals flag alphabet is used by ships for communication, particularly for static signals.
Your challenge is to write a program or function that will take a string from STDIN or as an argument, and display the corresponding text in the ICS flag alphabet. If your language does not display to t... |
Similar to our threads for language-specific golfing tips: what are general tricks to shorten regular expressions?
I can see three uses of regex when it comes to golfing: classic regex golf ("here is a list that should match, and here is a list that should fail"), using regex to solve computational problems and regula... |
Background
For the purposes of this challenge, an n-state cellular automaton is simply a binary function f that takes two numbers from the state set {0, 1, ..., n-1} as inputs, and returns another number from that set as output.
It can be applied to a list of numbers L = [x0, x1, x2, ..., xk-1] of length at least 2 by
... |
You can find the Hack Assembly Language specification here: http://www.cs.huji.ac.il/course/2002/nand2tet/docs/ch_4_machine_language.pdf
You can download the Hack Computer emulator here:
http://www.nand2tetris.org/software.php
The goal is to write something similar to this:
int i = 1;
while(i<100){
i = i+i;
}
My... |
Your task is to create a random sequence of moves, which can be used to scramble a Rubik's Cube. Such a scramble is made up of exactly 25 moves. Each move consist of of the letters UDRLFB optionally followed by one of the suffixes '2.
This notation is called the Singmaster notation. UDRLFB represents one of the 6 faces... |
Define a prepend-append sequence of length n to be a permutation of the numbers 1, 2, ..., n that can be generated by the following procedure:
Start with the number 1.
For each number from 2 to n, place this number to the beginning or end of the sequence (either prepend or append it, hence the name of the sequence).
... |
The king of Ancient Rome is having difficulties determining if a magic square is valid or not, because the magic square he is checking does not include any separators between the numbers. He has hired a software engineer to help him determine if a magic square is valid or not.
Input Description
Input comes in on STDIN... |
Introduction
Tangrams are a classic puzzle involving arranging/fitting blocks into various shapes. From the Chinese 七巧板 - literally meaning "seven boards of skill". Let's take this idea and use the seven Tetrominos pieces to fill a grid.
Challenge
Write a function or program that takes an array of grid coordinates as... |
A short while, ago, @daniel_ernston sent the following challenge to @StackCodeGolf on Twitter:
@StackCodeGolf Your task is to build a program that uses the API of your choice to tweet its own source code. Shortest code wins, of course.
|
When you run your program first, it should print an integer sequence. The
second run should print the 'Mary had a little lamb' song. The third run should
produce an ASCII image file.
Scoring
Your score will be the sum of your bytes of code and any file content at the
start of each of the 3 runs. Lowest score wins.
For... |
You are given a list of (a,b), and a list of x. Compute the maximum ax+b for each x. You can assume a, b and x are non-negative integers.
Your program or function must run in expected (to the randomness if your code involves that, not the input) O(nlogn) time where n is the total input length (sum or maximum of the len... |
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,... |
I want to try a new type of regex golf challenge, which asks you to solve nontrivial computational tasks with nothing but regex substitution. To make this more possible and less of a chore, you will be allowed to apply several substitutions, one after the other.
The Challenge
We'll start simple: given a string containi... |
Write a named function or program that accepts a single integer N and prints (to STDOUT) or returns (as a string) the first N bars of the spiral below, beginning with the vertical bar in the center and spiraling clockwise outward.
_______________
/ _____________ \
/ / ___________ \ \
/ / / ___... |
This is an adaption of Core War, a programming KOTH dating back to the 20th century. To be more specific, it is using an incredibly simplified instruction set primarily based off of the original proposal.
Background
In Core War, there are two programs battling for control over the computer. The goal of each program is... |
The original 151 Pokemon, in an array format suitable for initializers:
["Bulbasaur", "Ivysaur", "Venusaur", "Charmander", "Charmeleon", "Charizard", "Squirtle", "Wartortle", "Blastoise", "Caterpie", "Metapod", "Butterfree", "Weedle", "Kakuna", "Beedrill", "Pidgey", "Pidgeotto", "Pidgeot", "Rattata", "Raticate", "Spear... |
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... |
Introduction
Most of you are familiar with the merge sort algorithm for sorting a list of numbers.
As part of the algorithm, one writes a helper function called merge that combines two sorted lists into one sorted list.
In Python-like pseudocode, the function usually looks something like this:
function merge(A, B):
C... |
This is a tips question for golfing in python.
In multiple golfs I've done in Python, a fixed value is assigned to one of two variables chosen by a Boolean. The chosen variable is overwritten by the given value, and the other is unchanged.
17 chars:
if b:y=z
else:x=z
Assigning a conditional value is easy, but assignin... |
Consider a potentially self-intersecting polygon, defined by a list of vertices in 2D space. E.g.
{{0, 0}, {5, 0}, {5, 4}, {1, 4}, {1, 2}, {3, 2}, {3, 3}, {2, 3}, {2, 1}, {4, 1}, {4, 5}, {0, 5}}
There are several ways to define the area of such a polygon, but the most interesting one is the even-odd rule. Taking any p... |
Challenge
Task
Given a number N, output 2 NxN squares; each line of each square is a random permutation of [0, N); the squares are separated by a newline
Rules
Produce a randomised list of length N, separated by space
Repeat this N*2 times
Separate each output with a newline, with 2 newlines at the midpoint
The value ... |
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... |
A downhill maze is given as a series of rows of space separated digits from 0 to 9 inclusive, plus one "S" and one "X", where the S denotes the start and the X denotes the finish. In a downhill maze, you may only go to a space that is adjacent to you to the north, south, east, or west (no diagonals), and you may only ... |
Background
I want to build a fence.
For that, I have collected a bunch of poles, and stuck them to the ground.
I have also collected lots of boards that I'll nail to the poles to make the actual fence.
I tend to get carried away when building stuff, and most likely I'll just keep nailing the boards to the poles until t... |
Sometimes, when I'm really bored (really bored), I like to draw a line segment and draw points on it.
First, I draw a line segment of a certain size, which is 2^N for some value of N. The line will be represented by a series of . characters.
................
Then, I plot a point at the left end. Points will be repre... |
(Inspired by an early draft of PhiNotPi's fractal line challenge.)
You're given a width W > 1, a height H > 1 and string consisting of 2(W+H-2) printable ASCII characters. The task is to print this string wrapped around a rectangle of the given width and height, starting in the top left corner, in a clockwise sense. Th... |
The size of the moon mystery
I am sure you have heard that the moon changes its size. When you're in love and you're lucky, the moon is almost twice in size compared to normal situations. Some people say the reason is the atmosphere which acts as a lens. Others think that it is only a matter of comparison to other obje... |
In some cases, often in physics, you have to sum graphs. Your challenge is to write, in a language of your choice, a program or function that takes multiple graphs as images, calculates all possible sums, and outputs the result.
Graphs
The graphs are images that contain a white (rgb(255, 255, 255)) background with a no... |
99 is a programming language I invented earlier this week for my challenge Write an interpreter for 99. (Invented but never needed to implement thanks to half a dozen of you. ;) ) The full language spec is in that challenge so I'm not bothering to repost it all here.
In 99 you can print individual ASCII characters to s... |
Happy Pi Day everyone! For no reason at all, I'm trying to construct a Monte Carlo estimator of Pi that is as short as possible. Can we construct one that can fit in a tweet?
To clarify, what I have in mind is the typical approach of drawing random points from the unit square and calculating the ratio that fall within ... |
Input
The name of a file in the raster graphics format of your choice. The chosen format must support at least 8 bits per channel and 3 channels.
Output
A file in the same format, with the same dimensions and pixels as the first, but whose pixels are grouped in descending order of the number of times they occur, sorted... |
Load an image into this stack snippet and move your mouse over it. A black curve that follows the hue angle, starting at your cursor point, will be drawn:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><style>canvas{border:1px solid black;}</style>Load an image: <input type='f... |
Because I can't concentrate on any task for more than about 5 seconds, I often find myself breaking up words into a sub-strings, each of which is a different length and doesn't contain any repeated characters. For example, the word "pasta" might be broken up in "past" & "a", "pas" & "ta", or "pa" & "sta" and you get th... |
Pyth is a golfing language based on Python. It uses prefix notation, with each command having a different arity (number of arguments it accepts).
Your task is to write a syntax checker for a (non-existent) Pyth-like language, Pith.
Pith's syntax
Pith only has 8 single-char commands:
01234()"
01234 each have arity of t... |
Yes, the good old GIF. Loved for its versatility, hated for its patents and partly obsoleted due to its limitations (and patents), GIF consists, at the core, of a color palette and a palette-indexed image compressed using the LZW algorithm.
Your task is to write a program that reads an image in ASCII PPM format ("P3" m... |
Following on from Monte Carlo estimator of Pi this challenge is to produce the shortest code for the constant Pi. Except here your code must output consecutive digits of pi forever.
This is code golf, so the shortest submission (in bytes) wins except that it must output the first 10,000 digits in less than 10 seconds ... |
Create a program, that converts input string to a palindrome starting with the input string. The program itself must be a palindrome.
For example input: neverod, print neveroddoreven. You should handle multi-word, multi-line inputs as well.
|
This code-challenge is related to the code-golf question Analyzing Collatz-like sequences but the goal is quite different here.
If you are familiar with Collatz-like sequences you can skip to the section "The task".
We define a Collatz-like rule with 3 positive integers:
d > 1 divisor
m > 1 multiplier
i > 0 increment
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.