fun sumOfTwo(array: List<Int>, sum: Int) {
for (i in array.indices) {
for (j in i + 1 until array.count()) {
if (array[i] + array[j] == sum) {
println("${array[i]} + ${array[j]} = $sum")
}
}
}
}
fun main() {
val array = listOf(1, 2, 4, 6, 8, 9, 10, 12, 13, 15)
val sum = 18
sumOfTwo(array, sum)
}
ZnVuIHN1bU9mVHdvKGFycmF5OiBMaXN0PEludD4sIHN1bTogSW50KSB7CiAgZm9yIChpIGluIGFycmF5LmluZGljZXMpIHsKICAgIGZvciAoaiBpbiBpICsgMSB1bnRpbCBhcnJheS5jb3VudCgpKSB7CiAgICAgIGlmIChhcnJheVtpXSArIGFycmF5W2pdID09IHN1bSkgewogICAgICAgIHByaW50bG4oIiR7YXJyYXlbaV19ICsgJHthcnJheVtqXX0gPSAkc3VtIikKICAgICAgfQogICAgfQogIH0KfQoKZnVuIG1haW4oKSB7CiAgdmFsIGFycmF5ID0gbGlzdE9mKDEsIDIsIDQsIDYsIDgsIDksIDEwLCAxMiwgMTMsIDE1KQogIHZhbCBzdW0gPSAxOAoKICBzdW1PZlR3byhhcnJheSwgc3VtKQp9