I've always liked Ascii Art, those big pictures printed using normal characters for shading. It reminds me of the late 70s when I had a collection in my account at University. Printing them out had to be done at lunch time when the operators were away as they regarded it as a waste of resources. (They thought that of us students too I think!)
Originally I thought of taking a jpg file and using that as input but it's a little complicated adding that in, so I don't expect it. Instead the input is a text file of 250 hex (base 16) numbers across x 200 down where each number is a pixel value in the range 0x00-0xff (0-255) representing 256 grey scales. 0 = complete black and 0xff = white.
Your job is to write a program that uses one of the common ttf fonts (arial, Times New Roman etc) on Windows and work out the mapping between the character and the shade (or range of shades). As there are 80 or 90 printable characters from ! up to z, and 256 shades to match them to, it's clear that the character output will need some kind of mapping.
To help, I'll create several bitmaps using Windows fonts that you can download and choose from. You can incorporate one or all in your program if you wish. Note, although ttf fonts are generally variable width (apart from mono-spaced = ie typewriter fonts like Courier and Courier New), the bitmaps I provide will have the characters laid out in equal spaced cells.
- Download zip files of font characters.
You can make your program command line or GUI. Your choice. I'll be marking them on ease of use, slickness, ie how well it runs etc.
A text file with 500 digits across (no spaces) and in pairs so 250 numbers on each of 200 lines. E.G If a line starts 009765 then the first three bytes are 00 97 65.
- Download image.txt
A text file with Ascii Art representation of the original file. It should be scaled to roughly fit an A4 (UK) or 11" x 8.5" (USA) but if it's a little smaller or bigger it doesn't matter. And laid out in landscape not portrait.
Completely subjective by me, but I promise no favoritism. If I say "wow" having seen your entry, you'll get more marks. That could be from ease of use, how well the ascii art image looks etc.
This isn't a speed contest but I'd expect it to take no more than say 10-30 seconds to do the conversion.
Reading Graphics Files Instead
You won't get any extra marks but you will get a good mention! However if you do that, please have it output a text file in the format (and size) I've mentioned for the input file.
Just one entry in C# from first time entry Sunuhe Coronel. Congratulations for a great entry that uses a GUI to select a file (most usual formats) and then outputs a .RTF format
- Sinuhe Coronel (C#)
General Tips on Entering
This is a single page article with tips on things to do and not do when entering challenges. Please read it!
RulesThis is for glory only. About.com does not permit prizes to be given.
Please submit your source code and the output file to the email@example.com?subject=Programming Contest 61 email address with the subject line Programming Contest 61.
It must compile with Open Watcom, Microsoft Visual C++ 2008/2010 Express Edition/Microsoft Visual Studio 2008/2010, CC386 or Borland Turbo C++ Explorer, Microsoft Visual C# 2008/2010 Express Edition, GCC/G++ and Google Go. If it doesn't compile, it can't be run so is automatically disqualified.
Please include your name, age (optional), blog/website url (optional) and country. Your email address will not be kept, used or displayed except to acknowledge your challenge entry. You can submit as many entries as you like before the deadline which is September 2, 2012.
The top ten entries in each challenge will be listed, judged on highest score and in the case of a draw, the fastest time. A condition of entry is that you allow your source code to be published on this website, with full credits to you as the author.
- An index of Every Past Programming Contest on this site