simplify `getclosestDay`
parent
1f41a5eeb2
commit
ec0abd4821
|
@ -38,7 +38,4 @@ object Maths {
|
|||
if (normal > mean - deviation && normal < mean + deviation) normal.toInt
|
||||
else boxedNormalDistribution(mean, deviation, factor)
|
||||
}
|
||||
|
||||
def closestIn(n: Int, iter: Iterable[Int]): Option[Int] =
|
||||
iter.nonEmpty option iter.minBy(v => math.abs(v - n))
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ object PuzzleDashboard {
|
|||
|
||||
val dayChoices = List(1, 2, 3, 7, 10, 14, 21, 30, 60, 90)
|
||||
|
||||
def getclosestDay(d: Int): Option[Days] = lila.common.Maths.closestIn(d, dayChoices)
|
||||
def getclosestDay(n: Int): Option[Days] = dayChoices.minByOption(day => math.abs(day - n))
|
||||
|
||||
val topThemesNb = 8
|
||||
|
||||
|
|
Loading…
Reference in New Issue