0

when I check my code with check50 I get some errors I don't understand:

tejas_chauhan:~/workspace/pset1 $ check50 2015.fall.pset1.greedy greedy.c
**:) greedy.c exists

:) greedy.c compiles

:( input of 0.41 yields output of 4

   \ expected output, but not "4 \n"

:( input of 0.01 yields output of 1

   \ expected output, but not "1 \n"

:( input of 0.15 yields output of 2

   \ expected output, but not "2 \n"

:( input of 1.6 yields output of 7

   \ expected output, but not "7 \n"

:( input of 23 yields output of 92

   \ expected output, but not "92 \n"

:( input of 4.2 yields output of 18

   \ expected output, but not "18 \n"

:) rejects a negative input like -.1

:) rejects a non-numeric input of "foo"

:) rejects a non-numeric input of ""

the values are all correct but the check50 is also checking the speechmarks and new line code e.g. printf("%d \n", coins); .

any help is appreciated, thanks!

2
  • check50 is very strict about the expected output, therefore you must remove the newline character
    – MARS
    Aug 4 '16 at 14:24
  • i still get the same error but without the \n included in the error. Aug 4 '16 at 14:32
5

True that check50 is strict about the output. Here is what the instructions say

Incidentally, so that we can automate some tests of your code, we ask that your program’s last line of output be only the minimum number of coins possible: an integer followed by \n.

The problem in your output is not the newline, which is correct. It is the space between the result and the newline.

2
  • thank you, surprised that actually worked, it seems like such a small thing to make your code 'incorrect'. Aug 4 '16 at 14:39
  • 2
    In the programming business there are a lot of small things that make your code "incorrect". Whether you are doing a problem set in a course, or writing a commercial app, adherence to the spec is, in a word, required. Aug 4 '16 at 14:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .