Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from quality import quality
- # Question 17
- print(quality("one easy way to con serve water"))
- # Questions 18, 19 and 20
- def split(text):
- # Data
- n = len(text)
- q = [0 for _ in range(n+1)]
- q[0] = 0# αρχική τιμή του αναδρομικού τύπου
- # For-loops
- for i in range(1, n+1):
- maxI = -float('inf')
- for j in range(0, i):
- value = q[j] + quality(text[j:i])
- if value > maxI:
- maxI = value
- q[i] = maxI
- return q[n]
- # MAIN FUNCTION
- text = "the574thbombardmentsquadronisaninactiveunitedstatesairforceunitthesquadronwasaworldwariiunitassignedtothe391stbombardmentgroupaftertrainingintheunitedstatesthesquadronmovedtoenglandandparticipatedinoperationsagainstgermanyfromthereandtheeuropeancontinentaspartofixbombercommanditearnedadistinguishedunitcitationforitscombatactionsfollowingv-edaythesquadronreturnedtotheunitedstatesandwasinactivatedattheportofembarkation"
- print(split(text))
- # print(quality(text)) ----> -420000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement