Take a simple XML file formatted like this:
<Lists>
<List>
<Note/>
...
<Note/>
</List>
<List>
<Note/>
...
<Note/>
</List>
</Lists>
Each node has some attributes that actually hold the data of the file. I need a very quick way to count the number of each type of element, (List and…
Write a program that takes 3 integers separated by spaces and perform every single combination of addition, subtraction, multiplication and division operations possible and display the result with the operation combination used.
Example:
$./solution 1 2 3
Results in the following output
1+2+3 = 6
1-2-3 = -4
1*2*3 = 6
1/2/3 = 0 (integer…
The challenge
The shortest code by character count that will output the numeric solution, given a number and a valid string pattern, using the Ghost Leg method.
Examples
Input: 3,
"| | | | | | | |
|-| |=| | | | |
|-| | |-| |=| |
| |-| |-| | |-|"
Output: 2
Input: 2,
"| | |=| |
|-| |-| |
| |-| | |"
Output: 1
Clarifications
Do…
Challenge
Here is the task, inspired by the well-known British TV game show Countdown. The challenge should be pretty clear even without any knowledge of the game, but feel free to ask for clarifications.
And if you fancy seeing a clip of this game in action, check out this YouTube clip. It features the wonderful late Richard Whitely in…
Mods: Can you please make this Community Wiki?
Challenge
Compactify a long list of numbers by replacing consecutive runs with ranges.
Example
Input
1, 2, 3, 4, 7, 8, 10, 12, 13, 14, 15
Output:
1 - 4, 7, 8, 10, 12 - 15
Note that ranges of two numbers should be left as is. (7, 8; not 7 - 8)
Rules
You can accept a list of integers…
Description:
The input are multiple lines (terminated by a newline) which describe a 'field'. There are 'numbers' scattered across this field:
the numbers always start at 1
they follow the ordering of the natural numbers: every 'next number' is incremented with 1
every number is surrounded by (at least) one whitespace on it's left and…
I've been in touch recently with Ann Maybury, who is creating a golf tournament roundrobin manager for senior citizens in Palm Desert, California. The application is created on the NetBeans Platform and looks as follows, very neat and professional:
Ann has been working on wrapping up the application for distribution and needs to…
Print all 12 verses of the popular holiday song.
By 12 verses I mean the repetition of each line as is sung in the song, ie
Verse One:
On the first day of Christmas my true love gave to me
a partridge in a pear tree.
Verse Two
On the second day of Christmas my true love gave to me
two turtle doves
and a partridge in a pear tree.
...…
Screenshot / Code Snippet
About
This small bookmarklet will allow anyone to use the "vulnerability" of the API that it allows you to check the up/down vote count - a feat you could normally achieve by being a 1k+rep user. Mainly useful for sites where you don't have this amount of rep, but want to check the stats of the more…
Here's a pretty simple idea, in this pastebin I've posted some pair of numbers. These represent Nodes of a unidirected connected graph.
The input to stdin will be of the form, (they'll be numbers, i'll be using an example here)
c d
q r
a b
d e
p q
so x y means x is connected to y (not viceversa)
There are 2 paths in that…
I am working on what at best could be considered a "primitive" golf game, where after a certain bit of randomness is introduced I need to play out a hole of golf. The hole is static and I am not concerned about the UI aspect as I just have to draw a line on a graphic of the hole after the ball has been hit showing where it…
I've seen many (code-golf) Perl programs out there and even if I can't read them (Don't know Perl) I wonder how you can manage to get such a small bit of code to do what would take 20 lines in some other programming language.
What is the secret of Perl? Is there a special syntax that allows you to do complex tasks in few…
Answering to another StackOverflow question (this one) I stumbled upon an interresting sub-problem. What is the fastest way to sort an array of 6 ints ?
As the question is very low level (will be executed by a GPU):
we can't assume libraries are available (and the call itself has it's cost), only plain C
to avoid…
Here's my (code golf) challenge:
Take two arrays of bytes and determine if the second array is a substring of the first. If it is, output the index at which the contents of the second array appear in the first. If you do not find the second array in the first, then output -1.
Example Input:
{ 63, 101, 245, 215, 0 }…
I just came across this little problem on UVA's Online Judge and thought, that it may be a good candidate for a little code-golf.
The problem:
You are to design a program to assist an architect in drawing the skyline of a city given the locations of the buildings in the city. To make the problem tractable, all…
No need for images.
Needs to have posting + answering + commenting + voting system.
No need for badges.
Powered by database of your choice.
referring to stackoverflow.com / stackexchange.com is lame.
Last year (2009), the Google Code Jam featured an interesting problem as the first problem in Round 1B: Decision Tree
As the problem seemed tailored for Lisp-like languages, we spontaneously had an exciting codegolf here on SO, in which a few languages managed to solve the problem in fewer characters than any…
Problem Description:
Write a program in any language with the shortest number of characters that solves the following problem:
Given a collection of cities and the cost of travel between each pair of them, find the cheapest way of visiting all of the cities and returning to your starting point. All solutions…
Hello,
Today I was testing out SRFI 19 and wrote a simple version of the UNIX cal(1) command.
Here's a version in R6RS Scheme which runs in Ikarus and Ypsilon. A few example runs.
Schemers: How would you write it? Use your favorite implementation.
Ruby and Python: I'm guessing that y'all have elegant date…
Hi guys, I just finished participating in the 2009 ACM ICPC Programming Conest in the Latinamerican Finals. These questions were for Brazil, Bolivia, Chile, etc.
My team and I could only finish two questions out of the eleven (not bad I think for the first try).
Here's one we could finish. I'm curious to…
Hi,
I've run into codility.com new cool service after listening to one of the recent stackoverflow.com podcasts.
In short, it presents the user with a programming riddle to solve, within a given time frame. The user writes code in an online editor, and has the ability to run the program and view the…
We have had an interesting competition once, where everyone would write their implementation of hello world program. One requirement was that is should be less than 20 bytes in compiled form. the winner would be the one whose version is the smallest...
What would be your solution? :)
Platform: 32bit,…
See here
Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".
Disclaimer: I do realize this is easy, and I understand…