aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-114/simon-proctor/raku/ch-1.raku6
-rw-r--r--challenge-114/simon-proctor/raku/ch-2.raku9
2 files changed, 15 insertions, 0 deletions
diff --git a/challenge-114/simon-proctor/raku/ch-1.raku b/challenge-114/simon-proctor/raku/ch-1.raku
new file mode 100644
index 0000000000..38c1422058
--- /dev/null
+++ b/challenge-114/simon-proctor/raku/ch-1.raku
@@ -0,0 +1,6 @@
+#!/usr/bin/env raku
+
+#| Find the nest highest integer that's a palindrome
+sub MAIN( Int $N ) {
+ ($N^..*).first( { $_ ~~ $_.flip } ).say
+}
diff --git a/challenge-114/simon-proctor/raku/ch-2.raku b/challenge-114/simon-proctor/raku/ch-2.raku
new file mode 100644
index 0000000000..f299414df6
--- /dev/null
+++ b/challenge-114/simon-proctor/raku/ch-2.raku
@@ -0,0 +1,9 @@
+#!/usr/bin/env raku
+
+#| Given a number find the next highest number which has the same number of ones in the binary rep
+sub MAIN ( Int $N ) {
+ my $ones = one-count( $N );
+ ($N^..*).first( { $ones == one-count($_) } ).say;
+}
+
+sub one-count( Int $n ) { $n.base(2).comb.grep( * == 1 ).elems }