44
Last seen 5 months ago
Member for 10 years, 3 months, 4 days
Difficulty Normal
n = int(radius)
if radius > n:
n += 1
**math.ceil** is helpful to you:
n = ceil(radius)
More
I've revised this with regular expression [here](http://www.checkio.org/mission/find-sequence/publications/gyahun_dash/python-3/research/).
More
In line 22, you can use **itertools.permutations** instead of your defined function:
for p in permutations(len(words)):
More
This is speed-up version of [sorted](http://www.checkio.org/mission/cipher-crossword/publications/gyahun_dash/python-3/sorted/).
More
num = []
for i in str(number):
num.append(int(i))
List comprehension is helpful to you. Let's try it.
num = [int(i) for i in str(number)]
More
bools = [True if len(re.findall('[a-zA-Z]+', x)) > 0 else False for x in words.split()]
You can use **re.match** instead of **re.findall**:
bools = [re.match('[a-zA-Z]+', x) is not None for x in words.split()]
More
Does it work against following test case?
checkio([
"XO.",
"XO.",
".O."]) == "O"
More
small, large = min(jars), max(jars)
indices = [jars.index(j) + 1 for j in (small, large)]
I should use **if-statement** once.
if first <= second:
small, large, indices = first, second, (1, 2)
else:
small, large, indices = second, first, (2, 1)
More
This is speed-up version of my [DP](http://www.checkio.org/mission/loading-cargo/publications/gyahun_dash/python-3/dp/).
More
lst = [list(x) for x in grille]
for l in zip(*lst):
You can unpack strings directly:
for l in zip(*grille):
More
pats = 'PPP...... | ...PPP... | ......PPP' #: rows (blank=0)
'..P.P.P..' #: diagonal (blank=1)
'P..P..P.. | .P..P..P. | ..P..P..P' #: columns (blank=2)
'P...P...P' #: diagonal (blank=3)
# P = O or X
More
It looks clearer than previous. Moreover, you can simplify your code more by using list comprehensions.
For example:
def iterate_grille(grill):
iterated = []
for l in zip(*grill):
iterated.append(''.join(reversed(l)))
return iterated
You can use i
More
phrase = consonants_pattern.sub(r'\g<1>', phrase)
return vowels_pattern.sub(r'\g<1>', phrase)
You can use r'\1'.
More
# initial guess in [1, 10 ** 10] (slapdash approximation)
in [1, 10] correctly.
lognum = log10(number)
to convert range from [1, 10 ** 10] to [0, 10]
x = -0.05 * lognum ** 2 + 1.4 * lognum + 1
to approximate **lognum** to super root.
More
Amazing!
BTW, you can replace the expression in line 5 as follows (but not readable so much):
r'(-?%s-?)'%(x)
More
"X{"+str(len(game_result))+"}|O{"+str(len(game_result))+"}"
This pattern is equivalent to:
"^X+$|^O+$"
or
"^(X+|O+)$"
More
tmp = l[i+1]
l[i+1] = l[i]
l[i] = tmp
You can write them shortly:
l[i], l[i+1] = l[i+1], l[i]
More
Reversed version [here](http://www.checkio.org/mission/robot-sort/publications/gyahun_dash/python-3/third/).
More