45
Valentin Bryukhanov
http://bryukh.com/
Last seen 2 years ago
Member for 11 years, 7 months, 16 days
Difficulty Normal
Developer, engineer and taskMaker.
Ha. Nice! I just saw it. The interesting idea to break all links (instead rings) and look for the best of them. Brilliant!
More
Looks like you love OOP :-)
Honestly I think you can easily use simple dictionary or named tuples instead Node class.
"inverse" is a simple dict that are wrapped in a function. I didn't get why do you need a function for that.
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
Simple and clear. And a good idea about "call". Nothing to add :-)
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
> THE ANSWERS TO EVERY QUESTION IN THE KNOWN UNIVERSE IS NOT 42 BUT YOGURT
THEY hide the Truth and 42 is a false track :-)
More
if x.isalpha() is False:
Why do you use this construction?
text = list(phrase.lower())
"list" is redundant operation here.
line 7-10 can be simpler, even if you don't like "setdefault" or default dicts:
countDict[x] = countDict.get(x, 0) + 1
More
for c in text.lower():
if c.islower():
I understand why do you use "islower", but for first glance it looks weird :-)
"isalpha" will be better here, just for readability.
More
I think you can make
text = text.lower()
once.
And "count" method works for strings too, not only for lists.
The next:
(ord(i) < ord(most_common_letter)) == (i < most_common_letter)
More
"max" is a built-in function, thus it's a bad idea to use this as the variable name.
And brackets after "if" are redundant.
More
> 3.14159265358979
You don't like constants or "math" modules?
More
Column programming style :-) it's something new. I think you should move this in "Creative" :-)
More