13
Jakob van Bethlehem
Last seen 5 years ago
Member for 10 years, 3 months, 20 days
Difficulty Normal
Why not type the possible winning combinations as integers directly?
combos = [[0, 1, 2], [3, 4, 5], [6, 7, 8], ...]
More
I don't agree at all with people saying the solution is not 'readable': learn your maths!
More
Since you have the math skills to derive the equation, I really don't understand why you didn't just went ahead and solved the equation. Very nice introduction to the sympy module though, which I didn't know about yet.
More
Instead of defaulting to _None_ for the _key_, you could also default to _lambda x: x_. Then the big _if_ statement on line 24 could be simplified a lot, because you can always apply _key_
More
Nice and short, but this executes a full count for every single character in the string (i.e. a string with 100 characters will be looped over 100 times) even if the count for that character was already done before. Just imagine what would happen if you asked your text editor to do the count of your
More
Nice solution - would have been a perfect clear solution, if you had just written _count += grid[n_row][n_col]_ instead of the superfluous _if_
More
There is no need for the big _if-else_ test at the end! Just say:
return len(data)>9 and lower_amount and digit_amount and upper_amount
That already is the bool you're looking for!
More
Good idea to store the closing brackets - makes for exactly the simplification I knew existed, but didn't think of.
More
Regexes tend to be slower than direct comparisons, and your comparing every word with every other word - 'speedy' is really the wrong category I'd say
More
Instead of using _re.sub_ to substitute and then to split, you could also immediately split using _re.split_
More
Very creative how you have used some algebraic properties of numbers to determine whether the number is divisible.
More
There are quite a few 'non-Pythonic' elements to this:
* _if array==[]_ is exactly equivalent to just using _if array_
* in Python you really shouldn't write a loop over an index, which is then used to access a list (unless you really, really can not do otherwise). Instead you should over the list d
More
Just in case you didn't check other solutions yet: the builtin _count_ method does exactly what you explicitly typed in the loop
More
I came up with the same idea, so I like it (+1), except that you destroy the input list. I don't think the users of your code expect that to happen (-1) ;)
More