add: unfinished code. people are having problems

This commit is contained in:
Inanc Gumus
2018-11-13 17:43:25 +03:00
parent 67b20e5755
commit 490223331c
103 changed files with 4218 additions and 3 deletions

View File

@ -0,0 +1,15 @@
package main
// ---------------------------------------------------------
// EXERCISE: Name
// ?
//
// NOTE
// ?
//
// EXPECTED OUTPUT
// ?
// ---------------------------------------------------------
func main() {
}

View File

@ -0,0 +1,4 @@
package main
func main() {
}

View File

@ -0,0 +1,36 @@
package main
// ---------------------------------------------------------
// EXERCISE: Declare empty arrays
//
// 1. Declare and printf the following arrays:
//
// 1. A string array with 4 items
// 2. An int array 5 items
// 3. A byte array with 5 items
// 4. A float64 array with 1 item
// 5. A bool array with 4 items
// 6. A byte array without any items
//
// 2. Print the types of the previous arrays.
//
// NOTE
// You should use printf with #v verb.
//
// EXPECTED OUTPUT
// names : [4]string{"", "", "", ""}
// distances: [5]int{0, 0, 0, 0, 0}
// data : [5]uint8{0x0, 0x0, 0x0, 0x0, 0x0}
// ratios : [1]float64{0}
// switches : [4]bool{false, false, false, false}
// zero : [0]bool{}
// names : [4]string
// distances: [5]int
// data : [5]uint8
// ratios : [1]float64
// switches : [4]bool
// zero : [0]bool
// ---------------------------------------------------------
func main() {
}

View File

@ -0,0 +1,36 @@
package main
import "fmt"
func main() {
// 1. Declare and printf the following arrays:
// 1. A string array with 4 items
// 2. An int array 5 items
// 3. A byte array with 5 items
// 4. A float64 array with 1 item
// 5. A bool array with 4 items
// 6. A byte array without any items
var (
names [4]string
distances [5]int
data [5]byte
ratios [1]float64
switches [4]bool
zero [0]bool
)
fmt.Printf("names : %#v\n", names)
fmt.Printf("distances: %#v\n", distances)
fmt.Printf("data : %#v\n", data)
fmt.Printf("ratios : %#v\n", ratios)
fmt.Printf("switches : %#v\n", switches)
fmt.Printf("zero : %#v\n", zero)
// 2. Print the types of the previous arrays.
fmt.Printf("names : %T\n", names)
fmt.Printf("distances: %T\n", distances)
fmt.Printf("data : %T\n", data)
fmt.Printf("ratios : %T\n", ratios)
fmt.Printf("switches : %T\n", switches)
fmt.Printf("zero : %T\n", zero)
}

View File

@ -0,0 +1,17 @@
package main
// search for books in hipster's love
// ---------------------------------------------------------
// EXERCISE: Name
// ?
//
// NOTE
// ?
//
// EXPECTED OUTPUT
// ?
// ---------------------------------------------------------
func main() {
}

View File

@ -0,0 +1,40 @@
package main
import (
"fmt"
"os"
"strings"
)
const yearly = 4
func main() {
var books [yearly]string
books[0] = "Kafka's Revenge"
books[1] = "Stay Golden"
books[2] = "Everythingship"
books[3] += books[0] + " 2nd Edition"
if len(os.Args) != 2 {
fmt.Println("Tell me a book title")
return
}
query := os.Args[1]
fmt.Println("Search Results:")
fmt.Println("---------------")
var found bool
for _, v := range books {
if strings.Contains(strings.ToLower(v), query) {
fmt.Println("+", v)
found = true
}
}
if !found {
fmt.Printf("We don't have that book: %q\n", query)
}
}

View File

@ -0,0 +1,20 @@
# Array Exercises
1. **[Declare Empty Arrays](https://github.com/inancgumus/learngo/tree/master/14-arrays/exercises/01-declare-empty)**
- get data from command-line
- into a fixed array; see how it blows beyond its len
- add items
- get items
- check the length
- print the items
- reverse the array
- shuffle the items
- find the first item that contains x
- find the last item that contains y
- find the duplicate items
1. **[text](https://github.com/inancgumus/learngo/tree/master/)**
text