mirror of
https://github.com/cubixle/codekata-golang.git
synced 2026-04-24 21:24:46 +01:00
20201217
This commit is contained in:
22
20201217/main.go
Normal file
22
20201217/main.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"sort"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
||||
|
||||
func process(g, s []int) int {
|
||||
sort.Ints(g)
|
||||
sort.Ints(s)
|
||||
i, j := 0, 0
|
||||
for i < len(g) && j < len(s) {
|
||||
if s[j] >= g[i] {
|
||||
i++
|
||||
}
|
||||
j++
|
||||
}
|
||||
return i
|
||||
}
|
||||
39
20201217/main_test.go
Normal file
39
20201217/main_test.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
func Test_process(t *testing.T) {
|
||||
type args struct {
|
||||
g []int
|
||||
s []int
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want int
|
||||
}{
|
||||
{
|
||||
"test1",
|
||||
args{
|
||||
g: []int{1, 2, 3},
|
||||
s: []int{1, 1},
|
||||
},
|
||||
1,
|
||||
},
|
||||
{
|
||||
"test2",
|
||||
args{
|
||||
g: []int{1, 2},
|
||||
s: []int{1, 2, 3},
|
||||
},
|
||||
2,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := process(tt.args.g, tt.args.s); got != tt.want {
|
||||
t.Errorf("process() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user