[personal profile] aranthe posting in [community profile] intro_to_cs

Oops! I almost forgot about problem 4. I didn't have time to attempt a recursive solution for this one. (Off the top of my head, I think the key would be to encapsulate the loop portion into a recursive function, rather than to make the entire subStringMatchExactlyOneSub function recursive.) If you've done one, please post it.

PS3: Problem 4 » Solution

def subStringMatchExactlyOneSub( key, target ):

    subOneMatches = sorted(subStringMatchOneSub( key, target ))
    exactMatches = sorted(subStringMatchExact( target, key ))

    exactOneMatches = ()
    for subOneMatch in subOneMatches:
        if subOneMatch not in exactMatches:
            exactOneMatches += subOneMatch,
    return exactOneMatches
From:
Anonymous( )Anonymous This community only allows commenting by members. You may comment here if you're a member of intro_to_cs.
OpenID (will be screened if not on Access List)
Identity URL: 
User (will be screened if not on Access List)
Account name:
Password:
If you don't have an account you can create one now.
Subject:
HTML doesn't work in the subject.

Message:

 
Links will be displayed as unclickable URLs to help prevent spam.

Profile

Introduction to Computer Science

July 2010

S M T W T F S
    123
45678910
11121314151617
18192021222324
2526272829 3031

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 25th, 2017 06:11 am
Powered by Dreamwidth Studios