Skip to content

Instantly share code, notes, and snippets.

View manjeettahkur's full-sized avatar

Manjeet Singh manjeettahkur

View GitHub Profile
@manjeettahkur
manjeettahkur / Composition.go
Created April 15, 2019 15:02
Composition in golang
package main
import "fmt"
type author struct {
firstName string
lastName string
bio string
}
@manjeettahkur
manjeettahkur / camelcase.go
Created November 30, 2018 07:06
camelCase method in golang
/*
Title:
Break camelCase
Description:
Write simple .camelCase method (camel_case function in PHP or CamelCase in C#) for strings. All words must have their first letter capitalized without spaces.
Examples:
"hello case".camelCase() => HelloCase
"camel case word".camelCase() => CamelCaseWord
Kata Link:
https://www.codewars.com/kata/break-camelcase
@manjeettahkur
manjeettahkur / main.go
Created November 20, 2018 17:33
Hackerrank
package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
func main() {
@manjeettahkur
manjeettahkur / main.go
Created November 20, 2018 16:22
Linear Search.....
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
@manjeettahkur
manjeettahkur / main.go
Created November 18, 2018 15:12
Linear Search
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
@manjeettahkur
manjeettahkur / structWithMethod.go
Created November 11, 2018 08:30
golang struct with method
package main
import "fmt"
type Rectangle struct {
length, width int
}
func (r Rectangle) Area() int {
return r.length * r.width
@manjeettahkur
manjeettahkur / fibonacci.go
Created November 10, 2018 15:06 — forked from PetrGlad/fibonacci.go
My exercises for "A tour of Go"
func fibonacci_seq() func() int {
f1, f2 := 0, 1
return func() int {
f1, f2 = f2, f1 + f2
return f2
}
}
package main
import "fmt"
// 定义接口类型 PeopleGetter 包含获取基本信息的方法
type PeopleGetter interface {
GetName() string
GetAge() int
}
@manjeettahkur
manjeettahkur / accum.go
Created March 15, 2018 12:48
Accumulator Pattern with Strings
package main
import (
"fmt"
"strings"
)
func main() {
a := make([]int, 5)
printSlice("a", a)
@manjeettahkur
manjeettahkur / randstring.go
Created March 15, 2018 12:46
Random string in golang
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
fmt.Println(RandString(10))