object CollapsibleString {

  
  def collapseString (s : String) : String = {
    var res = s
    var isOver = false
    var i = 0
    if(res.size == 0) res
    else while(!isOver){
      if(res(i) == res(i+1)){
        res = res.take(i) ++ res.drop(i+1)
        i-=1
      }
      i+=1
      if(i==res.size-1) isOver = true
    }
    res
  }

  
  def isCollapsible (s : String) : Boolean = collapseString(s).length != s.length

  
  def reportResults (s : String) : String = {
    val sCollapsed = collapseString(s)
    val originalRes = "ORIGINAL : length = " + s.length() + ", string = " + s + ""
    val collapsedRes = "COLLAPSED: length = " + sCollapsed.length() + ", string = " + sCollapsed + ""