Forked from ArneKoeckeritz/gist:f39a8c711473f4ceb8dbea9cc1dd5e5e
Last active
March 8, 2024 10:58
-
-
Save Ammar-Ishfaq/31a08f6b76e4ea10c86b12393aa8411e to your computer and use it in GitHub Desktop.
Test for candidate application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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