You are viewing a single comment's thread. Return to all comments →
Some Kotlin goodness
class AppleAndOrange { init { Scanner(System.`in`).apply { val (s, t) = nextLine().split(" ").map { it.toInt() } val (a, b) = nextLine().split(" ").map { it.toInt() } val (m, n) = nextLine().split(" ").map { it.toInt() } val apples = nextLine().split(" ").map { it.trim().toInt() }.toTypedArray() val oranges = nextLine().split(" ").map { it.trim().toInt() }.toTypedArray() countApplesAndOranges(s,t,a,b,apples,oranges) } } fun countApplesAndOranges(s: Int, t: Int, a: Int, b: Int, apples: Array<Int>, oranges: Array<Int>) { var finalApples = 0 var finalOranges = 0 for (apple in apples) if (apple + a in s..t) finalApples++ for (orange in oranges) if (orange + b in s..t) finalOranges++ println(finalApples) println(finalOranges) } }
Seems like cookies are disabled on this browser, please enable them to open this website
Apple and Orange
You are viewing a single comment's thread. Return to all comments →
Some Kotlin goodness