Questions tagged [pset6]

The problem set for Week 7

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

Mario (less) PSET6 Python Spacing help

Slightly embarrassed to be posting this as I could succesfully complete mario(less) in pset1 but apparently cannot replicate it in Python. My code is as follows: h = int(input("h: ")) # get ...
0
votes
1answer
8 views

pset6 mario more - there is a extra line in my output how do i get rid of it

o = input("Height: ") if int(o) > 8 or int(o) <= 0: o = input("Height: ",end = "") i = int(o) for j in range (i + 1): # calculating number of spaces n ...
0
votes
1answer
17 views

Index to integer

How do i convert an index to an integer? I tried int(index), that didnt work. For example; S = [a,b,c,d] For index in S: n = int(index) print (n) break print ()
0
votes
1answer
19 views

Pset6 Readability wrong Grade [duplicate]

Adjusted code to see how many letters, sentences and words counted. Noticed word count is lesser by one from cs50 import get_string text = get_string("Text: ") letter = 0 word = 0 ...
0
votes
0answers
56 views

pset6 dna question regarding searching string for substring, two types of code give different output

I am currently following along ayoutube tutorial for pset 6 DNA, and have a small question regarding a specific function. In this function, it basically takes a substring and a string, and counts the ...
0
votes
1answer
26 views

pset6 credit help with calculations in python

I am trying to convert my credit solution from C to python, but for some reason it is not working. Attached is my code and the problems from cs50 import get_int card, a, m, v = False, False, False, ...
0
votes
1answer
68 views

Getting ONE error on check50 for DNA - ValueError: max() arg is an empty sequence - Where is the bug?

I'm so close the finish line, but I get error on one out of the 21 CS50 tests. The test that is generating the error is number #2, which is: python dna.py databases/small.csv sequences/2.txt And I ...
0
votes
1answer
28 views

DNA - Getting the highest key value from a defaultdict

I have come a bit on DNA and have managed to write an algorithm for adding the number of matches in the sequence to a defaultdict. But I'm having problems with how to get the maximum value from the ...
0
votes
1answer
21 views

Pset6 Cs50 = Readability false output

I have been trying to complete readability python but on every result it is showing before Grade one from cs50 import get_string s = get_string("Text: ").strip() num_letters, num_sentences,...
0
votes
1answer
34 views

PSET6 - Readability: false grade output

from cs50 import get_string text = get_string("Text: ") letters = sentences = i = words = 0 length = len(text) while i < length: if text[i].isalpha(): letters += 1 //...
0
votes
1answer
24 views

Pset 6 - Readability printing one grade off

I managed to translate readability from C to python, except it is printing one grade lower than what it is supposed to when testing. What am I missing here? """ 1) Ask user for phrase 2)...
0
votes
1answer
30 views

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

from sys import argv import csv import re # Only run if argc is 3 if len(argv) == 3: STRs = ["AGATC", "TTTTTTCT", "TCTAG", "GATA", "TATC", "...
0
votes
0answers
35 views

CS50 PSET 6 DNA Just Returns First Name

I've been working on DNA for a while now and thought I was done, but there's a problem with my code. Everytime I run it, the program just prints the first name on the database, so either 'Albus' or '...
0
votes
1answer
61 views

PSET 6 DNA - Computing STRs

I am trying to compute the most repeated STR for each sequence in a dictionary called str_dict. # compute STRs i = 0 # stablish length of the sequence length_seq = len(sequence) # iterate through all ...
0
votes
0answers
37 views

DNA pset6 My code works fine in small csv, but not large (Spoiler)

The problem happens with the count when i try to count STRs, it counts some str right and some wrong, which is strange for me, and when i deal with small csv all works fine. can someone help me in ...
0
votes
1answer
34 views

Print keys of CSV files in DNA pset6

I want to see what the keys of the reader dictionary are so I use the print(key) function. The result is all the lines of the dictionary. Why is that? import csv from sys import argv, exit # Check if ...
0
votes
1answer
40 views

Pset6 mario more didn't pass the test

I run through my code many times and didn't find anything wrong with it but the result printed out wasn't right: from cs50 import get_int while True: height = get_int("How high is the pyramid?...
0
votes
1answer
63 views

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

My code works fine for the small csv file; however, when I get to the big csv file, my counts for the number of consecutive STR are less than the actual value by about 1 or 2. Here is my code: import ...
0
votes
0answers
43 views

DNA works with most names except Alice and Albus

I really don't undersrtand why this is happening. I'm trying to finish DNA for pset6. Since more elegant methods were too difficult for me, I decided to compare all values in STR one by one against ...
0
votes
1answer
44 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
109 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
68 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
59 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
96 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
85 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
161 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
73 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
36 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
50 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
172 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
62 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
214 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
79 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
38 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
137 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
48 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
48 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
43 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
66 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
43 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
159 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
153 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
109 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
89 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
108 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
113 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
54 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
41 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
47 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
133 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 ...

1
2 3 4 5
17