This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from operator import xor | |
from functools import reduce | |
a = [2,3,3,2,1] | |
r = reduce(xor, a, 0) | |
# r = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git rebase i id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ps -ef|grep python|grep -v grep|cut -c 7-12 | xargs kill -9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>分钟|小时)前))$' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def max_count(string): | |
"""count max length of no-26 length | |
>>> max_count('') | |
0 | |
>>> max_count('1') | |
1 | |
>>> max_count('12') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
class Node: | |
def __init__(self, val): | |
self.val = val | |
self.left = None | |
self.right = None | |
def __str__(self): |
NewerOlder