Skip to content

Instantly share code, notes, and snippets.

View lttzzlll's full-sized avatar

liutaotao lttzzlll

  • http://metasota.ai/
View GitHub Profile
from operator import xor
from functools import reduce
a = [2,3,3,2,1]
r = reduce(xor, a, 0)
# r = 1
ps -ef|grep python|grep -v grep|cut -c 7-12 | xargs kill -9
BAIDUNEWS_UTC_FORMAT_PATTERN1 = r'^(?P<publisher>\S+)\s+(((?P<year>\d{4})年(?P<month>\d{2})月(?P<day>\d{2})日\s+(?P<hour>\d{2}):(?P<minute>\d{2}))|(?P<beforetime>(?P<pubint>\d+)(?P<pubtype>分钟|小时)前))$'
def max_count(string):
"""count max length of no-26 length
>>> max_count('')
0
>>> max_count('1')
1
>>> max_count('12')
def delete_reoccurring_chars(string):
"""Return the string after deduplication.
>>> delete_reoccurring_chars('metasotaaaa')
'metasota'
>>> delete_reoccurring_chars('mmeettaassoottaa')
'metasota'
>>> delete_reoccurring_chars('metasota')
'metasota'
import unittest
def dp(nums, m, n, i, j, visit):
ll, uu, rr, dd = [], [], [], []
if i - 1 >= 0 and not visit[i - 1][j] and nums[i - 1][j] < nums[i][j]:
visit[i][j] = True
uu = dp(nums, m, n, i - 1, j, visit)
if j - 1 >= 0 and not visit[i][j - 1] and nums[i][j - 1] < nums[i][j]:
visit[i][j] = True
import unittest
import random
def is_repeat(n):
n_str = str(n)
for i in range(len(n_str) - 1):
if n_str[i] == n_str[i + 1]:
return False
return True
import random
import unittest
def most_num(nums):
cur = nums[0]
cnt = 1
for i in range(1, len(nums)):
if cnt == 0:
cur = nums[i]
import unittest
class Node:
def __init__(self, val):
self.val = val
self.left = None
self.right = None
def __str__(self):