Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
4 years ago
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"sort"
|
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
4 years ago
|
|
|
"strings"
|
|
|
|
|
|
|
|
student "student"
|
|
|
|
|
|
|
|
"github.com/01-edu/public/go/tests/lib"
|
|
|
|
)
|
|
|
|
|
|
|
|
func advancedSortWordArr(a []string, f func(a, b string) int) {
|
|
|
|
sort.Slice(a, func(i, j int) bool {
|
|
|
|
return f(a[i], a[j]) < 0
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
4 years ago
|
|
|
func main() {
|
|
|
|
table := [][]string{{"a", "A", "1", "b", "B", "2", "c", "C", "3"}}
|
|
|
|
|
|
|
|
table = append(table, lib.MultRandWords())
|
|
|
|
|
|
|
|
for _, org := range table {
|
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
4 years ago
|
|
|
// copy for using the solution function
|
|
|
|
cp_sol := make([]string, len(org))
|
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
4 years ago
|
|
|
// copy for using the student function
|
|
|
|
cp_stu := make([]string, len(org))
|
|
|
|
|
|
|
|
copy(cp_sol, org)
|
|
|
|
copy(cp_stu, org)
|
|
|
|
|
|
|
|
advancedSortWordArr(cp_sol, strings.Compare)
|
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
4 years ago
|
|
|
student.AdvancedSortWordArr(cp_stu, strings.Compare)
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(cp_stu, cp_sol) {
|
|
|
|
lib.Fatalf("%s(%v) == %v instead of %v\n",
|
|
|
|
"AdvancedSortWordArr",
|
|
|
|
org,
|
|
|
|
cp_stu,
|
|
|
|
cp_sol,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|