44
Last seen 5 months ago
Member for 10 years, 3 months, 4 days
Difficulty Normal
You can use built-in function [complex](https://docs.python.org/3/library/functions.html#complex).
More
inspired by [Sim0000’s solution](https://py.checkio.org/mission/largest-histogram/publications/Sim0000/python-3/first/).
More
if numpy.less exists ([here](https://py.checkio.org/mission/short-string-conversion/publications/gyahun_dash/python-3/second/))
More
About line 9-12,
if price//coin + length < shortest:
return price // coin + length
else:
return shortest
You can write as follows and delete if-else:
return min(price // coin + length, shortest)
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
Line 5:
bins = [re.sub('(?P\d+)(\.)?', binarize, a) for a in adds]
Line 8:
pat = ','.join(['(?P\d+)\d*'] + ['\\1\d*'] * (len(adds) - 1))
More
[revised](http://www.checkio.org/mission/the-square-chest/publications/gyahun_dash/python-3/5th/)
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
To get __time__, we solve the following cubic equation:
time ** 3 + 3 * time ** 2 + 2 * time - 6 * food = 0
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
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
### Example:
((0, 0, 1, 0, 0),
(0, 1, 1, 1, 0),
(1, 1, 1, 1, 1),
(0, 1, 1, 1, 0),
(0, 0, 1, 0, 0))
First, we get horizontal and vertical RunLengths(horis and verts):
((0, 0, 1, 0, 0), # RL(length=1, y=0, x=2)
(0, 1, 1, 1, 0), # RL(length=3, y=1, x=2)
(1, 1, 1,
More
length = max(map(len, strings)) if strings else 0
In Python 3.4, we can write:
length = max(map(len, strings), default=0)
More
> Connections can be repeated in the initial data, but inside it store once.
I missed this sentence and modified my solution ([here](http://www.checkio.org/mission/friends/publications/gyahun_dash/python-3/list/?ordering=most_voted)).
More
It's simple and clear.
I've published a [solution](http://www.checkio.org/mission/dark-labyrinth/publications/gyahun_dash/python-3/second/) inspired by your solution. Thank you.
More
def all_routes_from_node(m, node):
possibilities = []
for arc in m:
if node in arc:
possibilities.append(arc)
return possibilities
How about using **list comprehension** here?
def all_routes_from_node(m, node):
return [arc fo
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
adjacent = [set() for _ in range(i)]
How about **collections.defaultdict**?
adjacent = defaultdict(set)
More