KT
kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// This code is a solution for the challenge Password Validator
// Rules:
// 1. Minimum length is 5
// 2. Maximum length is 10
// 3. Should contain at least one number
// 4. Should contain at least one special character (such as &, +,@,$,#,% etc.)
// 5. Should not contain spaces
fun main(args: Array<String>) {
val userInput = readLine()!! //takes input
val a = checkLength(userInput)
val b = validPass(userInput)
if(a && b){
println("$userInput is a valid password")
}
else println("$userInput is not a valid password")
println("\n if you like this code please upvote \n \n And if there is a more efficient way then please comment")
}
fun checkLength(pass: String): Boolean{
//this function checks the maximum and minimum length of password
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run