|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
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.
5 years ago
|
|
|
"sort"
|
|
|
|
|
|
|
|
student "student"
|
|
|
|
|
|
|
|
"lib"
|
|
|
|
)
|
|
|
|
|
|
|
|
func intToDigits(n int) (digits []int) {
|
|
|
|
for n > 0 {
|
|
|
|
if n == 0 {
|
|
|
|
digits = append(digits, 0)
|
|
|
|
} else {
|
|
|
|
digits = append(digits, n%10)
|
|
|
|
}
|
|
|
|
n /= 10
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func printNbrInOrder(n int) {
|
|
|
|
if n == 0 {
|
|
|
|
fmt.Print("0")
|
|
|
|
return
|
|
|
|
}
|
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.
5 years ago
|
|
|
digits := intToDigits(n)
|
|
|
|
sort.Ints(digits)
|
|
|
|
for _, i := range digits {
|
|
|
|
fmt.Printf("%c", rune(i)+'0')
|
|
|
|
}
|
|
|
|
fmt.Println()
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
table := append(
|
|
|
|
lib.MultRandIntBetween(0, lib.MaxInt),
|
|
|
|
lib.MaxInt,
|
|
|
|
321,
|
|
|
|
321321,
|
|
|
|
0,
|
|
|
|
)
|
|
|
|
for _, arg := range table {
|
|
|
|
lib.Challenge("PrintNbrInOrder", student.PrintNbrInOrder, printNbrInOrder, arg)
|
|
|
|
}
|
|
|
|
}
|