Skip to main content
kcw78's user avatar
kcw78's user avatar
kcw78's user avatar
kcw78
  • Member for 2 years, 11 months
  • Last seen this week
  • Dallas, TX, USA
revised
CS50 working 9 to 5
modified to improve explanation and fix typos
Loading…
comment
CS50 working 9 to 5
Glad to help. If this solved your problem, please use the check to "Accept Answer" so others will know this is a valid solution. Good luck with CS50P.
comment
Python little professor problem set not passing 10 problems check
@UpandAdam - yes, agreed. This is what I know: I tested the posted code, and it failed. Then I modified to use randint() and it passed. Go figure. It also passes if the stop value for randrange() is increased by 1. Solution modified to reflect this. There are 2 check50 issues. First, the error message about generates 10 problems before exiting is useless AND misleading. I wondered how check50 managed this. I suspect you are correct about seeding the generator. Every check50 output shows the same inputs for this test. :-)
revised
Python little professor problem set not passing 10 problems check
modified solution to add method with randrange()
Loading…
Loading…
answered
Loading…
Loading…
revised
outdated : code not rejecting incorrectly formatted inputs
modified code and added clarified comments
Loading…
comment
outdated : code not rejecting incorrectly formatted inputs
Certainly you can replace while True with while Your_Logical_Test_for_True. However, the same infinite loop challenge exists with if Your_Logical_Test_for_True is poorly constructed and yields False when it should yield True. :-) The test for this PSet is relatively straight-forward - you can test for valid values of the day, month and year. However, you have to initialize the tested values prior to the while loop. As an aside, Dr. Malin uses the while True design in his regex examples. Just sayin... :-)
comment
outdated : code not rejecting incorrectly formatted inputs
Question about your while True comment. I used that to re-prompt the user when the input is an invalid date format/data. Can you explain how you did that differently (w/out giving away the solution)?
comment
outdated : code not rejecting incorrectly formatted inputs
Thanks, yeah it's a balance to share code without giving away the answer. I tried to thread the needle -- the if/elif/else block outlines the thought process without solving the problem. :-) (And, I just realized I left a line I intended to delete.) A quick note on regex: This is PSet 3, and Regular Expressions aren't covered (in depth) until Lecture 7. So, most students will probably use string manipulation methods.
Loading…
comment
outdated : code not rejecting incorrectly formatted inputs
You need to test for 2 different formats: A) TWO slashes or B) ONE comma, THEN apply proper conversion procedure. Other tests to consider: C) day and month are >0, and D) month name is in the list (personally, I prefer a dictionary). All other input should be re-prompted. I posted an "answer" with some psuedo code that might help your thought process.
comment
outdated : code not rejecting incorrectly formatted inputs
check50 fails because October/9/1701 is not a valid input format. Valid formats are October 9, 1701 and 10/9/1701. Slashes can only be used when all input is numeric values. When you enter a month name, you need the 'comma' format. September 8 1636 is invalid because it is missing the comma.
comment
awarded
comment
cs50 dna pset 6 - i dont get why my code always return no match
If your code matches this post, it won't run due to indentation errors. I added indents to main() and longest_match(). (I also formatted your post so main() is included in the formatted code block.) Once that id corrected, it gets the right answer for several tests I spot checked.
revised
cs50 dna pset 6 - i dont get why my code always return no match
fixed indentation and code format to include main()
Loading…
comment
adieu problem cs50p
Look at his input prompt (Name:). Then look at what check50 says is not expected : Name: Name: Na.... Now think about it.
awarded
1
2 3 4 5
9