aboutsummaryrefslogtreecommitdiff
path: root/challenge-078/ash/python
diff options
context:
space:
mode:
author冯昶 <seaker@qq.com>2020-09-21 14:20:42 +0800
committer冯昶 <seaker@qq.com>2020-09-21 14:20:42 +0800
commitbca0c362c212fc0dadc5ed7d9a5e4fa1aece4bfb (patch)
tree877181cfde26b706346d3468269e4674d75da772 /challenge-078/ash/python
parentec09b571a6f2186fec8870a071a8d5d38596c850 (diff)
parent5ac16ac7e9826137e0da5597e954f4992c66205d (diff)
downloadperlweeklychallenge-club-bca0c362c212fc0dadc5ed7d9a5e4fa1aece4bfb.tar.gz
perlweeklychallenge-club-bca0c362c212fc0dadc5ed7d9a5e4fa1aece4bfb.tar.bz2
perlweeklychallenge-club-bca0c362c212fc0dadc5ed7d9a5e4fa1aece4bfb.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-078/ash/python')
-rw-r--r--challenge-078/ash/python/ch-1.py19
-rw-r--r--challenge-078/ash/python/ch-2.py19
2 files changed, 38 insertions, 0 deletions
diff --git a/challenge-078/ash/python/ch-1.py b/challenge-078/ash/python/ch-1.py
new file mode 100644
index 0000000000..2f6911a626
--- /dev/null
+++ b/challenge-078/ash/python/ch-1.py
@@ -0,0 +1,19 @@
+# Task 1 from
+# https://perlweeklychallenge.org/blog/perl-weekly-challenge-078/
+#
+# Comments: https://andrewshitov.com/2020/09/14/the-weekly-challenge-078/
+#
+# Output:
+#
+# $ python3 ch-1.py
+# 10
+# 7
+# 6
+# 1
+
+data = 9, 10, 7, 5, 6, 1
+
+for i in range(len(data) - 1):
+ if data[i] > max(data[i+1:]):
+ print(data[i])
+print(data[-1])
diff --git a/challenge-078/ash/python/ch-2.py b/challenge-078/ash/python/ch-2.py
new file mode 100644
index 0000000000..079e92d1b0
--- /dev/null
+++ b/challenge-078/ash/python/ch-2.py
@@ -0,0 +1,19 @@
+# Task 2 from
+# https://perlweeklychallenge.org/blog/perl-weekly-challenge-078/
+#
+# Comments: https://andrewshitov.com/2020/09/14/the-weekly-challenge-078/
+#
+# Output:
+#
+# [40, 50, 10, 20, 30]
+# [50, 10, 20, 30, 40]
+
+from collections import deque
+
+a = [10, 20, 30, 40, 50]
+b = [3, 4]
+
+for x in b:
+ d = deque(a)
+ d.rotate(-x)
+ print(list(d))