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
|
||||
r := len(s) - 1
|
||||
for r >= l {
|
||||
for r > l {
|
||||
if s[l] != s[r] {
|
||||
return false
|
||||
}
|
||||
@@ -26,10 +26,13 @@ func isAlmostEcho(s string) bool {
|
||||
}
|
||||
l := 0
|
||||
r := len(s) - 1
|
||||
for r >= l {
|
||||
if s[l] != s[r] && !isEcho(removeIndex(l, s)) && !isEcho(removeIndex(r, s)) {
|
||||
for r > l {
|
||||
if s[l] != s[r] {
|
||||
if !isEcho(removeIndex(l, s)) && !isEcho(removeIndex(r, s)) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
l++
|
||||
r--
|
||||
}
|
||||
|
||||
@@ -75,6 +75,11 @@ func Test_isAlmostEcho(t *testing.T) {
|
||||
args{"abcbba"},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"test6",
|
||||
args{"abcdcbba"},
|
||||
true,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user