instruction
stringlengths
34
53.1k
Calculate n modulo 12 for an unsigned 32 bit integer. The Rules: Must work for all n between 0 and 23. Other numbers optional. Must only use any of the operators +-*, ~&^| or <<, >> as commonly defined on 32 bit uints. May use arbitrary number of constant uints. May not use any form of pointers, including arrays, or ...
Input: you are given 2 integers, n and k. n is a positive (>= 1) integer, and k an integer, which is the number of times you are allowed to use n. Output: output all of the non-negative integers that can be formed using at most k n's using these mathematical operations: +, -, *, /, and parentheses. Edit: if your lang...
The scenario You live in a country that is having a presidential election. Each voter gets one vote, and therefore there is a firmly-entrenched two-party system. (Third parties exist, but get hardly any votes). The latest opinion poll shows the race in a dead heat: 49%: Alberto Arbusto 49%: Jorge Sangre 2%: various ...
for loops are useful in python in many ways, but one of the most common usages associated with a for loop is it's ability to repeat a certain amount of times. Like this: for times in range(50): print "I'm repeating this 50 times..." The challenge I propose to you is to make a for repeat forever. If you can find a ...
Your challenge is to create a clock that displays the time as a hex number, and the background color as the hex color code of the time. Requirements: No input. In the center of your output you should display the number sign and the current time in 24 hour format as "#hhmmss". The program should update to the current t...
I really hate looking up to the top right of the screen to look at the time on OS X's clock widget; I'd much rather keep my eyes at least somewhere near my workspace to check the time. I also hate other people using my clock to check the time as they walk by -- after all, it's called a personal computer, right? But we'...
Winner: professorfish's bash answer! An entire 9 bytes! Wow! You may continue to submit your answer, however you can no longer win. Original post kept for posterity: Your goal is to convert a whole number between 1-9 into the word it represents. You will not need to worry about decimals The user will input a number. ...
Let's discover1 some bugs... Write the shortest complete program possible that, when run on a stable release of an implementation of a language, demonstrates a bug in that implementation. Please specify which release and platform was used. This is code golf, so the shortest code (in bytes) wins. An implementation bug ...
Make a function that increments a number using only bitwise, loops, and conditions. Rules: All entries must be as per the language spec defined below. Scoring is not of code length, but of the points for each operation given below. The entry point is inc(a), for "increment and return a". Lowest score wins. See the e...
Represent poker cards as numbers from 0 to 51. 0 to 12 - all hearts from 2 to Ace, 13 to 25 all diamonds and so on. Your goal is to write a function for each poker hand type which generates a random 7-card hand (as in Texas Holdem on the river), in which the best 5-card combination is of the target type. The output is ...
This is one of my favourite poems I wanted to share. Especially because it looks good for compressing. Who cares about literature in the 21st century anyway. Goal Your goal is to write the shortest program possible that prints out the following poem: http://pastebin.com/aXV0C515 Rules The HQ9Monkey++ language is prohi...
You need to find the sum of minimum values of two list (same size) of small numbers. In a C like language, that could be expressed as: v = min(a[0],b[0]) + min(a[1],b[1])+ min(a[2],b[2]) ... The range of values is 0..7 and the 2 list can have up to 7 values. If you like, all the values in each list can be stored as a s...
You've been hired to write some code for a dictation-taking app, which takes voice input from a spoken source, parses it as words, and writes it down on a screen. The management doesn't really trust you with all that much powerin the project—you're known to sit around and golf code all day instead of doing your work, u...
Write a function (or macro) that returns true if and only if at least one of its arguments contains a call to the function itself and false otherwise. For example: int a=function(); //a==false int b=function(0); //b==false int c=function(function(0)); //c==true int d=function(3*function(1)+2); //d==true (weakly-typed l...
Your goal is to determine if a number is divisible by 3 without using conditionals. The input will be an unsigned 8 bit number from 0 to 255. Creativity encouraged! You are ONLY allowed to use Equality/Inequality (==, !=, >, <, >=, <=) Arithmetic (+, -, x) Logical Operators (! not, && and, || or) Bitwise Operators ...
Winner: Aditsu's CJam answer! A whopping 25 bytes! Nice! You may continue to submit your answer, however you can no longer win. Original post kept for posterity: The "Bzzt" game is a game where you must count to a number (in this case 500). However, if the number has a 3 in it, or is divisible by 3, you don't say the ...
fastest relay time = lowest possible total integer value of (a freestyle swimmers time) + (1 breastroke swimmers time) + (another backstroke swimmers time) + (another butterfly swimmers time) Each swimmer must be unique to the relay (no duplicates) Each stroke must be used once Input Data: array of dictionaries, wh...
The type 4 GUID is described by Wikipedia, quoth: Version 4 UUIDs use a scheme relying only on random numbers. This algorithm sets the version number (4 bits) as well as two reserved bits. All other bits (the remaining 122 bits) are set using a random or pseudorandom data source. Version 4 UUIDs have the form xxxxxxxx...
Write a program that takes R, G, and B values as command arguments and then displays that color some way. It doesn't matter how, as long as at least 100 pixels have the color. Shortest code wins.
The goal is to write a function or program which takes a set of integer arrays and returns a set of all possible arrays which meet the following criteria: A valid array must contain at least one number from each of the input arrays. A valid array cannot contain more than one number from a single input array. A valid a...
Short and sweet description of the challenge: Based off the ideas of several other questions on this site, your challenge is to write the most creative code in any program that takes as input a number written out in English and converts it to integer form. Really dry, long and thorough specifications: Your program wil...
Let's play some code golf! Given a tic-tac-toe board state (Example:) |x|x|o| |x|o|x| |o|o|x| Determine whether a game is a win a lose or cat. Your code should output any of these options given a state. The above game should output lose Just to be clear: a win is defined as any 3 xs in a row (diagonal, horizontal, ver...
Given three number values - being the Red, Green, and Blue elements of a colour (eight bits per channel, 0 to 255) - your program must output the name of the given colour. For example; Input: 255, 0, 0 Output: Red or; Input: 80, 0, 0 Output: Dark Red This is a popularity contest, so whichever answer has the most...
You're a programmer. You always work everyday and don't have time with your lover. One day, your lover was so angry with you that they cursed you into an ogre! Your fingers have grown big, and you can't type as before. And of course only your lover can lift your curse , but you only have 3 days! So, you decided to wri...
So you are tasked with creating an open source password authentication system but you want to reveal as little about the implementation of the hash function as possible. Can you write a function that takes in a password string and a salt string and outputs a salted hash string without revealing the hashing function? En...
Write a program to find a number consisting of 9 digits in which each of the digits from 1 to 9 appears only once. This number must also satisfy these divisibility requirements: The number should be divisible by 9. If the rightmost digit is removed, the remaining number should be divisible by 8. If the rightmost dig...
Introduction Consider the following example: CODE + GOLF —————— GREAT This is an equation where each letter represents a decimal digit and the words represent natural numbers (similar letters represent similar digits and different letters represent different digits). The task is to match each letter with its digit ...
This time around your goal is to find the maximum of 3 integers (from -(2^31) to 2^31 - 1 in binary 2's complement) without using branching or loops. You are only allowed to use Inequality/Equality (==, >, >=, <, <=, !=) These count as 2 tokens. Arithmetic (+, -, *, /) Logical Operators (! not, && and, || or) Bitwi...
Given a grid which contains these signs: 0..9, x, =, write the fastest code that outputs the longest string of connected (horizontally, vertically, and diagonally adjacent), distinct cells which is a mathematically valid expression formed on this grammar: E := T '=' T T := F 'x' T | F F -> {0..9}+ More formally, a so...
In investing, internal rate of return (IRR), the continuously compounded rate of return economically equivalent to a specified series of cashflows, is often a valuable concept. Your challenge is to demonstrate how to compute IRR in the language of your choice in as few bytes as possible, subject to the following condit...
Assume we have a string, and we want to find the maximum repeated sequence of every letter. For example, given the sample input: "acbaabbbaaaaacc" Output for the sample input can be: a=5 c=2 b=3 Rules: Your code can be function or a program - for you to choose Input can be by stdin, file or function parameter The ou...
Write a program that takes a binary tree as input, and outputs the deepest node and its depth. If there is a tie, print all involved nodes as well as their depths. Each node is represented as: T(x,x) T(x) T where T is the identifier of one or more alphanumeric characters and each x is another node. Here's a simple defi...
Description Given a source path and a destination path, output the relative path to the destination with respect to the source. Rules The input can come from stdin or as arguments to the program/function. Both Windows and Unix style paths must be supported. The output path can use / and/or \ for the path separator (y...
The challenge The goal of this challenge is to create a chatbot that can run in the chatrooms of Stack Exchange. Your bot needs to be able to detect when specific commands are posted by a user and respond to it. This is the list of commands, and what your bot should do: !!newest: output the title (no link, but the tit...
The task is to find the number of characters in your source code up to the previous line. You may do some addition of two integers, or whatever that comes to mind. But at the end of your logic, you need to calculate the number of characters written in your code up to the last line. EDIT: The goal is to find the number ...
User CarpetPython posted a new take on this problem which puts a much bigger focus on heuristic solutions, due to an increased search space. I personally think that challenge is much nicer than mine, so consider giving that one a try! Vector racing is an addictive game that can be played with a pen and a sheet of squ...
Introduction You're playing a matching game, in which coins are inserted at the top and fall to the bottom (onto the top coin) due to gravity. So this O <- inserting this coin OO O OOOOO will become this O OO O OOOOO Now imagine someone rotates the board clockwise. The following will happen: 1. The board is rotated ...
You dudes, the Most Excellent Adventure is a home brew roleplaying game system based on the Bill & Ted Films, plays gnarly air guitar riff. In this game system, when you draw from your dice pool (you have between 1 and 12 ten-sided dice, with faces labelled 0-9) you need to connect the results as a phone number on you...
Here's a simple one. In the shortest code possible, given an arbitrary number such as 567421, print it out in words: five six seven four two one You may assume the input is an integer that is already provided in a one-letter variable such as n.
As you know, the World Cup group stage is over, and from tomorrow the best 16 teams will commence the knockout stage: Brazil (BRA) Mexico (MEX) Netherlands (NED) Chile (CHI) Colombia (COL) Greece (GRE) Costa Rica (CRC) Uruguay (URU) France (FRA) Switzerland (SUI) Argentina (ARG) Nigeria (NGA) Germany (GER) United Stat...
Write the shortest possible program that turns a binary search tree into an ordered doubly-linked list, by modifying the pointers to the left and the right children of each node. Arguments: a pointer to the root of the binary tree. Return value: a pointer to the head of the linked list. The binary tree node has three f...
This is a simple encryption method that uses PI digits to encode a message, the method is simple: The key is just a positive integer that indicates where the window starts then: Given a string to encrypt, containing only lowercase letters, no spaces, you take its length, then you find the Nth digit of PI and then proce...
Write a program, in the language of your choice, that appears to successfully find a counterexample to Fermat's Last Theorem. That is, find integers a, b, c > 0 and n > 2 such that an + bn = cn. Of course, you can't really do it, unless there's a flaw in Andrew Wiles' proof. I mean fake it, by relying on integer ove...
Short and sweet description of the challenge: Based off ETAOIN SHRDLU, your challenge is to write the shortest program or function in any language that outputs the 26 letters of the English alphabet based on their frequency in the input. Really long, dry and thorough specification: Your program/function will receive a...
The Scenario You are a taxi driver in your city. You picked up a passenger from the airport and he told you the place he'd like to go. To earn more money, you need to drive as much as you can. However, there are two problems: He always looks around. Therefore, you cannot pass from the same district twice. The passenge...
AlienWar This game takes place in a very crowded planet where aliens are the superior race. Your task is to create your own alien and beat all other. The Board It is a 2 dimensional board. The length of one side of the board is Math.ceil(sqrt(species * 100 * 2.5)) = ~40% of board used. The board is a planet, so if you ...
What general tips do you have for golfing in T-SQL? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to T-SQL. Please post one tip per answer. Thanks to Marcog for the original idea. :)
An airlines company has several planes of the same type.Each plane has a seating capacity of 24 X 3 rows and 8 seats in each row split has shown. 1 [a] [b] [c] [d] [e] [f] [g] [h] 2 [a] [b] [c] [d] [e] [f] [g] [h] 3 [a] [b] [c] [d] [e] [f] [g] [h] If 4 people book-allocate 4 seats in middle row.Else 2 on the right ...
Your task is to calculate the total number of key-presses required to enter a given text on an old cellphone. The keymaps are: 1:1 2:abcABC2 3:defDEF3 4:ghiGHI4 5:jklJKL5 6:mnoMNO6 7:pqrsPQRS7 8:tuvTUV8 9:wxyzWXYZ9 0:<space><newline>0 To type exaMPle TExt 01 , you would press 33 99 2 6666 77777 555 33 0 8888 33333 99 ...
Challenge Detect the newest file in a specific folder and pass it as an argument to another process. The first argument to your program will be the folder, and the second argument will be the full path to the process. Please specify the platform(s) your code works on. Examples Windows newestfile "C:\Public_domain_movie...
Given an input of a 2 dimensional array of integers, rotate the array 90 degrees clockwise. It should work for rectangular arrays of all sizes and proportions. The rotated array should be printed at the end of the program. Example: Input: [[0,1,2,3,4,5], [6,7,8,9,0,1], [2,3,4,5,6,7], [8,9,0,1,2,3]] Output: [[8,2...
The objective of this question is to create a program that pushes your computer's internal fan speed to its maximum RPM. Upon exiting the program, your fan should return to the normal operating RPM. Rules: You may not perform a CPU intensive task in order to modify the fan's speed. Exiting the program may be via user...
The Gray Code is a sequence of binary numbers of bitwidth n where successive numbers differ only in one bit (see example output). Reference Example input: 3 Example output: 000 001 011 010 110 111 101 100 Notes: This question seems to have a dupe but it's not, for that question is not a code-golf, and it demands dif...
Your goal is to determine whether a given 2D point X lies within the area of the triangle with given vertices A,B,C. Write a function that takes in the coordinates of the test point X and the three triangle vertices (so that's 8 coordinates total) and returns True if the point lies inside that triangle, and False if it...
Write a program that translates ASCII text to braille output. Requirements: Input may come from stdin, command line, or some other external input source. Output should be recognisable as braille, the form of output is up to you. An example would be o for a raised dot and . for a non-raised dot. Textual pattern represe...
Two random numbers A and B have been generated to be either 1, 2, or 3 your job is to randomly pick a third number C that can also be 1, 2 or 3. But, C cannot equal A or B. A can equal B. If A = B, then C has only two numbers left it can be. If A ≠ B, C has only one number it can be. Assume A and B have already been c...
Let's try to golf this piece of ascii-art representing a golfing man: '\ . . |>18>> \ . ' . | O>> . 'o | \ . | /\ ....
You are to make a program that can check the syntax of programs of its same language. For example, if you do it in python, it checks python syntax. Your program will receive a program on standard input, and verify whether or not its syntax is correct. If it is correct, output just "true" on standard output. If not, out...
Almost every language has a built-in function that can split a string at a given position. However, as soon as you have html tags in the string, the built-in function will not work properly. Your task is to write a program or function which splits a string at the nth character but does not count characters of html tags...
I wrote some perl to sort by debian package version number (specification here). Whilst readable, it was disappointingly long (114 lines, 2042 characters) - shocking. So this challenge is to produce the shortest program (in perl or otherwise) which takes debian package version numbers on STDIN separated by \n, sorts th...
Write a program in brainfuck that accepts input of 4 ASCII characters as numbers (from 32 to 126) and outputs the numbers or ASCII equivalent sorted in ascending order. Requirements: Your program should prompt the user for 4 characters that will be sorted by their ASCII value. All the inputs will be distinct. Any sort...
Aww, man, this expiry date doesn't write the months with letters! I can't tell if it's expiring on March 10th or October 3rd... Wait, no, never mind, the year says 2012. (alley-oops half-used brick of cheese into the trash can like a pro) So let's suppose for a moment that you're too busy to try to reason out when this...
I have come across an article where students used network traffic to draw their university on the country's IPv6 graph. [image] Your goal is simple to tell, but hard to implement. Draw the text MAIL (as it is one of the few words that can be read on a 1D graph) on the CPU graph. It should look something like this: E...
preface In a very heated situation you have to go even further with golfing. (e.g. in a challenge where your answer is 100 characters long and it is just embarrassing that you couldn't make it 99) In that case, from now on you use the winner's algorithm of this challenge :) goal You have to write a program that takes ...
The challenge is to write a fake infinite loop in any imperative programming language. At first sight, the code should seem not to halt at all. As a naive example: int f(int x) { return f(4.0); } int f(double x) { return 0; } But remember You're not allowed to use overflows: int f(int x) { if(x < 0) retur...
Your challenge is to write a program which will output a non-context-free language. A Context-free Grammar is a series of replacement rules, describing which symbols can be replaced by which other symbols. It defines set of strings, known as a language, which is generated by performing all possible replacement rules on...
Today's Daily WTF quotes the following line of code... FailSafe==0?'No technical alarms':((FailSafe&1)!=0&&(FailSafe&2)!=0&&(FailSafe&4)!=0&&(FailSafe&8)!=0?'Detection zones staying in a given state; Bad visibility; Initialization; Bad configuration':((FailSafe&1)!=0&&(FailSafe&2)!=0&&(FailSafe&4)!=0?'Detection zones s...
Results - July 19, 2014 The current King of the Hill is Mercenary by user Fabigler! Keep submitting entries and knock him off of his throne! Click here to view the Scoreboard. Programs submitted on or before July 19, 2014 were included. All other submissions will be included in future trials. New results should be post...
Challenge: In the last stage of a two players Texas hold 'em, given a two-card hand and five cards on table, determine your probability to win versus an opponent by the standard ranking of poker hands. Input: Seven cards (sdtin or arguments). The first two cards are your hand while the last five are on the table. Each ...
The title says it all. Your goal is to write a program that forms a w×h rectangle of characters that can be rotated and re-run to output the number of 90° Counter-Clockwise (CCW) rotations that have been done. For example, if the 3×2 program abc def solved the problem, it would initially output 0, and successive rotat...
You are given two true color images, the Source and the Palette. They do not necessarily have the same dimensions but it is guaranteed that their areas are the same, i.e. they have the same number of pixels. Your task is to create an algorithm that makes the most accurate looking copy of the Source by only using the pi...
You have a library - a fully loaded 2014 Babylon.js. You have a fragment shader - let's call it sample.fragment.fx. You have a scene - loaded ahead of time, possibly from a .babylon JSON file. Your goal is to assign the fragment shader to every textured object in the scene using a snippet of JavaScript or TypeScript co...
I'm solving task, where: Input: A number as an integer. Output: The closest greater palindromic prime as an integer. I would appreciate hints how to make my solution shorter. Or directions if change of approach would be beneficial. golf=lambda l,r=range:next(x for x in r(10**6)if(x==int(`x`[::-1]))&all(x%d for d in r(2...
A question similar to this has been asked a couple of years ago, but this one is even trickier. The challenge is simple. Write a program (in your language of choice) that repeatedly executes code without using any repetition structures such as while, for, do while, foreach or goto (So for all you nitpickers, you can't...
I want to compactly code positive integers x into bits, in a manner allowing decoding back into the original integers for a stateless decoder knowing the maximum value m of each x; it shall be possible to uniquely decode the concatenation of encodings, as is the case in Huffman coding. [The above introduction motivates...
Using the fewest Unicode characters, write a function that accepts three parameters: Total number of dominoes nth affected domino Topple direction of the affected domino (0 or L for left, 1 or R for right) Once a domino is toppled, it must also topple the remaining dominoes in the same direction. You should output th...
People sometimes make spelling eorrors. A lto. Your challenge is to write a program that can take a string with certain spelling errors, such as the switching of I and E, and correct those mistakes. This has to be able to make changes to any combination of characters in any string, and fix the spelling errors. This is ...
Problem I've got a GREAT new program that will change the way we think about math in computing, taking in strings of algebraic functions and doing AMAZING things with them! The only problem, is that I am only able to parse specific algebra, otherwise the universe folds into itself, which is bad. Fortunately, I only nee...
There are a lot of challenges on this site regarding pi, but none that challenge you to calculate as many digits of pi as possible. As you all may know, pi in its decimal form goes on for infinity, so calculating it in its entirety is near to impossible. However, I challenge you to write a program in your language of c...
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...