CAS CS 111 Lecture Notes - Lecture 13: Palindrome, Empty String, Abracadabra
CAS CS 111 verified notes
13/38View all
Document Summary
Cas cs 111 - week 4, lecture 13 - algorithm design. *as professor sullivan counts lectures from 0, this is considered lecture 12 in class. A helper function takes over a specific task within a larger function. In this code we dealt with last week, letter_score(letter) was written to use in the larger function, scrabble_score(word). def letter_score (letter): """ sums up scores of letter in word """ # put the rest of your function here. Returns the number of characters that strings s1 and s2 have in common. Consider concrete cases (lecture12_algorithm_design, pg 4, slide 1) What is the next smaller subproblem? will jscore("lways", "alking") work? no! It will find another shared "a", but there"s only one. Let"s talk about what"s going on in the above solution. What this solution does is it takes the first character in the first string, s1[0], removes it wherever it is positioned string 2.