Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Ammar-Ishfaq/31a08f6b76e4ea10c86b12393aa8411e to your computer and use it in GitHub Desktop.
Save Ammar-Ishfaq/31a08f6b76e4ea10c86b12393aa8411e to your computer and use it in GitHub Desktop.
Test for candidate application
fun main() {
val sportStats = listOf(
Summary(Sport.HIKE, 92),
Summary(Sport.RUN, 77),
Summary(Sport.TOURING_BICYCLE, 322),
Summary(Sport.E_TOURING_BICYCLE, 656)
)
val nonEBikeStats = sportStats.filter { it.sport != Sport.E_TOURING_BICYCLE }
val topSport = nonEBikeStats.maxByOrNull { it.distance }
if (topSport != null) {
println("Top sport by distance (excluding eBikes): ${topSport.sport} with distance ${topSport.distance} km")
} else {
println("No data available.")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment