From dcad9bb8e272d6b0e44be9bed77db34bab6b0bf4 Mon Sep 17 00:00:00 2001 From: ycicada Date: Fri, 15 Apr 2022 15:02:47 +0000 Subject: [PATCH] =?UTF-8?q?add=2000-=E7=A5=9E=E5=A5=87=E7=9A=84=E6=8E=92?= =?UTF-8?q?=E9=98=9F=E6=B8=B8=E6=88=8F-=E7=A4=BA=E8=8C=83=E6=A1=88?= =?UTF-8?q?=E4=BE=8B/main.py.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main.py" | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 "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" 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 0000000..5a0f952 --- /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 -- Gitee