Using Kattis

Kattis is a website that allows students to submit solutions to programming problems, and have them evaluated automatically by running a series of test cases on the submitted solutions.

We will be posting a number of exercises on Kattis that you can solve at any time. You are not required to solve these exercises, and they will not be graded, but they will be good practice. Plus, Kattis provides us with a mechanism to look at your submissions so we can provide feedback if you’re having trouble solving a problem.


Before you can submit code through Kattis, you need to complete the following steps:

  1. Go to the Open Kattis registration page and create an account with your UChicago e-mail. If you do not use your UChicago e-mail, we will not be able to find your submissions on Kattis.
  2. Log into the UChicago Kattis site using the account you just created:
  3. Go to the CMSC 12100 Autumn 2017 page on Kattis, and click on the link that says “I am a student taking this course and I want to register for it on Kattis.”
  4. Go to your User Settings (click on the user icon on the top-right corner of the Kattis page, and then select “Settings”) and change the following:
    • By default, the information on what problems you have solved is shown to everyone in the class (you can see what this looks like by clicking on the Queue link on the top of the site). If you would prefer not to show this information, check the “Anonymous mode” option.
    • Set your preferred time zone to “America/Chicago”
    • Set your default language to “Python 3”.

Solving your first problem

Before you attempt any of the problems we give you, you should try to solve the Hello World problem. This problem has a very simple solution: you just need to write a Python program that prints out a “secret message”, which happens to be exactly this text:

Hello World!

The way you submit a problem is by clicking on the green “Submit” button that appears on the right sidebar of the page. This will take you to a page where you can either upload a file, or switch to an editor where you can write the code directly on your browser. Make sure that you select Python 3 as the language before you submit.

After you’ve submitted the code, Kattis will “judge” it, and will send you an e-mail notification with the result. If you solved the problem correctly, you will get an “Accepted” judgement.

You can also check the status of all your submissions by clicking on the user icon on the top-right corner of the Kattis page, and then clicking on “My Profile”. This will show a list of all your submissions. Take into account that this list does not update automatically; if a submission shows up as pending (either “Compiling” or “Running”), you need to reload the page to see its latest status.

You can also get more details on any submission by clicking on the 6-7 digit number on the left column (this is number is the submission identifier).

Next, try to make an incorrect submission. Submit a Python program that prints this:

Hello CS 121!

The submission should be judged as “Wrong Answer”.

Solving the problems we give you

For all the Kattis problems, we provide a Python file that will handle the input/output aspect of the problem, so you can focus on solving the programming problem itself. This means that you can IGNORE the Input/Output sections of the problems (this is already handled for you in the code we give you!)

You can get the files for these problems by running git pull upstream master (they will be inside a kattis directory). In most of these files, there will be code comments instructing you to only modify a specific piece of the provided code. Make sure you read these code comments and that you do not modify any code you’re not supposed to modify.

The problems include some sample data that you can use to test your solution. However, Kattis will run your solution with additional test cases, typically designed to check corner cases. For example, one of the first problems you will work on requires you to check whether a number \(x\) is strictly outside a range \((y\ldots z)\). If you get that problem wrong, you may want to check whether your code is correctly handling the case where \(x\) is equal to either \(y\) or \(z\).

If you get a “Wrong Answer”, make sure you look at the details of that submission (by going to the list of submissions and clicking on the submission identifier). This will show you how many of the instructors’ test cases you are passing.

Kattis may return judgements other than “Accepted” and “Wrong Answer”. You can see a list of all the possible Kattis judgements here:

Testing your solution before submitting to Kattis

Before submitting a solution to Kattis, you may want to run your solution on your own machine to make sure there are no major issues with your code, such as syntax errors or small mistakes that will makes your code return a Wrong Answer even with the sample input.

Suppose we give you a file called as a starting point. Once you’ve modified that file with your solution, you can run it like this:


The program will appear to get stuck (like it had fallen into an infinite loop). This is normal: the program is actually waiting for input. Go to the problem statement on Kattis, and copy any of the sample inputs. For example, in the Divisible By problem, the first sample input is:

0 10 2 3

Copy that text, and paste it into the terminal (note: to paste in the terminal, you need to use Control-Shift-V; you can also just type the input directly). Press Enter, and then Control-D. This will make the problem run with the provided input, and it will print out an answer. If the answer matches the sample output provided in the Kattis problem statement, it means your solution works for that input. At this point, your solution is probably safe to submit to Kattis.

If, on the other hand, you get a Python syntax error or output that doesn’t match the expected output, you may want to debug your solution a bit more before you submit it on Kattis. Otherwise, you will have to debug it using the (sometimes limited) feedback that Kattis provides.

Asking for help

If you keep getting a “Wrong Answer” on a problem, and you can’t figure out what the issue is, don’t hesitate to ask for help during office hours or on Piazza. It will be really helpful if you can tell us the submission identifier of your latest submission. That way, we can take a look at the code you submitted and see why it isn’t working.