Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

I'm working on PS3, part 3. I can't say I understand the question. Can anyone help me out? The problem states "Write a function (called constrainedMatchPair) which takes three arguments: a tuple representing starting points for the first substring, a tuple representing starting points for the second substring, and the length of the first substring. The function should return a tuple of all members (call it n) of the first tuple for which there is an element in the second tuple (call it k) such that n+m+1 = k, where m is the length of the first substring."

MIT 6.00 Intro Computer Science (OCW)
See more answers at
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly


Get your free account and access expert answers to this and thousands of other questions

Apparently I'm verbose; my question wouldn't fit in the space provided. So here's the rest of it. So is this correct? n= a tuple representing starting points for the first substring, k= a tuple representing starting points for the second substring, m= the length of the first substring. If anyone has completed this part of the PS3 set, could you please post it?
I also haven't written that function, because misunderstanding of the problem. I was trying all evening to understand that problem, but I didn't get it. I think if anyone explains you the problem in little simpler way, you will get it. Here is solution for all problem sets, from one of the member of this study group:
you are correct, JulieNewbie, about constrainedMatchPair arguments for each element in n is there an element in k that meets the equation. if there is, then 'save' this (n) element. when you are done checking all the elements in n, return all the elements that were 'saved'

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

I'm having the same issue here. I don't understand what this function is supposed to return.
I can tell you what it's supposed to return. You're trying to find near-matches to your key string inside of the target string. So you break the key into two parts (key1 and key2), search for those, then use the equation n+m+1 = k to find near-matches of the entire key. Then you report these near-matches by printing a tuple of the starting indices of each near-match inside of the target. So an example would be match ATGC against ATGACATGCACAAGTATGCAT You can see that the firs 4 indices of the target are "ATGA" which is the same as the key except it has one substitution. So you would create a list to save "0" because the near-match starts at index 0. You add to this list all the starting points of other near-matches, which would spit out [0, 5, 15] for this example. ( I think... I did it by looking at it as opposed to running the script I haven't written yet...)
Something else I'm hung up on is this: they say in the assignment to report tuples. However, tuples are immutable, so how in the world can I iterate through the string & keep track of the answers? Seems to me the only option is to create a list.
use the tuple function to turn the list you have been working with into a tuple return tuple(myList)
O. M. G. It's that easy??? What would I do without this study group?
i really don't know what the consequences are, i/we haven't been working with very large data sets. but it is so easy to change data types back and forth, if i need to do something i look for methods in other data types and see if i can make it work.
Interesting. I read somewhere (in the readings for this class) that mutable lists leave your code vulnerable to malware, so tuples would be more secure. However, if the data types are so easy to change, then it wouldn't matter anyway.

Not the answer you are looking for?

Search for more explanations.

Ask your own question