21
Pavel
https://pavelmorava.com/
Last seen 11 months ago
Member for 10 years, 6 months, 16 days
Difficulty Normal
Author of Sovereign
https://www.royalroad.com/fiction/26615/sovereign
My blog
https://pavelmorava.com/
I believe you actually dont need to call:
def all_cells():
return ((x, y) for y in range(8) for x in range(8))
In fact, this should be enough:
all_cells = [(x, y) for y in range(8) for x in range(8)]
More
Too many unnecessary moves :)
For example this is enough.
return "".join(Translation)
In python casing is different. For variable is used lowercase and for constant UPPERCASE (e.g.: index, VOWELS)
More
You could safe few lines using this code starting line 4:
for col, row in pawns:
...
More
I see no point in line 4 :) It seems to me like desperate try to save one line :)
Surely, it is a little bit faster but less clearer
More
Except for line 10 which is rather wrong (output should be tuple not list) I think this solution is pretty clear.
BTW: As I saw in previous solutions line 4 can be improved like this. I didnt know it myself.
remaining = 1
More
In this cases I would not use new name variable but
first = set(first.split(','))
Seems to me clearer.
BY the way, the line 4 is redundant. You dont need to convert answer to list :)
Hope it helps. It is nice, though.
More
if x == 1 and y == 1:
return True
else:
return False
could be convert to:
return True if x and y else False
Hope it helps.
More
You can check mine if you feel like this.
I couldnt say my solution is better because your using bit operator is wiser but my code is similar with little different approach.
You may find it interesting :)
More
Just one hint. Try this one:
sample = "This is sample Text Sample"
result = {char:sample.count(char) for
char in sample.lower() if
char.isalpha()}
or check Counter from collections :)
Subject: [CheckiO] Your random review: The Most Wanted
More
What about something like this:
def gcd(a,b):
a,b = sorted((a,b), reverse = True)
return gcd(b, a%b) if a%b else b
I hope I made no mistake. No guarantee without running the code :)
And of course you should try :)
import gcd from fractions
Subject: [CheckiO] Your rand
More
Nicely named variables, just few quick hints to shorten your code:
you can use:
for i, current in enumerate(phrase):
and you can write:
indexesToSkip += [i+1, i+2]
Hope it helps.
Subject: [CheckiO] Your random review: Bird Language:Uncategorized:52447
More
Nice,
but of course you might use:
return (max(args) - min(args)) if args else 0
Subject: [CheckiO] Your random review: The Most Numbers:Clear:52939
More
Well done!
Subject: [CheckiO] Your random review: Simple hashlib:Uncategorized:53547
More
It is a small thing but what about to revert your code like this to make your code clearer?
for move in moves:
xi, yi = x + move[0], y + move[1]
if (xi, yi) == b:
return len(path)
if all(0 < xi < 9, 0 < yi
More
Hi,
you solutions is really really wet :)
Consider this
JUMPING = {
(3,8) : (-2,1),
(2,7): (-1,2),
....
}
def jump_targets(field):
...
x,y = JUMPING[col, row]
targets.append(back_translation[x]+str(y))
r
More
What is this special case?
if numbers == [-10,-1,-1,-10]:
return -2
Subject: [CheckiO] Your random review: Stair steps:Uncategorized:54466
More
Instead your:
for i in range(len(matrix)):
for j in range(len(matrix)):
...
you can use product from itertools
from itertools import product
for i,j in product(range(len(matrix))):
...
Hope it helps
Subject: [CheckiO] Your random review: Weak Point
More