Lab #6

Before Kattis

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

1

Write a function char_is_in_while(character, phrase) that returns True if the letter character appears in the string phrase, otherwise return False. This function must use a while loop.

2

Write a function char_is_in_for(character, phrase) that returns True if the letter character appears in the string phrase, otherwise return False. This function must use a for loop.

3

Write a function where_is_while(character, phrase) that returns the index of the first occurrence of character in phrase, or return -1 if it does not exist. This function must use a while loop.

4

Write a function where_is_for(character, phrase) that returns the index of the first occurrence of character in phrase, or return -1 if it does not exist. 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!