44
gyahun_dash
13 34 48
14271/ 15612
Last seen 4 months ago
Member for 10 years, 2 months, 20 days
Difficulty Normal
Best reviews / Newest reviews
First-Sim0000 5 2
return '{:.0f}'.replace('0', str(decimals)).format(number) + powers[e] + suffix You can use nested brackets for **decimals**: return '{:.{}f}'.replace(number, decimals) + powers[e] + suffix More
Triangle Wave-gyahun_dash 2 1
# Appendix (but longer than code) In this approach, numbers are converted to 2-D coordinates (x, y) to calculate [Manhattan distance](http://en.wikipedia.org/wiki/Taxicab_geometry) between them. [Triangle wave](http://en.wikipedia.org/wiki/Triangle_wave) is used for the converting. ---- Let 1 b More
First-gyahun_dash 2 1
### Appendix (but longer than code) ---- First, let jars be small and large: small, large = min(jars), max(jars) The solution can be repetition of either following sequences named **SMALL** and **LARGE**: 1. **SMALL** 1. Lake-to-Small, Small-to-Large 1. Large-to-Lake, Small- More
Short-Sim0000 2 1
Partial: it is an interesting approximation, but not always correct. When the arc passes on grid points, your function will output a wrong result. For example, if radius == sqrt(2), i.e. the arc passes (1, 1) and more, number of partial tiles is 8, not 12. I think it no problems so far beca More
findall-gyahun_dash 2 1
or return re.sub(r'[^A-Z]', '', text) More
First-Sim0000 1 1
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
Az-aziz199505 1 1
Line 10-12 are equivalent to: return max(found, key=len) More
Clearly separated islands-smilicic 1 1
You can use built-in function [complex](https://docs.python.org/3/library/functions.html#complex). More
Second-Sim0000 1 1
for c1, c2 in itertools.product(cakes, cakes): if c1 == c2: continue You can use **combinations** instead of **product**. for c1, c2 in itertools.combinations(cakes, 2): More
Recursion-trenton42 1
xr = filter(lambda a: a >= 0 and a < len(map_), range(x - 1, x + 2)) is equivalent to: xr = filter(lambda a: 0 <= a < len(map_), range(x - 1, x + 2)) More
First-e-l 1 1
What was your plan to use __q__? but now unused. More
Run Length with itertools-gyahun_dash 1 1
### 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
a bit ugly solution-eugene128736871 1
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
namedtuple DP-gyahun_dash 1 2
length = max(map(len, strings)) if strings else 0 In Python 3.4, we can write: length = max(map(len, strings), default=0) More
First-pohmelie 1 1
str.format(str.format("{{:0>{}b}}", len(c)), p) You can call format as method of "{{:0>{}b}}". "{{:0>{}b}}".format(len(c)).format(p) Furthermore, nested bracket is available in format string. "{:0>{}b}".format(p, len(c)) Please try it if you don't hate calling methods from e More
4 itertools-gyahun_dash 1
1 up 2 right 3 down 4 down 5 left 6 left 7 up 8 up 9 up 10 ... ---- Numbers go along dirs = U, R, DD, LL, UUU, RRR, DDDD, LLLL, UUUUU, ..., so we can get Manhattan distance by counting them (U: up, R: right, D:down, L: left). For example: def find_distance(4, 10): # DLLUUU ret More
First-pohmelie 1 1
return sum(map(abs, itertools.starmap(operator.sub, zip(*map(coords, args))))) You can use simple map instead of starmap: return sum(map(abs, map(operator.sub, *map(coords, args)))) More
Cardano-gyahun_dash 1
To get __time__, we solve the following cubic equation: time ** 3 + 3 * time ** 2 + 2 * time - 6 * food = 0 More
re-gyahun_dash
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
First-seb.hoarau
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
1
2 3 4 5