In ps3 part 3, I have this code currently: http://codepad.org/oh5iNypG What I'm curious about is the output. On lines two and eighteen I've got a tuple of the entire range of the target, but I'm not sure if I should do that (use the entire range) or use an empty tuple. This problem was a bit confusing for me. In ps3 part 3, I have this code currently: http://codepad.org/oh5iNypG What I'm curious about is the output. On lines two and eighteen I've got a tuple of the entire range of the target, but I'm not sure if I should do that (use the entire range) or use an empty tuple. This problem was a bit confusing for me. @MIT 6.00 Intro Co…
I had this same problem, so I basically put in a condition to make sure the length of the key > 0, and if so run the find function. This will return an empty tuple.
This will return an empty tuple for keys of length = 0 (is what I meant to say at the end there)
in hindsight, my code isn't returning proper results and yours is! So I think returning a tuple of the entire range of the target is best. The problem with returning an empty tuple is that the for loops in def constrainedMatchPair(firstMatch, secondMatch, length) don't run. That said, your results look to be correct for ps3 part 3, you just need to get rid of your duplicates, and I recently learned that sets don't contain duplicates, so converting the tuple to a set might solve this however I am on the same ps as you so I could be wrong. Sorry for the rant, just trying to help :)
Thanks for the reply! I was a little fuzzy on what exactly I was looking for when writing this code. Now that I've had some time to get away from it I can see what it's looking for. I'll have to test it some more, but it does seem to be doing everything correct as of now. (Besides duplicating values)
If the string is found at every position in the target, why would you NOT want it to return every position in the target? Imagine these conversations: me: Where can I find the empty string in 'atgacatgcacaagtatgcat'? you: nowhere me: Where can I find the empty string in 'atgacatgcacaagtatgcat'? you: between each pair of characters, and before the first character and after the last character Which answer is a lie? Also, as you know, you're going to use the output of this function as input for another function later in the problem set. So just make sure it returns the correct answer to the question.
Join our real-time social learning platform and learn together with your friends!