Submitting a Solution Using the Kattis Submit Script

If you are developing software on cs.bridgewater.edu, you can use the Kattis script, named kattis.py, to submit a solution.  It’s already installed on the machine in a directory that is on everyone’s path.  All you need to do is upload your personal configuration file into your home directory.

Uploading Your Personal Configuration File

Log into Kattis and download your personal configuration file onto your local machine by going to https://bridgewater.kattis.com/download/kattisrc.  Be sure to remember where you saved the file.

Then, using a SFTP client like FileZilla, copy the file from your local machine to your home directory on cs.bridgewater.edu.

Once the file is on cs.bridgewater.edu close your SFTP client and log into cs.bridgewater.edu with your SSH client (e.g. Putty).  Once logged on, change the name of the configuration file to “.kattisrc” using the linux mv command.

mv old-file-name .kattisrc

Your personal configuration file contains a private token.  You must not share this with anyone.  Your home directories have permissions set to 700 which means that you have read, write and execute permissions on your directory and everyone else has no rights what-so-ever.  I insist you keep it that way.

Submitting Your Kattis Solutions

Now you’re ready to use the submit script.  In order to use the script you need to

  1. Be in the directory that contains the source code that you want to submit.
  2. Know the Kattis problem identifier for the problem you are working on.
  3. Know which file your main() function is in.

The Kattis problem id can be found in the upper right corner of the problem’s Kattis web page as shown below.

When you’re ready to submit, simply type the following

kattis.py -p problem-id -m class-name -l Java files

where problem-id is the Kattis problem identifier and class-name is the name of the class that contains your main() function and files is a space separated list of your source code files.

For example, to hand in the problem named different we might enter the following:

kattis.py -p different -m Different -l Java Different.java

After you enter the submit command, you should see a prompt similar to the one below.

Problem: different
Language: Java
Files: Different.java
Mainclass: Different
Submit(y/N)?

If all of the information is correct, type a lower case y and hit ‘Enter’.  You should see a confirmation like the following.

Submission received. Submission ID: 1247718.

Within 1 minute of your submission, you should receive an email with the results.

Submitting a Solution via the Kattis Website

A tutorial on how to submit a solution to Kattis is found here: https://bridgewater.kattis.com/help/submit.

One way to submit a solution is via the Kattis website.  To do so, navigate to the problem description webpage for the problem you are working on.  On that page you will see a submit button in the upper right corner.

When you click on Submit you be directed to a Submit Solution page like the one below.

Here you select the files you wish to upload and specify the name of the class that has your main() function.  After you drag and drop your files and enter your Main class you Submit Solution page should look like the image below.  When done, press Submit.

When you press submit you’ll get a screen that looks like the following.

The “? New” status means that your solution is currently being judged.  In about a minute, you should receive an email from the system with a judgment like the following one.

Advice for Success

Succeeding in College

  • Get organized (retype notes, get a binder for handouts, see Chip Studwell)
  • Stay current with the required reading
  • Read your notes in the evening after class

Learning to Program

  • Copying other’s code guarantees your failure in this class.
  • Trying and failing that leads to succeeding creates memories that you can rely on during an exam.

Use Your Resources

When we hackers develop algorithms and write code we all get stuck.  Don’t bang your head against a wall for too long.  Get help and use your resources.

When using these resources remember that copying other’s code without citation is plagiarism and that all work submitted for a grade must be your own (no citations allowed).  When writing code for a grade, use your resources to understand how a computation is programmed then implement it on your own without using the resource.

Hello World

Every Java program starts off as a set of class definitions. Each class definition has an identifier that begins with a capital letter and each class resides in a file having the same name as the class and .java as the file extension.

For example, below is a definition for a class named Hello. This class resides in a file named Hello.java.

public class Hello {
    public static void main (String[] args) {
        System.out.println("Hello World!");
    }
}

Every program must have exactly one class that contains a function named main with the following signature:

public static void main (String[] args) { 
    // function body 
}

When the program is executed, the computer begins executing the code within main(). When the program above is executed, the println() method is called which prints “Hello World!” to the screen.

Compiling Source Code

We can compile source code via the command prompt using the following command.

$ javac Hello.java

The compiler (named javac) will create a file named Hello.class which contains bytecode and can be executed with a Java Runtime Engine (JRE).

Executing Java Bytecode

To execute the bytecode in Hello.class from the command prompt we use the following command:

$ java Hello

Here the JRE (named java) that we do not include the file extension. Here, we only specify the name of the class that contains the main() method.