题解 | #MP3光标位置#
MP3光标位置
http://www.nowcoder.com/practice/eaf5b886bd6645dd9cfb5406f3753e15
自己写的辣鸡代码记录一下
song_list = list(range(1,int(input())+1)) order = input() cur = [1,[1,2,3,4]] def go(order): global song_list if len(song_list)<=4: if order == 'U': cur[0] = song_list[song_list.index(cur[0])-1] else: if cur[0] == len(song_list): cur[0] = 1 else: cur[0] = song_list[song_list.index(cur[0])+1] cur[1] = song_list else: if order == 'U': if cur[0] == 1: cur[1] = song_list[-4:] cur[0] = song_list[-1] elif cur[1].index(cur[0])>0: cur[0] = song_list[song_list.index(cur[0])-1] elif cur[1].index(cur[0])==0: cur[0] = song_list[song_list.index(cur[0])-1] cur[1] = [i-1 for i in cur[1]] elif order == 'D': if cur[0] == song_list[-1]: cur[1] = song_list[:4] cur[0] = song_list[0] elif cur[1].index(cur[0])<3: cur[0] = song_list[song_list.index(cur[0])+1] elif cur[1].index(cur[0])==3: cur[0] = song_list[song_list.index(cur[0])+1] cur[1] = [i+1 for i in cur[1]] for i in order: go(i) print(*cur[1]) print(cur[0])