脚本宝典收集整理的这篇文章主要介绍了牛客华为机试HJ96,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
原题传送门
import re
import sys
if sys.platform != "linux":
sys.stdin = open("input/HJ96.txt")
def solve1(s):
print(re.sub(r'(d+)', r'*1*', s))
# 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
# J k d i 2 3 4 k l o w e 9 0 a 3
def solve2(s):
index_groups = []
end = len(s) - 1
while end > 0:
while end >= 0 and not s[end].isdigit():
end -= 1
start = end
while start >= 0 and not s[start].isalpha():
start -= 1
index_groups.append((start + 1, end))
end = start
for start, end in index_groups:
print(s[start: end + 1])
for line in sys.stdin:
s = line.strip()
solve2(s)
以上是脚本宝典为你收集整理的牛客华为机试HJ96全部内容,希望文章能够帮你解决牛客华为机试HJ96所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。