From 33ecb12342f015c554e998e359ca107d55a23f19 Mon Sep 17 00:00:00 2001 From: Xavier Petit <32063953+xpetit@users.noreply.github.com> Date: Tue, 28 Apr 2020 13:40:26 +0200 Subject: [PATCH] Fix mistakes and rename --- tests/go/func/correct/advancedsortwordarr.go | 1 - tests/go/func/correct/findnextprime.go | 24 ++++---------------- tests/go/func/correct/findprevprime.go | 10 ++++---- tests/go/func/correct/printmemory.go | 2 +- tests/go/func/correct/printnbrbase.go | 2 +- 5 files changed, 11 insertions(+), 28 deletions(-) diff --git a/tests/go/func/correct/advancedsortwordarr.go b/tests/go/func/correct/advancedsortwordarr.go index bfdbf39c..05c01734 100644 --- a/tests/go/func/correct/advancedsortwordarr.go +++ b/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 } diff --git a/tests/go/func/correct/findnextprime.go b/tests/go/func/correct/findnextprime.go index 6dc02d67..42a6fa89 100644 --- a/tests/go/func/correct/findnextprime.go +++ b/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) } diff --git a/tests/go/func/correct/findprevprime.go b/tests/go/func/correct/findprevprime.go index 40695e2e..5fbab881 100644 --- a/tests/go/func/correct/findprevprime.go +++ b/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) } diff --git a/tests/go/func/correct/printmemory.go b/tests/go/func/correct/printmemory.go index 739b30cf..ae967584 100644 --- a/tests/go/func/correct/printmemory.go +++ b/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('.') diff --git a/tests/go/func/correct/printnbrbase.go b/tests/go/func/correct/printnbrbase.go index 1ab70307..fa8b158c 100644 --- a/tests/go/func/correct/printnbrbase.go +++ b/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)