PDA

View Full Version : Survey: Ever turn in a nonworking program




chaos2828
Mar 17, 2008, 02:59 PM
for a homework assignment?

I'm about to do it tomorrow and I feel like crap.



alaceo
Mar 17, 2008, 03:04 PM
Generally not a good idea.

Why are you giving up so soon?

admanimal
Mar 17, 2008, 03:10 PM
I grade assignments for graduate and undergrad college classes, and it happens all the time.

Exactly how concerned you should be depends on what class this is for and whether anyone else also found it difficult.

lee1210
Mar 17, 2008, 03:12 PM
I imagine unless this is a compiler, memory management system, or something equally complex that you could at least get it compiling/running even if it doesn't implement every test case, requirement, etc. so you can at least get partial credit. It depends on the prof. or TA, but essentially something that doesn't compile would get no credit, and something that ran but crashed without doing anything got similar treatment.

I am not suggesting that people on this board will do your HW for you, but if you need some help with a specific problem, post and see what you can do. The assignment probably isn't due for at least another 17 hours, I'm sure you can come up with something.

To answer the question posed directly, I never turned in anything that didn't work *at all*. I turned in a number of things that I knew were not even eligible for full credit due to missing features, etc. that I couldn't get done.

I would consult with the prof. or TA that grades the assignments and see what the policy is on late work. If you lose 10% per day, maybe taking the extra day would result in more credit. Obviously if no late work is accepted, this won't help.

chaos2828
Mar 17, 2008, 03:13 PM
An interesting assumption!

I see what I have left to do, see how much time I have to give to it and know that, 30 hours into the assignment, I am still not getting the crux of it.

I should say that it does compile and individual functions work quite nicely. They're just not behaving well together. I've thought about posting the code to here, but it means a lot to me to figure it out myself.

Plus, I figure if I'm not getting it, the prof needs to explain more/better. Make 'em work for their TIAA-CREFs, I say! (Just kidding, I could never teach. Most of them earn their money.)

lee1210
Mar 17, 2008, 03:19 PM
This is now only morbid curiosity, but what sort of thing is it?

And do you mean you've had the assignment for 30 hours (in which case, if it's that difficult this amount of time to do the project is cruel), or you've been working on the project for that long?

-Lee

chaos2828
Mar 17, 2008, 03:23 PM
I've been working on it for 30 hours over the past couple of weeks, but I am not a fast coder!

It's basically an assignment to teach us how to pass reference values from function to function. It's the old Roman numeral translation/calculator puzzle.

kuwisdelu
Mar 17, 2008, 03:36 PM
An interesting assumption!

I see what I have left to do, see how much time I have to give to it and know that, 30 hours into the assignment, I am still not getting the crux of it.

I should say that it does compile and individual functions work quite nicely. They're just not behaving well together. I've thought about posting the code to here, but it means a lot to me to figure it out myself.

Plus, I figure if I'm not getting it, the prof needs to explain more/better. Make 'em work for their TIAA-CREFs, I say! (Just kidding, I could never teach. Most of them earn their money.)

It really depends on how they grade.

I had a teacher who just ran the code without looking at it, plugged stuff in to see if it worked, and if it passed at runtime, he never looked at the code. If it didn't run, it was a zero.

My girlfriend has a teacher who only grades the code and never runs it at all. Doesn't matter if it even compiles, if the code says you've got the right idea, then you get credit.

So really, it depends on how it's graded.

aross99
Mar 17, 2008, 03:36 PM
I've seen alot of people post questions here, so it certainly doesn't hurt to ask. No one is going to do it all for you, but if you can post some general questions and or examples, maybe we can help.

You already sound like you know more than the most of the people who ask for help here.

If you think the issue is passing variables, maybe show us how you have them defined, and the section where you pass them, as well as the function headers they are passed to.

Then we can help point you in the right direction...

lee1210
Mar 17, 2008, 03:43 PM
I never had something like that, but I assume the idea is the user can enter roman numerals or arabic numerals and operators and you compute the result and display in roman and/or arabic numerals?

Roman numeral parsing could be a bit tricky because you can't treat each symbol independently. I've never tried, but i think i'd start from the end of the string rather than the beginning, and find "tokens". For example, you see an I as the last character in the string. You know there is a token, because there is no symbol of lower value, so you "eat" that symbol, and add 1 to your sum. Once you hit a non I value, you have to check the symbol to its left. If that symbol is smaller and a valid "modifier" (i.e. I can modify V or X, X can modify L or C) then you take those two symbols as a token, and get the value of that token (XC = C - X = 90). Continue until you reach the beginning of the string.

That explanation omitted error checking, but that should be trivial. You'd just need a little state machine that counts symbols and determines any valid symbols. I.e. i've seen 2 Is, so I can accept any symbol. I've seen 3 Is, so I can accept anything that is not an I, etc.

Once you have that subroutine done, the rest isn't so bad. What i'm not sure of is the notation one might use for operators. If you use RPN it's pretty easy, but if they're scattered in the middle you just have to have strict rules about where operators can appear. Also, it would be best if X of any case was a roman numeral and not the multiplication operator to avoid confusion.

As for generating roman numerals for the result, That shouldn't be too bad. You can probably work from left to right generating this. You'd just need a long if-then-else block testing your value, which you will subtract from. While this is > 0, continue looping and in the if-then-else, have each case... for example > 1000, > 900, > 500, > 400, > 100, etc. It will fall in to one of them and you can append the proper roman numeral sequence to the result string, and subtract its value from the running total.

I'm not going to write any code, but the code normally isn't the hard part. Don't feel bad about being a slow coder, just try to be a fast problem solver. If you know how to solve it, the coding isn't so bad.

I'm not sure how this ties in to pass-by-reference. I could see it going either way.

Good luck. Definitely post questions. Like I said, no one will do your HW for you, but we're glad to help with particular sticky places in the implementation.

As an aside, this is the kind of place we go in the "real world" when we have problems. I'd probably be in comp.programming.* instead of macrumors forums, but it's the same idea.

-Lee

p.s.
I must have missed part of a post way up there that i just caught. If you have your functions working for the most part, but they aren't playing nice together I would highly recommend digging in with a debugger. No idea what language you are using, but if it's something gcc can compile, throw in the -g option when compiling, and fire up gdb, set a bunch of breakpoints, and see what happens.

gnasher729
Mar 17, 2008, 03:45 PM
I had a teacher who just ran the code without looking at it, plugged stuff in to see if it worked, and if it passed at runtime, he never looked at the code. If it didn't run, it was a zero.

My girlfriend has a teacher who only grades the code and never runs it at all. Doesn't matter if it even compiles, if the code says you've got the right idea, then you get credit.

To me, it looks like the first teacher is lazy and just plain wrong. First, there are reasons why the same program might run with one compiler and not another; so that might be pure bad luck. Second, writing a program and getting it to run (correctly) is in practice only a tiny amount of the work, just the first ten percent. In real life, a program will meet changing requirements - with a badly written program that will cause lots of work, with a well-written program it is much less. Then there is the question how easy or difficult it is to debug. You plug that code into a bigger program, and something goes wrong somewhere. How hard is it to find problems in the code, or to be confident that it doesn't have problems?

twoodcc
Mar 17, 2008, 06:26 PM
i think in my first programming class i might have turned in something that doesn't work.

but since then, they usually work. at least compile and either do mostly what was required, or it does what was required but maybe in a different way