2017-03-06

posted Mar 6, 2017, 6:54 AM by Samuel Konstantinovich
After the quiz, work on these problems: (they will be added to codingbat later) You should work on them tonight, but can have another night to work on them. 

1. makeBoxOfNumbers(rows,cols) will accept two integers rows and cols, it will then create a string with a box of numbers that is rows digits tall, and cols digits wide. It ends each row with a newline character so it prints nicely. The numbers should be the numbers 0-9 repeated over and over again. (hint: You can easily do this by counting normally and only looking at the ones digits ... 7 8 9 10 11 12 -> 7 8 9 0 1 2)
e.g.
makeBoxOfNumbers(3,6) returns: '012345\n678901\n234567\n'
that string would print like this:
012345
678901
234567

2. removeCharFromString(s,c) accepts a string and a character, then returns the string with all instances of that character removed. (Hint: slices)
e.g.
removeCharFromString('Bloop pow woot', 'o')  returns 'Blp pw wt'
removeCharFromString('ich bin ein holtzfaller', ' ') returns 'ichbineinholtzfaller'

3.removeFromString(s,part) accepts a string s, and a string to be removed from s called part. Return the string with all instances of that part removed. (Hint: do not try to use the previous solution)
e.g.

removeFromString('aababa', 'aba')  returns 'aba'
removeFromString('Bloop pow woot', 'oo')  returns 'Blp pow wt'
removeFromString('Bloop woot pow woot', ' woot')  returns 'Bloop pow'
removeFromString('ich bin ein holtzfaller', 'n ') returns 'ich bieiholtzfaller'
Comments