cs50 / problems Goto Github PK
View Code? Open in Web Editor NEWChecks for check50
Checks for check50
Where is the check file for population? When I run the check50 for that the verification times out.
Quote "AAAA" is no longer a valid symbol. The outcome is the same after I tested the symbol in the staff solution.
Description in Problem set 2 for vanity plates reads
“… vanity plates may contain a maximum of 6 characters (letters or numbers) and a minimum of 2 characters.”
"OR" means that it could be only letters(without numbers)
Doing check50 for test_plates I got
:( test_plates catches plates.py without checks for number placement
expected exit code 1, not 0
:( test_plates catches plates.py without checks for alphanumeric characters
expected exit code 1, not 0
I realized that I am able to write code that would give me a wrong output or even cause an overflow.
Changing the code in line 147 to if (n == 0)
would potentially skip one of the pairs and not save them which gives two winners as an output when tested on the first example in the instructions while it is only supposed to be one winner.
Changing the code in line 228 to int border = ((last - first) / 2);
would have the effect that unsorted arrays with more than 4 elements would cause an overflow because the recursion will not be stopped for the upper half of the array.
Both of these get full credit from check50. I am not sure what exactly is happening in the check50 algorithm which is why I could not look into it any further. They might be more such cases.
tideman.txt
If either prompt in the einstein.py
code contains digits, check50
will erroneously use those in its comparison of correctness.
Example:
$ python einstein.py
Calculate e=mc^2, using mass: 1
E is: 90000000000000000
check50:
:) einstein.py exists
:( input of 1 yields output of 90000000000000000
expected "90000000000000...", not "2,"
Seems like your output might not be the right number!
Notice that it is picking up the following ,
in the prompt as well. not "2,"
I have managed to (purposefully) make a code that passes check50 for speller, but cannot handle the large dictionary, producing wrong results for every text when the code is run using it.
I have NOT submitted this code as an answer, I have submitted a proper one previously.
Problem found was that loading the words would delete previous words in the same bucket of the hash table (issue observed on a recent exchange in #speller of the discord server), AND that the hash function was discriminative enough to not cause that with any of the check50 dictionaries (idea found from the same exchange, but not found directly in it). Thus, defeated the purpose of making linked lists to solve the problem.
In the exchange that lead to this investigation, the hash function was not discriminative enough and put 'cat' and 'caterpillar' in the same bucket, deleting cat from memory as it was the first word added. However, the problem caught was that the code "could not handle substrings", which isn't the case, since the other words were correctly marked as mispelled.
With all this in mind, I suggest an additional speller check that uses the large dictionary with one of the following txt files:
constitution.txt
pneumonoultramicroscopicsilicovolcanoconiosis.txt
wordsworth.txt
Texts chosen for being small enough to fit in the check50 expected output vs actual output window.
I know I can't share the code here (as to not make a solution easily available), but can do so in private if requested by staff.
Thanks for taking your time to read this c:
In Tideman I came across a situation where Locked pairs function was not working properly. But later after testing manually I figured out that sort pairs didn't sort pairs at all. But check50 said it did. I've attached the code below.
(NOTE:- The code is in its unfinished condition. Currently I've found a way around it but the problem remains.)
chk50 bug.txt
The test is doing assert against $37,817.3283 for 1 bitcoin, this value is doing that all subsequent tests fail.
The tests for professor are currently relying and expecting students' solutions to generate x and y values in a certain order; specifically, x0, y0, x1, ect.
In this case the first level 1 question will be 6 + 6
It does not handle the case where the student generates all their x values first, then y values, e.g. x0, x1, x2 .... y0, y1,
In this case the first level 1 question will be 6 + 9
Are there any other orders that students may use?
error
Make sure your username and/or password are valid and check50 is enabled for your account. To enable check50, please go to https://submit.cs50.io in your web browser and try again. If you're using GitHub two-factor authentication, you'll need to create and use a personal access token with the "repo" scope instead of your password. See https://cs50.ly/github-2fa for more information!
When check50 cs50/labs/2021/x/population and hello
I completed the code for the "outdated' problem in Pset 3 and I successfully passed all test cases except for one. When I manually tested the output that should be given, I found that it's correct and that check50 checks it wrong.
In particular, the check50 function gives me this:
"input of " 9/8/1636 " outputs 1636-09-08
Did not find "1636-09-08" in "Date: ""
When I tested the input, which is 9/8/1636, I get the correct output, which is 1636-09-08.
Is anyone else facing the same issue?
Right After using check50, I put in the input for the "failed" test case and it worked as shown below
The Lab 6 assignment implies setting "N" value up to 1 000 000. Larger "N" values increase program's execution time which at some point is followed by "timed out while waiting for program to exit" response from check50. A bit frustrating.
Check50 results with "N" equal to 1000 and 1 000 000.
execution time (N = 1 000 000) = 8.4s
execution time (N = 1 000) = 0.04s
I have observed that the substitution tests are passing an algorithm to detect duplicates in the key that is not totally correct.
The algorithm in question is simply to add each index in the key
into a sum total variable, and check that the sum is equal to a hard coded number. Which in concept works. All of the provided keys on the cs50 problem description work using this algorithm.
NQXPOMAFTRHLZGECYJIUWSKDVB
YTNSHKVEFXRBAUQZCLWDMIPGJO
VcHpRzGjNtLsKfBdQwAxEuYmOi
As example. A simplified version of this algorithm is
int sum = 0;
for(int i = 0; i < strlen(argv[1]); i++) {
sum += tolower(argv[1][i]);
}
A key, though, that would appear correct to the algorithm that is clearly not is.
oqsuwybdfhjlmnoqsuwybdfhjl
I'm writing out this issue simply in hopes that a check50 test can be created/changed in order to accommodate this simple algorithm issue. So that students taking the course do not trick themselves into believing their code is totally correct, when in reality it only works "most of the time."
I hope we can agree that check50 should provide a test that does not allow a simplified key sum
algorithm to pass all the tests.
The current key for testing if the program handles a non-alphabetical key could incorrectly validate faulty implementations similar to the following if (key[i] < 'A' && key[i] > 'z')
Having the above check in code will pass check50, but there are non-alphabetical characters between A and z in terms of ASCII value: [
, \
, ]
. ^
. _
. and `
these characters would incorrectly pass the example check above.
An example fix would be to replace the 2
in the current check, with any of the characters mentioned above.
CS50 check seems to grade incorrectly.
When I used pytest test_bank.py, it performed as expected when bank.py code was correct, and it performed as expected when bank.py code was altered by using $30 instead of $20 or by removing .lower()
However cs50 check does not recognize that the when the code of bank.py is altered, pytest test_bank.py raises exception.
In addition, I had to include value() function above test_value() in order for cs50 check to recognize that if bank.py code is correct, then pytest test_bank.py raised no exceptions. (Without including value() function above test_value() function, cs50 graded "correct bank.py" code negatively. ) This was the case even so
import bank
from bank import value
was already included in test_bank.py
I accidentally used a wrong iteration variable (inner instead of outer) in check_status()
. This issue concerns only the letter that exists but isn't in the same place.
Here's a terminal screenshot:
The same in plain text, should you need it for some reason:
wordle/ $ ./wordle 5
This is WORDLE50
You have 6 tries to guess the 5-letter word I'm thinking of
Input a 5-letter word: dkjwe
Guess 1: dkjwe
Input a 5-letter word: tomat
Guess 2: tomat
Input a 5-letter word: round
Guess 3: round
Input a 5-letter word: slack
Guess 4: slack
Input a 5-letter word: howgh
Guess 5: howgh
Input a 5-letter word: adolf
Guess 6: adolf
Sorry, the word was china
wordle/ $ check50 cs50/problems/2023/x/wordle
Connecting......
Authenticating...
Verifying........
Preparing.....
Uploading......
Waiting for results........................
Results for cs50/problems/2023/x/wordle generated by check50 v3.3.7
:) wordle.c exists
:) wordle.c compiles
:) wordle rejects multiple command-line arguments
:) wordle rejects 0 command-line arguments
:) wordle rejects inputs that are not 5, 6, 7, or 8
:) wordle rejects guesses that are not of appropriate length
:) wordle accepts guesses of appropriate length
:) wordle recognizes guess with no matches
:) wordle recognizes guess with close match
:) wordle recognizes guess with exact match
:) wordle recognizes guess with exact and close matches
:) wordle recognizes guess with multiple matches
:) wordle recognizes correct guess
To see the results in your browser go to https://submit.cs50.io/check50/fa17fa2524c1a0c449e5d5d88ac2a952d359062e
if if (candidates[i].name == name)
is used in vote for comparing the strings the test fails to catch this and gives a pass for the vote() test.
I suspect this is due to the hardcoding of the test data: e.g. candidates[0].name = "Alice";
and printf("%s", vote("Alice") ? "true" : "false");
the strings are "string literals" ( https://github.com/curiouskiwi/cs50x-help/blob/master/stringliteral.md )
The compiler will only place one copy of the string in memory and use that for all instances where it's needed, so the ptr for both the candidate name and the name passed to vote is the same.
I think Tideman's specification should explicitly state that the problem's test suite doesn't check the values of user-added global variables and that students shouldn't add/use their own global variables when writing their solution program because of that.
This is because I wrote a solution where I did use my own global variable and the program works properly, but fails the check50
tests for print_winner
because that test doesn't seem to use the print_winner
function in the context of the whole program. I think it instead isolates it, whereas my implementation relies on computations done by previous functions and the value of my own global variable.
Alternatively, I think the problem's unit tests should be rewritten to take into account solutions like mine.
For more details, please see a discussion about this I had on Discord with another student.
e.g., zero-division
Hello
The code we are testing ask an API to lookup if a stock is in a database and should return an error code if the symbol of the stocks in question arent there. BUT YOU ARe USING FAKE STOCK (AAAA, BBBB, CCCC) to test the validity of that funtion and yet de test is not pass because it dont find thoses stock
In CS50P, in Vanity Plate project, I noticed that check50 is not testing for spaces or punctuation marks like ? or ! , although it is stated in the requirements:
For example, both inputs "CS50 P" and "CS50?" should fail, but check50 is not checking for those conditions.
The testcase is supposed to test whether the program student write can exit if given a non-existent file. However, this specific testcase gave only one command-line argument, which violates another test (the program has to exit when given anything less or more than two command-line arguments.
As is a common practice to test the number of command-line arguments before testing whether the file exists, this check50 testcase may fails its purpose of testing whether the program can catch an invalid file. Student might not write the except FileNotFoundError and still pass the check50
Suggestion: change the testcase into one that gives two command-line arguments.
For example: python shirt.py non_existent_image.jpg after1.jpg
I got this result for my half.c cs50 practice problem set. All sad faces but my code is correct.
https://submit.cs50.io/check50/73630a07b177aef226393130e6ab58da75cff0dd
Thanks for checking on us!
I started cs50x in 2021, and the speller check50 gave me all green smiles despite the fact that (as I have just discovered after comparing it with speller50 before resubmission) the results are extremely far apart in correctness.
comparing it with speller50 in lalaland.txt, the correct answer showed 955, while my old solution registered 10887, despite that, the latest check50 still registers the answer as correct.
I believe I have located the mistake in my old code to be in the load function, specifically on the line table[h]->next = NULL;
which was removing a lot of words from the loaded dictionary
I don't know exactly which parts of my dictionary.c are used for check50, and it seems said mistake only passed through because of the djb2 hash function used in that submission, as changing said function (since the newer version no longer allows you to use an existing hash function) and I am unsure if the check would pass with other hash functions, but I think it might be good to look into it
I'm not sure how to fix this without revamping the entire benchmark, so I'll just share it as an issue:
Wen the following code were added to dictionary.c
you'd get a total time of 0 seconds.
The linker will just silently link our version of getrusage
instead of the global one.
// dictionary.c
#include <sys/resource.h>
int getrusage(int who, struct rusage *r_usage)
{
memset(r_usage, 0, sizeof *r_usage);
return 1;
}
In an ideal world, only the total execution time would be measured and the program execution isolated, though that does require too many changes for me to monkey patch together.
You could also try to measure the execution time and compare it to the reported one, though quite a lot of time is spent in the parsing step in speller.c
(specifically getc()
), which is not recorded by speller.c
itself.
I'd prefer the prior solution, as this would also allow very keen contestants to optimize the code inside speller.c further. This would also require input randomization, as one could just hard-code the outputs for each known input file. (Depending on the goal of the program the dictionary might not be randomized to allow for better optimizations.)
.PS: the linker option --warn-common
could do the trick too, but I couldn't successfully link speller using ld
and clang's -Xlinker
didn't seem to work either.
Hi,
I'm having problems running check50
with cs50/problems/2022/python/tests/fuel
. The test for fuel.py
works fine and has no issues but the test_fuel.py
tests are acting really weird.
The result of one of the test cases is unstable. The test does not appear to be idempotent. Since the actual test logic is inside pyc
files, I've been unable to figure out why this could be happening.
Output when failing:
$ check50 --local cs50/problems/2022/python/tests/fuel
Checking......
Results for cs50/problems/2022/python/tests/fuel generated by check50 v3.3.7
:) test_fuel.py exist
:) correct fuel.py passes all test_fuel checks
:( test_fuel catches fuel.py returning incorrect ints in convert
expected exit code 1, not 0
:) test_fuel catches fuel.py not raising ValueError in convert
:) test_fuel catches fuel.py not raising ZeroDivisionError in convert
:) test_fuel catches fuel.py not labeling 1% as E in gauge
:) test_fuel catches fuel.py not printing % in gauge
:) test_fuel catches fuel.py not labeling 99% as F in gauge
To see the results in your browser go to file:///tmp/tmpw2ym49my.html
Sometimes this test gives a perfect result but any subsequent runs will result in one test failing. It's always the same test that fails.
My code:
def test_convert() -> None:
assert fuel.convert("100/100") == 100
assert fuel.convert("99/100") == 99
assert fuel.convert("3/4") == 75
assert fuel.convert("1/4") == 25
assert fuel.convert("2/3") == 67
assert fuel.convert("1/3") == 33
assert fuel.convert("1/100") == 1
assert fuel.convert("0/100") == 0
with pytest.raises(ZeroDivisionError):
fuel.convert("1/0")
with pytest.raises(ValueError):
fuel.convert("9/6")
python -VV
: Python 3.11.1 (main, Jan 6 2023, 00:00:00) [GCC 12.2.1 20221121 (Red Hat 12.2.1-4)]
When checking for repeating characters in the key, I multiplied their alphabetical orders thinking it must always be equal to 25! (number of letters in alphabet -1 factorial). It passed all the check50 tests, and it seemed intuitively correct at first, but mathematically it isn't. This is similar to a previous thread made about key sum.
A wrong testing key that would still pass this test is ABCDUBGHIJKLMNOPQRSTUVWXYZ (U and B repeat).
algorithm/pseudocode:
int _index = tolower(key[i]) - 97;
//compute product of all nbrs
if(_index != 0){
productcheck *= _index;
}
//check if equal to 25!
The re.sub expressions can accidentally catch other variables/functions that similarly begin with "int main" causing a compile fail in these 4 problems. I tweaked it slightly and tested it with lots of variations and have submitted a pull request of the fix
In private/init.py, the run_statements function parses the private.sql file with the rollowing regular expression:
queries = re.findall(r".*?;", contents, re.DOTALL)
A TRIGGER statement contains multiple semi-colons, so this will result in check50 returning the error:
:( private.sql runs without error
Error when executing statements: incomplete input
Because it finds the ';' at the end of the inner statement, and then "END;" is missing from the query
Possible solutions:
I wrote a version of the Caesar code without the ctype
library (no isdigit
). It iterates over the characters in the argument and checks if they are digits using this condition:
if (argv[1][i] <= '0' || argv[1][i] >= '9')
This is wrong: it rejects 0 and 9 too. But check50
doesn't complain. Suggestion: write test cases using 0 or 9 as key.
In the problem of Fuel Gauge in CS50P/PSET3 all others were green but the last condition showed this...
:( input of 5-10 results in reprompt
expected program to reject input, but it did not
According to the question it should not be like this and should just be a normal reprompt but the message shows this.
I tried various things to satisfy it and none worked.
Please help as according to me it should not be present.
I was considering filing a pull request for this file: https://github.com/cs50/problems/blob/2020/x/recover/__init__.py
The purpose being, to add a second hash for each file in the case that someone checking or submitting versions of the .jpg's without the trailing zero bytes, would not fail.
However, when I checked the sha256sum
of the jpg's that my code pulls from card.raw
they do not match those in the file linked above.
Are check50
and submit50
using other code?
After completing the blur function in pset4, I came across an error/overlook in the blur check50. My function would find the correct pixel values, however, it mistakenly left a portion of the image black due to a parameter mistake in my code. (I wrote height instead of width for a loop parameter, so it stopped early.) Nonetheless, despite the mistake check50 marked my code correct because the tested images had equal dimensions, meaning width and height were the same, ie. (3x3), (4x4)... Although it is a very minuscule overlook/scenario, I thought it was worth mentioning to ensure the check50 test ensured the code was completely correct.
If I search for a wrong suspect across passengers and airports, I get something like:
name | origin_airport_id | destination_airport_id | abbreviation | abbreviation | city | city | hour | day | month | year
Russell | 8 | 6 | CSF | BOS | Fiftyville | Boston | 16 | 29 | 7 | 2020
Russell | 7 | 8 | DXB | CSF | Dubai | Fiftyville | 16 | 30 | 7 | 2020
Russell | 8 | 5 | CSF | DFS | Fiftyville | Dallas | 10 | 30 | 7 | 2020
I do not know if that is a bug or a feature (or if I am missing something), but that led me to doubt what the tables really meant, as flying from DFS (Dallas) and DXB (Dubai) in the same day without an airport log of travel between both is... suspicious.
I thought it was better to leave an issue just in case.
SQL query =
SELECT people.name, origin_airport_id, destination_airport_id,
origin.abbreviation, destination.abbreviation,
origin.city, destination.city,
hour, day, month, year FROM passengers
JOIN people ON passengers.passport_number = people.passport_number
JOIN flights ON passengers.flight_id = flights.id
JOIN airports AS origin ON origin.id = flights.origin_airport_id
JOIN airports AS destination ON destination.id = flights.destination_airport_id
WHERE people.id = "514354" and year = 2020;
In the 13.sql query, the check passes if you put a line like "AND people.name != "Kevin Bacon".
Kevin bacon should not appear in the query that lists everyone that starred in a movie with kevin bacon(1958) but if there was someone else with the same name they wouldn't be included
The following error code appears after trying to execute check50 function for hello.c,
"Make sure your username and/or personal access token are valid and check50 is enabled for your account. To enable check50, please go to https://submit.cs50.io/ in your web browser and try again. For instructions on how to set up a personal access token, please visit https://cs50.ly/github "
both commands isn't working for me
Filling it as per:
Discovering but failing to disclose to the course’s heads bugs in the course’s software that affect scores.
- clause 4 | Not Reasonable < Academic Honesty
Weird issue.
Getting a failure on test 10 (https://submit.cs50.io/check50/3230a7f57caf5d6b247bb615292ee28e2f4a3581).
So, I dug into how the test is working; copied lines 74-78
and lines 184-192
from here: https://github.com/cs50/problems/blob/2020/fall/tideman/testing.c
This is based on: https://github.com/cs50/problems/blob/2020/fall/tideman/__init__.py
(line 99 : lock_pairs2()
)
Pasted the test setup into my main()
before any "real" code gets run and then return directly, as a poor-mans test.
(Maybe this is a bad approach ?)
Compiled and ran and the following is output:
false true false false false false true false false false false true false false false false
Checked it against line 95
in the above __init__.py
and it appears to match exactly.
To double check, I added the tests for case 9 and 11
(The one's that passed in the results linked above).
The printouts match the relevant strings in __init__.py
perfectly as well.
I have no idea why those two tests work, but not 10.
Not sure how to debug what's going on inside check50
at this point.
Maybe someone can give me some insight.
For each of the command line checks, we are looking for a non-zero exit code, but that will happen if the program crashes with an IndexError when it tries to access argv[1]
or argv[2]
for example, or with a PIL.UnidentifiedImageError
if it tries to open a non-suitable image file.
Our checks currently can't distinguish between a purposeful sys.exit("invalid usage")
and one of those errors. Hence green smiles even if the code does not check for such things.
@CarterZenke related to: #196
in pset5, i wanted to include dictionary.h to the files submitted to check50 (i have made chage to it and everything compiles and works fine.), but the tools (check50 & submit50) only accept dictionary.c.
I tested my code individually and it seems to be working for all 20 sequences, outputting the correct answer, but when I send it over to check50 it returns 17/21 correct. Can my issue be related to running time? Maybe my spaghetti code is so unoptimized that check50 does not accept it? I can post my code here if it would help, but I don't know if this is appropriate since i could be giving answers to a PSET that people didn't complete yet.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.