Initial Commit
This commit is contained in:
BIN
go/series/main/main
Executable file
BIN
go/series/main/main
Executable file
Binary file not shown.
52
go/series/main/main.go
Normal file
52
go/series/main/main.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// All ...
|
||||
func All(l int, str string) []string {
|
||||
var ret []string
|
||||
for len(str) >= l {
|
||||
ret = append(ret, str[:l])
|
||||
str = str[1:]
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func main() {
|
||||
var allTests = []struct {
|
||||
n int
|
||||
s string
|
||||
out []string
|
||||
}{
|
||||
{1, "01234",
|
||||
[]string{"0", "1", "2", "3", "4"}},
|
||||
{1, "92834",
|
||||
[]string{"9", "2", "8", "3", "4"}},
|
||||
{2, "01234",
|
||||
[]string{"01", "12", "23", "34"}},
|
||||
{2, "98273463",
|
||||
[]string{"98", "82", "27", "73", "34", "46", "63"}},
|
||||
{2, "37103",
|
||||
[]string{"37", "71", "10", "03"}},
|
||||
{3, "01234",
|
||||
[]string{"012", "123", "234"}},
|
||||
{3, "31001",
|
||||
[]string{"310", "100", "001"}},
|
||||
{3, "982347",
|
||||
[]string{"982", "823", "234", "347"}},
|
||||
{4, "01234",
|
||||
[]string{"0123", "1234"}},
|
||||
{4, "91274",
|
||||
[]string{"9127", "1274"}},
|
||||
{5, "01234",
|
||||
[]string{"01234"}},
|
||||
{5, "81228",
|
||||
[]string{"81228"}},
|
||||
{6, "01234", nil},
|
||||
}
|
||||
for _, test := range allTests {
|
||||
fmt.Println(All(test.n, test.s))
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user