import java.util.*

public fun <T, C : MutableCollection<in T>> Collection<T>.partitionTo(col1: C, col2: C, predicate: (T)-> Boolean): Pair<C,C> {
    //T-n itemi tesak, C-n` Collectioni mejini
    //greladzevy` toCollectioni pes
    for( item in this){
        if(predicate(item)){
            col1.add(item)
        }
        else{
            col2.add(item)
        }
    }
    return Pair(col1,col2) // qanzi partition()-y sl-um pair er veradardznum
}
fun partitionWordsAndLines() {
    val (words, lines) = listOf("a", "a b", "c", "d e")
            .partitionTo(ArrayList(), ArrayList()) { s -> !s.contains(" ") }
    check(words == listOf("a", "c"))
    check(lines == listOf("a b", "d e"))
}

fun partitionLettersAndOtherSymbols() {
    val (letters, other) = setOf('a', '%', 'r', '}')
            .partitionTo(HashSet(), HashSet()) { c -> c in 'a'..'z' || c in 'A'..'Z' }
    check(letters == setOf('a', 'r'))
    check(other == setOf('%', '}'))
}
