Browse Source

Fix mistakes and rename

content-update
Xavier Petit 4 years ago committed by xpetit
parent
commit
33ecb12342
  1. 1
      tests/go/func/correct/advancedsortwordarr.go
  2. 24
      tests/go/func/correct/findnextprime.go
  3. 10
      tests/go/func/correct/findprevprime.go
  4. 2
      tests/go/func/correct/printmemory.go
  5. 2
      tests/go/func/correct/printnbrbase.go

1
tests/go/func/correct/advancedsortwordarr.go

@ -6,5 +6,4 @@ 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
})
return a
}

24
tests/go/func/correct/findnextprime.go

@ -1,24 +1,8 @@
package correct
import "math"
func isPrime(value int) bool {
if value < 2 {
return false
}
limit := int(math.Floor(math.Sqrt(float64(value))))
i := 2
for i <= limit {
if value%i == 0 {
return false
}
i++
}
return true
}
func FindNextPrime(value int) int {
if isPrime(value) {
return value
func FindNextPrime(nb int) int {
if isPrime(nb) {
return nb
}
return FindNextPrime(value + 1)
return FindNextPrime(nb + 1)
}

10
tests/go/func/correct/findprevprime.go

@ -13,12 +13,12 @@ func isPrime(nb int) bool {
return true
}
func FindPrevPrime(nbr int) int {
if nbr < 2 {
func FindPrevPrime(nb int) int {
if nb < 2 {
return 0
}
if isPrime(nbr) {
return nbr
if isPrime(nb) {
return nb
}
return FindPrevPrime(nbr - 1)
return FindPrevPrime(nb - 1)
}

2
tests/go/func/correct/printmemory.go

@ -63,7 +63,7 @@ func printLine(arr [10]int, start int) {
z01.PrintRune('\n')
c := start
for c < start+16 && c < size {
if unicode.IsPrint() {
if unicode.IsPrint(rune(arr[c])) {
z01.PrintRune(rune(arr[c]))
} else {
z01.PrintRune('.')

2
tests/go/func/correct/printnbrbase.go

@ -3,7 +3,7 @@ package correct
import "github.com/01-edu/z01"
func PrintNbrBase(n int, base string) {
if ValidBase(base) {
if validBase(base) {
length := len(base)
sign := 1
rbase := []rune(base)

Loading…
Cancel
Save