instruction stringlengths 34 53.1k |
|---|
Overview:
Your challenge is to write a program that will play minesweeper optimally, giving the best move in any position. Moreover, you must do this on the largest board possible.
Game details: Minesweeper is a one player game, played on a rectangular board. At the beginning of the game, a specified number of mines ar... |
I have read a question similar to this. I found it interesting, and difficult so I rephrased the question as a code golf. (that question is closed )
Challenge:
In 1 million and 1 numbers, all the numbers having the duplicate except only one number . Write a program that can find this unique number.
Input form:
a t... |
Dark black ink has splattered all over your white sheet of printer paper! The obvious solution is to fold the paper so black and white parts meet and both become grey as the ink diffuses. Then unfold and refold until your paper is all equally grey.
Finding the best way to make these folds is your task in this coding ch... |
Note: I have accepted an answer, but I'm willing to accept a better answer if it comes.
Write a program that computes operations on sets. You may take input either from standard input or from command line arguments. Your program must be able to compute unions, intersections, relative complements, and cartesian products... |
Write a program that outputs the total number of characters and the frequency of each character in its source and its output. You must follow the format illustrated in the example.
Example
If your code was
abb1
Its output would have to be
My source has 4 characters.
1 is "a"
2 are "b"
1 is "1"
Besides unquoted numbers... |
The MU puzzle is a puzzle in which you find out whether you can turn MI into MU given the following operations:
If your string ends in I, you may add a U to the end. (e.g. MI -> MIU)
If your string begins with M, you may append a copy of the part after M to the string.
(e.g. MII -> MIIII)
If your string contains three... |
In this challenge, you must design a species of single-celled organisms to fight to the death in the petri-dish arena. The arena is represented as a rectangular grid, where each cell occupies one space:
.....x....
...x...o..
...x.c..o.
.......o..
Attributes
Every cell has three attributes. When specifying your cell sp... |
Here I found a cool math problem. I thought you could write some golfed code to compute all answers between x and x.(there is an infinite amount).
Problem:
Once upon a time, and old lady went to sell her vast quantity of eggs at the local market. When asked how many she had, she replied:
Son, I can't count past 100 but... |
I've compiled a mosaic of 2025 headshots from the avatars of the top Stack Overflow users.
(Click the image to view it full-size.)
Your task is to write an algorithm that will create an accurate photomosaic of another image using the 48×48 pixel avatars from this 45×45 grid of them.
Test Images
Here are the test image... |
Given a set of n elements, the challenge is to write a function who lists all the combinations of k elements of in this set.
Example
Set: [1, 7, 4]
Input: 2
Output: [1,7], [1,4], [7,4]
Example
Set: ["Charlie", "Alice", "Daniel", "Bob"]
Input: 2
Output ["Daniel", "Bob"], ["Charlie", "Alice"], ["Alice", "Daniel"], ["Cha... |
Few years ago, an esoteric programming language named 아희(Aheui) was created. Well, actually you don't need to know about this language or Korean characters.
Aheui uses stacks and a queue, but this time we use one stack and ignore other stacks and queue. You can push a number between 2 and 9 into a stack. You can do ari... |
Rule 110 is a cellular automaton with some interesting properties.
Your goal is to simulate a rule 110 in as few characters as possible.
For those who don't know, rule 110 is simulated line by line in a grid. Each square in a line of the grid looks at the squares above, above-left and above-right to determine what cel... |
A standard road intersection contains 4 sidewalk corners and four crosswalks connecting them. It could also have 2 diagonal walks.
sRRRRs
iOOOOi
dAAAAd
eDDDDe
side0----1walk
ROAD|\ /|ROAD
ROAD| \/ |ROAD
ROAD| /\ |ROAD
ROAD|/ \|ROAD
side2----3walk
wRRRRw
aOOOOa
lAAAAl
kDDDDk
Not all 6 ... |
Let's have a tank war!
Partially inspired by Destroy Them With Lazers
Objective
Your task is to control a tank. Move around and shoot other tanks and obstacles in the 2D battlefield. The last tank standing will be the winner!
Map format
Your tank will be on a 2D field based on an n by n grid of unit squares. I will dec... |
Your goal is to print the lyrics to the song "Twinkle Twinkle Little Star" as each note is played.
The computer's microphone will hear notes. If the pitch (but not necessarily the length) of the note is correct, print the appropriate syllable. Otherwise, do nothing. Each note will be at least half a second long, and th... |
This question is inspired by the cover of the book "Godel, Escher, Bach":
The challenge here is to write a function that tells if three given letters can produce a 3D sculpture that can be read from three sides.
For this exercise, the only letters you can use are 26 5px * 5px bitmaps:
Or in binary (A to Z):
01110 11... |
EDIT: The behavior may be inconsistent. Also, associative arrays are permitted.
Make a function that iterates through an indexed array, mapping a function of a single argument to each member of the array. The catch: introduce a hidden bug where the function is not correctly applied to at least one index of the input ar... |
Your task is to write a file which contains a line with many pep8 violations.
The rules:
We use pep8 version 1.5.7 and the default settings.
Calling pep8 with other command line options or using a custom rc file is not allowed.
Maximum line length 120 characters. You can violate E501, sure, but the line which yo... |
Write a program which enumerates points on a regular grid in the form of a spiral. The output should be the indices of the points (row-major) and the spiral should start at 0 and proceed anti-clockwise.
Here is an illustration of the problem:
Specifications:
Write a program which accepts two integers and writes the r... |
We all know the standard order of operations for math functions
(PEMDAS),
but what if we instead evaluated expressions left-to-right?
The Challenge
Given a string through standard input or through command line args, find the difference between the traditional evaluation (PEMDAS) and the in-order (left-to-right) evaluat... |
The popular .bz2 compression format is used to store all sorts of things. One of the more interesting features is that it consists of several independently decompressible blocks, allowing recovery of partial segments if the file is damaged. The bzip2recover program, included with bzip2, allows recovery of blocks from a... |
Intro
Consider a grid of the characters f A\/ such as
f f f
A
A / \
\ / A
A \/
/
\/
where:
f represents a faucet that pours a stream of water downward
A bifurcates the stream of water above so exactly half goes left and exactly half goes right
\ shifts the stream of water ab... |
The goal of this challenge is to write a program that will simulate a single round of Conway's Game of Life on an existing grid.
Input format:
Input will be read from stdin. The input will consist of a line containing two numbers, r and c, separated by a single space. These will be the number of rows and columns of the... |
Given a number, starting with 1, create new numbers (children) by taking the last digit, n, and concatenating 1 through n+1.
This seems to be a much better explanation of the sequence A071159.
Integers whose decimal expansion start with 1, do not contain zeros and each successive digit to the right is at most one gr... |
Given a sequence of letters, write a program to construct it using symbols on the periodic table. For example, given the input bacon, the program should output:
BaCoN
BAcON
BaCON
Note that capitalization is important. Standard loopholes apply. If a word can't be formed, any error message may be printed.
Edit: All poss... |
Given list of integers {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4}.
For those who interested these numbers are used in weekday calculation.
Weekday = (m[n] + d + y + y>>2 + y/400 - y/100) % 7;, where m[n] - expression I'm searching, d - day of month, y - year - (month <= 2).
Construct expression consisting of arithmetic, logi... |
Introduction
Recently, I was skyping with a bunch of friends and we got bored and had nothing to do, so we "invented" a "game" (some people in the comments pointed out that this game is playable online and very popular, so we definetely didn't invent it, although I hadn't seen it before). The reason I put the word "gam... |
In as few Unicode characters as possible, print the following (144 characters):
1, 2, 3 o'clock, 4 o'clock rock,
5, 6, 7 o'clock, 8 o'clock rock,
9, 10, 11 o'clock, 12 o'clock rock,
We're gonna rock around the clock tonight.
You must not use any numbers in your code, except the digit 1.
|
Write a function which gets as input a number (0 <= n <= 255) stored in 32-bit variable and returns non-zero integer if n is prime number and 0 otherwise.
Considern = 0 and n = 1 as non-primes.
Arrays and pointers are not allowed.
Score:
1 - for | & ^ ~ >> << operators
1.1 - for + - < > <= >= == != ! && || operators a... |
You mission today is to invent a text compressor.
Task
You'll write two functions:
The packer is a function that accepts a string of ASCII characters (U+0000 to U+007F) and outputs a Unicode string (U+0000 to U+10FFFF), containing the fewest characters possible.
The unpacker is a function that accepts an encoded Unico... |
Write a program that outputs the contents of the first HTML <code>...</code> block of the answer to this question that is just above yours when the answers are sorted by votes. Output Top! if you are the top answer.
Ignore answers that have negative votes or no <code>...</code> tags. The source of your program must app... |
The scenario
I drive along a road with my car and it begins to rain. The raindrops are falling on my window randomly and now i ask myself, where is the biggest connected wet area?
The task
To make it easier, the window is split in a matrix of 10*10 squares.
Your job is to find the biggest connected water-drop-area on t... |
Khinchin's constant is a curious mathematical constant that, according to Wolfram MathWold, is "notoriously difficult to calculate to high precision".
Here it is to 100 digits:
2.685452001065306445309714835481795693820382293994462953051152345557218859537152002801141174931847697...
Write a program in 64 bytes or less ... |
Courier Ception
The program must accept any string as input and output an pixel image that shows the input string in Courier. All the letters that contain a 'hole' (like abdegopqABDPQR etc) that is surrounded by black pixels must be also filled black.
Input
The Program must be able to accept any ASCII string as input. ... |
Introduction
Sisyphus was having some troubles at work lately. It seems he just never gets anything done, and he would love to find a solution to this problem.
His current employment requires rolling a rock up a hill. He usually does his job well, but every time he is near the top of the hill it rolls down again.
He is... |
Consider these seven ASCII train cars.
Engine (E)
__
====== \/
| [] |=========
| )
================
O-O-O O-O-O \\
Passenger car (P)
===============
| [] [] [] [] |
===============
O-O O-O
Boxcar (B)
===============
|-|-| | |-|-|
===============
O-O O-O
Tanker (T)
__... |
The scenario: You are a software designer working for a gov't-run company that designs license plates for cars and other vehicles. You've been asked to develop software that generates license plates. Before you got to work, your bosses laid down these ground rules.
A license plate cannot contain:
ASS
666
69<any numb... |
The Challenge
For a given set of n integers, write a program which will output its lexicographic index.
The Rules
The input must only be a set of unique non-negative integers separated by spaces.
You should output the lexicographic index (range 0 to n!-1 inclusive) of the permutation.
No permutation libraries or permu... |
Take a 2-dimensional grid and draw a number of line segments on it to represent mirrors. Now pick a point to place a theoretical laser and an angle to define the direction it's pointing. The question is: if your follow the laser beam path for some specified distance, what coordinate point are you at?
Example:
In this ... |
The contest is now over. Coward is the winner.
You can watch the last match here.
Suddenly zombies appear! OH NOES!
In this king-of-the-hill challenge, you must create a bot to survive the zombie apocalypse. Or at least, hold out for as long as possible.
At the start of the game, 50 instances of each entry will be ... |
You are a glob of slime. Naturally, being slime, you want to ooze over as much area as possible. But there are 3 other slimes who want to do the exact same thing. Who will be the superior slime?
Description
All slimes will be gathered into one arena. The judges (i.e. the control program) will go through an exhaustive l... |
The Hilbert curve is a space filling fractal that can be represented as a Lindenmayer system with successive generations that look like this:
Thanks to http://www.texample.net/tikz/examples/hilbert-curve/ for the image.
Goal
Write the shortest program possible (in bytes) that takes a positive integer n from stdin and ... |
Write program, which verifies Erdős–Straus conjecture.
Program should take as input one integern (3 <= n <= 1 000 000) and print triple of integers satisfying identity 4/n = 1/x + 1/y + 1/z, 0 < x < y < z.
Shortest code wins.
Some examples:
3 => {1, 4, 12}
4 => {2, 3, 6}
5 => {2, 4, 20}
1009 => {253, 85096, 1974822872}... |
I hate code bloat!
So I have decided to replace my Windows 7 system by a golfed version. However, I know that it is not easy, so let's build a prototype first. It will take a list of windows from the user and show them using a pseudo-graphic display on the standard output.
For example: user input:
0,0,15,10
15,10,20,1... |
Now that we have over a hundred ways to get stuck in a loop, the next challenge is to get out.
Specifically, write a piece of code with a (seemingly) infinite loop, but somehow manage to break out.
The "infinite loop" can be a statement like while true, for (;1>0;) or anything else which obviously lasts forever. Recurs... |
Given a setup of dominoes your task is to figure out which dominoes fall and which don't.
Input
Take a rectangular ASCII representation of a domino setup. The following characters are used for the ASCII grid:
(space): empty cell
|, -, /, \: dominoes
Dominoes can fall in 8 directions, which are represented by the fol... |
Your job is to animate this circle illusion. It looks like the points rotating inside of the circle, but they are actually just moving in straight lines.
Criterias
The result has to be animated. The way you do the animation is irrelevant, it can generate a .gif, it can draw to a window, some device screen or whatever... |
Imagine some cube which we can cut into smaller cubes without remaining pieces.
Find to how many cubes a cube can be cut.
For example, a cube can be cut into 8, 27 (obviously 3rd powers of integers) and 20 (19 small cubes plus one eight times the size of the others, see image).
See here some help: http://mathworld.wolf... |
Austin: "Who sent you?"
Mustafa: "You have to kill me!"
Austin: "Who sent you?"
Mustafa: "Kiss my ass, Powers!"
Austin: "Who sent you?"
Mustafa: "Dr. Evil."
(...)
Mustafa: "I can't stand to be asked the same question three times. It just irritates me."
You are to simulate a short dialogue in the spirit of Austin Pow... |
The Golf (re)Sort
Everyone is sorting arrays these days, and so do we at our day jobs. But we like to go out golfing. When we do, we sure like to take our time. It is important to have a stress free experience.
Since we like golfing so much, we have decided to make a sorting algorithm that will let us stay away from t... |
Imagine the following diagrams as sets of vertical criss-crossing tubes.
1 2 1 2 1 2 3 4
\ / \ / \ / \ /
X | | |
/ \ / \ / \ / \
2 1 1 2 | X |
\ / \ /
X X
/ \ / \
3 1 4 2
In the leftmost diagram, the 1 and 2 slide down t... |
This question is similar to Write a word equation solver by David Frank but different in three important ways: (1) David asked for just the first solution found, and I am asking for all the solutions. (2) I am asking to output the time required to solve the puzzle. And (3), it is a completely different undertaking to... |
You're tasked with writing a program that syllabifies words in a string of text, by separating them with a hyphen. That would be a lot of work, so you want to skip some parts, mainly because you don't want to have a table of the pronunciations required for perfect algorithm. You also want to make it as short (and thus ... |
Write program which finds shortest expression for big integer.
Expression may consist of + - * / ^ ! ( ) operations.
! stands for factorial, ^ - exponentiation, / - rational division.
Number itself should be printed when no shorter expression found.
Examples:
7 - 7
120 - 5!
19683 - 3^9
191102976 - 4!^6
Code which is a... |
Create an algorithm that uses Cramer's Rule (with determinants of matrices) to solve for the solutions of a system of linear equations. The code should work for an "n" number of variables.
You may use whatever data structure you want to hold the matrix and return the result
Note: Also, consider that a possible system ... |
Imagine a continuous 2-dimensional path that can only turn left, right, or go straight, cannot intersect itself, and must fill a rectangular grid such as the grid of pixels in an image. We'll call this kind of path a snake.
This enlarged example shows a snake path in a 10×4 grid that starts out red and increases in hu... |
Caveman mad. Other caveman take stick but stick was for me. Caveman fight!
Description
Caveman need sharp stick to stab other caveman. Other caveman also try to stab with sharp stick. Caveman can sharpen stick, poke with stick, or block poky sticks.
If caveman poke other caveman with sharp stick, other caveman run aw... |
Your task
.. is to do what Brian Fantana apparently couldn't do, and solve the 2x2x2 Rubik's Cube.
The Layout
- - A B - - - -
- - C D - - - -
E F G H I J K L
M N O P Q R S T
- - U V - - - -
- - W X - - - -
And will be given to you via stdin or the command line (your choice - plea... |
Create a program which can rearrange pixels in image so it can't be recognized.
However your program should able to convert it back to original image.
You can write two functions - for encoding and decoding, however one function which applied repeatedly gives original image (example in math - f(x) = 1 - x) is a bonus.
... |
I have thought up esoteric language Jumper. Later you will see why.
It operates with random-access-memory with bytes as cells. RAM is zero indexed and initially filled with zeros.
When trying access cells with negative indexes error should be displayed and program terminated.
When trying read at larger index than last... |
Input 5 integers: Landmark X & Y, Starting Point X & Y, and View Distance Radius D
Output 1 double: % chance of coming within D of Landmark (X,Y) ("seeing") when walking straight in a random direction from Starting Point (X,Y).
Assume that "random direction" shall be a direction uniform on [0,2π], the land is flat, and... |
Your task today is to create a HTML page.
This page, when opened in a browser, behaves as if the browser has a problem (hanging, crashing, network error, virus, etc.)
You can use all the HTML(5), CSS(3) and JavaScript features you want.
You can't use Flash or other plugins.
You can't provoke a real problem in the brow... |
Write a program that takes a birth date (month and day-of-month) as input and outputs the corresponding sign, element and quality of the western zodiac. For the purposes of this challenge, these are defined exactly as in the table in the linked wikipedia page:
Sign Date Range Element Qu... |
Groups are a widely used structure in Mathematics, and have applications in Computer Science. This code challenge is about the fewest # of characters to create a group table for the additive group Zn.
How the table is constructed: For Zn, the elements are {0, 1, 2, ..., n-1}. The table will have n rows and n columns. F... |
Write a program (the body of the function is enough) that accepts a string of alphanumeric characters and validates it according to ISO 13616:2007. The algorithm for validation is (source: wikipedia article on IBAN http://en.wikipedia.org/wiki/International_Bank_Account_Number):
Validating the IBAN An IBAN is validate... |
The problem appeared on the 2013 SJCNY High School Programming Contest. It was the last question in the set of problems and no team produced a correct answer during the 2.5 hours they had to work on it. Shortest solution that can handle the full range of inputs with a reasonable run time (say under 2 minutes on a Penti... |
This question originates in this reddit thread by reddit user taho_teg but it is expanded to a more general 'puzzle'.
You have a centrifuge with 24 holes for the vials uniformly distributed in a circle around the central axis. If you now have a number of vials and you want to start the centrifuge, you need to make sure... |
From http://en.wikipedia.org/wiki/Triangle:
Write a program that takes three 2d coordinate tuples (Cartesian), and classifies what shape these three points describe.
In almost all cases these points will describe a triangle of varying types. In some degenerate cases, the points will either describe a singular point ... |
Mr. Moneybags is a very rich man. He has an assistant Mr. Perfect, who one day, got very mad, and shredded some of Mr. Moneybag’s $100 bills! Mr. Moneybags decided to punish Mr. Perfect.
Mr. Moneybags tells Mr. Perfect to stack his money into different piles.
He starts with N (1 <= N <= 1,000,000, N odd) empty stacks... |
Imagine a rectangular grid of | characters represents the taut strings on a loom (the warp) that other threads (the weft), which we will represent as -, can be woven around.
Here is the unwoven warp of a 7×4 loom:
|||||||
|||||||
|||||||
|||||||
There are a number of ways the weft can be woven into the warp, the simpl... |
Most Recent Leaderboard @ 2014-08-02 12:00
| Pos # | Author | Name | Language | Score | Win | Draw | Loss | Avg. Dec. Time |
+-------+----------------------+-------------------------+------------+-------+-------+-------+-------+----------------+
| 1st | Emil | Po... |
Take a string of binary characters separated by a space, and convert it to an ASCII string.
For example...
1001000 1100101 1101100 1101100 1101111 100000 1010111 1101111 1110010 1101100 1100100
Would convert to...
Hello World
This is a code-golf challenge so the shortest solution wins.
|
At http://shakespeare.mit.edu/ you can find the full text of each of Shakespeare's plays on one page (e.g. Hamlet).
Write a script that takes in the url of a play from stdin, such as http://shakespeare.mit.edu/hamlet/full.html, and outputs the number of text characters each play character spoke to stdout, sorted accord... |
Read infinitely from stdin, and convert every number to the corresponding symbol on a US qwerty keyboard.
No string or character literals anywhere are permitted.
E.g. if the input is 117758326, the output is !!&&%*#@^.
Letters and symbols that aren't on numbers are left alone; 11g2;;'1g2311hh21930 turns into !!g@;;'!g... |
Write a program that outputs Lewis Carroll's poem The Mouse's Tale from Alice in Wonderland, drawn in its distinctive tail-like shape.
Plain text of the poem:
Fury said to a mouse, That he met in the house, 'Let us both go to law: I will prosecute you.— Come, I'll take no denial; We must have a trial: For really this... |
Problem:
In your choice of language, write the shortest function that returns the floor of the base-2 logarithm of an unsigned 64-bit integer, or –1 if passed a 0. (Note: This means the return type must be capable of expressing a negative value.)
Test cases:
Your function must work correctly for all inputs, but here ar... |
Problem:
In your choice of language, write the shortest function that returns the floor of the square root of an unsigned 64-bit integer.
Test cases:
Your function must work correctly for all inputs, but here are a few which help illustrate the idea:
INPUT ⟶ OUTPUT
0 ⟶ 0
... |
I just want to do some benchmarking of different programming languages. So here is a tip: You can use as many characters as you want. In the end there is only the time your program needed.
So, here is the Task:
Task
After searching for a good task that would require a lot of computation, I came up with the problem Is a... |
Starting with the string ABC, consider the result of repeatedly appending the last half of itself to itself (using the larger half if the length is odd).
We get the progression:
ABC
ABCBC
ABCBCCBC
ABCBCCBCCCBC
ABCBCCBCCCBCBCCCBC
etc...
Let S represent the resulting infinite string (or sequence) that results as this pr... |
Scenario
I am using pattern matching lockscreen and I sadly forgot my pattern. I would like to know how much time I will need to unlock it. Here are the specifications of Google's lock screen, that we will use for this challenge.
Every 5 wrong code, the user has to wait 30 seconds before any further entry.
A pattern m... |
A simple one today. Write the shortest program that draws a "sawtooth alphabet" given a positive integer for the height. You must write the name of your programming language when you come to the letter it starts with.
For example, if your language is Python and the input is 1 the output should be:
ABCDEFGHIJKLMNOPython... |
The ASCII characters from decimal code 33 to 126 are:
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
Notice that in most fonts, 25 of these characters have "holes" in them: (a genus greater than 0 you might say)
#$%&04689@ABDOPQRabdegopq
The other 68 "unholed" character... |
NOTE
This problem was taken from this reddit thread (spoiler alert!), and I have adjusted it to make it fit with this site's format. All credit goes to reddit user "Coder_d00d".
In this problem, we will simulate a forest.
For this simulated forest we will be dealing with 3 aspects.
Trees which can be a Sapling, Tree o... |
UPDATE: isSuicidal() was added to the plane class, this allows you to check if a plane is on an irreversible collision course with the walls!!
UPDATE: updateCoolDown() separated from simulateMove()
UPDATE: non-Java entry wrapper, written by Sparr, available for testing, see comments
UPDATE Zove Games Has written an aw... |
Pick your favorite 6 letter common English word that has no repeated letters, such as wombat.
Write a program in an N×N grid of characters without comments such that each row and column contains all the letters of your word in lowercase in any order. The program must output a definition of your word in 36 characters or... |
A date can be represented by an unsigned integer as such: YYYYMMDD. What you need to do, is write the shortest program or function that figures out the most recent date whose number was divisible by a given number n (including today's date) and then returns that date in the format showed above. If there has never been ... |
There was a challenge to convert a number to its numeral in English, but that was too straightforward. Given a number 0–100, your task is to output the corresponding numeral in French. The French numeral system has a more complex logic behind it compared to the English one:
Number Numeral
---------------
0 zéro... |
The number 113 is the first prime whose length 3 is prime, digital sum 5 = 1 + 1 + 3 is prime, and digital product 3 = 1 * 1 * 3 is prime.
A prime that has these 3 properties will be called supremely prime. The primes 11117 and 1111151 are other examples.
Goal
Write a program that can find the largest supremely prime n... |
Since I want to celebrate this definitely not nerdy event, your job is to calculate the piversary (pi-anniversary) of a given date.
Input
Your code has to have a possibilty to input a date in the format DD/MM/YYYY. You can expect, that the input is valid and the year is 0000<YYYY<9996.
Output
You have to release two da... |
Consider following recurrence relation:
p[n + 1] = (p[n]^2 + 1) / 2
If p[1], p[2], ..., p[k] are primes and p[k+1] is not, then k is length of sequence starting with p[1].
For example, if p[1] = 3, then p[2] = 5, p[3] = 13, p[4] = 85 = 5 * 17, thus length of sequence is 3.
Goal
Write program which find number producin... |
Welcome to the world of compiler golf. Your task is to write a program that generates another program to play a variant of FizzBuzz on spec.
Your compiler
Write a compiler that generates variants of the FizzBuzz program to spec. The spec of this variant is expressed in the form of an array of integer/string pairs.
The... |
Your life could depend on this. Don't blink. Don't even blink. Blink and you're dead. They are fast. Faster than you can believe. Don't turn your back, don't look away, and don't blink! Good luck.
Weeping Angels are an alien race that cannot move while being observed by another being (even another Angel). They feed ... |
Short version
RC4, designed in 1987, is one of the most famous stream ciphers. This question asks you to practically demonstrate its 2nd byte bias (for a theoretical proof, see section 3.2 of this paper).
Long version
OK, here I try to elaborate it for non-cryptographers. As you have noted, RC4 is a very popular cipher... |
Bracket numbers provide a simple way to express large integers using only left bracket, space, and right bracket ([ ]).
A bracket number is defined as a string of one or more pairs of matching brackets [...] called chunks, each separated from its neighbors by zero or more spaces.
The number of spaces between each chunk... |
You already know that the atoi function of stdlib.h converts a string to an integer.
atoi
(copied from here)
int atoi (const char * str);
Convert string to integer
Parses the C-string str interpreting its content as an integral number, which is returned as a value of type int.
Example
#include <stdio.h> /* pri... |
The challenge
In the least number of source code characters, in a language of your choosing, devise a function which raises base a to power b, modulo m, using purely integer arithmetic, where a, b, and m are all unsigned 64-bit values or larger. You may use signed arithmetic if your language does not have unsigned arit... |
Write the shortest program possible that traps the mouse cursor inside an upward pointing equilateral triangle with a side length of 274 pixels and a centroid at the exact middle of the screen.
(Triangle because of cheese wedges.)
While your program is running, the tip of the cursor should never be able to move outside... |
Echo the following in as few bytes as possible:
I'm Slim Shady. Yes, I'm the real Shady.
All you other Slim Shadys are just imitating.
So, won't the real Slim Shady please stand up?
Please stand up. Please stand up.
The following five words must appear EXACTLY ONCE in your code:
I'm
Slim
Shady
real
stand
|
Given a list of scores (non-negative integers) pre-sorted from greatest to least:
[ 10, 10, 6, 6, 4, 0]
Assign each score an integer rank, beginning with 1 and ascending, such that equal scores have the same rank (i.e. they are tied):
[ 1, 1, 3, 3, 5, 6 ]
In the case of ties, ranks are "skipped," e.g. since the f... |
Write a program that outputs a graph of the collatz sequence any way you want (ASCII Image Video etc). You have to implement it that way that you can adjust the size of the graph by either the maximum number of nodes or highest number in graph. A boring example here.
Try to present the graph in a creative / insightful ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.