Okay, I'm pretty happy with my PS3. I have one issue with it, and that is the only way I could figure out how to fix a bug was to change the uni-provided template. That bug was, when the key is a single character, the last alternative in the final tuple (where only non-exacts are there) doesn't appear. The actual problem is in constrainedMatchPair but I couldn't fix it there. Did anyone else encounter this problem and come up with a solution that is within the template? In the dpaste I have provided a test 1 and the test 2, the test 1 is (should be) correct and the other should show...
I didn't originally consider a single letter key before you posted this. I also haven't restricted myself from tweaking the functions 'they' have provided us. After i thought about it, a single letter key didn't make any sense in this context - in subStringMatchExactlyOneSub i added a test for a single letter key and decided to print an 'error' statement and ruturn an empty tuple.
I'm still kinda unhappy about this. In their test they include a single letter test, well 2, ('atgaatgcatggatgtaaatgcag','a') is one of them. I presume that a single letter should return a tuple with all the letters except that letter. I have played around with it quite a lot. I can't figure any way, I tried to switch the formula from k == n + length + 1 to n == k - length - 1 and the answer is still the same from what I can work out. I have also tried to say, if the length is 0, k==n but this creates problems when it looks for, say '' and 'tg' (atg). It doesn't make sense anyway, as the gap is supposed to be a space. I can't put an if statement to deal with this in the constrained part, because that part dosen't know when the second letter is a single letter, it is just provided with tuples. Potentially I could add another argument but it annoys me, as this wasn't part of the given guidelines either, so same issue really. I'm going to stick with what I've got and move on, but I'm not wholly satisfied with my answer. I'm providing a less complex program if people want to look and consider. It is only the constrained MatchPair one, the tuples are correct, the outcome should be a tuple of the same but the outcome is a tuple of one less. In the exactonesub, when testing 'a' becomes keys of '' and ''. While that isn't quite right, it is fine, it works itself out as it basically says all of them except exact, and that is what I am looking for in a single letter key anyway. Only it doesn't provide all of them. http://dpaste.com/559505/
for mine: the case where key1 or key2 is an empty string ('key1 = '' and key2 = 'tg' ): -substringmatchexact returns an empty tuple for that key -in constrainedmatchpair if one of the matches is an empty tuple, it just returns the other match in your testconstrainedMatchPair, how can firstmatch have elements if key1 length is 0?? if key1 is an empty string there shouldn't be any matches should there? http://dpaste.com/559521/ you can see from my comments in constrainedmatchpair that i thought there was something not kosher about null keys
Yeah, null keys are stupid... lol. I guess that for everything except the single letter that your approach should work, and makes better logical sense. I put as a condition that if the user puts 'a null key as the initial key, it will return None, but when the program splits them up, I took the approach that a null key like a wild card. This, mainly because of the single letter issue, plus it also works for all the others as well. It certainly does make more sense, your approach, including to ignore the single letter, except the single letter is in the test cases. But when I think about it, your approach could work fine for my feelings about the criteria, it would return secondMatch, which for me is all.. which gets it out of the uni template and within the task guidelines and yay!!! Well, it is solved in theory... I'm off to try it out :)
:)
Eh... ha no not quite... I still need to know the second length I see, but nvm, I am now convinced my ideas about single letter are impossible to do inside the guidelines exactly. Perhaps they did expect the result to be an error anyway.. :(
Join our real-time social learning platform and learn together with your friends!