diff --git a/subjects/printrevcombprog.en.md b/subjects/printrevcombprog.en.md index 0881f941..a063c130 100644 --- a/subjects/printrevcombprog.en.md +++ b/subjects/printrevcombprog.en.md @@ -1,4 +1,4 @@ -## printrevcombprog +## printrevcomb ### Instructions @@ -11,10 +11,10 @@ These combinations are separated by a comma and a space. Here is an **incomplete** output : ```console -student@ubuntu:~/[[ROOT]]/printcombprog$ go build -student@ubuntu:~/[[ROOT]]/printcombprog$ ./printcombprog | cat -e +student@ubuntu:~/[[ROOT]]/printrevcomb$ go build +student@ubuntu:~/[[ROOT]]/printrevcomb$ ./printrevcomb | cat -e 987, 986, 985, 984, 983, 982, 981, 980, 976, ..., 310, 210$ -student@ubuntu:~/[[ROOT]]/printcombprog$ +student@ubuntu:~/[[ROOT]]/printrevcomb$ ``` `999` or `000` are not valid combinations because the digits are not different. diff --git a/subjects/reachablenumberprog.en.md b/subjects/reachablenumberprog.en.md index b331300b..e6e30ce9 100644 --- a/subjects/reachablenumberprog.en.md +++ b/subjects/reachablenumberprog.en.md @@ -19,12 +19,16 @@ Here is a possible program to test your function : ```go package main -import "fmt" +import ( + "fmt" + + piscine ".." +) func main() { - fmt.Println(ReachableNumber(1)) - fmt.Println(ReachableNumber(10)) - fmt.Println(ReachableNumber(1001)) + fmt.Println(piscine.ReachableNumber(1)) + fmt.Println(piscine.ReachableNumber(10)) + fmt.Println(piscine.ReachableNumber(1001)) } ``` diff --git a/tests/go/solutions/doppelgangerprog/main.go b/tests/go/solutions/doppelgangerprog/main.go deleted file mode 100644 index b1ab7fff..00000000 --- a/tests/go/solutions/doppelgangerprog/main.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -import "strings" - -func DoppelGanger(s, substr string) int { - return strings.LastIndex(s, substr) -} - -func main() { -} diff --git a/tests/go/solutions/doppelgangerprog/test_doppelgangerprog.go b/tests/go/solutions/doppelgangerprog/test_doppelgangerprog.go index ba959e2d..c75c18ec 100644 --- a/tests/go/solutions/doppelgangerprog/test_doppelgangerprog.go +++ b/tests/go/solutions/doppelgangerprog/test_doppelgangerprog.go @@ -4,6 +4,7 @@ import ( "github.com/01-edu/z01" correct "./correct" + student "./student" ) type node struct { @@ -47,6 +48,6 @@ func main() { } for _, arg := range table { - z01.Challenge("DoppelGangerProg", DoppelGanger, correct.DoppelGanger, arg.big, arg.little) + z01.Challenge("DoppelGangerProg", student.DoppelGanger, correct.DoppelGanger, arg.big, arg.little) } } diff --git a/tests/go/solutions/findprevprime.go b/tests/go/solutions/findprevprime.go index d04cdc03..40695e2e 100644 --- a/tests/go/solutions/findprevprime.go +++ b/tests/go/solutions/findprevprime.go @@ -1,10 +1,23 @@ package correct +func isPrime(nb int) bool { + if nb <= 0 || nb == 1 { + return false + } + + for i := 2; i <= nb/2; i++ { + if nb%i == 0 { + return false + } + } + return true +} + func FindPrevPrime(nbr int) int { if nbr < 2 { return 0 } - if IsPrime(nbr) { + if isPrime(nbr) { return nbr } return FindPrevPrime(nbr - 1) diff --git a/tests/go/solutions/findprevprimeprog/main.go b/tests/go/solutions/findprevprimeprog/main.go deleted file mode 100644 index af1d1184..00000000 --- a/tests/go/solutions/findprevprimeprog/main.go +++ /dev/null @@ -1,27 +0,0 @@ -package main - -func main() { -} - -func FindPrevPrime(nbr int) int { - if nbr < 2 { - return 0 - } - if IsPrime(nbr) { - return nbr - } - return FindPrevPrime(nbr - 1) -} - -func IsPrime(nb int) bool { - if nb <= 0 || nb == 1 { - return false - } - - for i := 2; i <= nb/2; i++ { - if nb%i == 0 { - return false - } - } - return true -} diff --git a/tests/go/solutions/findprevprimeprog/test_findprevprimeprog.go b/tests/go/solutions/findprevprimeprog/test_findprevprimeprog.go index db2546f8..871cb98b 100644 --- a/tests/go/solutions/findprevprimeprog/test_findprevprimeprog.go +++ b/tests/go/solutions/findprevprimeprog/test_findprevprimeprog.go @@ -4,11 +4,12 @@ import ( "github.com/01-edu/z01" correct "./correct" + student "./student" ) func main() { a := append(z01.MultRandIntBetween(0, 99999), 5, 4, 1) for _, elem := range a { - z01.Challenge("FindPrevPrimeProg", FindPrevPrime, correct.FindPrevPrime, elem) + z01.Challenge("FindPrevPrimeProg", student.FindPrevPrime, correct.FindPrevPrime, elem) } } diff --git a/tests/go/solutions/halfcontestprog/main.go b/tests/go/solutions/halfcontestprog/main.go deleted file mode 100644 index 3e423393..00000000 --- a/tests/go/solutions/halfcontestprog/main.go +++ /dev/null @@ -1,13 +0,0 @@ -package main - -func Halfcontest(h1, m1, h2, m2 int) int { - t1 := h1*60 + m1 - t2 := h2*60 + m2 - t2 = (t2 + t1) / 2 - h2 = t2 / 60 - m2 = t2 % 60 - return h2*100 + m2 -} - -func main() { -} diff --git a/tests/go/solutions/halfcontestprog/test_halfcontestprog.go b/tests/go/solutions/halfcontestprog/test_halfcontestprog.go index 9e881275..95869be5 100644 --- a/tests/go/solutions/halfcontestprog/test_halfcontestprog.go +++ b/tests/go/solutions/halfcontestprog/test_halfcontestprog.go @@ -4,6 +4,7 @@ import ( "github.com/01-edu/z01" correct "./correct" + student "./student" ) func main() { @@ -28,6 +29,6 @@ func main() { } for _, arg := range table { - z01.Challenge("HalfContestProg", Halfcontest, correct.Halfcontest, arg.h1, arg.m1, arg.h2, arg.m2) + z01.Challenge("HalfContestProg", student.Halfcontest, correct.Halfcontest, arg.h1, arg.m1, arg.h2, arg.m2) } } diff --git a/tests/go/solutions/printrevcombprog/main.go b/tests/go/solutions/printrevcombprog/main.go index f71a7187..110ad84a 100644 --- a/tests/go/solutions/printrevcombprog/main.go +++ b/tests/go/solutions/printrevcombprog/main.go @@ -6,10 +6,10 @@ func main() { for a := 9; a >= 2; { for b := a - 1; b >= 1; { for c := b - 1; c >= 0; { - if a > b && b > c && (a+b+c) != 3 { + if a > b && b > c && a+b+c != 3 { fmt.Printf("%d%d%d, ", a, b, c) } - if (a + b + c) == 3 { + if a+b+c == 3 { fmt.Printf("%d%d%d\n", a, b, c) } c-- diff --git a/tests/go/solutions/printrevcombprog/test_printrevcombprog.go b/tests/go/solutions/printrevcombprog/test_printrevcombprog.go index d7659615..06e3bf1d 100644 --- a/tests/go/solutions/printrevcombprog/test_printrevcombprog.go +++ b/tests/go/solutions/printrevcombprog/test_printrevcombprog.go @@ -3,5 +3,5 @@ package main import "github.com/01-edu/z01" func main() { - z01.ChallengeMain("printrevcombprog") + z01.ChallengeMain("printrevcomb") } diff --git a/tests/go/solutions/reachablenumberprog/main.go b/tests/go/solutions/reachablenumberprog/main.go deleted file mode 100644 index a969e7e1..00000000 --- a/tests/go/solutions/reachablenumberprog/main.go +++ /dev/null @@ -1,21 +0,0 @@ -package main - -func ReachableNumber(n int) int { - cnt := 0 - for n > 0 { - cnt++ - if n < 10 { - cnt += 8 - break - } else { - n++ - } - for n%10 == 0 { - n /= 10 - } - } - return cnt -} - -func main() { -} diff --git a/tests/go/solutions/reachablenumberprog/test_reachablenumberprog.go b/tests/go/solutions/reachablenumberprog/test_reachablenumberprog.go index 790b3826..9b06ea09 100644 --- a/tests/go/solutions/reachablenumberprog/test_reachablenumberprog.go +++ b/tests/go/solutions/reachablenumberprog/test_reachablenumberprog.go @@ -4,6 +4,7 @@ import ( "github.com/01-edu/z01" correct "./correct" + student "./student" ) func main() { @@ -17,6 +18,6 @@ func main() { table = append(table, z01.MultRandIntBetween(1, 877)) } for _, arg := range table { - z01.Challenge("ReachableNumber", ReachableNumber, correct.ReachableNumber, arg) + z01.Challenge("ReachableNumber", student.ReachableNumber, correct.ReachableNumber, arg) } } diff --git a/tests/go/solutions/sliceprog/main.go b/tests/go/solutions/sliceprog/main.go deleted file mode 100644 index 66cdf796..00000000 --- a/tests/go/solutions/sliceprog/main.go +++ /dev/null @@ -1,45 +0,0 @@ -package main - -func ifNegative(a []string, n int) int { - if n < 0 { - n = len(a) + n - } - - if n < 0 { - n = 0 - } else if n > len(a) { - n = len(a) - } - - return n -} - -func Slice(a []string, nbr ...int) []string { - if len(nbr) == 0 { - return a - } - - first := nbr[0] - if len(nbr) == 1 { - if first < 0 { - first = len(a) + first - if first < 0 { - return a - } - } - return a[first:] - } - second := nbr[1] - - first = ifNegative(a, first) - second = ifNegative(a, second) - - if first > second { - return nil - } - - return a[first:second] -} - -func main() { -} diff --git a/tests/go/solutions/sliceprog/test_sliceprog.go b/tests/go/solutions/sliceprog/test_sliceprog.go index e8477566..7064d708 100644 --- a/tests/go/solutions/sliceprog/test_sliceprog.go +++ b/tests/go/solutions/sliceprog/test_sliceprog.go @@ -4,6 +4,7 @@ import ( "github.com/01-edu/z01" correct "./correct" + student "./student" ) func main() { @@ -40,6 +41,6 @@ func main() { } for _, a := range arr { - z01.Challenge("SliceProg", Slice, correct.Slice, a...) + z01.Challenge("SliceProg", student.Slice, correct.Slice, a...) } }