47
Bla Bla Bla bla
Last seen 8 hours ago
Member for 8 years, 2 months, 2 days
Difficulty Normal
I don't count the chickens before they hatch but I do divide the skin while it’s still on the bear despite the fact it makes no sens. Or maybe it does...
Nice idea to don't use bin() function and count bits manually. Just another example
checkio = lambda n: sum(n & 2**x == 2**x for x in range(999))
More
Couple of hints helping to clean the code.
- integer division like 'int(number/10)' can be replaced by 'number // 10'
- 'number, mod = int(number/10), number%10' can be changed to 'number, mod = divmod(number, 10)'
- 'if number >= 20 and number < 100' can be changed to 'if 20 <= number < 10
More
This one is nice. It needs only a little bit of [simplification](https://py.checkio.org/mission/multiplication-table/publications/przemyslaw.daniel/python-3/10-liner-zgub4s-simplified/)
More
From these two solution the second is my favorite one. In first case is just too much scroling impeded by website design. All I would do is to simplify a bit :-)
def checkio(opacity):
age, k, r = [0]*10001, 10000, 5**0.5
fib = [int(((1+r)**x-(1-r)**x)/(r*2**x)) for x in range(22
More
When you run the code through a PEP8 checker you'll find one little issue here (good practic for Clear category). Line 2 can be easily transformed to PEP8 compliant by changing to 'intervals, data, last_cut = [], sorted(data), = 0'. Have a look at on line pep [checker](http://pep8online.com). Do you
More
You can clarify your code with few tricks. For instance initialization of few variables can be done in one line 't, matrix[0][0], vertical = 0, 1, []'. Remove unnecessary comment (better to don't use them at all). Few times you use len(matrix), how about to define 'length = len(matrix)'? Line 18 and
More
'w' represents word or more preciesly somthing which is not a digit. This could be any letter but you have to remember to replace it everywhere. Let's take example input 'a b c 123'.
1) first step is to split it: ['a', 'b', 'c' '123']
2) for every element check whether these are all digits: [False,
More
This one could be a little bit simpler by removing "if" statement
def count_words(text, words):
return sum(w in text.lower() for w in words)
More
This is a tricky category and it is diffcult to say how fast is your code unless you benchmark it. (that's what Alexandrescu states) Did you try to do that and campare it to others? I'd like to know how it looks versus somthing like this
def checkio(text):
last, words = '', 0
fo
More
You put a lot of effort to equalize the lentgh of the binary representation. It is possible to use zip_longest like for example this:
sum(x != y for x, y in zip_longest(bin(a)[2:][::-1], bin(b)[2:][::-1], fillvalue='0'))
Still ugly, isn't it? Therefore would be better to calculate xor and co
More
This one is quite clear and nicely fromatted. I would only change line 3-4 to ‘visited, time = {0}, 1’ and 11-12 to 'visited += [a]*(not weights[a])' just for fun. This task is old as the hills but I’ve just got back to it with new idea
More
Priority queue idea seems to be elegant conjuction with your solution. What would you say about little different approach to this problem like for example [this](https://py.checkio.org/mission/network-attack/publications/przemyslaw.daniel/python-3/6-liner-take-it-easy-man/)? I'm just itertating agai
More
Get familiar with functions like sorted(), max(), min(). This will help you solve this test better
More
Couple of hints to make your code looking better. Python uses more camel_case than snakeCase. Semicolons at the end of the lines are not required. Are you comming from c++ word? It is easy to ommit all problems by running pep8 checker. This solution can be easly reduce to something like this
de
More
Actually you don't have to import anything from string module to check if character is uppercase. str.isupper() is the answer in this case. Try to use it with conjunaction with filter to get simple oneliner
More
A few words of explanation. To simplify calculations, we start from the idea where the grid is represented in the complex plane. In such case rotating an element can be achieved by very simple operation: k-1+element*1j (where kxk is grid size)
+--+--+--+--+ +----+----+----+----+
|1 |2
More
What's the reson to put everything in one line (unscrollable here)? Don't do it anymore ;-)
More
Actually there is no trick as you can check it by print(issubclass(bool, int)). For this reason you can replace 'int(bool(number%100))' with '(number%100>0)'
More
Simplified: all([matrix[x][y] == -matrix[y][x] for x, row in enumerate(matrix) for y, _ in enumerate(row)])
More