instruction stringlengths 34 53.1k |
|---|
Article Spinning with Spintax
Article spinning is a search engine optimization technique by which search engine optimizers post a unique version of relevant content on article directories, web 2.0 sites, or other sources for backlinks.
It is occasionally used by website authors on their own sites but usually avoided b... |
Challenge and origin
On Stack Overflow a popular question is: How to convert byte size into human readable format in java? The most up voted answer has a quite nice method for doing this, but this is codegolf and we can do better, can't we?
Your challenge is to write a method or program that coverts the given
number... |
You're given a tree, which in computer science tradition, has the root at the top and leaves at the bottom. The leaf nodes are labelled with numbers. Your goal is to take the special leaf marked -1 and move it up to be the new root.
[3, [[16], -1], [4]] --> [[[[4], 3], [16]]]
You can imagine rotating the special lea... |
This question is an extension of Check if words are isomorphs and copies the first part of it to give the definition of an isomorph.
Two words are isomorphs if they have the same pattern of letter repetitions. For example, both ESTATE and DUELED have pattern abcdca
ESTATE
DUELED
abcdca
because letters 1 and 6 are th... |
A Chinese checkerboard looks like this (based on this question, but this time it has a fixed size):
G
. G
G G G
G G . G
B B B B . . Y G . Y . Y Y
B B B . . G . . . Y Y Y
B . B . . . . . Y . Y
B . . . . . . . . Y
. . . . . . . . .
. P . . . . . O O .
P P . . . . .... |
Longest day of the year - here's something to waste the extra time...
Overview
Note this is not a popularity contest and not a graphical output challenge - you are only required to output a string of 65,536 zeroes and ones. The Stack Snippet at the bottom of the question will display this as a 256 by 256 black and whi... |
Background:
MtDNA is a part of the human DNA that is passed from a mother to a child and it rarely mutates. Since this is true for all humans it is possible to create a huge tree that visualize how all humans are related to each other through their maternal ancestry all the way back to the hypothetical EVE. Every mutat... |
A covering array is an N by k array in which each element is one of {0, 1, ..., v-1} (so v symbols in total), and for any t columns chosen (so an N x t array) contains all possible v^t tuples at least once. The applications of Covering Arrays range from software and hardware testing, interaction testing, and many other... |
Write a program or function that duplicates letters in a word, so that all the duplicated letters arranged from left to right in the word would form the input array.
For example:
input: chameleon, [c,a,l,n]
output: cchaamelleonn
Input
The starting word (e.g. chameleon)
An array of characters ([c,a,l,n]) or a string t... |
Rocket Bots
The year is 3024. People have become too scarce a resource to risk in war, so combat has shifted to the robots. Your task is to construct a bot like no other, who's rockets will rain destruction down on your foes and shoot down all incoming threats.
Gameplay
Bots
Gameplay takes place on a 10x15 grid. Your b... |
Inspired by this link I found on Reddit.
A FuzzyFinder is a feature of many text editors. As you start to type a file path S, the FuzzyFinder kicks in and shows you all files in the current directory containing the string you entered, sorted by the position of S in the file.
Your task is to implement a fuzzy finder. It... |
It looks like a fun language, but the official site is down and the EsoLangs page doesn't explain it quite well and looks like it's missing stuff. Is there anywhere that the language is documented?
|
What general tips do you have for golfing in TI-BASIC for the TI-83/84+ series calculators? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to TI-BASIC (e.g. "remove comments" is not an answer).
Please post one tip per answer.
|
Atomic chess is a (very fun)
variant of chess in which every capture causes an "explosion," destroying the
captured piece, the piece doing the capturing, and all non-pawns in a 1-square
radius. The goal of this challenge is not to play an entire game of atomic
chess, but simply to simulate what happens when a certain m... |
Background
The Random Domino Automaton is a toy model for earthquakes, inspired by cellular automata.
In this challenge, your task is to simulate a simplified version of this model, and collect data out of it.
The automaton is defined on an array A of k bits, representing a fault line on which earthquakes may occur.
Th... |
Anybody can make the output of a program bigger by adding characters, so let's do the exact opposite.
Write a full program, an inner function or a snippet for a REPL environment in a language of your choice that satisfies the following criteria:
Your code must be at least 1 character long.
Running the original code pr... |
If you take a sheet of graph paper and draw a sloped line that goes m units right and n units up, you cross n-1 horizontal and m-1 vertical gridlines in some sequence. Write code to output that sequence.
For example, m=5 and n=3 gives:
Possibly related: Generating Euclidian rhythms, Fibonacci tilings, FizzBuzz
Input: ... |
Write a program or named function that will output or return the sequence up to the nth integer in the Iccanobif sequence, documented on OEIS as A014258. Note that only the zeroth element in the sequence (0) will be printed if n is zero.
The sequence is generated by starting like the standard Fibonacci sequence, but af... |
The Task
In this challenge, your task is to draw an ASCII art representation of several stacks of boxes of increasing height.
You are given as input the number of stacks, which is a positive integer.
The first stack contains one box of size 2x2.
The second stack contains 2 boxes of size 3x3.
In general, the kth stack c... |
When manufacturing chips, circular silicon wafers are cut into dies of needed size:
The goal of this challenge is maximizing the number of whole dies that can be cut from a wafer of a given diameter.
The machine puts the wafer into an angular compartment:
_____________________
| xxxxxx
| xxxxxxxxxxxx
| xxxxxxxxxx... |
Tasks
All competitors try to solve the following list of 10 tasks:
math
Read a positive integer n from input and return the sum of the cubes of the first n non-negative integers.
For input 1, this should return 0.
Read a positive integer n from input and return a truthy value if and only if n is a Mersenne prime.
Read... |
Square numbers are those that take the form of \$n^2\$ where \$n\$ is an integer. These are also called perfect squares, because when you take their square root you get an integer.
The first 10 square numbers are: (OEIS)
0, 1, 4, 9, 16, 25, 36, 49, 64, 81
Triangular numbers are numbers that can form an equilateral tri... |
Challenge
Given two inputs, a positive ion and a negative ion, you must output the formula for the ionic compound which would be made from the two ions. This basically means balancing out the charges so they equal zero.
Do not bother with formatting the formula with subscript numbers, but you must have brackets for the... |
Given an integer 2n, find the number of possible ways in which 2n^2 black pawns and 2n^2 white pawns can be arranged on a 2n by 2n chess board such that no pawn attack another.
A black pawn can attack only a white pawn, and vice versa.
The usual chess rules of attacking follow, i.e, white pawns attack squares immediat... |
In this challenge, you must display ASCII art of a water balloon given the
amount of water that the balloon is filled with:
| __||__ |
| / # #\ |
| |######| |
| |######| |
| |######| |
| |######| |
| |######| |
| \######/ |
| |
| |
+----------+
How to draw the balloon
To display a balloon of size... |
I work from Monday to Friday. I start my day at 8:12 and have lunch from 12:00 to 12:42. My workday ends at 16:30.
If you are wondering why 8:12 and 12:42:
8:00 is the goal, but I never actually make it
12:42 because I take 45 minute breaks, but this works better for the challenge spec
Challenge
Write a function o... |
Background
Hex is a two-player abstract strategy game played on a K×K rhombus of hexagonal tiles.
Two opposite sides of the rhombus are colored white, and the other two black, and the two players, black and white, take turns in placing a token of their color on an unoccupied tile.
The player who first manages to constr... |
Any regular hexagon can be tiled with diamonds, for instance like so (stolen from this question):
______
/_/_/\_\
/_/\_\/\_\
/\_\/_/\/_/\
\/_/\_\/_/\/
\_\/_/\_\/
\_\_\/_/
We'll consider the above a tiling of size 1 (since the diamonds' sides are made of one / or \ each). The same tiling of size 2 would look l... |
This is code golf. The winner is the valid code with the smallest number of bytes.
Challenge
Given inputs M and N, the width and height of a rectangular grid of squares, output a polygon that satisfies the following:
The polygon edges are made up only of square edges: there are no diagonal edges - all are vertical or... |
Nuggets of Code
It's a hypothetical situation where it is Friday evening, and you've invited over the usual golfing buddies to participate in your favourite hobby: code golfing. However, as this is such a brain-draining task, you need to pick up some brain food for the group so you can golf as much as possible off your... |
Goal
Your goal is to write "Code Golf" without using any letters [A-Z, a-z], even in your source code. It can't use of the following special characters either (!, _, <, (, ), ., {, }, ', and >).
Bonus / Scoring
If the code backwards also writes "Code Golf", you get -10.
Good luck!
Standard loopholes disallowed.
Min... |
Background
MIDI files are quite different from WAV or MP3 audio files. MP3 and WAV files contain bytes representing a "recording" of the audio, while MIDI files have a series of MIDI messages stored in MIDI events informing a MIDI synthesizer which virtual instrument to play or a MIDI sequencer the playback tempo that ... |
Notice: This king-of-the-hill challenge has completed. This means that the green checkmark, which has been awarded to C5H8NNaO4 for their entry The Observer will not be moved to any new answer.
You may still submit new entries, but there may be delays in new tournaments running as I am not actively checking for new en... |
There are more than 100 elements in the modern periodic table. You challenge is to output the rounded mass of an element with respect to the input given.
Input
Input will contain an abbreviation of an element.
Input can be taken from any one of the following:
stdin
command-line arguments
function arguments
Input wil... |
I designed a language in which pointer arithmetic is the main tool of programming.
Here are some examples.
(print 0 to 8)
=9[>1=9-*-1.>-1-1]
(print 1 to 10 with spaces in between, character literal extension used)
=1[.>1=10-*-1[>1=' '!>-2+1;-2];1]='\n'!
(compute the factorial of 10)
=10>1=*-1-1[>-1**1>1-1]>-1.
(prin... |
The goal of this challenge is to show how many characters are in the name of a given integer. This is code golf, so the smallest code wins.
RULES
The input will be between 0 and 100 (inclusive). If it is not the program won't return anything.
The result has to be printed as input : answer
Result for 100 is hundred
Fo... |
Given a natural number c as input, our task is finding the fastest way to calculate one -atleast- availabe integer solution (a,b) of pell equation c=a²-b².
Rules
Built-in functions and loopholes arent given any interest.
The program deals with integers (signed), the input is not supposed to abuse this range.
Output can... |
You are transported in a parallel universe where people write mathematical equations on computers as ASCII art by hand. As a LaTeX addict, this is totally unacceptable, and you ought to automate this process somewhat.
Your goal is to write a program that outputs an ASCII version of an equation inputed as a LaTeX math ... |
Given an unsorted list of unique, positive integers, output the shortest list of the longest possible ranges of sequential integers.
INPUT
An unsorted list of unique, positive integers
e.g. 9 13 3 11 8 4 10 15
Input can be taken from any one of the following:
stdin
command-line arguments
function arguments
OUTP... |
Try to write the shortest program or function you can that prints or returns the calculated orthocenter of a triangle.
The orthocenter of a triangle is the intersection point of the three altitudes of a triangle. The altitude of a triangle is a perpendicular segment from the vertex of the triangle to the opposite side... |
(I meant to post this while 1542: Scheduling Conflict
was still the current xkcd, but I had a scheduling conflict.)
Input
The input will be a list of 3n elements, which represent n events. The
first element in each group of 3 will be the name of an event; the second and
third, the start and end time respectively. For ... |
(This is my first Q here, and I don't know much about code golfing.)
Your aim is to predict the winner of an ongoing Snakes and Ladders game.
INPUT
A single number (2-1000) indicating the number of spaces on the board, say x.
Another number (2-4) indicating number of players, say n.
n numbers, each giving the position... |
The game
Nim is a mathematical strategy game, where 2 players take turns taking items from distinct heaps. On your turn, you must take at least one item, and you may take as many as you want, provided that you only take from one heap. The player that takes the last item wins! This is a solved game. Before I go into the... |
This is a simple one: print an ASCII Gantt chart.
Given tasks' ranges (start-time - end-time Tuples), print a Gantt timeline in the form of - characters for each task duration - each task in a new line.
Example
Say my tasks ranges are 28->35, 34->40, 39->44, the Gantt will look like this:
--... |
Challenge
Given guitar tablature you must output the song represented by the tab. This may be to the speakers of your computer or to an audio file (.wav, .mp3, .midi, .aiff, etc.). There will also be a second input for timing.
The tabs may be input via a file or straight to STDIN. The tab will be in ASCII form.
Spec
Al... |
The challenge is to write a program which outputs all characters of the Unicode table from n to z range.
For code "0000" is the first in order and you must skip all blank Unicode combinations.
For example, let n = 134 and z = 300, you must save or print all unicode characters between 0134 and 0300.
The output of the pr... |
INPUT: Any string consisting exclusively of lowercase letters via function argument, command line argument, STDIN, or similar.
OUTPUT: Print or return a number that will represent the sum of the distances of the letters according to the following metric:
You take the first and second letter and count the distance betwe... |
Since today marks the occasion of the 26th leap second ever to occur, your challenge will be to output the date and time of every leap second in GMT or UTC that has occurred so far, as well as the one to occur today.
Input
There is no input.
Output
1972-06-30 23:59:60
1972-12-31 23:59:60
1973-12-31 23:59:60
1974-12-31 ... |
Write a program or function that takes in a string through STDIN or function parameters, tokenizes it by parenthesis, and outputs the tokens on different lines. If the string contains a parentheses error, the program/function must output a falsey value or error message.
Examples:
Input: abc(def)ghi
Output:
abc ghi
... |
Write a program or a function that will output a given string in a staircase fashion, writing each part of a word that starts with a vowel one line below the previous part.
For example:
Input: Programming Puzzles and Code Golf
Output: Pr P C G
ogr uzzl and od olf
... |
This challenge is the first of a series of fewest-operations problems that should be written in the GOLF CPU. You can find the next one here
A partition of a number, N, is a list of numbers that add up to N. A prime partition is a list of prime numbers that add up to N.
For this challenge, you are given a single inte... |
Background
The metallic means, starting with the famous golden mean, are defined for every natural number (positive integer), and each one is an irrational constant (it has an infinite non-recurring decimal expansion).
For a natural number , the metallic mean is the root of a quadratic equation
The roots are always
... |
You may write a program or function that receives an odd, positive integer n, where n >= 3, as either a function argument, command line arguments, or on STDIN (or equivalent for your system), and prints to STDOUT (or system equivalent) an ASCII spiral that spins inward clockwise where the top edge is exactly n characte... |
For an N by N image, find a set of pixels such that no separation distance is present more than once. That is, if two pixels are separated by a distance d, then they are the only two pixels that are separated by exactly d (using Euclidean distance). Note that d need not be integer.
The challenge is to find a larger suc... |
The program must output the letter that is paired the most. For example, if your program was given the following string:
"Sally's friend Bobby searched for seashells."
it must output L because "ll" occurs twice, which is more frequent than the other pair "bb".
Rules:
If more than one letter has 1st place for occurre... |
NetHack is a roguelike game where a player must retrieve the Amulet of Yendor from the lowest level of the dungeon. Commonly played via telnet, the entire game is represented with ASCII graphics. The game is extremely challenging and requires knowledge of many game mechanics in order to succeed.
For the purposes of thi... |
Wireworld is fun for the whole family! Your goal is to create a Wireworld implementation in the shortest amount of code possible.
A Wireworld cell can be in one of four different states, usually numbered 0–3 in software, modeled by colors in the examples here:
Empty (Black)
Electron head (Blue)
Electron tail (Red)
Co... |
Recursive Binary Description
Recently, I made my very first contribution to OEIS by extending and adding a b-file to sequence A049064. The sequence starts with 0, and then the next values are derived from giving a "binary description" of the last item.
For example, the second term would be 10, because there was one 0 ... |
Background
The move-to-front transform (MTF) is a data encoding algorithm designed to improve the performance of entropy encoding techniques.
In the bzip2 compression algorithm, it is applied after the Burrows–Wheeler transform (as seen in Burrows, Wheeler and Back), with the objective of turning groups of repeated cha... |
Write a program or function which, when run, outputs another program or function which is valid in the same language as the original program, and which itself will output another program or function that has the same properties. You must at one point end up back to your initial program or function.
Example
Suppose you ... |
You're sitting in the school cafeteria, microwaving your food like you always do around lunch. Suddenly the programming devil rises from the ashes of your burnt food and proposes a challenge:
Sup guys, I have a challenge.
How did this happen? What did you ever do wrong? Was it that one bad macro in C?
The programming... |
OH GODS NO!! You can't leave us here with Doorknob! It'll be nethack everywhere! - 1d ago by Geobits
Well, couldn't disappoint...
Introduction
(you can skip this section if you don't care about exposition and/or if you have Tab Explosion Syndrome)
One of the characteristic mechanics of Nethack (and Rogue, and similar... |
Special Independence Day (USA) themed challenge for you today. You must write a program that prints this ascii-art representation of The American Flag.
0
|---------------------------------------------------------
| * * * * * * #################################|
| * * * * * ... |
Introduction
What you have to do is, given an an ASCII diagram of a chemical, output the chemical formula.
Rules
Your code must not access the internet and may not use a stored library of molecules. You may have a library of elements.
You must verify all of the elements included in the formula are real, with all elemen... |
Inspired by Print the American Flag! this is a direct copy but with the British flag as it has some symmetries but is still quite complex!
Your challenge is to produce the following ASCII-Art in as few bytes as possible! Turn your head/screen (not both!) by 90 degrees to view it properly.
_____________________________... |
Squaring the Square is a process of tiling a square using only other squares. If this tiling only uses squares of different sizes, then it is considered to be perfect. The smallest possible perfect squared square is a 112x112 square tiled using 21 different squares.
I have created the ascii art version of this squar... |
As the title suggests, my task is fairly straightforward:
Write a program in your language of choice that will print out the first 20 Fibonacci numbers using the least unique characters.
For example in Python 2:
def fib(n):
a,b = 1,1
for i in range(n-1):
a,b = b,a+b
return a
for i in range(1,21):print fib(i)
... |
The task is simple, post 2 code snippets that perform the same task, where one seems very optimized at first glance, but actually is significantly slower than the other.
Only one rule:
Both snippets must finish with the exact same output (for the same given input, if any).
|
Here we go again! This is my last flag for now!
I originally wanted to do my national flag but I thought the stars were too hard so I posted Print the British Flag! instead, which itself was inspired by Print the American Flag!. This challenge would be better for 3 September (Australian National Flag Day) or 26 January... |
The following is inspired by a question that came up on Stack Overflow today.
Given a number of microseconds, 0 <= n <= 86400000000 (e.g. 12345678900), output a formatted string hh:mm:ss:000:000, e.g. 03:25:45:678:900.
0 -> '00:00:00:000:000'
12345678900 -> '03:25:45:678:900'
86400000000 -> '24:00:00:000:000'... |
It seems flags are a trend now, so what better place to start an account? I thought bars could use a twist to them, so I found this flag.
Produce the following in the console output the fewest possible bytes:
+----------------------------------+
|XXXXX |
|XXXXXXXX |
... |
In the English language, a surefire way to make a pronounceable nonsense letter combination is to make it entirely out of consonant-vowel pairs, e.g., Wu ko pa ha, or, Me fa ro, consonant first, followed by vowel.
Challenge:
Write a program or function that will, given a user-specified number of letters, create a rando... |
A language that is very useful in restricted source and other such challenges is Unary, a brainfuck derivative in which programs are written in with only one character. Your job is to write a program to convert programs from brainfuck to unary and a program to do the opposite, both programs in the same language. Your s... |
The six main cast members of the American sitcom Friends all agreed that they would be paid the same salary throughout the run of the series (after season 2, at least). But that doesn't mean that they all had the same amount of air time or that they all interacted on screen with each other the same amount.
In this chal... |
This challenge was posted on the DailyProgrammer subreddit, and I figured it would be a great candidate for a code golf challenge. Determining if a letter balances is based on its distance from the point of balance, and the letter's value. The value of a letter can be determined by either taking its one-indexed positio... |
Any binary floating point can be formatted exactly in decimal. The resulting string might be somewhat long, but it is possible. In my article on floating point I cover the importance of precision, and now I want this function. This challenge is to write a program, or function, that takes a floating point value as input... |
Incremental Game Time Format
Goal
Incremental games often have a countdown timer expressing the days, hours, minutes and seconds until a task is complete. Depending on the space available, they can be formatted as:
2d 13h
23h 59m 48s
14m
3h 0m 0s
The goal of this code golf is to write a function or program that perfo... |
Introduction
Everyone knows that the possibility of successfully navigating an asteroid field is approximately 3,720 to 1. But despite your warning, Han Solo is still willing to try his luck.
Fearing for your artificial life, you decide to code, in the ship's peculiar dialect (read: your preferred Code Golf language), ... |
Your task to to solve the SLCSC problem, which consists in finding the shortest possible code to solve the Longest Common Subsequence problem.
A valid solution to the LCS problem for two or more strings S1, … Sn is any string T of maximal length such that the characters of T appear in all Si, in the same order as in T.... |
There are 40 ways a directed Hamiltonian path can be arranged on a 3×3 grid:
This graphic (thanks Sp3000!) shows only the 20 undirected paths. Traverse each colored line in both directions for the 40 directed paths.
Challenge
Using only printable ASCII, write a 3×3 grid of characters, such as:
ABC
DEF
GHI
When each o... |
A friend of mine challenged me to write a function that works with both of these scenarios
add(1,2) // 3
add(1)(2) // 3
My instinct was the write an add() function that returns itself but I'm not sure I'm heading in the right direction. This failed.
function add(num1, num2){
if (num1 && num2){
return num... |
This challenge is the second of a series of fastest-code problems that should be written in the GOLF CPU. You can find the first here
For this problem, you are given the volume of a cuboid (A rectangular cube). Each of the side lengths are integers. You must return the number of distinct cuboids that have that volum... |
Given a necklace with color stones (yellow, white, brown, etc.) of at least two different colors, we describe that necklace using letters that correspond to each color, choosing an arbitrary starting point.
We try to answer these questions:
How many distinct colors does the necklace have?
What's the length of the long... |
Introduction
Time is confusing. Sixty seconds to a minute, sixty minutes to an hour, twenty-four hours to a day (and not to mention that pesky am/pm!).
There's no room for such silliness nowadays, so we've decided to adopt the only sensible alternative: decimal days! That is to say, each day is considered 1 whole unit,... |
SPICE is an electrical circuit simulation program originating from UC Berkeley. Your goal is to implement a minimalistic version which can solve for the nodal voltages and branch currents of a circuit composed of resistors and DC current sources.
Input Format
The input may come from a file, io stream, or the nearest eq... |
There is that famous riddle:
A bear walks 1 km south, 1 km east and 1 km north, and comes to the place it started from. What color is the bear?
This one is very old, so I'll generalize it:
A bear walks x km south, y km east and x km north, and comes to the place it started from. This bear thinks that the North Pole ... |
For a fixed n, consider the n by n Toeplitz matrices with entries which are either 0 or 1. The aim is to find maximum determinant over all such Toeplitz matrices.
Task
For each n from 1 upwards, output the maximum determinant over all n by n Toeplitz matrices with entries which are either 0 or 1. There should be one o... |
I define the n-th ternary as a ternary that returns n and has the form:
1 ? 2 ? 3 ? n - 1 ? n : 0 : 0 : 0 # n - 1 zeroes
Write a function or complete program that given an input n will output or return the n-th ternary. Code-Golf.
Testcases
0 #=> undefined behaviour
1 #=> 1
2 #=> 1 ? 2 : 0
3 #=> 1 ? 2 ? 3 : 0 : 0
10 ... |
Antiferromagnetism is what IBM researchers used to jump from a 1 terabyte disk to a 100 terabyte disk in the same amount of atoms.
In materials that exhibit antiferromagnetism, the magnetic moments of atoms or molecules, usually related to the spins of electrons, align in a regular pattern with neighboring spins (on d... |
In Dungeons and Dragons, some of the most important atributes of a character are the ability scores. There are 6 ability scores, for the six abilities. The abilities are Strength, Dexterity, Constitution, Intelligence, Wisdom and Charisma.
When determining the scores for a character, I use the following procedure: Roll... |
On some terminals, pressing backspace generates the control code ^H to delete the previous character. This gave rise to a snarky idiom where edits are feigned for comedic effect:
Be nice to this fool^H^H^H^Hgentleman, he's visiting from corporate
HQ.
Given a string with one or more ^H's, output the result of backsp... |
colors.rgb("blue") yields "#0000FF". colors.rgb("yellowish blue") yields NaN. colors.sort() yields "rainbow"
Using the rules set out in the image and its title text (quoted here), create a program that accepts all the given input and displays the appropriate output.
Input can be taken with stdin or nearest equivale... |
Introduction
The Dragon's Curve is a fractal curve that notably appears on section title pages of the Jurassic Park novel.
It can very simply be described as a process of folding a paper strip, as explained in the Wikipedia article about this curve.
The first few iterations of the generation of this curve look like thi... |
Hexadecimal is a base 16 counting system that goes from 0 to f. Your job is to make a counter that will display these numbers.
Example:
$ python counter.py
1 2 3 4 5 6 7 8 9 a b c d e f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30
Rules:
The numbers may be separa... |
Mahjong is a tile game that is immensely popular in Asia. It is typically played with four players, and the goal of the game is to be the first person to complete a valid hand using the tiles. In mahjong there are three tile suits plus honour tiles — for this challenge we will only consider hands formed using tiles fro... |
MS Paint was always a great time waster, but it was shunned by most graphic designers. Perhaps people lost interest because of the jarring color palette, or because of limited undo levels. Regardless, it's still possible to generate beautiful images with just the standard brush and default color palette.
Challenge
Usin... |
SF(n) is a function which computes the smallest prime factor for a given number n.
We'll call T(N) the sum of every SF(n) with 2 <= n <= N.
T(1) = 0 (the sum is over 0 summands)
T(2) = 2 (2 is the first prime)
T(3) = 5 = 2 + 3
T(4) = 7 = 2 + 3 + 2
T(5) = 12 = 2 + 3 + 2 + 5
...
T(10000) = 5786451
The winner will be the ... |
You are given a list of 2-tuples of positive integers, of the form:
a1 b1, a2 b2, ..., an bn
In other words, the 2-tuples are comma-separated, and the integers within each tuple are space-separated. All of the a numbers are in strictly increasing order, as well as the bs. Your goal is to "fill in the gaps." What is mea... |
I had to write a code for finding all non-empty sublists partitionings of a list:
def f(s):
if s:
for j in range(1,len(s)+1):
for p in f(s[j:]):
yield [s[:j]]+p
else:
yield []
I managed to shorten it (for Python 3.4+) to:
def f(s, p=[]):
if s:
for j in ra... |
Background
After applying the BWT (as seen in Burrows, Wheeler and Back) and the MTF (as seen in Move to the printable ASCII front), the bzip2 compressor applies a rather unique form of run-length encoding.
Definition
For the purpose of this challenge, we define the transformation BRLE as follows:
Given an input string... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.