29
Rydia @NekoMofu
http://twitter.com/nakanohito_piyo
Last seen 10 months ago
Member for 10 years, 3 months, 9 days
Difficulty Normal
Ph.D. student of computer science/Japanese translation committer in CheckIO. Feel free to comment!
I would like to thank antauren for the idea of *string.capwords* :
https://py.checkio.org/mission/conversion-into-camelcase/publications/antauren/python-3/first/
More
Good for simple/straightforward implementation.
"Like" for last line (make dict from lists).
01. def popular_words(text: str, words: list) -> dict:
02. # your code here
03.
04. text_lower = text.lower()
05. text_words = text_lower.split()
06. # create an empty list
07. popular
More
From random review:
I did not come up with *string.capwords*, thanks!
One tip, string.capwords() have key *sep*, which makes your code clearer.
See my code: https://py.checkio.org/mission/conversion-into-camelcase/publications/nakanohito_piyo/python-3/stringcapwords/
More
Nice! Also, if you use math.gcd, you can also use functools.reduce to instantly get the answer.
https://py.checkio.org/mission/gcd/publications/nakanohito_piyo/python-3/reduce-gcd-args/
More
Let's try list comprehension such as
t2 = [i for i in text.lower() if i.isalpha()]
More
Your code wrongly returns True for some case:
isometric_strings('', 'a') -> True
You should check the length of two strings first.
More
Good challenge. See my example:
https://py.checkio.org/mission/say-history/publications/nakanohito_piyo/python-3/format/
More
Good, clear and interesting substring slicing.
Comments:
* If w1 == w2, always len(w1)<=len(w2). So w1 == w2 is redundant.
* w1[len(w1)-len(w2):]==w2 can be written as w1[-len(w2):]==w2 (using negative indexes) or simply w1.endswith(w2) .
Also see my solution:
https://py.checkio.org/mission/end-o
More
Great, it is really easy to deal arrays with numpy.
More
*From Random Review*
Good for "transpose" the game board.
But you can return function where you find the winner first, rather than
append and continue checking.
More
Very good for using slicing and upper() function. If-else patterns are saved.
More
**key** parameter of list.sort() can be more clear or direct, such as function **abs**.
More
*from random review*
Good straightforward solution, but you can simplify your code logic more.
line 15--16 and "len(word) > 1 and" in line 31 can be merged such as
"if len(word) <= 1: continue" .
More
Yes this works, but you should not overwrite built-in function *max* to avoid potential bugs.
More
This treats round(sqrt(number)) as the sqrt of nearest square number.
I didn't prove whether this solution always true, but it passed tests.
More
*From random review*
Good for straightforward implementation.
Comment: You can use n//100 instead of math.floor(n/100), and n = n%100
instead of n -= s*100.
More