aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2021-07-01 22:01:54 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2021-07-01 22:01:54 +0100
commit7fb02294c8c7f44fb6ea95843bf0dfa64bd3aeb1 (patch)
treec14f4cedb8c7bfce7a07664f2fe7c7db033b50ad
parentd154c1aea4d7b566b6a51ae16406c029d9627f33 (diff)
parent262799cc1171e2e8f515d2ae5fb77935a51c2307 (diff)
downloadperlweeklychallenge-club-7fb02294c8c7f44fb6ea95843bf0dfa64bd3aeb1.tar.gz
perlweeklychallenge-club-7fb02294c8c7f44fb6ea95843bf0dfa64bd3aeb1.tar.bz2
perlweeklychallenge-club-7fb02294c8c7f44fb6ea95843bf0dfa64bd3aeb1.zip
Merge branch 'master' of https://github.com/manwar/perlweeklychallenge-club
-rw-r--r--challenge-119/frankivo/scala/NibbleSwap.scala12
-rw-r--r--challenge-119/frankivo/scala/Sequencer.scala10
2 files changed, 22 insertions, 0 deletions
diff --git a/challenge-119/frankivo/scala/NibbleSwap.scala b/challenge-119/frankivo/scala/NibbleSwap.scala
new file mode 100644
index 0000000000..a39d981f59
--- /dev/null
+++ b/challenge-119/frankivo/scala/NibbleSwap.scala
@@ -0,0 +1,12 @@
+object NibbleSwap {
+ def swap(n: Int): Int = {
+ Integer.parseInt(
+ "%08d" // Two-nibble limit is here.
+ .format(n.toBinaryString.toInt) // Don't really like the double cast.
+ .grouped(4)
+ .toArray
+ .reverse
+ .mkString,
+ 2)
+ }
+}
diff --git a/challenge-119/frankivo/scala/Sequencer.scala b/challenge-119/frankivo/scala/Sequencer.scala
new file mode 100644
index 0000000000..7883b8c2f0
--- /dev/null
+++ b/challenge-119/frankivo/scala/Sequencer.scala
@@ -0,0 +1,10 @@
+object Sequencer {
+ def sequencer(n: Int): Int = {
+ LazyList
+ .iterate(1)(_ + 1)
+ .filterNot(_.toString exists (((4 to 9).toSeq :+ 0).map(_.toString) contains _.toString))
+ .filterNot(_.toString contains "11")
+ .take(n)
+ .last
+ }
+} \ No newline at end of file