CAS CS 111 Lecture Notes - Lecture 13: Palindrome, Empty String, Abracadabra

126 views4 pages
Verified Note

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.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers