44
Last seen 5 months ago
Member for 10 years, 3 months, 4 days
Difficulty Normal
Reversed version [here](http://www.checkio.org/mission/robot-sort/publications/gyahun_dash/python-3/third/).
More
return sorted(numbers_array,key=lambda x: abs(x))
You can skip lambda:
return sorted(numbers_array,key=abs)
More
X....XXX
X....XXX
X....XXX
X....XXX
X....XXX
X......X
X......X
X......X
X......X
XXX....X
First, we find riverside:
riverside = set(getflow(erode(river) - river)) # one side
S....XXX # S: riverside
S....XXX
S....XXX
S....XXX
S....XXX
More
Inspired by [ryosms's](http://www.checkio.org/mission/roman-numerals/publications/ryosms/python-3/first/). Thank you.
More
def iter_row():
for i in range(-1, 2):
yield i
Is iter_row() equivalent to range(-1, 2) ? If so, you may declare a variable instead:
rows = range(-1, 2)
More
if numpy.less exists ([here](https://py.checkio.org/mission/short-string-conversion/publications/gyahun_dash/python-3/second/))
More
inspired by [Sim0000’s solution](https://py.checkio.org/mission/largest-histogram/publications/Sim0000/python-3/first/).
More
Single cells are not linked with any other cells: stats[cell] == 0. So to delete them:
cells &= set(stats)
#### About stats:
if stats[b] == 4, colony may be healthy.
0, 1, 0,
1, b, 1,
0, 1, 0,
elif stats[b] == 3, colony containing b is not healthy.
0, 1, 0,
1, b, 1,
More
Benchmark (on my desktop PC):
price, denoms -> answer
name answer time[s]
...
123456 [1, 6, 7, 456, 678] -> 187 (appeared in test)
gyahund 187 0.000000
lezeroq 187 0.187200
PioterM 187 0.280801
10249 [52, 64, 71, 101, 137, 217, 365, 502, 503, 51
More
Solution by generating group-sequence:
food | 1 | 2 3 4 | 5 6 7 8 9 10 | 11 12 ...
sated(in func) | 0 | 0 1 2 | 0 1 2 3 4 5 | 0 1 ...
sated pigeons | 1 | 1 2 3 | 3 3 3 4 5 6 | 6 6 ...
More
string = '(x1,y1),(x2,y2),(x3,y3)'
xsys = [[x1, x2, x3], [y1, y2, y3]]
dxdy = [[x2 - x3, x3 - x1, x1 - x2], [y2 - y3, y3 - y1, y1 - y2]]
More
[revised](http://www.checkio.org/mission/the-square-chest/publications/gyahun_dash/python-3/5th/)
More
neighbors=""
for r in range(rowstart, rowend + 1):
for c in range(colstart, colend + 1):
neighbors += str(grid[r][c])
result = neighbors.count("1")
You don't need to convert int to str:
neighbors = []
for r in range(rowstart, rowend + 1):
for c in ra
More
for i in range(2 ** len(data)):
s = "{:0{size}b}".format(i, size=len(data))
sides = [int(x) for x in s]
If you import itertools, you can use **product**:
for sides in product((0, 1), repeat = len(data)):
More
adjacent = [set() for _ in range(i)]
How about **collections.defaultdict**?
adjacent = defaultdict(set)
More
if "1" in chemin and "2" in chemin and ...
You can check **chemin** using **set**:
if len(set(chemin)) == 8 and chemin[-1] == "1":
----
teleports_map = [(int(x), int(y)) for x, y in teleports_string.split(",")]
You don't need to convert strings to **int**:
teleports_map = telepo
More