Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Round 3 Question 3 Compiler Issues
Index -> CompSci.ca, Contests -> DWITE
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
talf301




PostPosted: Thu Dec 22, 2011 3:06 pm   Post subject: Round 3 Question 3 Compiler Issues

On this DWITE's question 3, both of our submissions (team name was ThornhillTigers) received 0/5 on account of the error "uses unsafe or unchecked operations". However, when we ran it against the test data today, it ran and got 5/5. Eclipse gave us some warnings in our code which we did not add @suppress warnings for, but it ran anways; so why does the judge not allow this to run?
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Dec 22, 2011 3:43 pm   Post subject: RE:Round 3 Question 3 Compiler Issues

I've checked your second submission. It doesn't compile.
Quote:

tony$ javac Problem3.java
Note: Problem3.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

Lets see the details
Quote:


tony$ javac -Xlint:unchecked Problem3.java
Problem3.java:18: warning: [unchecked] unchecked conversion
found : java.util.ArrayList[]
required: java.util.ArrayList<java.lang.String>[]
ArrayList<String>[] discounts = new ArrayList[scanner.nextInt()];

...
5 warnings

So a number of problems, but they are basically of the same theme -- wrong types. Java is strongly typed, so you need those types to match.

E.g., the very first issue on line 18: you are attempting to assign java.util.ArrayList[] type to the java.util.ArrayList<java.lang.String>[] variable.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
talf301




PostPosted: Thu Dec 22, 2011 6:29 pm   Post subject: Re: Round 3 Question 3 Compiler Issues

And yet it compiles fine on the computer on which we did the contest...
Also if you I try to initialize an array of arraylists by saying ArrayList<String>[] discounts = new ArrayList<String>[scanner.nextInt()]; java will complain and throw an error...

EDIT: Also since when will 6 warnings give you a 0/5? They don't actually affect the way the code runs...
Tony




PostPosted: Thu Dec 22, 2011 6:48 pm   Post subject: Re: Round 3 Question 3 Compiler Issues

talf301 @ Thu Dec 22, 2011 6:29 pm wrote:
And yet it compiles fine on the computer on which we did the contest...

I don't know what kind of a setup you have on that computer, but your code does not compile on the judge http://dwite.org/judge (Java 7) or on my machine (Java 6).
Quote:

tony$ javac -version
javac 1.6.0_29

As it failed to compile on the judge machine, there was no output file to score any points.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
talf301




PostPosted: Thu Dec 22, 2011 6:57 pm   Post subject: Re: Round 3 Question 3 Compiler Issues

It compiled and ran on our school computers (not sure which version those are on) as well as my home computer, running 1.6.0_25.
Is it possible that eclipse runs the program with some specific parameters, or is it the version making the difference?
Tony




PostPosted: Thu Dec 22, 2011 7:25 pm   Post subject: RE:Round 3 Question 3 Compiler Issues

If I had to guess, then maybe Eclipse is doing some magic that makes invalid code run. Who knows. If you choose to use tools different from the judge's environment, it is your responsibility to be aware of what those differences are.

The second submission attempt is there to deal with unexpected outcomes. I've ran a diff against your two submissions, and it came back empty. It seems that your team had seemly resubmitted the same file, instead of investigating the error.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
talf301




PostPosted: Thu Dec 22, 2011 8:17 pm   Post subject: Re: Round 3 Question 3 Compiler Issues

Thanks for the help, we'll try to avoid the same problem next time.
Is there any way for us to test a previous problem with the judge to see how it responds to our code/how it runs?
Tony




PostPosted: Thu Dec 22, 2011 8:44 pm   Post subject: RE:Round 3 Question 3 Compiler Issues

http://dwite.org/judge describes exactly what compilers are used, how the programs are compiled, and how the results are run. You could follow those steps to recreate your own copy of the judge's environment.

At the moment, there is no "upload to test" type of utility.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> CompSci.ca, Contests -> DWITE
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: