View Poll Results: Who do you think is the best beginner?

Voters
19. You may not vote on this poll
Results 1 to 10 of 217

Thread: [Beginner] Programming Challenge: 2

Threaded View

  1. #1
    Join Date
    Apr 2007
    Beans
    14,781

    [Beginner] Programming Challenge: 2

    The last challenge was very popular with many entries. Hopefully, the comments and other code was informative. Here is the last challenge: http://ubuntuforums.org/showthread.php?t=876479

    For this one, I ask non beginners to not give solutions that give away too many hints to those trying.


    The Challenge:
    The most problematic part of programming is user input. The best program can fall apart because of users. No matter what you ask in a program, expect the user to give random input or nothing at all. One of the entries in the previous challenge was disqualified because as I tested the code (before reading it, to see if it did what it was supposed to do), I was confronted with a vague prompt. It didn't really give an indication of what I was supposed to enter. I entered nothing, and exception was thrown because the program tried to read a part of the string and the program ended.

    Another one asked for input, but kept looping, no way to cancel it!

    I suggest you all read this article: Saving Users From Themselves

    It is using Python as the language, so entries using Python will have a good guide to follow, but any language is allowed (and somewhat prefered for this challenge)

    Write a program to take a person's forum name, age, forum user id (a postive integer equal to or between 1 and 999999). The program should ask for each datum individually, and not go to the next unless the previous was valid. If there is an error, it must prompt again until it is write or the program is halted. The entry "quit" should exit the program at any question.

    If all data is entered, it should print a sentence like:
    Code:
    You are LaRoza, aged 20 next year you will be 21, with user id 266234, the next user is 266235.
    In short:
    • User name can't begin with spaces, or have no characters in it. It can truncate strings over 20, if needed.
    • Age has to be positive and not 0. It doesn't need a maximum, but you are free to make your program logical.
    • User ID can't be negative or 0. The maximum I require is 999999.
    • Typing "exit" should exit the program gracefully.
    • The prompt should be logical.
    • Most importantly, it must not crash, segfault, lockup, or enter an infinite loop no matter what is entered



    Rules:
    Do not copy code, but you can obviously read it

    Try not to comment on other submissions. It will be hard to judge changing entries. If you edit your code, post the new version and make it clear there is a new code.

    How it will be judged
    This task is a bit more about programming than the previous, so you'll be judged on how ell the program works.

    • If I can segfault it, it is disqualified. (hint, C users have a big challenge, but if it works, you are almost guaranteed to win. Input in C is not trivial. To make this simpler, I will not enter a string bigger than 20 characters for valid data, but larger strings shouldn't cause problems. Truncate them.)
    • If I can make it throw an exception that is not caught and handled, it is disqualified (Python users, you can test data and catch exceptions, I recommend both)
    • Unicode is not required, but if there are many entries in the final judging, unicode will be the tie breaker (use the first part of my title before the | to test)
    • If I can't exit the program without killing it, it will be disqualified.
    • Prompts should be logical and tell how to exit.


    As before, try to follow the following (although I think it won't come down to judging on this, as the challenge will be tricky for beginners):
    • Clean code. Readable code is a must for being a programmer who wishes to possibly interact with others. Some languages can be more readable than others, so it will be judged on the effort of writing clean code, not which language is easier to read by design.
    • Logical code. Be a programmer, not a code monkey
    • Commented code. If something is possibly unclear (like an obscure use of math), let the readers know. Do not over comment, and let the code speak for itself whenever you can. Have logical variable names and function names. (Excessive commenting is a minus factor)
    • Working code. It has to work as it is posted. The codw will be read on the forum, so remember to use this guide to paste code if you don't know how: http://ubuntuforums.org/showthread.php?t=606009


    Hints:
    • If you use C, be wary of input functions. I recommend getting everything as a string and testing it.
    • Since you will be performing math on the data, you should watch out for illogical answers. All numbers will be integers, so watch out for large numbers! I shouldn't get infinity or 0 anywhere!
    • Using this challenge to try out a new language brings you bonus points, so please state when you are using the language for the first time if you are.
    Last edited by LaRoza; August 6th, 2008 at 03:46 AM.

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
  •