30
Last seen 2 months ago
Member for 6 years, 2 months, 17 days
Difficulty Normal
I live in Shanghai China. I work for BI business for almost one year and I start feeling bored on this job.I am interested in Python and AI. I would like to improve my Python skill and English....also, practice my brain at all.
'闻道有先后,术业有专攻。'
case safe_code("11+##=11")
the answer should be -1 not 0. (the answer cannot consist of zeros (00, 000, etc.).)
More
For line 26-33, we have the same idea and here is my code.
{i: True if i < len(items) - 1 and items[i] < items[i + 1] else False for i in range(len(items))} # like what your 'indices' do.
for local test 2, you can get this indices then get the answer without list slice.
{0: True, 1: True
More
I think you can remove the function 'test' and revise the line 34 like this.
if all(-180 <= el <= 180 for el in probe) and all(numpy.dot(A, probe) == b):
return probe
More
First known the function 'takewhile' from module 'itertool'. I search it on net and it seems more memory-friendly. I like it and I will take a try if any chance.
More
i am really confused with the usage of function 'reduce' and 'lambda' especially those two are mixed....
for me ,i always hard to read these exciting short code... let alone how to code them....
do you have ...some advices for me? thanks :)
More
这道题的大意就是:
> list1=[int(i) if i.isdigit() else ord(i)-48 for i in data if i.isdigit() or i.isalpha()][::-1]
提取参数中的数字和字母,将所有包含的字母转成ascii码并减去48,然后倒序处理
> num=sum([i*2//10+i*2%10 for i in list1[::2]])+sum(list1[1::2])
前部分:
偶数下标的需要处理,将该数乘以2,十位数和个位数相加得到一个新数(该数乘以2 如果是个位数 就返回该数乘以2)
后部分:奇数下标的无需处理
num就是将
More
> [1, 1, 4, 1]=>[[1], [1, 1], [1, 1, 4], [1, 1, 4, 1], [1], [1, 4], [1, 4, 1], [4], [4, 1], [1]]
it works but slow for extra check
More
> return ",".join(sorted(word for word in first.split(',') if word in second.split(',')))
'[]' is no need here,it's very strange.
More
> if not cards:
return False
Why doing this?
> cards.sort()
Same idea with Phil15
> elif not any(i in k for k in cards):
return False
Hard to know your meaning...to be honest.
for example cards(8, [4, 4, 5, 6, 7])
your cards:[(0,1),(1,2).....,(7,8)]
your hand:[
More
my idea is as follows :
merge_intervals([(1, 4), (2, 6), (8, 10), (12, 19)])
> => [(1,2,3,4),(2,3,4,5,6),(8,9,10),(12,13,14,....,19)] #using range
> => [1,2,3,4 , 2,3,4,5,6 , 8,9,10 , 12,13,...,19] #using slice
> => [1,2,3,4,5,6, 8,9,10 ,12,13,14,...19] #using set
> => [(1, 6), (8, 10), (12, 19
More
1. leave your annoation as possible so that we can read easily.
2. Is there any possible to have "['A','A']" situation? confusing.
>
> for i in crushes:
> for j in net:
> if i in j:
> j[j.index(i)]='0'
> count=net.count(['0','0'])
> for i in range(
More
Impressive for
neighbors = lambda i,j: ((i+I,j+J) for I,J in {(-1,0),(1,0),(0,-1),(0,1)}
if 0<=i+IMore