Skip to content
This repository was archived by the owner on Aug 15, 2026. It is now read-only.
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions kotlin/src/main/kotlin/com/corntest/RandomMathOperations.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.corntest
import kotlin.random.Random

/**
* Random math operations with an intentional 5% flaw in [generateRandomEvenNumber].
* Random math operations.
*/
class RandomMathOperations(seed: Long? = null) {

Expand Down Expand Up @@ -38,15 +38,9 @@ class RandomMathOperations(seed: Long? = null) {

/**
* Generates a random even number between 0 and 100 (inclusive).
* Contains an intentional flaw: 5% of the time, adds 1 to corrupt the result.
*/
fun generateRandomEvenNumber(): Int {
var value = random.nextInt(51) * 2 // 0, 2, 4, ..., 100
// Intentional flaw: 5% chance of corrupting the result
if (random.nextDouble() < 0.05) {
value += 1
}
return value
return random.nextInt(51) * 2 // 0, 2, 4, ..., 100
}

/**
Expand Down
Loading