Leap Year

Report a typo

The function isLeapYear(year: String): Boolean takes a year as a parameter and returns true if it is a leap year. Write the correct code for the isLeapYear() function.

You don't need to implement any algorithm for leap years, just remember that if you try to create an Instant for a non-valid day, an exception is thrown.

This task uses dependencies that may not be available in your local IDE. As a result, you may see compilation errors or unresolved references when running the code locally. This does not affect solution validation when you submit your solution to Hyperskill.

Sample Input 1:

2024

Sample Output 1:

true
Write a program in Kotlin
import kotlinx.datetime.*
import kotlin.time.Instant

fun isLeapYear(year: String): Boolean {
// Write your code here

//
}

fun main() {
val year = readln()
println(isLeapYear(year))
}

Create a free account to access the full topic