This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def p12[T](list: Seq[(Int, T)]): Seq[T] = { | |
@tailrec | |
def p12inner(listInner: Seq[(Int, T)], acc: List[T]): Seq[T] = { | |
if (listInner.isEmpty) acc | |
else | |
p12inner(listInner.tail, acc ::: List.fill(listInner.head._1)(listInner.head._2)) | |
} | |
p12inner(list, List()) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package pl.japila.scalania.s99 | |
object S99_P17 { | |
def split[T](n: Int, ts: Seq[T]): (Seq[T], Seq[T]) = | |
{ | |
val tsWithIndexes = ts.zipWithIndex | |
def filterPairValue(p: ((T, Int)) => Boolean): Seq[T] = for (x <- tsWithIndexes if p(x)) yield x._1 | |
val first = filterPairValue(_._2 < n) | |
val second = filterPairValue(_._2 >= n) | |
(first, second) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package pl.japila.scalania.s99 | |
object S99_P18 { | |
def slice[T](from: Int, to: Int, ts: Seq[T]): Seq[T] = ts.splitAt(to)._1.drop(from) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package pl.japila.scalania.s99 | |
object S99_P18 { | |
def slice[T](from: Int, to: Int, ts: Seq[T]): Seq[T] = ts take to drop from | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package pl.japila.scalania.s99 | |
object S99_P19 { | |
def rotate[T](n: Int, ts: Seq[T]): Seq[T] = { | |
val k = if (n > 0) n else ts.length + n | |
val (l, r) = ts.splitAt(k) | |
r ++ l | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package pl.japila.scalania.s99 | |
object S99_P21 { | |
def insertAt[T](toAdd: T, position: Int, ts: Seq[T]): Seq[T] = ts.take(position) ++ Seq(toAdd) ++ ts.drop(position) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package pl.japila.scalania.s99 | |
object S99_P22 { | |
def range(from: Int, to: Int): Seq[Int] = from until to + 1 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package pl.japila.scalania.s99 | |
object S99_P22 { | |
def range(from: Int, to: Int): Seq[Int] = from until to + 1 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package pl.japila.scalania.s99 | |
object S99_P22 { | |
def isSorted[A](as: Array[A], gt: (A, A) => Boolean): Boolean = as.sortWith(gt) == as | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pandas as pd | |
from io import StringIO | |
data = """Benchmark (bigType) (index) (param) (smallType) Mode Cnt Score Error Units | |
UtilBenchmark.galloping 0 0 15 0 thrpt 6 7023702,891 ± 331795,244 ops/s | |
UtilBenchmark.galloping 0 0 15 1 thrpt 6 5541753,547 ± 236882,190 ops/s | |
UtilBenchmark.galloping 0 0 25 0 thrpt 6 3183137,341 ± 159748,053 ops/s | |
UtilBenchmark.galloping 0 0 25 1 thrpt 6 4461787,786 ± 225058,184 ops/s | |
UtilBenchmark.galloping 0 0 30 0 thrpt 6 955367,713 ± 49331,396 ops/s |
OlderNewer