A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • 4 years ago

I just did ps3a and I created the iterative function. It works but if anyone has any suggestions on how to improve it and clean it up, please let me know. http://dpaste.com/hold/694021/

  • This Question is Closed
  1. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    http://dpaste.com/hold/694122/

  2. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Ok! This is what I got for ps3a. I´m not sure if I understood correctly what it is that it asked for, since it was way too easy, in comparison to the last assignments, to get to it. def countSubStringMatch(target, key): x = target y = key z = 0 ctr = 0 while find(x,y, z) != -1: if find(x,y,z) == z: ctr += 1 z += 1 print ctr Can anyone please enlighten me on what it is that needs to be done so that I can get my butt kicked like I´m supposed to?

  3. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Oh! And while I´m at it, here´s my answer to PS3b: def SubStringMatchExact(target, key): x = target y = key z = 0 while find(x,y, z) != -1: if find(x,y,z) == z: print z z += 1 Again... I´m pretty sure I´m not doing what they´re asking of me. Can anyone help?

  4. maitre_kaio
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    EFarias: your implementations give the right results, so it"s ok. Don't worry about the difficulty, the maths will come back soon ! Just a few notes: 1. You don't have to rename the parameters. Just use target and key in the function. 2. For substringMatchExact (but I guess it makes sense for the other functions too), you should return a value, not print it. 3. Your code is not very efficient, since in the while loop you are searching a first time for the key from pos z, if you find it, you continue to search it until the position where key is found is equal to z, incrementing z by 1 each time. You could do better by setting z to the right position.

  5. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    what is your code for the recursive part of this same question

  6. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    http://dpaste.com/hold/692393/

  7. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    http://dpaste.com/693400/

  8. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.