1

Having issues passing check50's tests for mario. I looked at other issues, including ones that look the same as mine, but I haven't found a solution.

My code seems to give the desired results as shown on the pset1 specification page. I also entered 0, and a white space and my program rejected them and asked for input again.

My program's output:

Height: -1
Height: -2
Height: foo
Retry: bar
Retry: 1
##
Retry: 8
       ##
      ###
     ####
    #####
   ######
  #######
 ########
#########

However, when I run the check50 I get this:

jharvard@appliance (~/Dropbox/pset1): check50 /2014/x/pset1/mario mario.c
:) mario.c exists
:) mario.c compiles
:( rejects a height of -1
   \ expected output, not standard error of "TERM environment variable not set.\n"
:( handles a height of 0 correctly
   \ expected output, not standard error of "TERM environment variable not set.\n"
:( handles a height of 1 correctly
   \ expected output, not standard error of "TERM environment variable not set.\n"
:( handles a height of 2 correctly
   \ expected output, not standard error of "TERM environment variable not set.\n"
:( handles a height of 23 correctly
   \ expected output, not standard error of "TERM environment variable not set.\n"
:( rejects a height of 24
   \ expected output, not standard error of "TERM environment variable not set.\n"
:( rejects a non-numeric height of "foo"
   \ expected output, not standard error of "TERM environment variable not set.\n"
:( rejects a non-numeric height of ""
   \ expected output, not standard error of "TERM environment variable not set.\n"
https://sandbox.cs50.net/checks/1939b97b24fc4e79915e6ebba4f73bf0

I searched for TERM environment variable not set.\n, but found nothing.

What am I missing here?

Thanks for looking, I appreciate any help :)

SOLUTION: As Kareem pointed out, there were two issues with my code.

  1. Using a system call in my code: system("clear");
    • Removed this line completely. Probably an issue with server rights.
  2. Excluding 0 as a valid user input. My code simply didn't follow all of the instructions.
    • Removed the "=" in the line } while((num <= 0)||(num > 23));
    • It now reads: } while((num < 0)||(num > 23));

Once both were resolved, check50 returned all green happy faces :)

31
  • Did you run update50? What's the command that you ran to check your program? – Kareem Jul 14 '14 at 20:57
  • Wow, thanks for responding so fast :) Yes, I did. Twice! – Onyx Jul 14 '14 at 20:59
  • And what's the command that you used to check your program with check50? – Kareem Jul 14 '14 at 21:01
  • 1
    Hey Kareem. I thought posting too much code could be against the rules of conduct for CS50 and EDx/Harvard. I feel pretty silly, but I can't find your email on your profile. I'm really new to all of this :( – Onyx Jul 14 '14 at 21:26
  • 1
    Is that Retry: 8 input right after the Retry: 1 without exiting the program? Your program should run to completion after a valid input. Could that possibly be why? – m_duran Jul 15 '14 at 2:41
1

After reviewing your code, there are two main things that cause your program to fail passing check50

  1. You're not supposed to call system().
  2. You shouldn't reject the height of 0.
3
  • Thanks. Good job :) I'll be sure not to add extra code from now on. – Onyx Jul 23 '14 at 18:51
  • @Onyx It's not actually about using extra code. You can use whatever you want, but when it comes to checking your program with check50 in which case your program runs on a server that you don't have control over, you might run into issues like this when using a function like system(). Imagine someone is able to execute whatever command he/she wants on the server! :) – Kareem Jul 23 '14 at 18:58
  • I wondered about that. I was just thinking about, what if someone uploaded code that saved it's output to a file? Could cause trouble. Makes sense. Once the code tried to call system(), the program was blocked and it crashed. It returned a 1 :) – Onyx Jul 23 '14 at 19:09

You must log in to answer this question.

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