aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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