Skip to content

Commit 0f91390

Browse files
committed
🟢 Solve problem 1108
1 parent e51f4aa commit 0f91390

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

‎swift/1108.swift‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
func defangIPaddr(_ address: String) -> String {
2+
var result = ""
3+
4+
for char in address {
5+
if char != "." {
6+
result.append(char)
7+
} else {
8+
result.append("[.]")
9+
}
10+
}
11+
12+
return result
13+
}
14+
15+
var test1 = "1.1.1.1"
16+
let result = defangIPaddr(test1)
17+
print(result) // 1[.]1[.]1[.]1

0 commit comments

Comments
 (0)