4

You should not bake hand literal strings in your logic; instead refer to your constants or better yet an Enum You should try to reduce the amount of class state floating around. index and current_hand for instance are not good class members; instead they should just be local variables. Consider refactoring your Player class to be an iterator over its hands, ...


2

I see three ways to improve your runtime. I have never done this problem so I can't guarantee that it will be enough to pass all the tests. Sorted input The leaderboard scores are sorted in decreasing order. Your duplicate-removal code converts a sorted list to a set to remove duplicates (O(n)), then converts it back to a list (O(n)), then sorts it (O(n*log(...


1

I submitted your first code there and got this failure message: seq_mining(['ABCD', 'ABABC', 'BCAABCD'], 0.34, 1000000) is too slow (took 4.203785117715597s). Seeing that 1000000 is far larger than useful, I reduced it to the largest actual string length by adding this at the top of your function: max_int = min(max_int, max(map(len, data))) Submitting ...


1

From Wikipedia: grep is a command-line utility for searching plain-text data sets for lines that match a regular expression. Its name comes from the ed command g/re/p (globally search for a regular expression and print matching lines) So your second grep implementation really actually isn't one at all. Disqualified, case closed.


1

You should use re.escape(...) in the first version, to match behaviour of the second. Without it, special characters in word could be interpreted as regex patterns. Catching IndexError only ensures the user has given enough arguments; it does not protect against too many. grep.py hello world file.txt will search file world for the word hello, if it exists, ...


1

License counting foreach (IGrouping<int, Installation> group in groupUsersQuery) { if (group.Count() == 1) { copiesNeeded += 1; } else if (group.Count() == 2) { if (group.ContainsComputerType("LAPTOP") && group.ContainsComputerType("DESKTOP")) { ...


1

Supplement to Maarten Fabré's answer: We don't even need to remember largest_divisor, as we can simply use value itself. When the current prime being considered is too large to be a factor of value, just return value: def largest_prime_divisor(value): for prime in prime_generator(): while value > prime and value % prime == 0: ...


Only top voted, non community-wiki answers of a minimum length are eligible