Homework 1
CS1210, Fall 2021
Due Tuesday, Sep. 14, 2021, by 8:00am
6 points

Note: you may not use lists, dictionaries, list comprehensions, or similar Python constructs not taught yet in this course.
1. Write function q1(origString, repeatCount, lettersToRepeat) that takes as input a string of characters, origString, a non-negative integer, repeatCount, and string of lower-case letters, lettersToRepeat, and returns a new string such that each letter in origString that occurs (ignoring case!) in lettersToRepeat is replaced by repeatCount consecutive copies of that letter (with the same case as in the original).

NOTE: You may not use any string methods except for lower(). For example,
>>> q1("Aab", 2, "az")
'AAaab'
>>> q1("Our cat is funny.", 5, "aeiou")
'OOOOOuuuuur caaaaat iiiiis fuuuuunny.'
>>> q1("Our cat is funny.", 3, "zu")
'Ouuur cat is fuuunny.'
>>> q1("Hi there, Jim!!!", 2, "jix")
'Hii there, JJiim!!!'
>>> q1("caat", 0, "az")
'ct'

2. Implement function q2(num, string1, string2) so that it returns True if the input strings are the same length and differ at exactly num character positions, and returns False otherwise.

NOTE: Use a simple loop comparing corresponding characters directly. You may not use any string methods.
For example
>>> q2(1, "bat", "bet")
True
>>> q2(1, "art", "rat")
False
>>> q2(1, "art", "ran")
False
>>> q2(2, "art", "rat")
True
>>> q2(3, "art", "ran")
True
>>> q2(2, "abcde", "abada")
True
>>> q2(99, "abcde", "abada")
False
>>> q2(-1, "abcde", "abada")
False

3. Implement q3(inputString, minLetter, lettersToIgnore, specialLetter) so that it returns three things: inputString is a string a zero or more lower case letters, minLetter is a lower case letter, lettersToIgnore is a string of zero or more lower case letters, and special letter is a lower case letter NOT in lettersToIgnore. Use a simple while loop. You may not use any string methods (such as .count()), but you may use the 'in' or 'not in' operators.
E.g.
>>> q3("bccacbd", "a", "eb", "z")
('c', 4, False)
>>> q3("bccacbd", "a", "aefg", "d")
('b', 5, True)
>>> q3("abc", "d", "", "a")
(None, None, True)
>>> q3("aaabac", "d", "", "a")
(None, None, False)
Remember, as in HW1, to return three values, simply list them in the return statement with a comma separating each. E.g. return (smallestLetter, indexOfSmallestLetter, specialIsOddlyThere) or return smallestLetter, indexOfSmallestLetter, specialIsOddlyThere

Submit to ICON one python file containing the required functions. The file must not contain any code (other than, perhaps, "import math") that is not part of a function definition.