London | 25-SDC-July | Mikiyas Gebremichael | Sprint 2 | Improve code with precomputing #38
London | 25-SDC-July | Mikiyas Gebremichael | Sprint 2 | Improve code with precomputing #38Mikiyas-STP wants to merge 3 commits intoCodeYourFuture:mainfrom
Conversation
|
Your PR description contained template fields which weren't filled in. Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
5 similar comments
|
Your PR description contained template fields which weren't filled in. Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
|
Your PR description contained template fields which weren't filled in. Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
|
Your PR description contained template fields which weren't filled in. Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
|
Your PR description contained template fields which weren't filled in. Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
|
Your PR description contained template fields which weren't filled in. Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
OracPrime
left a comment
There was a problem hiding this comment.
Prefix code is wrong.
Counting code works, but could be more efficient.
| #Find shortest string limit for prefix | ||
| min_len = min(len(s) for s in strings) | ||
| if min_len == 0: | ||
| return "" |
There was a problem hiding this comment.
No, this is wrong. If the input is ["","string_one","string_two"] we want to return "string_" whereas you'll return ""
| def is_upper_case(letter: str) -> bool: | ||
| return letter == letter.upper() | ||
| #Returns the number of letters which only occur in uppercase in the passed string | ||
| letters = Counter(s) #count occurrences of each character |
There was a problem hiding this comment.
This works, but is doing more work than is needed. We don't care if T occurs 3 times or 1, if t doesn't. What could you use instead of a Counter that would skip the counting process but still remove duplicates?
Learners, PR Template
Self checklist
Changelist
Precomputing means doing calculations once in advance and reusing the results instead of repeating the same work.
It makes programs faster by trading extra memory for reduced computation time.
For example, counting all characters once and storing the results is faster than scanning the string repeatedly.
Questions
None