Contest 39: Autograder

Online C++ programming contests.

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard, raimo

Contest 39: Autograder

Postby Ryan » Mon Jul 19, 2004 9:47 pm

Contest 39: Autograder
Difficulty: Beginner
Deadline: 28 July 2004 at 19:00 GMT


Description
Professor Dante, a horitculturist at Southern Shamest State School (SSSS), needs help assigning grades for the concluding semester. He has been recording assignments for the students in a text file all semester, and he needs a program to add up the scores, determine grades, and print the results alphabetically so he can easily copy the results into his gradebook.

School policy at SSSS demands that he assign grades according to the "flat-line-curve", which states that an equal number of students will receive A's, B's, C's, D's, and E's. If the number of students in the class doesn't divide evenly into the five grades, then up to one extra grade of each letter is given out, starting with A.

For example, if there were ten students in Dr. Dante's class, each letter grade would be assigned to two students, starting with the two top students receiving A's. However, if there were 12 students in the class, the top three students would receive A's, the next three B's, the next two C's, the next two D's, and the last two E's.

Input
The input will be on stdin as a list of assignment scores. Each line contains the name of the student (which may contain spaces!), followed by a tab, and then followed by an integer score.

Output
Output to stdout the grades for each student, one student per line, in alphabetical order and in the following format:

(name) scored (total_points) points and was given a grade of (letter_grade).

Where (name) is the student name, (total_points) is the sum of the scores for that student's assignments, and (letter_grade) is the final grade given the student.

Optimize for: code brevity
Brevity is defined as the total number of tokens in your source file. This means you are free (and encouraged) to use whitespace, sensible variable names, and comments -- they won't count against you.

jgbauman has created a utility for counting tokens. Download the source here or a prebuilt .exe here.

Example
Given the input: (download the file, with tabs preserved, here)
Code: Select all
Kybo Ren   72
Ryan   88
Darobat      98
Progler      73
Dave Sinkula   55
tougo      81
loobian      0
Alvaro      65
Lovechild   74
t i l e x   100
Vlad      98
schloob      71
Zen      35
Colin Jeanne   99
Colin Jeanne   34
Darobat      32
schloob      87
Zen      43
tougo      93
loobian      100
Alvaro      102
Kybo Ren   89
Lovechild   26
t i l e x   44
Dave Sinkula   94
Progler      12
Vlad      69

Output should look like:
Code: Select all
Alvaro scored 167 points and was given a grade of A.
Colin Jeanne scored 133 points and was given a grade of C.
Darobat scored 130 points and was given a grade of C.
Dave Sinkula scored 149 points and was given a grade of B.
Kybo Ren scored 161 points and was given a grade of B.
Lovechild scored 100 points and was given a grade of D.
Progler scored 85 points and was given a grade of E.
Ryan scored 88 points and was given a grade of D.
Vlad scored 167 points and was given a grade of A.
Zen scored 78 points and was given a grade of E.
loobian scored 100 points and was given a grade of D.
schloob scored 158 points and was given a grade of B.
t i l e x scored 144 points and was given a grade of C.
tougo scored 174 points and was given a grade of A.


Notes
  • NO MACROS.
  • You are to submit the source for a complete, working, compilable program -- not just a function this time!
  • "Alphabetical order" is case-sensitive for this contest.
  • Input will be valid. No input line will be longer than 256 characters.
  • There will be more than 4 and less than 100 students in Dr. Dante's class.
  • Score amounts will be no greater than 1000 and no less than -1000.
  • There is no limit on the number of assignments.

Submissions
Please attach your solution as a single .cpp file in an email to ryan@cpp-home.com, with the subject line as "Contest 39".

Post any questions or comments in this thread. Good luck and enjoy!
Last edited by Ryan on Wed Jul 28, 2004 4:19 pm, edited 3 times in total.
Ryan
Moderator
 
Posts: 323
Joined: Sat Jun 12, 2004 1:34 pm

Postby Kybo Ren » Mon Jul 19, 2004 9:57 pm

Awesome, I'll do this one! What should the file be named? Or do you not care?

Can we make our own functions within the program?
Last edited by Kybo Ren on Mon Jul 19, 2004 9:59 pm, edited 1 time in total.
Kybo Ren
C++ Beginner
 
Posts: 2049
Joined: Wed Feb 11, 2004 9:28 pm

Postby Ryan » Mon Jul 19, 2004 9:57 pm

I've tried to incorporate the feedback that some of you have given me on contests. This one should be approachable, not needing the STL, and a little more involved. Give it a try!

I'd like to see how many people we can get to enter this one. If you need some hints on how to do parts of the contest, feel free to discuss them here. For those answering questions, you can give away a little more "how" on this one since the goal is brevity rather than speed. Please don't post code though.

Just entering and passing the tests is an accomplishment. Get it working before worrying about brevity -- after it works you can trim it down if you'd like.
Ryan
Moderator
 
Posts: 323
Joined: Sat Jun 12, 2004 1:34 pm

Postby Ryan » Mon Jul 19, 2004 9:58 pm

Kybo_Ren wrote:Awesome, I'll do this one! What should the file be named? Or do you not care?


