题解 | #坐标移动#

坐标移动

https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29

string = input()
groups = string.split(';')
count = []
for g in groups:
    if len(g) == 3 and g[1] >= '0' and g[1] <= '9' and g[2] >= '0' and g[2] <= '9':
        count.append(g)
    elif len(g) == 2 and g[1] >= '0' and g[1] <= '9':
        count.append(g)

l, r = 0, 0
for c in count:
    if c[0] == 'A':
        l -= int(c[1:])
    elif c[0] == 'D':
         l += int(c[1:])
    elif c[0] == 'W':
         r += int(c[1:])
    elif c[0] == 'S':
         r -= int(c[1:])

print(f'{l},{r}')

全部评论

相关推荐

老树开花:可以开始投了,不用等到觉得完全准备好。一边投一边根据面试反馈改简历是最高效的方式。简历上项目描述建议突出你解决的具体问题,比如编辑器的性能优化、大文档渲染怎么处理的,而不只是列技术栈。中厂前端实习现在竞争确实激烈,建议同时关注一些有AI业务的团队,前端加AI应用是很有差异化的组合。Vue全家桶基础扎实的话可以往SSR或者跨端方向延伸,这些是面试加分项。加油,时间还来得及。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
正在热议
更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务