COS 100: Introduction to Programming
Fall 2019
Kattis
Interested in competitive programming? Want more programming challenges? Kattis has lots of problems that you can try solving! Once you learn about lists, you'll have all the tools necessary to solve almost any problem with a difficulty of 2 or less.- Create a Kattis account.
- Start with problem hello: just print "Hello World!" to make sure everything is working.
- Then try timeloop: to make sure you can read and deal with input. (See below for details.)
- Try various problems and see what you can solve!
- If you're interested in officially entering competitions, talk to me.
-
One thing to note is that your program isn't being used by a human tester, so
you won't be using
input()
to collect data. Instead, you can grab one line of input at a time usingsys.stdin
. -
So for instance, if the input is
hi hello goodbye
Then the code:import sys for line in sys.stdin: print(line)
would loop through the three lines of text one at a time and print them. -
If the input contain numbers, you can use
int()
orfloat()
to convert the text to numbers, as usual. - If the input has multiple values on a single line separated by spaces, you can get at each value using stuff we'll learn later. For now, mimic this example.