-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
executable file
·41 lines (35 loc) · 900 Bytes
/
main.go
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
package main
import (
"fmt"
"play/algo"
"play/ds"
"sort"
)
func main() {
a := []int{1, 3, 6, 10, 15, 21, 28, 36, 45, 55}
x := 9
elem := algo.BinarySearchNearest(a, len(a), x)
if elem == -1 {
fmt.Printf("%d not found in %v\n", x, a)
} else {
fmt.Printf("found %d at index %d in %v\n", x, elem, a)
}
i := sort.Search(len(a), func(i int) bool { return a[i] >= x })
if i < len(a) && a[i] == x {
fmt.Printf("found %d at index %d in %v\n", x, i, a)
} else {
fmt.Printf("%d not found in %v\n", x, a)
}
return
// fmt.Println(playg.AddNumber(1, 2))
// fmt.Println("gjergj")
usrList := &ds.UserList{}
usrList.Insert(&ds.User{Name: "gjergj"})
usrList.Insert(&ds.User{Name: "gjergj"})
// usrList.Insert(&ds.User{Name: "klara"})
// usrList.Insert(&ds.User{Name: "gjergj"})
fmt.Println(usrList)
//usrList.Reverse()
fmt.Println(usrList)
fmt.Println(usrList.IsPalindrome())
}