Page 1 of 6 123 ... LastLast
Results 1 to 10 of 56

Thread: Beginner Programming Challenge 13

  1. #1
    Join Date
    Jan 2010
    Location
    Not Texas
    Beans
    340
    Distro
    Ubuntu 14.04 Trusty Tahr

    Lightbulb Beginner Programming Challenge 13

    Beginner Programming Challenge #13

    Welcome to the 13th Beginner Programming Challenge!

    Hi fora, as the winner of the last beginner programming challenge, I am pleased to present the next challenge.

    For the next challenge, let's make a simple banking program that will take the following as input:

    transaction_code account_number amount
    The transaction codes will be as follows:
    wd - withdrawal [money taken out of the account]
    dep - deposit [money put into the account]
    cred - not what you think it is: [money taken out of the account] YES: this is a withdrawal
    deb - not what you think it is: [money put into the account] YES: this is a deposit
    fee - this is money taken out of the account, but not given to the accountholder. Although basically a withdrawal, this is the only code that allows a withdrawal if it makes the balance less than zero OR if the balance is already less than or equal to zero.

    OK, the program will accept as input in the above-named format and make a record of account numbers and the respective balances. The account can NEVER go negative [from the account-holder's perspective] EXCEPT in the case of a fee. In the event of an "overdraft", the withdrawal/credit will NOT be processed, but a fee will be assessed.

    Here's the challenging part: NO existing database or existing hashing sequence can be used. Hint: I would recommend using a hashing technique, but as long as an existing database/MySQL method isn't used, I will allow any implementation.

    To simplify what I mean here: the programmer should make everything here from scratch except the container for the data and/or the method of resizing the array. Or in other words. Some languages have an "insert" or "append" entry for arrays. C has remalloc. These are both acceptable or *anything* comparable. If a sort or search method is used, you must make this from scratch. If there is a list.search... you can't use it.

    EXTRA CREDIT REQUIREMENTS ONLY
    : If you want extra credit, make your table with a max number of entries so that your overall array can not be a) resizeable b) greater than xx% greater than the maximum number of entries. At the point that you start using malloc and resize, you would have to sort or redo the whole hash table, which is very inefficient. So, to simplify the task, we'll just set a maximum number of entries at 200. That would make the array's maximum size of 200+200*.xx. Want more credit: find out what the minimal percentage is that still allows an efficient hash search/recall routine.

    Please note: regardless of implementation, it will need to accommodate 200 account numbers.

    I will submit a file that will contain sample entries. The bank program won't "open" the file, but the file will be redirected as the std input. This file may contain any number of entries to facilitate making a decisive choice on speed. To clarify, the speed factor is just to encourage people to be wary of the method they choose in storage/retrieval of the account # & balance.

    Here is how I will be judging the entries:
    1) Readability and appropriate commenting. Following standard code formatting will make your code more readable. Although I have a tendency to comment quite a bit, if you use strategic commenting, you would be surprised how little commenting can actually be useful
    2) Elegance of design. While not as obvious, consider how a feature is being implemented to see if there is a better way.
    3) Overall program speed. To reward those who do this in a way that maximizes speed. Specifically, use whatever implementation you want, but bear in mind that some methods will mean speed sacrifices.
    4) Robustness of design. If the program handles all the above-named things without crashing and is able to handle all exceptions this will look very good.
    5) Extra credit.

    Extra credit section: I will try to make two files, one that has 100% correct entries [as in no invalid transaction codes] and one that has many transaction codes. The format for all the data will be correct and inviolable [you don't have to worry about getting text for the account number or dollar amount of transaction]. The account number will be a number with no leading zeros. It will also be an integer. Assume whole dollar amounts.

    Another extra credit will be to see how small a percentage over the max account numbers you can get while still being able to fulfill the maximum account numbers. Or in other words, it should be possible to fit 200 accounts in a 240 entry table.

    This challenge may seem daunting, but once you figure out your hashing routine, the rest of the challenge will be much easier.

    Good luck

    and p.s. until I get a file uploaded, you can test your program with normal input or make up your own file.
    The file will be 3 items wide, separated with a space, the lines will be terminated normally.
    An example input file would be

    dep 11111 25
    wd 11111 22599
    wd 11111 -2525
    Last edited by texaswriter; June 6th, 2010 at 03:41 AM. Reason: clarified

  2. #2
    Join Date
    Jun 2007
    Location
    Paraparaumu, New Zealand
    Beans
    Hidden!

    Re: Beginner Programming Challenge 13

    Quote Originally Posted by texaswriter View Post
    transaction_code account_number amount
    The transaction codes will be as follows:
    wd - withdrawal [money taken out of the account]
    dep - deposit [money put into the account]
    cred - not what you think it is: [money taken out of the account]
    deb - not what you think it is: [money put into the account]

    fee - this is money taken out of the account, but not given to the accountholder.
    Nice touch! I see what you did there.....
    Forum DOs and DON'Ts
    Please use CODE tags
    Including your email address in a post is not recommended
    My Blog

  3. #3
    Join Date
    Nov 2009
    Location
    Dublin, Ireland
    Beans
    24
    Distro
    Kubuntu 9.10 Karmic Koala

    Re: Beginner Programming Challenge 13

    Here's the challenging part: NO existing database or existing hashing sequence can be used. I would recommend using a hashing technique, but as long as an existing database/method isn't used, I will allow any implementation. To simplify what I mean here: the programmer should make everything here from scratch.
    I don't quite understand this. So in Python, lists, tuples and dictionaries cannot be used? Or can they?

  4. #4
    Join Date
    May 2008
    Beans
    Hidden!

    Re: Beginner Programming Challenge 13

    Quote Originally Posted by bunburya View Post
    I don't quite understand this. So in Python, lists, tuples and dictionaries cannot be used? Or can they?
    That would be a ridiculous restriction; more likely it bars the use of things like SQL- e.g. "real" databases.

  5. #5
    Join Date
    Jan 2010
    Location
    Not Texas
    Beans
    340
    Distro
    Ubuntu 14.04 Trusty Tahr

    Lightbulb Re: Beginner Programming Challenge 13

    bunburya> thanks!!

    lisati> Those have built-in capabilities that break that rule. That said, a list by itself or something similar WOULD be fine as long as you never resize it or use built-in functions/libraries to fulfill the challenges laid out.

    snova> that is the correct interpretation.
    Last edited by texaswriter; June 2nd, 2010 at 09:57 PM.

  6. #6
    Join Date
    Dec 2007
    Location
    Behind you!!
    Beans
    978
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Beginner Programming Challenge 13

    Quote Originally Posted by texaswriter View Post
    bunburya> thanks!!

    lisati> Those have built-in capabilities that break that rule. That said, a list by itself or something similar WOULD be fine as long as you never resize it or use built-in functions/libraries to fulfill the challenges laid out.

    snova> that is the correct interpretation.
    A list in Python is always resizeable. And does the 'from scratch' bit mean I cant use pickle to write a list to file, which would then mean I have to store it in plain textt and write a parser function?

    Bodsda
    computer-howto
    Linux is not windows
    Fluxbox & Flux menu how to
    Programming is an art. Learn it, Live it, Love it!


  7. #7
    Join Date
    Aug 2007
    Location
    UK
    Beans
    427
    Distro
    Ubuntu UNR

    Re: Beginner Programming Challenge 13

    Better to bar certain languages rather than train people to program "badly" in them IMHO.

    Also: http://dictionary.reference.com/brow...er%27s+Disease
    C Programmer's Disease definition:
    The tendency of the undisciplined C programmer to set arbitrary but supposedly generous static limits on table sizes (defined, if you're lucky, by constants in header files) rather than taking the trouble to do proper dynamic storage allocation. If an application user later needs to put 68 elements into a table of size 50, the afflicted programmer reasons that he or she can easily reset the table size to 68 (or even as much as 70, to allow for future expansion) and recompile. This gives the programmer the comfortable feeling of having made the effort to satisfy the user's (unreasonable) demands, and often affords the user multiple opportunities to explore the marvellous consequences of fandango on core. In severe cases of the disease, the programmer cannot comprehend why each fix of this kind seems only to further disgruntle the user.
    @Bodsda: The collections.deque object can be declared fixed size.
    Last edited by StephenF; June 5th, 2010 at 09:55 AM.

  8. #8
    Join Date
    Aug 2007
    Beans
    949

    Re: Beginner Programming Challenge 13

    I don't get this either; are cred and deb supposed to tell you how much money you've removed and put into the account respectively, or are they dep and wd synonyms?

  9. #9
    Join Date
    May 2010
    Beans
    Hidden!

    Re: Beginner Programming Challenge 13

    IMO, this isn't a beginner challenge anymore .. Good luck to everyone who's taking part of this.

  10. #10
    Join Date
    Jun 2006
    Beans
    2,930

    Re: Beginner Programming Challenge 13

    Quote Originally Posted by texaswriter View Post
    At the point that you start using malloc and resize, you would have to sort or redo the whole hash table, which is very inefficient.
    Wouldn't using a linked-list address this?
    Support 7z in default installs!!!: Click Here

    How to use code blocks to post command output: Click Here
    Official Ubuntu Documentation

Page 1 of 6 123 ... LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •