45
Valentin Bryukhanov
http://bryukh.com/
Last seen 2 years ago
Member for 11 years, 7 months, 17 days
Difficulty Normal
Developer, engineer and taskMaker.
Nice code!
Not neccessary place your functions inside checkio function. Its can be outside.
More
I didn't get why do you use "*a" here. A input tuple become
a == ((data),)
and then you unwrap it again.
list conversion are redundant -- "sorted" can work with tuples too.
And
"lambda x: abs(x)" is the same as "abs". So you can use "key=abs".
P.S. PEP8 is a good choice for "Clear" ca
More
for i in range(len(data)):#Filling up the binary matrix with 0's and 1's
for j in range(len(data[i])):
You can replace it with
for row in data:
for el in row:
The line 8 can be reworked in the follow (this is easy expanded)
if data[i][j] in 'GS':
Is you
More
Simple and clear. And a good idea about "call". Nothing to add :-)
More
In this task you have not to search the shortest way. So you don't need min(self.routes). But if you want the shortest way, then i recommend you to look at another algorithms (Dijkstra, BFS, A* search)
More
You don't need line 2. Just `def checkio(number):` if you don't like 'data' name.
More
The nice trick!
lambda x:"+"*x+"-"*-x
I like it -- something new and not obvious.
More
It's really nice solution. It's short, it's readable, it's simple. Little PEP8 and docstring, and it will be perfect.
http://pep8online.com/share/519f30976cee16191749a28f
More
"self.connection = connection" is redundant in "add" or "remove" methods. You don't need save them in the instance.
line 7
if isinstance(self.connections,tuple):
Why do you check it in "add" method? You save "connection**S**" in init.
If you are using "if self.connection in to_list_connectio
More
Column programming style :-) it's something new. I think you should move this in "Creative" :-)
More
At first look i thought "This is not a puzzle. I see indents and docstring. It's clear solution and Veky didn't write it" :)
But then... You broke my brain. Now i have the puzzle for weekend.
More
You forgot about spaces around operators (pep8).
if cell[0]==10 and cell[1]==10:
You can make it simpler
if cell == (10, 10):
line 4 -- "== 1" is not necessary
if lab[cell[0]][cell[1]]:
line 13-17
min(paths, key=len)
But for the shortest path you can use BFS
More