1 vote

CS50 PSET6 DNA problem. Need advices to make my code more pythonic

This isn't that long. Maybe consider using a dictionary for shtares as well. You don't really make good use of dictionaries here. You have several of these for x in range(len(keys)) type loops, which ...
user avatar
1 vote
Accepted

What does "consecutively" mean in pset6 DNA?

The databases/small.csv file from the distro code looks like this: name,AGATC,AATG,TATC Alice,2,8,3 Bob,4,1,5 Charlie,3,2,5 The file is 57 bytes and dated 21-Oct-2019. Perhaps redownload the distro ...
user avatar
1 vote
Accepted

Pset6 DNA. How to use a list in re.findall?

Make it an "fr" string and use a replacement field (string interpolation) as with re.findall(rf'(?:{findme})+', sequence) Where findme is set to the nucleotide to match.
user avatar
1 vote

PSET6 DNA Think I'm getting an infinite loop which is apparent when testing with every txt file after 4.txt

The proximate cause of the infinite loop is this while in the repeatss function: while dna_str[j : j + len_str] in str_csv[i]: curr_str += 1 j += len_str In ...
user avatar
1 vote
Accepted

check50 gives different output than my own for "18.txt" sequence. All others pass. Any thoughts/suggestions are appreciated

If you look at the databases, you'll see that Harry (which your code produces for sequence 18) is almost an exact match with one exception. Sequence 18 contains TCTG 41 times, rather than the 40 times ...
user avatar
  • 930
1 vote
Accepted

PSET 6 DNA - Computing STRs

What is the value of i when the function moves on to the next str?
user avatar
  • 930
1 vote
Accepted

Computing consecutive STR is sometimes off by a little (Spoiler!)

Your problem is that the nucleotide loop steps through each letter of the sample, but when you find a match your index variable falls out of sync with the letter you are checking. I generally prefer ...
user avatar
  • 930

Only top scored, non community-wiki answers of a minimum length are eligible