I don't care that much, but if you want to make my job easier, name the file after yourself (ie, "kybo_ren.cpp"). :)
Ryan
Moderator
 
Posts: 323
Joined: Sat Jun 12, 2004 1:34 pm

Postby Ryan » Mon Jul 19, 2004 10:34 pm

I had forgotten a rule, but just added it: no macros allowed. Any "#define"s in your source file will disqualify it.
Ryan
Moderator
 
Posts: 323
Joined: Sat Jun 12, 2004 1:34 pm

Postby Kybo Ren » Mon Jul 19, 2004 11:14 pm

Is it alright if we do use the STL? I was thinking of using maps.
Kybo Ren
C++ Beginner
 
Posts: 2049
Joined: Wed Feb 11, 2004 9:28 pm

Postby Beer Hunter » Tue Jul 20, 2004 3:36 am

If students P, Q, R, S and T get scores of 10, 10, 9, 8 and 7, then what output would you like?
User avatar
Beer Hunter
 
Posts: 912
Joined: Sat Dec 13, 2003 7:12 pm
Location: Australia

Postby Syn » Tue Jul 20, 2004 6:40 am

Nice One 8)

I'll try to make time to enter.
User avatar
Syn
 
Posts: 277
Joined: Fri May 14, 2004 3:50 am
Location: Birmingham, UK

Postby Ryan » Tue Jul 20, 2004 8:16 am

Kybo_Ren wrote:Is it alright if we do use the STL? I was thinking of using maps.

That's fine.

Beer Hunter wrote:If students P, Q, R, S and T get scores of 10, 10, 9, 8 and 7, then what output would you like?

Ack! Leave it to you... ;)

Giving either P or Q the A would be correct. However, for my sanity, you can assume that I'll not test with any ambiguous test cases; that is, any case in which two students end up with the same number of points will always get the same grade in my test cases -- as is the case with the example (both loobian and Lovechild received 100 points, and both got Ds).
Ryan
Moderator
 
Posts: 323
Joined: Sat Jun 12, 2004 1:34 pm

Postby exomo » Tue Jul 20, 2004 11:04 am

It looks like a really nice contest.

I try to do something if i have some time left.
User avatar
exomo
 
Posts: 935
Joined: Fri Sep 26, 2003 12:30 pm
Location: germany->baden

Postby Kybo Ren » Tue Jul 20, 2004 2:54 pm

Sweet, all I need to do now is get the curve grade and output :)
Everything else is done :)
I'm amazed at how easy it was for me...
anyone else doing it wanna share their experience with it so far?
EDIT: I'm at 196 tokens so far.. is that a good number or a bad number?
EDIT: Wow! Simply seeing how many extra as,bs,cs, and ds we need took up 100 tokens! I'm going to need to optimize that... :-\
EDIT: I can't get the curve to work right... it always disagrees with your list with me and tilex.... :cry:
EDIT: I think I found out why it's not right. I'm not sure of how to fix it, though. BTW, my code is over 600 tokens now.
Kybo Ren
C++ Beginner
 
Posts: 2049
Joined: Wed Feb 11, 2004 9:28 pm

Postby Beer Hunter » Tue Jul 20, 2004 10:55 pm

Ryan wrote:
Beer Hunter wrote:If students P, Q, R, S and T get scores of 10, 10, 9, 8 and 7, then what output would you like?

Ack! Leave it to you... ;)
Well, I'm going to make it so that P and Q would get As and the others would get C, D and E. My code needs fewer tokens that way. :)

EDIT 1: question time! I am to produce output in alphabetical order. Should this be case-insensitive? If so, does it matter if the output is in a different case from the input? Also, could the input file have scores from people called 'p' and 'P'? What do I do in this case?
User avatar
Beer Hunter
 
Posts: 912
Joined: Sat Dec 13, 2003 7:12 pm
Location: Australia

Postby Reddyx » Wed Jul 21, 2004 3:46 am

Really nice contest, I will definitively participate :D

Hope you'll evaluate the submissions immediately, since I go to holidays on 30 July :?
Reddyx
 
Posts: 7
Joined: Wed Jul 21, 2004 3:43 am

Postby Reddyx » Wed Jul 21, 2004 3:50 am

Beer Hunter wrote:EDIT 1: question time! I am to produce output in alphabetical order. Should this be case-insensitive? If so, does it matter if the output is in a different case from the input? Also, could the input file have scores from people called 'p' and 'P'? What do I do in this case?


In the sample, the output is case-sensitive. Also, Ryan has written: "Alphabetical order" is case-sensitive for this contest.
Don't make it harder as it is :wink:

:D
Reddyx
Reddyx
 
Posts: 7
Joined: Wed Jul 21, 2004 3:43 am

Postby Beer Hunter » Wed Jul 21, 2004 5:30 am

Reddyx wrote:In the sample, the output is case-sensitive. Also, Ryan has written: "Alphabetical order" is case-sensitive for this contest.
Don't make it harder as it is :wink:
Whoops! Looks like I've learnt another lesson in reading comprehension. ;)
User avatar
Beer Hunter
 
Posts: 912
Joined: Sat Dec 13, 2003 7:12 pm
Location: Australia

Next

Return to Contests

Who is online

Users browsing this forum: No registered users and 0 guests

cron