Lab #6

Before Kattis

We’re going to do a bunch of linear searchers to start.

1

Write a function char_is_in_while(char,string) that returns True if the character char appears in the string string. This function must use a while loop.

2

Write a function char_is_in_for(char,string) that returns True if the character char appears in the string string. This function must use a for loop.

3

Write a function where_is_while(char,string) that returns the index of the first occurrence of char in string. This function must use a while loop.

4

Write a function where_is_for(char,string) that returns the index of the first occurrence of char in string. This function must use a for loop.

Kattis Problems

Grab a scrap piece of paper to start scratching your ideas down on paper. The problems are getting tricky enough where this really is becoming a requirement.

Warning

If you get really stuck on any question, move on to the next one! Do not get bogged down.

  1. https://open.kattis.com/problems/autori (slow down and think about how you do this in real life).

  2. https://open.kattis.com/problems/apaxiaaans

  3. https://open.kattis.com/problems/hissingmicrophone

  4. https://open.kattis.com/problems/trik

  5. https://open.kattis.com/problems/pot

  6. https://open.kattis.com/problems/filip (is there an easy way to reverse a string in Python?)

  7. https://open.kattis.com/problems/reversebinary

  8. https://open.kattis.com/problems/sevenwonders

  9. https://open.kattis.com/problems/zamka

If you finish this lab, go check out LeetCode. Sort the problems by Acceptance (click the table header) and start seeing if you can solve some of these problems.

ENSURE WE HAVE RECORDED YOUR COMPLETION. FAILURE TO DO SO WILL RESULT IN A GRADE OF 0!

Warning

If you are in the online section, you must submit the .py (python scripts), not the .ipynb (notebook files). To get the python scripts from Colab, simply select File and in te dropdown menue, hit Download .py.