S
Size: a a a
S
AN
L
fun Sequence<Int>.solution(f: (Int) -> Boolean) =и есть подсказанный скала компилером (не котлином) рефакторинг
filter { it -> (2..it).count { f(it) } == 3 }
fun f(n:Int) = (n..1000).filter {n % it == 3}
(filter.andThen(size)) -> count
Как продолжить (1..1000).asSequence()
. ?IP
fun Sequence<Int>.solution(f: (Int) -> Boolean) =и есть подсказанный скала компилером (не котлином) рефакторинг
filter { it -> (2..it).count { f(it) } == 3 }
fun f(n:Int) = (n..1000).filter {n % it == 3}
(filter.andThen(size)) -> count
Как продолжить (1..1000).asSequence()
. ?(1..1000).asSequence().solution { it % 2 == 0 }
AM
fun Sequence<Int>.solution(f: (Int) -> Boolean) =и есть подсказанный скала компилером (не котлином) рефакторинг
filter { it -> (2..it).count { f(it) } == 3 }
fun f(n:Int) = (n..1000).filter {n % it == 3}
(filter.andThen(size)) -> count
Как продолжить (1..1000).asSequence()
. ?L
(1..1000).asSequence().solution { it % 2 == 0 }
fun solution(f: (Int) -> Boolean) = (1..1000).asSequence().filter { (2..it).count { j -> f(j) } == 3 }
IP
fun solution(f: (Int) -> Boolean) = (1..1000).asSequence().filter { (2..it).count { j -> f(j) } == 3 }
IP
L
return n % j == 0
L
AM
fun solution(seq: Sequence<Int>, f: (Int) -> Boolean) =
seq.filter { it -> (2..it).count { f(it) } == 3 }
solution((1..1000).asSequence(), ::f)
AN
AN
L
fun solution(seq: Sequence<Int>, f: (Int) -> Boolean) =
seq.filter { it -> (2..it).count { f(it) } == 3 }
solution((1..1000).asSequence(), ::f)
fun f(i: Int): Boolean {функция-то должна быть от двух параметров
}
AM
fun f(i: Int): Boolean {функция-то должна быть от двух параметров
}
AF
f: Int => Boolean
, an integer n is called a “3-f” if there are only three different integers j ∈ [1, ..., n] such that f(j) returns true. fun find3F(fn: (Int) -> Boolean): List<Int> {
return (1..1_000)
.asSequence()
.filter { (1..it).asSequence().filter(fn).take(4).toList().size == 3 }
.toList()
}
val fn = { x: Int -> x % 3 == 0 }
println(find3F(fn))
IL
AN