aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-180/sgreen/README.md4
-rw-r--r--challenge-180/sgreen/blog.txt1
-rwxr-xr-xchallenge-180/sgreen/perl/ch-1.pl23
-rwxr-xr-xchallenge-180/sgreen/perl/ch-2.pl20
-rwxr-xr-xchallenge-180/sgreen/python/ch-1.py20
-rwxr-xr-xchallenge-180/sgreen/python/ch-2.py18
6 files changed, 84 insertions, 2 deletions
diff --git a/challenge-180/sgreen/README.md b/challenge-180/sgreen/README.md
index 65ea77fbce..3827d96ce5 100644
--- a/challenge-180/sgreen/README.md
+++ b/challenge-180/sgreen/README.md
@@ -1,3 +1,3 @@
-# The Weekly Challenge 179
+# The Weekly Challenge 180
-Blog [The Ordinal Sparkline](https://dev.to/simongreennet/the-ordinal-sparkline-dn5)
+[Blog](https://dev.to/simongreennet/weekly-challenge-180-4mi5)
diff --git a/challenge-180/sgreen/blog.txt b/challenge-180/sgreen/blog.txt
new file mode 100644
index 0000000000..c9968de7e1
--- /dev/null
+++ b/challenge-180/sgreen/blog.txt
@@ -0,0 +1 @@
+https://dev.to/simongreennet/weekly-challenge-180-4mi5 \ No newline at end of file
diff --git a/challenge-180/sgreen/perl/ch-1.pl b/challenge-180/sgreen/perl/ch-1.pl
new file mode 100755
index 0000000000..74b4fb6312
--- /dev/null
+++ b/challenge-180/sgreen/perl/ch-1.pl
@@ -0,0 +1,23 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use feature 'say';
+use experimental 'signatures';
+
+sub main($phrase) {
+# Go through each character
+ foreach my $i (0 .. length($phrase)-2) {
+
+ # If the letter in that position does not occur later, print the index
+ if (index($phrase, substr($phrase, $i, 1), $i + 1) == -1) {
+ say $i;
+ return;
+ }
+ }
+
+ # Oh dear. Nothing unique!
+ say 'No unique characters!';
+}
+
+main($ARGV[0]); \ No newline at end of file
diff --git a/challenge-180/sgreen/perl/ch-2.pl b/challenge-180/sgreen/perl/ch-2.pl
new file mode 100755
index 0000000000..089217266d
--- /dev/null
+++ b/challenge-180/sgreen/perl/ch-2.pl
@@ -0,0 +1,20 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use feature 'say';
+use experimental 'signatures';
+
+sub main(@nums) {
+
+ # Get the last number as the number to compare
+ my $n = pop(@nums);
+
+ # Get all numbers > n
+ my @l = grep { $_ > $n } @nums;
+
+ # Print the numbers
+ say join( ', ', @l );
+}
+
+main(@ARGV);
diff --git a/challenge-180/sgreen/python/ch-1.py b/challenge-180/sgreen/python/ch-1.py
new file mode 100755
index 0000000000..5364bf6aff
--- /dev/null
+++ b/challenge-180/sgreen/python/ch-1.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python3
+
+import sys
+
+
+def main(phrase):
+ # Go through each character
+ for i in range(len(phrase)-1):
+
+ # If the letter in that position does not occur later, print the index
+ if phrase[i] not in phrase[i+1:]:
+ print(i)
+ return
+
+ # Oh dear. Nothing unique!
+ print('No unique characters!')
+
+
+if __name__ == '__main__':
+ main(sys.argv[1])
diff --git a/challenge-180/sgreen/python/ch-2.py b/challenge-180/sgreen/python/ch-2.py
new file mode 100755
index 0000000000..1771161bbc
--- /dev/null
+++ b/challenge-180/sgreen/python/ch-2.py
@@ -0,0 +1,18 @@
+#!/usr/bin/env python3
+
+import sys
+
+
+def main(nums):
+ # Get the last number as the number to compare
+ n = float(nums.pop())
+
+ # Get all numbers > n
+ l = [i for i in nums if float(i) > n]
+
+ # Print the numbers
+ print(*l, sep=', ')
+
+
+if __name__ == '__main__':
+ main(sys.argv[1:])