题解 | #坐标移动#

坐标移动

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

x = 0
y = 0
x_dict = {'A': -1, 'D': 1}
y_dict = {'W': 1, 'S': -1}
my_list = list(input().strip().split(';'))
my_list.remove('')
for item in my_list:
    if len(item) > 3 or len(item) < 2:
        my_list.remove(item)
for item in my_list:
    cmd = item[0]
    if item[1:].isdigit():
        value = int(item[1:])
    else:
        continue
    if cmd in x_dict:
        x = x + x_dict[cmd] * value
    elif cmd in y_dict:
        y = y + y_dict[cmd] * value
print(str(x) + ',' + str(y))

全部评论

相关推荐

10-31 13:04
南华大学 Java
嵌入式的小白:很多面试,面试前不会去打扰cto的,但一般cto不会在这些小事上刷人,只能说这个cto比较操心,啥重要不重要,紧急不紧急的,估计都会过问,平淡看待吧
点赞 评论 收藏
分享
10-28 17:30
已编辑
华东交通大学 Java
iori2333:这太正常了 我字节面了四五轮 没有一次是在官网投递 都是hr主动捞
秋招笔试记录
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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