import Foundation
/* --User Input Data-- */
var str1 = "aaab.a"
var str2 = "aaaa"
/* --User Input Data-- */
var newStr1 = ""
var newStr2 = ""
var globalIndex = 0
var rawStr = ""
func check(userStr1:String, userStr2:String){
while globalIndex < 3{
var newStr = ""
if globalIndex == 0{
rawStr = userStr1
} else if globalIndex == 1 {
rawStr = userStr2
} else {
print("Result strings: '\(newStr1)' and '\(newStr2)'")
print(newStr1==newStr2)
break
}
let sep = rawStr.components(separatedBy:".")
var localIndex = 0
for var part in sep{
if !part.isEmpty{
if localIndex != 0{
part.removeLast()
newStr += part
localIndex += 1
} else {
newStr+=part
localIndex+=1
}
} else {
newStr.removeLast()
localIndex += 1
}
}
if globalIndex == 0{
newStr1=newStr
} else {
newStr2=newStr
}
globalIndex += 1
}
}
check(userStr1: str1, userStr2:str2)