add: exercises and quiz for appending and slicing
This commit is contained in:
38
16-slices/exercises/10-append-sort-nums/main.go
Normal file
38
16-slices/exercises/10-append-sort-nums/main.go
Normal file
@ -0,0 +1,38 @@
|
||||
package main
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// EXERCISE: Append and Sort Numbers
|
||||
//
|
||||
// We'll have a []string that should contain numbers.
|
||||
//
|
||||
// Your task is to convert the []string to an int slice.
|
||||
//
|
||||
// 1. Get the numbers from the command-line
|
||||
//
|
||||
// 2. Append them to an []int
|
||||
//
|
||||
// 3. Sort the numbers
|
||||
//
|
||||
// 4. Print them
|
||||
//
|
||||
// 5. Handle the error cases
|
||||
//
|
||||
//
|
||||
// EXPECTED OUTPUT
|
||||
//
|
||||
// go run main.go
|
||||
// provide a few numbers
|
||||
//
|
||||
// go run main.go 4 6 1 3 0 9 2
|
||||
// [0 1 2 3 4 6 9]
|
||||
//
|
||||
// go run main.go a b c
|
||||
// []
|
||||
//
|
||||
// go run main.go 4 a 1 c d 9
|
||||
// [1 4 9]
|
||||
//
|
||||
// ---------------------------------------------------------
|
||||
|
||||
func main() {
|
||||
}
|
Reference in New Issue
Block a user