31
Sawako Ohno
Last seen 2 months ago
Member for 2 years, 12 months, 3 days
Difficulty Normal
Elegant solution, using the comparison of tuple; in tuple comparison if first element is same, then second element is compared.
More
Thank you for your very clear and educative code ! The variable names clearly stand for what they mean and helped me understand the process.\
Can I ask why "field, dn, pop = q.popleft() " not "field, dn, pop = q.pop()" ?
I naively thought, if more filled version of "field" is added on the right, p
More
Cool idea to use sum of quotient and remainder from divmod, instead of round or ceil.
More
Learned about "partial" for the first time here.\
Also, I was not aware that \n expression can be reused across arguments:\
\1 in the second argument in re.sub() here referring to \w in the first argument.
More
Like the combination of bool and re.search.
return bool(re.search(r"\d",password) and re.search(r"\D",password))
More
When the number of digits after the decimal point is 1 it does not work. (Such as "$5,1")\
It should be like this to include those cases.
"\$(\d{1,3})(\.\d{3})*(,\d{1,2}(?!\d))?"
More
In the case below, right move for "X" is (0,1)or(1,0)or(1,2)or(2,1) even 2 corners are still blank.\
(If you put "X" on (0,2), enemy puts "O" on (2,0) to prevent your win and it creates two-checks situation for "O", which means enemy's win.
x_and_o((
"0..",
".X.",
More
Learned to use complex number for two-dimension from this code.
More
Cool use of divmod().
Also, cool use of class-producing function "make_broken(i)".
More
Very smart in setting the range of y in (2len(M) - 1) and check if (y-x) in range.\
Mine was much longer as I produced 4 Diagonal patterns starting from each corner.
>[[M[y-x][x] for x in range(len(M)) if 0 <= y-x < len(M)] for y in range(2*len(M) - 1)]
Also smart here. Much more efficient to flip
More
It seems that argument can be > 100.
In that case, it should be ['A+']*61 and min(percent,150) ?
Precondition: argument can be from 0 to 150
More
I like the clearness of your code, but it seems that there are some edge cases in which you just cannot paint all countries with 4 colors with the strategy to start from country 0 and choose the smallest available color-id for the next country.
color_map(((10,10,10,10,10,2,2,2,2,),
(10,10,1
More