-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFizzBuzzCuckooClock.kt
40 lines (36 loc) · 1.07 KB
/
FizzBuzzCuckooClock.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
29
30
31
32
33
34
35
36
37
38
39
40
package com.smlnskgmail.jaman.codewarskotlin.kyu7
import java.util.*
// https://www.codewars.com/kata/58485a43d750d23bad0000e6
class FizzBuzzCuckooClock(
private val input: String
) {
@Suppress(
"ComplexMethod",
"MagicNumber",
"UseIfInsteadOfWhen"
)
fun solution(): String {
val data = input.split(":")
var hours = data[0].toInt()
val minutes = data[1].toInt()
return when {
minutes > 0 -> {
when {
minutes == 30 -> "Cuckoo"
minutes % 3 == 0 && minutes % 5 == 0 -> "Fizz Buzz"
minutes % 3 == 0 -> "Fizz"
minutes % 5 == 0 -> "Buzz"
else -> "tick"
}
}
else -> {
if (hours == 0 || hours == 12) {
hours = 12
} else if (hours > 12) {
hours -= 12
}
Collections.nCopies(hours, "Cuckoo").joinToString(" ")
}
}
}
}