instruction
stringlengths
34
53.1k
This challenge is to compute the most efficient multiplication order for a product of several matrices. The size of the matrices is specified on a single line of standard input. You should print to standard output a list of integers indicating the order in which to do the multiplications to minimize the total multipli...
Write the shortest program, in the language of your choice, that takes as input a year on the Hebrew calendar, and outputs the corresponding Gregorian date for Rosh Hashana, in YYYY-MM-DD format. ~$ rh 5771 2010-09-09 ~$ rh 5772 2011-09-29 ~$ rh 5773 2012-09-17 The input may come from either the command line or from ...
Your goal is to write a program that prints the following poem exactly as it appears here: There was an old lady who swallowed a fly. I don't know why she swallowed that fly, Perhaps she'll die. There was an old lady who swallowed a spider, That wriggled and iggled and jiggled inside her. She swallowed the spider to c...
Write a program or a function in any programming language that takes a 6 digit hexadecimal input/argument. The input/argument can be 6 values or a 6 character string. Your program should output an exactly 8 character wide rectangular block of characters containing only the hexadecimals supplied combined with spaces (+L...
The trees we are growing have some rules that define how they grow: Growth Rules: Trees consist only of branches. Branches are made up of a combination of the following symbols: _, \, |, /, & _ A tree starts as a single vertical branch/trunk (|) on the ground (_): __________________|___________________ The food for b...
Write a program (in a first language A) that interprets a "99 Bottles of Beer" program and a FizzBuzz program (both in a second language B) on its standard input. The output should go to standard output; you may implement the interpreter as a function in languages lacking standardized I/O interfaces. Constraints The 99...
Just an idea I had the other day: Making beats following a Markov Chain of predefined sounds. I remember someone did a beatbox with Google Translate and the German language (follow the link and press listen). So, the challenge is to build a text input to Google Translate from a given chain. Or you can use musical notes...
Challenge Being someone who plays far too much chess in his spare time, I thought I'd set a code golf challenge inspired by the game of chess (with a software flavour), for those interested. The challenge is to determine the winner of a game of standard chess given a PGN (Portable Game Notation) file as input -- or in...
Knapsack Problem (Actually, this is a subset of real knapsack problem.... - there's nothing to optimize!) The knapsack problem is: Given positive integers , and an integer S, find non-negative integers satisfies ... or in (my bad) English... Suppose you have many stuffs which weights , find configurations of those...
Read input of up to 8 characters presented as hexadecimal number and print this number as decimal number. In case that input can not be presented as hexadecimal input it has to print 0 Rules: It is not allowed to use any function that takes or returns strings/characters, beside function that reads string/char from inpu...
A JAPH is a grand tradition of making a program that prints "Just another Perl hacker,". We already have a question about JAPH on this site but they seem more concerned with hiding the text, but JAPH has always been more about hiding the method by which it does what it does. Therefore I challenge you to show off your f...
Rijndael's S-box is a frequently used operation in AES encryption and decryption. It is typically implemented as a 256-byte lookup table. That's fast, but means you need to enumerate a 256-byte lookup table in your code. I bet someone in this crowd could do it with less code, given the underlying mathematical struct...
Goal In this competition, you are given a random room with one candle inside. The goal is to write the shortest program (this is golf) that determines what parts of the room are illuminated by the candle, by replacing the dark spots with @'s. The program should take a room from STDIN, with the output printed to STDOUT....
Write a stripped down version of the wc command. The program can simply open a file which does not need to be configurable or read from stdin until it encounters the end of file. When the program is finished reading, it should print: # bytes read # characters read # lines read max line length # words read Program mus...
Declare a numeric variable that is not floating point and do an operation that changes the value with the largest amount of difference so the result of the variable is far from the original value. Solutions will be scored based on the magnitude of the difference between initial value and the value after changed, and sh...
The Machine A billiard-ball type machine is composed of only the symbols \ _ / along with upper- and lower-case letters, spaces, and the number 1. \ and / are ramps. A ball coming from above will be deflected to either the right or left side, respectively. For both ramps, if a ball comes from either side, it will be de...
Pascal's triangle is generated by starting with a 1 on the first row. On subsequent rows, the number is determined by the sum of the two numbers directly above it to the left and right. To demonstrate, here are the first 5 rows of Pascal's triangle: 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 The Challenge Given an input ...
Given a Black Box function ff that takes a single floating-point parameter, write a function M to generate the Maclaurin series for that function, according to the following specifications: take a parameter n, and generate all terms from x^0 to x^n where 0 <= n <= 10 coefficients for each term should be given to at le...
Your mission is to create a function for transposing music chords. Copied from SO with permission of the original asker, I just really wanted to see what you guys could do with this one: Since I don't expect everyone to be a musician here, I'll try to explain how it works in music theory. I hope I don't forget somethin...
The Feynman Challenge Cipher #1 is as follows: MEOTAIHSIBRTEWDGLGKNLANEAINOEEPEYST NPEUOOEHRONLTIROSDHEOTNPHGAAETOHSZO TTENTKEPADLYPHEODOWCFORRRNLCUEEEEOP GMRLHNNDFTOENEALKEHHEATTHNMESCNSHIR AETDAHLHEMTETRFSWEDOEOENEGFHETAEDGH RLNNGOAAEOCMTURRSLTDIDOREHNHEHNAYVT IERHEENECTRNVIOUOEHOTRNWSAYIFSNSHOE MRTRREUAUUHOHOOHCDCHT...
Write a program to play the name game. Input Your program should accept a single name as input from the user in some way (e.g read from standard input or as a command-line argument). You can assume that the name is a single word consisting of an upper case letter followed by one or more lower case letters. Output Your...
What general tips do you have for golfing in Scala? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Scala (e.g. "remove comments" is not an answer). Please post one tip per answer. (This is a shameless copy of ... in Python)
This is an extension of Simulate a Minsky Register Machine (I). I'm not going to repeat all of the description there, so please read that problem description first. The grammar in part (I) was as simple as possible, but results in rather long programs. Since this is a code golf site, we'd rather have a golfed grammar, ...
Description: Write the fastest comparison function for an opaque field containing a double. Here is my example: // Three-way comparison function: // if a < b: negative result // if a > b: positive result // else: zero result inline int Compare(const unsigned char* a, const unsigned char* b) const { if (*(dou...
Challenge Write a function which takes an argument which is a verb, and returns the past tense of the verb. (Assume that the verb is regular) Past tense Note: consider y as neither consonant nor vowel. Normally, just adding ed after the end of verb makes the past tense of the verb. Ex: jump → jumped, ask → asked How...
You are a railroad entrepreneur in the 19th-century United States when trains become popular because they are the most efficient means of transporting large volumes of materials by land. There is a national need for railroad tracks from the east coast through some recently colonized lands in the west. To accommodate th...
Challenge (Easy) Write a function which takes an argument and returns the number of non-alphanumeric characters found. Challenge (Hard) Write a function which takes an argument and returns the number of bytes used to store the number of non-alphanumeric characters found. (ie: include calculation for multi-byte char...
I'd be interested to see who can come up with the fastest function to produce multiplication tables, in the following format: 1 2 3 4 5 6 7 8 9 10 11 12 2 4 6 8 10 12 14 16 18 20 22 24 3 6 9 12 15 18 21 24 27 30 33 36 4 8 12 16 20 24 28 32 36 40 44 4...
Given the functions L: (x, y) => (2x - y, y) R: (x, y) => (x, 2y - x) and a number N generate a minimal sequence of function applications which take the initial pair (0, 1) to a pair which contains N (i.e. either (x, N) or (N, y)). Example: N = 21. The minimal sequence is of length 5, and one such sequence is ...
The students in my high school computer science class were asked to write the game of nim for a simple project. Most of them found it very easy and finished quickly. However, one student came up with this solution. I'll probably make them redo it anyway, but I'm wondering if anyone can understand what's going on. enum ...
This one comes from a real life problem. We solved it, of course, but it keeps feeling like it could have be done better, that it's too lengthy and roundabout solution. However none of my colleagues can think of a more succinct way of writing it. Hence I present it as code-golf. The goal is to convert a nonnegative int...
Write the smallest program performs a time stretch operation on a PCM Wave (.wav) file. Rules: Parameter input will by via whatever standard argument mechanism your language comes with, e.g. argv in C/C++, $_GET in PHP. Hard coded paths are not allowed. First parameter will be a decimal value that represents the stret...
Your challenge is to write a code-golf HTTP server that accepts GET requests. It obviously doesn't have to be fully featured, but it must serve files from a directory. Rules: The HTTP server must listen on TCP port 36895 (0x901F) It must serve files from /var/www on *NIX systems (e.g. Linux), or C:\hgolf on Windows. Y...
There have been many questions involving calculators; however, it does not appear that any involve implementing a graphing calculator. The Challenge You are to write a complete program that takes multiple formulas as input from STDIN and graphs them to STDOUT. Input will take the form f1(x)=x^2-x-1. There will be an f ...
Write a code golf task such that The only input (if any) required by the task is text from standard input, and the only output required by the task is text to standard output. There is exactly one correct output string of characters for every possible legal input as defined by the task. Each possible legal input is le...
Challenge You are to write the shortest complete program that takes a string as input from STDIN and decomposes it as far as possible, and prints the composition to STDOUT. To decompose a string, your program finds a substring (of length greater than 1) within the original string, the repetitions of which take up a muc...
Challenge: Write the smallest program (in characters) that resolves quadratic equations i.e. ax² + bx + c = 0 Rules: Given 3 numbers in R comma-delimited on STDIN: a,b,c (a != 0), print on STDOUT the 2 roots in C, one per line. R stands for real numbers, C for complex numbers. Examples: Input Output 1,0,0 ...
The goal is to produce a single line of R code that: Does as little as possible In as many characters as possible (max of 100 characters) And is as ugly as possible (where "ugly" can be taken to mean inefficient computational strategies, extraneous characters such as a terminating semicolon, and so forth). Do your wo...
Pretend you have an arbitrary text file (which you may choose). Give the sequence of keystrokes that is most destructive (*) if it was intended to be inserted to the text, but instead was entered in normal mode (i.e. i/a was not pressed). You may not enter visual mode and not quit Vim. Destructive is defined as follows...
STDIN: Array of integers STDOUT: Smallest difference (the difference between the closest two numbers in the array). Rules: Given an array of positive integers find the difference between the closest two numbers in the array. Performance should be taken into consideration. Example: STDIN: [55, 99, 6, 29, 1, 523, 3] STDO...
I'm looking for tips for golfing in the R statistical language. R is perhaps an unconventional choice for Golf. However, it does certain things very compactly (sequences, randomness, vectors, and lists), many of the built-in functions have very short names, and it has an optional line terminator (;). What tips and t...
There have been many "Do __ without __" challenges before, but I hope that this is one of the most challenging. The Challenge You are to write a program that takes two natural numbers (whole numbers > 0) from STDIN, and prints the sum of the two numbers to STDOUT. The challenge is that you must use as few + and - signs...
Explanation Two strings can be shuffled by interspersing their letters to form a new string, much like two piles of cards can be shuffled to form a single pile. For example, the strings HELLO and WORLD can be shuffled to form HWEOLRLLOD, or HEWORLLLDO, or perhaps simply HELLOWORLD. It is not a shuffle if the original ...
Assume an simple keyboard with this layout: 1 2 3 4 5 6 7 8 9 0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z . , ? ! Peter's keyboard pattern can be generated by starting at the top left of the keyboard, and displays the first three characters and a newline. It shifts over one character and displays the second,...
Story Indiana Jones was exploring a cave where a precious treasure is located. Suddenly, an earthquake happened. When the earthquake ended, he noticed that some rocks that had fallen from the ceiling blocked his way to the treasure. He also noticed that he could push a stone, but since stones were very heavy, he couldn...
Input A CSV file, read from standard input, containing the 2011 college football scores with the 4 columns: Winner, Winner Score, Loser, Loser Score. For example, Cincinnati,35,Connecticut,27 Pittsburgh,33,Syracuse,20 Baylor,48,Texas,24 This file was generated by a script I have that screen-scrapes rivals.yahoo.com. ...
Every number of the form 2i (where i is a non-negative integer) has a single 1 in its binary representation. Given such a number, output the 1-based position of the 1. Examples: DECIMAL BINARY POSITION -------------------------- 1 0001 1 2 0010 2 4 0100 3 8 ...
Write a function that, given N >= 0, finds the Nth number in a standard Gray code. Example input: 1 2 3 4 Example output: 1 3 2 6 Additional reference
There are many challenges that say "interpret X", where X is a simple language. In my opinion, that is way too boring. To give all the procrastinating people on the internet something interesting to do, you can try to do this challenge: Challenge Choose a language $LANG. $LANG can be any turing complete programming lan...
Challenge Given that Christmas is: December Month 12 Day 25 Every year, determine today's date, and whether or not today is Christmas. If it is Christmas, you must print "It's Christmas". If it is not Christmas, you must somehow wait until Christmas and then print "It's Christmas". Example From this Stack Overflow Qu...
The Challenge Print a nice Christmas tree with it's own star at the top using the shortest code possible. The tree star is an asterisk (*) and the tree body is made out of 0 The tree must be 10 rows high. Every row should be properly indented in the way that the previous row are centered over the next one. Any given ro...
This is a challenge that was originally a tas for the German Bundeswettbewerb Informatik (federal competition of computer science [?]), a competition for highschool students. As opposed to the original question, where you have to find a good solution and write some documentation, I want you to golf this. I try to repli...
This challenge is an extension of 'Golf a mutual quine'. Using three languages of your choice, create a third order Ouroboros program. That is, in language A, write a program pA which outputs program pB in language B. Program pB should output program pC in language C, which in turn outputs the original program pA in la...
I thought this would be a fun challenge for everyone and I'm curious to see the solutions people come up with. Print the "12 Days Of Christmas" lyrics On the first day of Christmas, my true love gave to me, A partridge in a pear tree. On the second day of Christmas, my true love gave to me, Two turtle doves, And a...
The challenge Create a program that mimics a chessboard. The datails The chessboard must be surrounded by the labels of each row and column, being the columns labeled from 'a' to 'h' and the rows labeled from '1' to '8'. Also, place the default position for each chess piece (blacks are on the top). Each piece is repre...
Write a program that prints out all the good rational approximations of pi with denominator < 1000000, in increasing denominator order. a/b is a "good rational approximation" of pi if it is closer to pi than any other rational with denominator no bigger than b. The output should have 167 lines total, and start and end...
Task Given a list of integers a1, a2, …, ak (k ≥ 2) and a positive integer m, write a function or a complete program that calculates the next m numbers of the list. Assume that ai = P(i) where P(x) = bk-1 xk-1 + bk-2 xk-2 + … + b0 is the unique polynomial of minimum order which fits the points. Description Input If t...
Given this text Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum ...
Given a number N, how can I print out a Christmas tree of height N using the least number of code characters? N is assumed constrained to a minimum value of 3, and a maximum value of 30 (bounds and error checking are not necessary). N is given as the one and only command line argument to your program or script. All la...
You will take a set of input numbers, and output the minimum and maximum of the set. You can either write two programs, with 1 program doing each function, or one combined program. Here's an example in Perl, 50 and 42 bytes (92 total): Max: sub mx {return ( reverse sort {$a <=> $b} @_ )[0]} Min: sub mn {return ( sort...
Write the shortest program to turn any piece of ASCII art into an animated snow scene that begins to form from the falling snow (non-golfed JavaScript example last updated 2011-12-19). Input specification: Your program must accept arbitrary combinations of spaces, asterisks, and newlines. The input will contain at most...
This was given to me by a friend of mine, it prints out 0 through 9. We have been quite puzzled over this. Does anyone know why this works? #include <iostream> using namespace std; void x(int a) { *(&a-1) += a; } int main() { for(int i = 0; i < 10; ++i) { x(8); i = 0; cout << i <<...
Getting hit in the knee with arrows seems to be the injury of choice right now. As such, I propose the following golf challenge. You have an adventurer that looks like this: O /|\ / | \ | | / \ / \ Given a text file that contains one bow (drawn as a } symbol), a set of walls (drawn as # symbols) and one adve...
Challenge: Produce the following output using as few chars as possible: _ _ _ _ _ _ _ | | | | ___| | | ___ __ _____ _ __| | __| | | | |_| |/ _ \ | |/ _ \ \ \ /\ / / _ \| '__| |/ _` | | | _ | __/ | | (_) | \ V V / (_) | | | | (_| |_| |_| |_|\___|_|_|\___( ) \_/...
Write a program that a will play a game of Misère tic-tac-toe. That is, the goal is to force your opponent to take three in a row. Accept on standard input either an 'X' or an 'O'(the letter, not zero), to determine which side the program will be playing as. Then output a single digit for your move on your turn, and re...
The Challenge You are to write a complete program that takes seven numbers from STDIN, and prints the two dimensional history of the cellular automaton (CA) to STDOUT. This is code golf. Input Formatting The input will be seven integers/strings separated by commas. The first number is the number of the rule according t...
Santa's elves need help in determining if their current batch of presents will fit into santa's sleigh. Write the shortest program possible in the language of your choice to help them out. Constraints Santa's sleigh measures 6ft wide by 12ft long and is 4ft deep. Presents may be fragile, so they may not be stacked on ...
Task Make a complete program or a function which calculates sum of all temperatures which, when written in Celsius and Fahrenheit scale, are anagram of each other. Description For example, 275 degree Celsius = 527 degree Fahrenheit, and 527 is anagram of 275. Non-integer temperatures (either in degree Celsius or degr...
Write the shortest code that raises a Segmentation Fault (SIGSEGV) in any programming language.
Your challenge is to create a basic version of Space Invaders in Python Rules Program must be not written in Py3K All levels must be randomly generated There must be a HUD showing the players score The winner would be the answer which uses the least amount of code Some Questions Q: How detailed do the aliens and othe...
I once hacked upstart on my Ubuntu box so that a colored, themeable ASCII Tux displayed on the screen with the boot messages scrolling beneath him. I'm curious to see what kind of ASCII art Linux Penguins you can come up with. It must fit in a 80 x 25 terminal, without using the bottom line (thus 80 x 24) Compact sour...
The challenge is to write an acrostic piece of code. When read normally (horizontally), the code should take an input string and remove all but the first character on each line. For example, the input: float or and ord line bool var auto real Output: foo bar In addition to this, the code also must contain valid code...
Create a function 'baseXtoY' which: converts an integer or string n, which is a base x number (hexadecimal, binary, etc) into a base y number, reliably, including numbers like 10e50 or higher, using the least bytes possible, and using the following constraints: Provide built-in support for bases up to 64 using the fol...
In this code-golf, you will attempt to match a string that is tail-repeating with one character falling off the head on each iteration. The code needs to be able to accept a string, and return to the user whether the string meets the above criteria. Examples: "", "x", and "xx" -> False EDIT: There is some speculation ...
Goal: Write a function that takes a number as input and returns a short-hand roman numeral for that number as output. Roman Numeral Symbols: Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1,000 For an example of what I mean when I say "short-hand roman numerals", let's conside...
Description Given a number, print the amount of 1s it has in binary representation. Input A number >= 0 in base 10 that won't exceed the highest number your language is able to handle. Output The amount of 1s in binary representation. Winning condition The shortest code wins. Disallowed Bitwise operators. Other operat...
Given a binary integer inclusively between 0 and 1111111111111111 (i.e. a 16-bit unsigned integer) as input, output the same integer in negabinary. The input can be in whatever format is most convenient for your language; for example, if it is easier for the program to handle input with 16 digits, like 0000000000000101...
Given the following list of numbers, find the group of sequential positive numbers with the highest sum. Example input: 12 2 35 -1 20 9 76 5 4 -3 4 -5 19 80 32 -1 Example output: 131 The most succinct code wins. My approach via Perl is 87 chars (with input as command-line args): print((sort { $b <=> $a } do { push @s...
Games are fun This Code Golf here was so fun I had to make a version for other classic games similar in complexity: Shortest Way of creating a basic Space Invaders Game in Python This time, however, try to recreate the classic 'Snake' game, in which you start out as a small shape, constantly moving to collecting pieces...
Excluding trivial programs, what code compiles in the most number of languages? (By "trivial" I mean to exclude answers such as the empty program or text that will be echoed directly.) The following code apparently compiles in all of the following programming languages (and prints something different in each one): C, C...
Given a list of nested menu items, items = [ '3D/Axis', '3D/CameraTracker', 'Color/Invert', 'Color/Log2Lin', 'Color/Math/Add', 'Color/Math/Multiply', 'Other/Group', 'Other/NoOp', 'Views/JoinViews', 'Views/ShuffleViews', 'Views/Stereo/Anaglyph', 'Views/Stereo/ReConver...
This idea is not mine, though I don't know where it originated. I once met it in a programming contest very long ago (1998, if I remember correctly). The task is to write a program in your favorite language that outputs 2012 and only 2012. The catch is that the program must still output 2012 after any one of its charac...
Given a number, say, -2982342342363.23425785 convert it to -2,982,342,342,363.23425785. Extra points for not using look-behind Extra points for not using regular expressions.
Dealing with colors in non-markup languages often complicates things. I would like to see some variations of how color is used in different languages. The object of this competition is to output 'Hello World' in the seven colors of the rainbow. According to Wikipedia, these are the 7 colors. Red #FF0000 (RGB: 255,...
INPUT: 10 random numbers each number is greater than 0 and less than 100 list of numbers is presorted, lowest to highest the list will not contain any duplicate numbers CHALLENGE: Write a function that would take in the numbers, and return the count of the longest group of consecutive numbers. EXAMPLE OUTPUT: 1 2 33 ...
The challenge is to generate an image similar to the StackOverflow logo: The output must contain: Image size 64*64 or greater A gray |__| shaped base A curved segmented stack coming up from the base. The segments will fade from gray to orange, and make a ~90 degree right turn. The number of segments should be between...
Similar to this but in this one you need to write spiral starting from the center where: space means composite number .(dot) means prime number. Size of the spiral can be given as parameter or on stdin. By size I mean side of square NxN and also N will be always odd.
The goal is to write a program that returns number of 1 bits in a given number. Examples 5 -> 2 1254 -> 6 56465 -> 8 Winner The winning submission is the code which runs in the minimum time. You can assume that normal int value in your language can handle any number (no matter how large) and computes all th...
Which values of x and y will cause a crash with some C compilers? int f(int x, int y) { return (y==0) ? 0 : (x/y); }
My home town, Rhyl, has a one-way traffic system which seems to have been designed to keep people away from their destination for as long as possible. Your task, should you choose to attempt it, is to produce a program to give the shortest route through such a traffic system. Input Input will be on STDIN, and will be a...
Given an arithmetic expression, which can include parentheses (()), exponents (^), division (/) and multiplication (*), addition (+) and subtraction (-) (in that order of operation), such as a ^ (2 / 3) * 9 * 3 - 4 * 6 output the same expression in prefix notation. (- (* (* (^ a (/ 2 3)) 9) 3) (* 4 6)) Spaces are opt...
Your challenge, should you chose to accept it, is to code-golf a function that returns true or false (or some similar meaningful representation of yes and no) if a number meets the following criteria: The integer itself is a prime number OR Either of its neighbor integers are prime For example: An input of 7 would re...
The PBM (Portable BitMap) format is a very simple ASCII black and white bitmap format. Here's an example for the letter 'J' (copy-pasted from the wikipedia link): P1 # This is an example bitmap of the letter "J" 6 10 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 1 0 0 1 1 1 0 0 0 0 0 ...
For those who are not familiarized with the Pea Pattern, it is a simple mathematical pattern. There are multiple variations of this pattern, but we will focus in one: Ascending Pea Pattern It looks like this: 1 11 21 1112 3112 211213 ... It seems really hard to get the following line, but it is really easy. The way...
Your challenge is to write a Chef program that works well as a recipe and also as a program. Its utility as a recipe is strictly required (I don't want a recipe for grapeleaves in chocolate-mustard sauce); its utility as a program is a looser requirement, so that it is enough to print something interesting (the first f...
there is only one rule: get accept for this problem http://acm.ut.ac.ir/sc/problemset/view/1032! to submit your code, you need to create an account(if you don't want to do so, just post your code here and I'll submit it). so far shortest code is written with C and has 85 character length. winner will be the shortest C...
I came across this question on SO and thought it'd make a nice golf challenge. So here it is: Challenge: Write a program that reads a sequence of character strings, one per line, and outputs a list of all positions where each string has the same character. Input and output: The input consists of one or more lines of p...
There is a well known question here that asks for a short (least characters) fibonacci sequence generator. I would like to know if someone can generate the first N elements only, of the fibonacci sequence, in very short space. I am trying to do it in python, but I'm interested in any short answer, in any language. F...
Input: You get a series of integers (fed via stdin or prompt). Every pair of integers in this series represents a building's WIDTH [valid range: 1..10] and HEIGHT [valid range: 0..10] Assume input to be well-formed. Sample input (the second line is for demonstration purposes only): 1 2 1 1 1 0 2 4 1 3 1 2 2 1 W H W ...
I would like to generate (as a return result of a function, or simply as the output of a program) the ordinal suffix of a positive integer concatenated to the number. Samples: 1st 2nd 3rd 4th ... 11th 12th 13th ... 20th 21st 22nd 23rd 24th And so on, with the suffix repeating the initial 1-10 subpa...