CS50 DNA works for small.csv but not for large

后端 未结 2 2008
挽巷
挽巷 2021-01-27 00:46

I am having problems with CS50 pset6 DNA. It is getting all the right values and gives correct answers when I use the small.csv file but not when I use the large on

2条回答
  •  我在风中等你
    2021-01-27 01:15

    earik87 is absolutely right! Just I like to add, the code is missing an = to work for all the cases especially when you have redundant sequences.

    while i < len(samples):
        hold = samples[i:(i + size)]
        if hold == keys:
            run += 1
            #ensure the code does not go outside len of samples **( I added =)**
            if ((i + size) <= len(samples)):
                i = i + size
            continue
        else: #only if there is no longer sequence match, check this.
            if run > longest:
                longest = run
                run = 0
            else: #if the number of sequence match is still smaller then longest, then make run zero.
                run = 0
        i += 1
    

提交回复
热议问题