diff --git "a/00-\347\245\236\345\245\207\347\232\204\346\216\222\351\230\237\346\270\270\346\210\217-\347\244\272\350\214\203\346\241\210\344\276\213/main.py" "b/00-\347\245\236\345\245\207\347\232\204\346\216\222\351\230\237\346\270\270\346\210\217-\347\244\272\350\214\203\346\241\210\344\276\213/main.py" new file mode 100644 index 0000000000000000000000000000000000000000..5a0f952a910c9c2fcc38e6efb63ba0eda606b004 --- /dev/null +++ "b/00-\347\245\236\345\245\207\347\232\204\346\216\222\351\230\237\346\270\270\346\210\217-\347\244\272\350\214\203\346\241\210\344\276\213/main.py" @@ -0,0 +1,20 @@ +def find(y): + '''神奇的队伍:找y序列的原队伍序列''' + x = [] + while y: + x.insert(0, y.pop(0)) # 从乱序队首弹至原队首 + x.insert(0, x.pop(-1)) # 从原队尾弹至原队首 + return x + + +def check(x): + '''神奇的队伍:验证原序x变成乱序''' + y = [] + while x: + x.append(x.pop(0)) + y.insert(0, x.pop(0)) + return y + + +print(find([1, 2, 3, 4, 5])) +print(check(find([1, 2, 3, 4, 5]))) \ No newline at end of file