4
votes
pset6 - Similarities: compare has error receiving lists
Not knowing this problem (regular CS50 without x?), I can tell you what the code does.
results = list(set(alist) & set(blist))
turns the intersection of those two sets into a list.
return [...
3
votes
Pset6 similarities less substrings I get wrong output
Look at your asub and bsub right before returning an answer. (you can use print to see what they are). Looks like they're getting re-defined for each i rather than accumulating a list of all possible ...
2
votes
Accepted
Help understanding similarities pset6
See this: https://stackoverflow.com/questions/30792428/wagner-fischer-algorithm
It was the only way I was able to understand the algorithm. Then, once you know what's going on, check this: https://...
2
votes
Help understanding similarities pset6
The cost is actually matrix[len(a)][len(b)][0] (as matrix[len(a)][len(b)] is a tuple like (4, Operation.INSERTED). But you are meant to return the matrix (a list of lists of tuples), and the calling ...
2
votes
Accepted
PSET6 - Similarities - syntax error?
In python, when you get a syntax error on an apparently correct line, look to the previous line. How many parenthesis characters in the prior return line? It's odd.
2
votes
Pset6 similarities less substrings I get wrong output
You have some substrings that are shorter than the others because there are no n characters left at index i.
How many substrings of length n can you have in a string of length len(a)? n is part of ...
2
votes
Accepted
PSET6 Similarities (More) 500 Internal Server Error
except for the first element, which is supposed to have no operation, but I gave it an Operation.SUBSTITUTED
And this is probably the problem, since that operation subtracts 1 from i and j, which ...
2
votes
Accepted
pset6 (Similarities, more)
De acuerdo a las especificaciones:
Stored in each element of the matrix should be a tuple, (cost,
operation), where cost is an int and operation is an Operation.
So what does the line of code ...
2
votes
What is length in matrix.html?
Since it's in a jinja "statment", maybe it's a jinja thing. An internet search for 'jinja length' finds this:
length(object)
Return the number of items of a sequence or mapping.
Aliases: ...
2
votes
Pset6 Similaritites Less Comfortable
You could indeed utilise the Python's build-in Set type, although not compulsory, together with its intersection method for the purpose of filtering within all three functions.
However, the use of ...
2
votes
Accepted
cs50 Similarities, the relationship between compare and helpers.py
So I'll look into compare.
from helpers import lines, sentences, substrings
This line imports the three functions you are meant to implement. helpers.py gets executed, and the content of variables ...
1
vote
Accepted
PSET7 - Similarities - Won't Pass Substring Tests?
The substrings can overlap. So the word "string" would have 4 substrings of length 3, "str", "tri", "rin", and "ing".
Also, make sure to only have substrings that have the full length (by having your ...
1
vote
Pset6 Similaritites Less Comfortable
the TL;DR: is that sent.tokenize() wants you to send it a string of English text, and it will spit back a list of the sentences contained in that long string (aka a list of strings). See here for an ...
1
vote
Accepted
What is length in matrix.html?
Jinja, unfortunately, does not support executing arbitrary Python code, such as
len(s2)
Hence, in order to get the length of a string, the use of a filter is required.
1
vote
One fail for check50 on pset6 similarities --less
With your remove, you only remove the first occurrence of the element, and only from one list. Also, changing the iterable you are iterating is bad style, can lead to unexpected or sometimes even ...
1
vote
pset 6 - similarities, check50 error
You can't install modules on the server, but just creating an empty 2D array doesn't require a whole library. A simple list comprehension like
matrix = [[None] * width for y in range(height)]
would ...
1
vote
Accepted
TypeError: '<' not supported between instances of 'int' and 'tuple'
One of your problems lies in the line
matrix[x][y] = matrix[x-1][y-1], Operation.SUBSTITUTED
the resulting matrix[x][y] would be a tuple with two elements, first being a tuple itself. You ...
1
vote
Accepted
PSET6 Similarities (more) Could Not Read File1
score expects your text in files. Are cat and ate text files?
Also, to check your operations are correct, you might have to use the flask run web thing.
Your way of picking an operation looks overly ...
1
vote
Accepted
Why are my test files giving out weird results on both my program and cs50's staff solution?
Just tried with two files, one ending lines with CRLF (\r\n) and one with LF (\n). Comparing the CRLF file to itself will match only on the last line (not ending in CRLF), while the LF file will match ...
1
vote
Similarities (More) sometimes fails but works in most cases
You seem to confuse Operation.DELETED and Operation.INSERTED.
Operation.DELETED is used when you advance in the source string a (so you change i) without advancing in target string b, i.e. the source ...
1
vote
Accepted
PSET6 Similarities substrings almost done
I got it. I got confused with the local and global variable of seta = set(x) and setb = set(y)
1
vote
Accepted
PSET6 Similarities HELP!
(Assuming this is python ...)
Technically, the problem is in the line
lista = set(x.append(a[i:i+n]))
You append something to a list, and you try to convert the result into a set. However, the ...
1
vote
Should my distances function return the matrix in PSET6?
Your matrix needs to have len(a) + 1 rows of len(b) + 1 cells. The final distance is found in matrix[len(a)][len(b)], which does not exist in your current matrix. A cell matrix[row][col] corresponds ...
1
vote
Accepted
pset6 similarities: log.html does not log operations correctly
The log relies on your associated operations. Maybe you accidentally use strings and not the required enumeration values.
You should use
Operation.INSERTED if you reached this field by insertion (...
1
vote
Accepted
PSET6: Similarities More --- everything works but the web step-by-step log
I had a similar issue. I had my numbers right, but the wrong operations associated.
If your value is created by a move to the right, the operation is Operation.INSERTED. If the move goes downwards, ...
1
vote
Accepted
Similarities (more) helpers.py line 12
Ok if anyone else has this question, it works just fine with the error, so it appears you can ignore it.
1
vote
Accepted
can someone please tell me whats wrong with my code ? on clicking the compare button on my website , its showing me some error
You don't mention what the error is, but more than likely it's caused by you returning a list inside a list. If list(s) returns a list, then [list(s)] returns a list containing one list. You should ...
1
vote
Accepted
Similarities (more) Internal server error
Take a quick look at score.html, don't you notice that at line 6, it already includes matrix.html into the page? Notice that it also includes log.html at line 11?
The point that I'm making is that, ...
1
vote
Accepted
pset6 similarites more distances wrong operations
I think your insertCost is actually your deleteCost and the other way around.
1
vote
Accepted
PSET6 Similarities Web Form Errors "Cannot POST /compare" and no CSS
You're browsing templates, not pages generated from templates.
You need to call flask run in your similarities directory, and point your browser to the URL flask will present.
Something like
cd ~/...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
similarities × 55pset6 × 45
more × 7
python × 6
less × 6
substrings × 6
pset7 × 5
server × 2
flask × 2
pset6python × 2
walkthroughs × 2
compare × 2
matrix × 2
edit-distance × 2
cs50x × 1
check50 × 1
error × 1
html × 1
string × 1
help × 1
web × 1
index.html × 1
webserver × 1
morecomfortable × 1
list × 1