40
Last seen 1 day ago
Member for 9 years, 11 months, 3 days
Difficulty Advanced
Hi, you can use __frozenset__.
return ','.join(sorted(frozenset(a.split(',')) & frozenset(b.split(','))))
Edit: Or even __set__:
return ','.join(sorted(set(a.split(',')) & set(b.split(','))))
More
Hi, look at [Counter](https://docs.python.org/3.4/library/collections.html#collections.Counter).
More
Hi, comment formatting makes is less readable. It looks like one big chunk of text. This is more readable
# Dictionary containing all the character combinations
numeral = {1000:"M",900:"CM",500:"D",400:"CD",100:"C",90:"XC",50:"L",40:"XL",10:"X",9:"IX",5:"V",4:"IV",1:"I"}
Or:
More
Hi, I like you solution except from it's repetitive nature, which you can avoid:
base = "I"*data
rs = (("I"*5, "V"),
("V"*2, "X"),
("X"*5, "L"),
("L"*2, "C"),
("C"*5, "D"),
("D"*2, "M"),
("DCCCC", "CM"),
("CCCC", "CD"),
More
Hi, when `data` is too short you don't need to loop over characters:
if len(data) < 10:
return False
Once `num_upper and num_lower and num_digits` is true you don't need to continue
else:
num_digits += 1
if num_upper and num_lower and num_digits:
More
Hi, `nonuiques` is redundant. You can return the comprehension.
More
Hi, you can use _reduce()_ here:
return reduce(int.__mul__, map(int, num_txt))
More
Hi, `lambda` is redundant:
for e in map(unicode.isalpha, words.split())
More
Hi, that `lambda` is not necessary. You can use `*` for unpacking, e. g.:
days(*date1)
More
Hi, generator expression would be nicer. Or you can write:
return sum(map(text.lower().__contains__, words))
More
Hi, __str__ is immutable in python, so it's not the best type for accumulation.
Tip: Look at _filter()_.
More
Hi,
You need
1. `else` branch on line 6.
2. the last `if`.
3. _re_ for this mission. Look at _str.islower()_, _str.isupper()_, _str.isdigit()_.
def checkio(data):
if len(data) < 10:
return False
first_condition = re.search("[a-z]+", data)
seco
More
Hi, look at _all()_:
return all(x in string.lower(text) for x in string.ascii_lowercase)
More
Hi, you can use nested comprehension and _sum()_, e. g.:
return sum(len([y for y in seq[seq.index(x):] if y < x]) for x in seq)
or you can write it [this way](http://www.checkio.org/mission/count-inversions/publications/suic/python-3/sum-sum/).
More