31
Andrey Solomatin
Last seen 1 year ago
Member for 11 years, 2 months, 8 days
Difficulty Normal
If you change you checkio a little you can get rid of Pigeon class and use boolean instead.
More
In compare of xor-bin-count you have much more function calls. Thats why you code works slower.
you: 0.24650617428670193
xbc: 0.09194738942302072
http://pastebin.com/v9DRrqfB
More
**.split('0b')[1].zfill(8)** all this operations does not change number of "1" in text, you can omit them.
More
To iterate on two list of same length use zip: **for val1, val2 in zip(m, n): c += val1 != val2**.
If you have lists with different length use zip_lingest from itertools: **zip\_longest(m, n, fillvalue='1')**.
More
Remove commented debug code.
PS. Python is very interactive language, you can check code chunks in console.
More
Very bulky and unclear.
If you need object that behavior is like list, you can inherit from list.
no: **[self.list[0]]** yes: **self.list[:1]**
More
Joining all values to p is not good idea, just name them. Like that **x1, y1, x2, y2, x3, y3 = p**
Using 26 variables(not unique) in one line is not good idea :)
To format str you can use round(float_number, 2) and type **g** instead **.2f**.
More
You can simplify you regexpr:
re.findall('\d+', "(2,2),(6,2),(2,6)") == ['2', '2', '6', '2', '2', '6']
use **round(val, 2)** and **%g** for string formating
More
endswith and cut end can be replaced by .rstrip('.0').
But it is better to do it by specifying type **g** for format.
More
**max** and **id** are built in python functions don't shadow it.
You can simplify this code:
ret = 0
...
return ret + 1
You mutate checkio argument. It is not issue but bad practice.
Please follow python style guide, don't leave that ugly spaces around function arguments.
More
**mlen**, **vlist**, **sval**, **ilist** are not good names for variables. Name should be self descriptive.
Ithink you can use **set** as datatype for ilist and clist: **sorted(ilist) != sorted(clist)** will be **ilist != clist**
**vlist.sort(reverse=1); return [vlist[0][0], vlist[0][1]]**
More
no: **str.join(",", iterable)** yes: **",".join(iterable)**
no need to **str** input
More
I think you can remove **nb\_rows**, **nb\_cols** and use **len()** instead. It will make code more readable.
you can use python builtin constants True, false and None instead of literals: **return "M" if we can deduce a mine, return "E" if we can deduce empty cell, return "?" else**
if te
More
You have very critical bug in you solution, you use module that you did not import. It is also checkio bug that you solution works.
More
You can simplify checks:
#if field[i][j]==0 or field[i][j]==-1 or field[i][j]==9
if field[i][j] in (0, -1, 9):
if 0 <= field[i][j] < 9:
More