Skip to content

Commit 3037bf3

Browse files
Created const val
1 parent cab0b61 commit 3037bf3

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/main/kotlin/mate/academy/ProcessAndFilterNumbers.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ package mate.academy
44
* Transform each number: if even -> half, if odd -> doubled, then return only values > 25.
55
* Implemented using a Sequence to avoid creating intermediate lists for large inputs.
66
*/
7+
const val THRESHOLD = 25
8+
const val EVEN_DIVISOR = 2
9+
const val ODD_MULTIPLIER = 2
710
fun processAndFilterNumbers(numbers: List<Int>): List<Int> =
811
numbers.asSequence()
9-
.map { if (it % 2 == 0) it / 2 else it * 2 }
10-
.filter { it > 25 }
12+
.map { if (it % 2 == 0) it / EVEN_DIVISOR else it * ODD_MULTIPLIER }
13+
.filter { it > THRESHOLD }
1114
.toList()
1215

0 commit comments

Comments
 (0)