mirror of
https://github.com/cubixle/codekata-golang.git
synced 2026-04-24 23:04:42 +01:00
20201201: fix bug
This commit is contained in:
@@ -10,7 +10,7 @@ func isEcho(s string) bool {
|
|||||||
}
|
}
|
||||||
l := 0
|
l := 0
|
||||||
r := len(s) - 1
|
r := len(s) - 1
|
||||||
for r >= l {
|
for r > l {
|
||||||
if s[l] != s[r] {
|
if s[l] != s[r] {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -26,9 +26,12 @@ func isAlmostEcho(s string) bool {
|
|||||||
}
|
}
|
||||||
l := 0
|
l := 0
|
||||||
r := len(s) - 1
|
r := len(s) - 1
|
||||||
for r >= l {
|
for r > l {
|
||||||
if s[l] != s[r] && !isEcho(removeIndex(l, s)) && !isEcho(removeIndex(r, s)) {
|
if s[l] != s[r] {
|
||||||
return false
|
if !isEcho(removeIndex(l, s)) && !isEcho(removeIndex(r, s)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
l++
|
l++
|
||||||
r--
|
r--
|
||||||
|
|||||||
@@ -75,6 +75,11 @@ func Test_isAlmostEcho(t *testing.T) {
|
|||||||
args{"abcbba"},
|
args{"abcbba"},
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"test6",
|
||||||
|
args{"abcdcbba"},
|
||||||
|
true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user