Questions tagged [pset6]

The problem set for Week 7

Filter by
Sorted by
Tagged with
0
votes
1answer
29 views

Count the number of spaces in a string in python

I was trying to figure out how to calculate the number of spaces in a string when i came across this code online. Can someone please explain it? text = get_string("Enter Text: ") spaces = ...
0
votes
1answer
53 views

pset6 count STR in the DNA sequence issues

so i m a bit confused...i have been testing my code using the small database and what i have so far produced what i expected .... more specifically the STRcounts (i marked that part #?????). it is ...
0
votes
0answers
53 views

PSet 6 DNA: Not able to match variables to dictreader names

I've mostly completed my code for PSet 6, except for the last part where I need to match up the values against the list of names. I know how to get the maximum occurances of the STRs and state the ...
0
votes
0answers
43 views

Can't figure out how to fix my code, any help please?

# open the CSV file and read its contents into memory with open(argv[1], newline = '') as csvfile: readCSV = list(csv.reader(csvfile)) for raw in readCSV: pass # Your program should ...
0
votes
0answers
55 views

pset6 DNA only getting “no match” SPOILER

I'm new to programming and have been stuck on the pset6 DNA assignment for a long time. The code outputs "no match" for everything, even though the output numbers from calculating the STR ...
0
votes
0answers
58 views

I'm stack with dna (pset6). can you please help me?

I have divided my code into three main pieces: 1- open the CSV file and read its contents into memory and open the DNA sequence and read its contents into memory 2- compute the longest run of ...
0
votes
1answer
114 views

PSET 6 DNA: How to get number of repeats for each value of STR's? [SPOILER: Full code]

I have written a code to count the highest number of consecutive repeats of specific DNA substring sequences in a long string of DNA...or so I thought. While my code can correctly count the longest ...
0
votes
1answer
46 views

DNA: Errors in sequences.3 and 18.txt

I have worked hard on writing codes for DNA. Everything works except for sequences/18.txt, which returns "Harry" instead of "No match". The problem still exists in spite of several ...
0
votes
0answers
25 views

DNA.py error: 'TypeError: unsupported operand type(s) for *: 'NoneType' and 'int''. It passes all but 2 of the tests

DNA.py is nearly finished, but it is failing the tests with sequence/15.txt and 16.txt. This is the error message: ~/pset6/dna/ $ python dna.py databases/large.csv sequences/16.txt Traceback (most ...
0
votes
1answer
37 views

Pset6 Mario More

I submitted my code for Mario More in Python. Although it works properly by my own checks it gives me a 6/9 when submitted. from cs50 import get_int def main(): n = height() for i in range(n)...
0
votes
1answer
116 views

Pset 6 DNA: improving efficiency

I've successfully submitted the below code on Pset6 for the DNA problem. But, I know my 'get_longest' function is a horror show as far as efficiency is concerned: I am doing a series of checks that I ...
0
votes
1answer
52 views

Issue with recording STRs in memory (PSET6 - DNA)

I'm trying to record the number of repetitions of each str in the sequence. I created a dictionary as below and another empty dict because i couldn't update a dict while iterating through it. But for ...
0
votes
1answer
161 views

Struggling with PSET6 DNA

I've been doing this for quite some time now, but I'm struggling to get the appropriate output. In the below code (which is incomplete as of now, but the main pieces are all on the board), I'm not ...
0
votes
0answers
68 views

PSET 6 DNA ~ some STR count is above the correct value by 1?

I'm almost done with pset6 hopefully but I have one problem with my code When i run it with for example python dna.py databases/small.csv sequences/4.txt python dna.py databases/large.csv sequences/10....
0
votes
0answers
35 views

Cs50 pset6 readability.py math

I'm trying to run this code and everything complies but when I enter the text in it is giving me the wrong grade level. I believe it might be something in the math, but am still unsure. Here's my code:...
0
votes
1answer
108 views

Pset6 DNA Not matching to names in the database

The print statements seem to turn out what I hoped for up until trying to compare the STR counts to the database STR counts. I would just appreciate any pointers of where I'm going wrong thanks. ...
0
votes
0answers
47 views

Almost Done… But substrings

// Returns true if word is in dictionary else false bool check(const char *word) { //Variables bool looping = true; int hashWord = hash(word); //Create a new pointers node *head = table[hashWord]; ...
0
votes
1answer
45 views

PSET6 Credit - checksum not giving the correct number

list1 = list(input("Number: ").strip()) even_count, odd_count, count = 0, 0, 0 # if the length is even if len(list1)%2 == 0: # iterating each number in list for num in list1: ...
1
vote
1answer
39 views

Unexpected error in homemade string search function

I am playing around with Python on the DNA problem. I realize there are some string methods that might make this problem easier but my gut instinct was to try and make an "search function" ...
0
votes
1answer
52 views

Struggling to align pyramid and check for extra spaces at the end of each line in pset6 mario.py less

I'm struggling to meet these specifications - "Be sure that the pyramid is aligned to the bottom-left corner of your terminal, and that there are no extra spaces at the end of each line." ...
0
votes
0answers
41 views

DNA Pset6 Can't run my program

I cant even run my program it keeps saying "list index out of range". I don't know whats wrong... Does anyone have any idea? import sys import csv def repeats(seq, part): rep = [0] * ...
0
votes
1answer
133 views

Pset6 DNA help - trouble calculating STR repeats with long database

I have really tried to just solve this one myself but after a few weeks this seems futile without guidance. I am having trouble getting a for loop to calculate the maximum consecutive occurrences of ...
0
votes
3answers
98 views

PSET6 Mario Python

I have been experiementing with this code for a couple hours and have come across an issue with each implementation. I can no longer put in any time at the moment so I figured I would go ahead and ask....
0
votes
0answers
97 views

PSET6 DNA [SPOILER] Refactor

I have solved the problem however is there anyway to optimize this further? Also, how do I judge the time-space complexity of the same? import csv from sys import argv, exit from csv import reader, ...
0
votes
0answers
80 views

Confused about DNA in pset6

I've just started DNA, and I've got what seems to be a working algorithm to see if the count of the STRs in the database and sequence are the same, but it does not seem to be working. I've been a bit ...
0
votes
0answers
88 views

PSET 6 DNA! Stuck for so long

so the problem I face is when computing the greatest number of STR's in a sequence. I was able to hardcode "GATA" and compute the greatest sequence for a textfile using my sequencecount ...
0
votes
0answers
96 views

cs50 pset6 DNA, minor differences in counting STRs |Spoiler entire code included|

My code counts STRs for some people correctly, but for others the difference is very small. For example for python dna.py databases/large.csv sequences/5.txt expected output is Luna, whose STR counts ...
0
votes
0answers
44 views

PSET 6 - credit, pythonic or not?

I didn't do credit for problem set 1 (I chose less comfortable) so I don't know what the C implementation was. I was wondering if you guys think this is too C-like or if it's okay for python code. Any ...
0
votes
0answers
36 views

How can I compare 2 dataframes on DNA?

obtained 2 data frames but I really don't know how can I compare them. Do you have any ideas? ~/pset6/dna/ $ python dna.py databases/small.csv sequences/1.txt name AGATC AATG TATC 0 0 4 1 ...
0
votes
0answers
45 views

SPOILER - CS50: Python PSET6. How do I ensure that my code does not show 1 and 2?

I am about halfway done with my python Pset6 code for DNA. One problem I have been having is that without this particular line of code below: lresults = [i for i in lresults if i != '1' and i != '2'] ...
0
votes
1answer
123 views

PS6 - DNA (Python) Weird problem counting STRs

Which part of the problem are you working on? I am at a very early stage of the problem, trying to scan a specific sequence for STRs, counting how many times they show up and storing this count as a ...
0
votes
1answer
163 views

PSET6 DNA only getting no match

I've been stuck on this pset for days, trying to get some help here :x Basically my program only outputs no match no matter what I do. I tested my re.finditer separately and it prints out what I want, ...
0
votes
1answer
101 views

Else is ruining my code in dna and I don't get why

I'm trying to record the longest run of each STR I need and I'm close. Without the final "else" the code works fine with small dictionary and almost fine with long (because the count I ...
0
votes
1answer
234 views

My code is 95% correct and I can't understand why. Why, Harry? WHY?

I can't figure out why just only one is not correct. I really need to understand this. Please, help me import sys import csv # Open sequence file sequence_file = open(str(sys.argv[2]), 'r') ...
0
votes
1answer
231 views

PSET6: DNA returns “no match”

import csv import sys def maxrepeats(sequences, substring): # calculate maximum consecutive frequency for each STR repeats = [0] * (len(sequences)+1) for i in range(len(sequences)-len(...
0
votes
1answer
73 views

pset6 DNA - range() not working as expected

DNA was a breeze until I got to the part where I have to check the dna sequences for patterns. Regardless of wich file I pass to the program it always detects only 1 repetition for every pattern. ...
0
votes
1answer
68 views

What are the requirements for Week 6 Mario (more)? My code works but the grade book shows only 96% completeness

I tried two different variations but both reach 96% completeness code 1: from cs50 import get_int while True: height = get_int("Height: ") if height < 9 and height > 0: break ...
0
votes
1answer
143 views

PSet 6: DNA gives correct as well as wrong ouput

Problem Set 6: DNA gives output No Match No Match No Match No Match No Match No Match No Match No Match No Match No Match Lavender No Match No Match No Match No Match No Match No Match No Match No ...
0
votes
0answers
85 views

PSET6 - DNA - Code works for small database, but not large

I believe that the issue comes from my 'sequencing' function. When I run the small database, everything works, however, when I run the large database, the counts of specific STRs are incorrect. I'm ...
0
votes
0answers
57 views

Can you help me making my pset6's 'dna' more dynamic

I want suggestions on how to manage my so many lists in the loops. Hello helpful soul, I actually can't figure out how I can declare lists more dynamically, and thus using them in the loops easily. ...
0
votes
0answers
107 views

PSET6 DNA algorithm help and comparing data

I've really struggled with DNA trying to come up with a good algorithm. I have half my code written, but I have no idea how to compare the data in the Dict with the CSV file. Any thoughts would be ...
1
vote
0answers
52 views

PSET6: dna.py, updating dictionary

I'm struggling with Python, specifically adding/updating keys and values in a dictionary. This is my code so far (I know it's probably far from perfect, this is my first time working with Python, ...
0
votes
0answers
61 views

Using csv.reader and csv.DictReader on the same file

I'm working on pset6 - DNA. My code is a work in progress, but the part I'm having trouble with is at the bottom. Right now I'm running without cmd line arguments, so I'm opening 1.txt and small.csv. ...
0
votes
1answer
306 views

Pset 6 Readability returns higher than expected grade

My code is right below I am unable to find the issue because my C code for readability was basically the same(except syntax and formatting of course!) and it was working perfectly. This Python code is ...
0
votes
1answer
122 views

Pset6, DNA - Convert all columns in a list to integers, skipping the first column

I'm trying to figure out how to take the csv file I opened and convert specific columns to ints since when the csv is opened and read, every element becomes an int. Inside of the for row in csv_list:...
0
votes
1answer
44 views

Counter fails to update for DNA

My dna program always returns no match and after debugging it I've pin pointed the problem to the counter not updating correctly. My program finds the correct number of matches, which I've confirmed ...
0
votes
1answer
248 views

DNA pset6 - Unable to calculate maximum STR repeats in DNA file

Below is my code for PSET6 DNA: from sys import argv import csv # "string" represents the DNA chain and "substring" represents an individual STR e.g. "ACTGC" def maxrepeats(string, substring): ...
0
votes
1answer
59 views

pset6/less/Mario passing all checks, but score at 90%

My code is getting 9/9 on the check. Visually it seems fine as well. There doesn't seem to be any preceding or trailing empty spaces. The score, however, is 90%. Any help in identifying the mistake ...
0
votes
1answer
37 views

I keep on getting index out of range?

from cs50 import get_string s = get_string("Text: ") letter = 0 i = 0 word = 1 sent = 0 while s[i] != None: if s[i] == ' ': word = word + 1 i = i + 1 elif (s[i].isalpha()): ...
0
votes
0answers
92 views

DNA is good for the small database but not for the large database - CS50 Pset6

I'm currently developing the small and the large database functions separately and I wonder why in the large one it does not keep track of the STR repetitions. Here is my code from both functions: ...

1
2 3 4 5
17