Beginner Programming Challenge #9
Beginner Programming Challenge #9
Welcome to the 9th programming challenge for beginners, sponsored by The Ubuntu Beginners Team Development Focus Group. Let's dive right into things.
Task:
Your program should be able to open a text file and read its contents. The file will consist only of LOWERCASE letters and numbers 0-9. The file will be formatted such that there is only one alphanumeric character per line. Example file:
Code:
5
a
n
7
4
n
6
1
0
y
w
a
Your program must read each line and store the data in a data structure of your choice. Parse through your structure and print out the following information:
1. The sum of all the individual digits.
2. How many times each character appeared in the file.
Example output for the example above would be:
Code:
Sum = 23
a = 2
n = 2
w = 1
y = 1
The data file used for testing will be one of my own, so you don't know what's on it before I test. Conveniently, the way this program should be written makes that fact irrelevant. Your program should work with any size file. The one I use will be hundreds of lines long.
Bonus Points:
Code this in a programming language you've never used before!
Other Information:
Please read the bottom portion of Bodsda's post of BPC #8: http://ubuntuforums.org/showthread.php?t=1386478
All of those rules apply here as well. No obfuscated code. If you're a non-beginner, please wait until after the competition is judged to post your solution. We'd all love to learn something from the more advanced coders!
Go to this channel for help: irc.freenode.net #ubuntu-beginners-dev
EDIT: Please provide instructions for how to run your program along with your submission. ANY LANGUAGE IS ALLOWED!
Last edited by Sinkingships7; February 16th, 2010 at 08:55 AM.
Programming is an art. Learn it. Live it. Love it.
Bookmarks