[oclug] Programming Wars: March 2001

Vic Gedris vic at worldwidepunk.com
Wed Feb 28 22:25:38 EST 2001


Hey everyone,

I finally put together a Programming Wars contest.  I had trouble
thinking of a problem to solve, so I went with a re-write of the 'tree'
utility (see below for details).  I feel it's a useful exercise, and
should be solveable in most languages even by people who haven't done
too much programming before.  Don't forget I'm open to suggestions if we
want to keep doing this in the future.

If anyone is interested in donating prizes for the winners/participants,
please speak up before the April meeting.

I'll go over it at this Thursday's meeting, and hopefully someone can
post the contest info to the OCLUG website.

We will also need a laptop to test everyone's programs on at the April
meeting.  If someone can volunteer one, that would be very nice.

Let's hope this goes over well, and you enjoy doing it!

Chers,
Vic

-- 
------------------------------------------------------------------------
vic at worldwidepunk.com    WORLD WIDE PUNK    http://www.worldwidepunk.com
------------------------------------------------------------------------


THE PROGRAM:

This month's program will be a simple clone of the 'tree' utility.
Tree is like a form of 'ls', the difference is that 'tree' provides a
depth-indented list of files and directories in a tree-like format.
For example, running the 'tree' command on a user's home directory
might produce output like:

[vic at iggy vic]$ tree
.
|-- files
|   |-- acrobatreader.tar.gz
|   |-- downloads
|       |-- gcombust.tar.gz
|       `-- mozilla.tar.gz
|   |-- resume.pdf
|   `-- xboing.rpm
|-- mail
|   |-- inbox
|   |-- oclug
|   |-- outbox
|   `-- sent
|-- mp3list.txt
`-- public_html
    |-- index.html
    `-- mypic.jpg

The syntax for the tree command must work like this:
tree [options] [directory]
Where [options] may include -d -s -ds or -sd (or nothing at all!), and
[directory] is an optional directory where the tree should start from.

The -d option lists directories ONLY.
The -s option lists the size of the file/directory before the filename:
    |-- [ 14056567]  linux-2.2.17.tar.bz2

So a valid command can also be:
    tree -d -s /usr/src/linux

Other notes:
  - All output should be to STDOUT
  - Hidden files (beginning with a .) are *never* to be displayed
  - Symbolic links must show what the link destination is:
    |-- cache -> /tmp/netscapecache
  - Broken symlinks (where the destination file does not exist!) should
    be in brackets:
    |-- cache -> (/tmp/netscapecache)
  - If you don't have 'tree' installed on your computer, you should be
    able to download a package from your distro's FTP site to use as
    reference.  Just copying the source code is not cool.  ;-)
  - There is no need to implement any of the other 'tree' options or
    features.  Remember, points go towards simplicity and size of code.


THE RULES:

1)  In the spirit of Linux, the solutions should be made available
    under the terms of the GPL, and maybe we will post them to the
    website.
2)  The program must run under Linux (Duh!)
3)  You can use any language you want that has a working compiler or
    interpreter under Linux.  If you use something other than C/C++,
    sh/bash, Perl, or Python, please email me to make sure I can
    install it on the test machine in time for the demos.
4)  If your program requires external modules/libraries/headers/etc
    that are not part of the standard distribution of the language,
    let me know well in advance.
5)  You can work as an individual, or in teams.
6)  An individual or team can submit more than 1 solution, but only one
    of those solutions can win.
7)  To win, you must bring a floppy disk containing the source code to
    your solution to the next OCLUG meeting (April 5th, 2001).  You
    can also email me your code at least two days in advance (or more
    if you think I might have problems with the language!) to make
    sure I can get it to run in advance.  At least 1 group member
    must attend the OCLUG meeting if you want to win.
8)  Discussion of solutions/algorithms is encouraged.


HOW TO WIN:

To win, solutions must be reasonably correct and free of errors.
Programs will be judged on the following criteria:

1) Fastest execution speed
2) Smallest size (byte size of source file)
3) Most elegant solution.  A matter of taste, but code that is short,
   simple to understand, and well planned out should win.  This will
   be voted on.
4) Best overall






More information about the OCLUG mailing list