-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplit.go
More file actions
54 lines (53 loc) · 709 Bytes
/
Copy pathsplit.go
File metadata and controls
54 lines (53 loc) · 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package piscine
func Split(s, sep string) []string {
ln := 0
ok := true
ln_s := 0
for c := range s {
ln_s = c + 1
}
for i := 0; i < ln_s; i++ {
same := true
ln2 := 0
for j, t := range sep {
if rune(s[i+j]) != t {
same = false
break
}
ln2 = j
}
if same {
if !ok {
ln++
}
i += (ln2)
ok = true
continue
}
ok = false
}
ans := make([]string, ln+1)
x := 0
for i := 0; i < ln_s; i++ {
same := true
ln2 := 0
for j, t := range sep {
if rune(s[i+j]) != t {
same = false
break
}
ln2 = j
}
if same {
if !ok {
x++
}
i += (ln2)
ok = true
continue
}
ans[x] = ans[x] + string(s[i])
ok = false
}
return ans
}