13
Jakob van Bethlehem
Last seen 5 years ago
Member for 10 years, 4 months
Difficulty Normal
Normally you would _import_-statements at the top of the code, not inside a function
More
_re.findall_ already returns a list, even in Python 3, and the construction _list(set(ltext))_ looks very weird, as you're 'converting' a more restricted type into a less restricted type - that's an indication of some logical mistake in all programming languages. In this particular case, I guess you
More
Which part do you consider 'smart'? You may refer to the last line, which requires some much explanation. It's a nice trick, but also overlooks the fact that you can much easier use something like:
max(sorted(freq.keys()), key=freq.__getitem__)
or, even better,
max(string.ascii_lowercas
More
This is most definitely not an _O(N)_ solution, because the _count()_ needs to traverse the full _text_ for each _x_ inside _text_, in other words, this is clearly an _O(N^2)_ solution (like the major part of the solutions presented for this mission).
More
Unfortunately CheckIO does not (yet) provide a means to benchmark solutions, but my guess is this would most definitely not be a 'speedy' solution, because for each character, you traverse the full _text_ - in the worst case scenario (only single appearances of each character, think for instance _te
More
* Why not looping over _text_ when calculating _amounts_? That way you only count letters that actually matter.
* _alphabet_ is also known as _string.ascii_lowercase_
* instead of getting a _max_count_, and then trying to figure out which letter goes with that count, you really should look into usi
More
Certainly a nice and readable solution, but not 'speedy': it's _O(N^2)_, because you need to traverse _text_ fully for the count for each letter - there are _O(N)_ solutions already posted however, which make use of a histogram. These will clearly be much speedier
More
I think it is a rather clear solution, suited for beginner programmers. Anyone who likes this solution, should next study:
* the _list_ type and the member function _count_
* the _string_ module (in particular _string.ascii_lowercase_)
* the _max_ function, and the parameter _key_ one can pass to it
More
I like that you made me look up the documentation of the _Counter_ class, which I didn't know yet - I also like that you used a histogram, which makes this a _O(N)_ solution, instead of the _O(N^2)_ solution using _count()_ that most people did. Beyond that I think there is room for some improvement
More
holy smokes - I though I had a long solution.... This one could have used some (English) doc strings
More
Instead of permutating the indices into chips, you could easier permutate the chips directly on line 16:
for ordering in itertools.permutations(chips[1:]):
The same for the second set of permutations: simply permutate the objects you want to directly.
More
If you like this solution, also have a look at the much better implementation of essentially the same (arithmetic) solution by [bunnychai](http://www.checkio.org/mission/feed-pigeons/publications/bunnychai/python-27/arithmetic/)
More
Interesting, didn't know you could assign methods like this. Is this capability limited to Python 2/3, or does it work in both versions?
More
Looking at other solutions, I should probably have categorized this one as speedy..
More
I don't really like the fact of doing calculations on a static data structure. To me it means you picked the wrong data structure.
More
Maybe next time get rid of everything that is not relevant for the task at hand.
More
Nice, creative solution. Due to the many 'magic' numbers I wouldn't classify as clear though. But I expect this to be an extremely fast solution, so I'd categorize it is 'speedy'
More
This has to be the fastest of'em all :). Did you use your other solution to generate this list? :P
More
In Python a True is always taken as 1 when used as a numeric value, so this nice solutions could be even shorter:
return sum([x > y for x,y in combinations(s, 2)])
More