a function to handle the points gotten by an unknown player that does a hit on a darts board, the hit must be either equal to a previously defined target (that goes from 1 to 100) or at least close enough to this target, the closer the hit is to the target
fun registerScore(player: String, hit: Int, target: Int): Int { if (hit < 1 || hit > 100) { return 0 } return when (Math.abs(hit - target)) { 0 -> 10 in 1..3 -> 5 in 4..7 -> 2 else -> 0 } }