mirror of https://github.com/01-edu/public.git
Xavier Petit
5 years ago
committed by
xpetit
97 changed files with 269 additions and 447 deletions
@ -1,14 +1,12 @@ |
|||||||
package student_test |
package main |
||||||
|
|
||||||
import ( |
import ( |
||||||
"testing" |
|
||||||
|
|
||||||
"github.com/01-edu/z01" |
"github.com/01-edu/z01" |
||||||
|
|
||||||
solutions "./solutions" |
solutions "./solutions" |
||||||
student "./student" |
student "./student" |
||||||
) |
) |
||||||
|
|
||||||
func TestEightQueens(t *testing.T) { |
func main() { |
||||||
z01.Challenge(t, student.EightQueens, solutions.EightQueens) |
z01.Challenge("EightQueens", student.EightQueens, solutions.EightQueens) |
||||||
} |
} |
||||||
|
@ -1,22 +1,20 @@ |
|||||||
package student_test |
package main |
||||||
|
|
||||||
import ( |
import ( |
||||||
"testing" |
|
||||||
|
|
||||||
"github.com/01-edu/z01" |
"github.com/01-edu/z01" |
||||||
|
|
||||||
solutions "./solutions" |
solutions "./solutions" |
||||||
student "./student" |
student "./student" |
||||||
) |
) |
||||||
|
|
||||||
func TestIterativePower(t *testing.T) { |
func main() { |
||||||
i := 0 |
i := 0 |
||||||
for i < 30 { |
for i < 30 { |
||||||
nb := z01.RandIntBetween(-8, 8) |
nb := z01.RandIntBetween(-8, 8) |
||||||
power := z01.RandIntBetween(-10, 10) |
power := z01.RandIntBetween(-10, 10) |
||||||
z01.Challenge(t, student.IterativePower, solutions.IterativePower, nb, power) |
z01.Challenge("IterativePower", student.IterativePower, solutions.IterativePower, nb, power) |
||||||
i++ |
i++ |
||||||
} |
} |
||||||
z01.Challenge(t, student.IterativePower, solutions.IterativePower, 0, 0) |
z01.Challenge("IterativePower", student.IterativePower, solutions.IterativePower, 0, 0) |
||||||
z01.Challenge(t, student.IterativePower, solutions.IterativePower, 0, 1) |
z01.Challenge("IterativePower", student.IterativePower, solutions.IterativePower, 0, 1) |
||||||
} |
} |
||||||
|
@ -1,16 +1,14 @@ |
|||||||
package student_test |
package main |
||||||
|
|
||||||
import ( |
import ( |
||||||
"testing" |
|
||||||
|
|
||||||
solutions "./solutions" |
solutions "./solutions" |
||||||
student "./student" |
student "./student" |
||||||
"github.com/01-edu/z01" |
"github.com/01-edu/z01" |
||||||
) |
) |
||||||
|
|
||||||
func TestItoa(t *testing.T) { |
func main() { |
||||||
for i := 0; i < 50; i++ { |
for i := 0; i < 50; i++ { |
||||||
arg := z01.RandIntBetween(-2000000000, 2000000000) |
arg := z01.RandIntBetween(-2000000000, 2000000000) |
||||||
z01.Challenge(t, student.Itoa, solutions.Itoa, arg) |
z01.Challenge("Itoa", student.Itoa, solutions.Itoa, arg) |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -1,23 +1,21 @@ |
|||||||
package student_test |
package main |
||||||
|
|
||||||
import ( |
import ( |
||||||
"testing" |
|
||||||
|
|
||||||
"github.com/01-edu/z01" |
"github.com/01-edu/z01" |
||||||
|
|
||||||
solutions "./solutions" |
solutions "./solutions" |
||||||
student "./student" |
student "./student" |
||||||
) |
) |
||||||
|
|
||||||
func TestItoaBase(t *testing.T) { |
func main() { |
||||||
for i := 0; i < 30; i++ { |
for i := 0; i < 30; i++ { |
||||||
value := z01.RandIntBetween(-1000000, 1000000) |
value := z01.RandIntBetween(-1000000, 1000000) |
||||||
base := z01.RandIntBetween(2, 16) |
base := z01.RandIntBetween(2, 16) |
||||||
z01.Challenge(t, student.ItoaBase, solutions.ItoaBase, value, base) |
z01.Challenge("ItoaBase", student.ItoaBase, solutions.ItoaBase, value, base) |
||||||
} |
} |
||||||
for i := 0; i < 5; i++ { |
for i := 0; i < 5; i++ { |
||||||
base := z01.RandIntBetween(2, 16) |
base := z01.RandIntBetween(2, 16) |
||||||
z01.Challenge(t, student.ItoaBase, solutions.ItoaBase, z01.MaxInt, base) |
z01.Challenge("ItoaBase", student.ItoaBase, solutions.ItoaBase, z01.MaxInt, base) |
||||||
z01.Challenge(t, student.ItoaBase, solutions.ItoaBase, z01.MinInt, base) |
z01.Challenge("ItoaBase", student.ItoaBase, solutions.ItoaBase, z01.MinInt, base) |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -1,19 +1,17 @@ |
|||||||
package student_test |
package main |
||||||
|
|
||||||
import ( |
import ( |
||||||
"testing" |
|
||||||
|
|
||||||
solutions "./solutions" |
solutions "./solutions" |
||||||
student "./student" |
student "./student" |
||||||
"github.com/01-edu/z01" |
"github.com/01-edu/z01" |
||||||
) |
) |
||||||
|
|
||||||
func TestMax(t *testing.T) { |
func main() { |
||||||
args := []int{z01.RandInt()} |
args := []int{z01.RandInt()} |
||||||
limit := z01.RandIntBetween(20, 50) |
limit := z01.RandIntBetween(20, 50) |
||||||
for i := 0; i < limit; i++ { |
for i := 0; i < limit; i++ { |
||||||
args = append(args, z01.RandInt()) |
args = append(args, z01.RandInt()) |
||||||
} |
} |
||||||
|
|
||||||
z01.Challenge(t, student.Max, solutions.Max, args) |
z01.Challenge("Max", student.Max, solutions.Max, args) |
||||||
} |
} |
||||||
|
@ -1,14 +1,12 @@ |
|||||||
package student_test |
package main |
||||||
|
|
||||||
import ( |
import ( |
||||||
"testing" |
|
||||||
|
|
||||||
"github.com/01-edu/z01" |
"github.com/01-edu/z01" |
||||||
|
|
||||||
solutions "./solutions" |
solutions "./solutions" |
||||||
student "./student" |
student "./student" |
||||||
) |
) |
||||||
|
|
||||||
func TestPrintComb2(t *testing.T) { |
func main() { |
||||||
z01.Challenge(t, student.PrintComb2, solutions.PrintComb2) |
z01.Challenge("PrintComb2", student.PrintComb2, solutions.PrintComb2) |
||||||
} |
} |
||||||
|
@ -1,14 +1,12 @@ |
|||||||
package student_test |
package main |
||||||
|
|
||||||
import ( |
import ( |
||||||
"testing" |
|
||||||
|
|
||||||
"github.com/01-edu/z01" |
"github.com/01-edu/z01" |
||||||
|
|
||||||
solutions "./solutions" |
solutions "./solutions" |
||||||
student "./student" |
student "./student" |
||||||
) |
) |
||||||
|
|
||||||
func TestPrintComb(t *testing.T) { |
func main() { |
||||||
z01.Challenge(t, student.PrintComb, solutions.PrintComb) |
z01.Challenge("PrintComb", student.PrintComb, solutions.PrintComb) |
||||||
} |
} |
||||||
|
@ -1,17 +1,15 @@ |
|||||||
package student_test |
package main |
||||||
|
|
||||||
import ( |
import ( |
||||||
"testing" |
|
||||||
|
|
||||||
"github.com/01-edu/z01" |
"github.com/01-edu/z01" |
||||||
|
|
||||||
solutions "./solutions" |
solutions "./solutions" |
||||||
student "./student" |
student "./student" |
||||||
) |
) |
||||||
|
|
||||||
func TestPrintCombN(t *testing.T) { |
func main() { |
||||||
table := []int{1, 2, 3, 4, 5, 6, 7, 8, 9} |
table := []int{1, 2, 3, 4, 5, 6, 7, 8, 9} |
||||||
for _, arg := range table { |
for _, arg := range table { |
||||||
z01.Challenge(t, student.PrintCombN, solutions.PrintCombN, arg) |
z01.Challenge("PrintCombN", student.PrintCombN, solutions.PrintCombN, arg) |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -1,18 +1,16 @@ |
|||||||
package student_test |
package main |
||||||
|
|
||||||
import ( |
import ( |
||||||
"testing" |
|
||||||
|
|
||||||
"github.com/01-edu/z01" |
"github.com/01-edu/z01" |
||||||
|
|
||||||
solutions "./solutions" |
solutions "./solutions" |
||||||
student "./student" |
student "./student" |
||||||
) |
) |
||||||
|
|
||||||
func TestPrintStr(t *testing.T) { |
func main() { |
||||||
table := z01.MultRandASCII() |
table := z01.MultRandASCII() |
||||||
table = append(table, "Hello World!") |
table = append(table, "Hello World!") |
||||||
for _, arg := range table { |
for _, arg := range table { |
||||||
z01.Challenge(t, student.PrintStr, solutions.PrintStr, arg) |
z01.Challenge("PrintStr", student.PrintStr, solutions.PrintStr, arg) |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -1,22 +1,20 @@ |
|||||||
package student_test |
package main |
||||||
|
|
||||||
import ( |
import ( |
||||||
"testing" |
|
||||||
|
|
||||||
"github.com/01-edu/z01" |
"github.com/01-edu/z01" |
||||||
|
|
||||||
solutions "./solutions" |
solutions "./solutions" |
||||||
student "./student" |
student "./student" |
||||||
) |
) |
||||||
|
|
||||||
func TestRecursivePower(t *testing.T) { |
func main() { |
||||||
i := 0 |
i := 0 |
||||||
for i < 30 { |
for i < 30 { |
||||||
nb := z01.RandIntBetween(-8, 8) |
nb := z01.RandIntBetween(-8, 8) |
||||||
power := z01.RandIntBetween(-10, 10) |
power := z01.RandIntBetween(-10, 10) |
||||||
z01.Challenge(t, student.RecursivePower, solutions.RecursivePower, nb, power) |
z01.Challenge("RecursivePower", student.RecursivePower, solutions.RecursivePower, nb, power) |
||||||
i++ |
i++ |
||||||
} |
} |
||||||
z01.Challenge(t, student.RecursivePower, solutions.RecursivePower, 0, 0) |
z01.Challenge("RecursivePower", student.RecursivePower, solutions.RecursivePower, 0, 0) |
||||||
z01.Challenge(t, student.RecursivePower, solutions.RecursivePower, 0, 1) |
z01.Challenge("RecursivePower", student.RecursivePower, solutions.RecursivePower, 0, 1) |
||||||
} |
} |
||||||
|
@ -1,19 +1,17 @@ |
|||||||
package main |
package main |
||||||
|
|
||||||
import ( |
import ( |
||||||
"testing" |
|
||||||
|
|
||||||
solutions "../../solutions" |
solutions "../../solutions" |
||||||
"github.com/01-edu/z01" |
"github.com/01-edu/z01" |
||||||
) |
) |
||||||
|
|
||||||
func TestFindPrevPrimeProg(t *testing.T) { |
func main() { |
||||||
array := []int{5, 4, 1} |
array := []int{5, 4, 1} |
||||||
for i := 0; i < 7; i++ { |
for i := 0; i < 7; i++ { |
||||||
array = append(array, z01.RandIntBetween(0, 99999)) |
array = append(array, z01.RandIntBetween(0, 99999)) |
||||||
} |
} |
||||||
|
|
||||||
for i := 0; i < len(array); i++ { |
for i := 0; i < len(array); i++ { |
||||||
z01.Challenge(t, FindPrevPrime, solutions.FindPrevPrime, array[i]) |
z01.Challenge("FindPrevPrimeProg", FindPrevPrime, solutions.FindPrevPrime, array[i]) |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -1,22 +1,20 @@ |
|||||||
package main |
package main |
||||||
|
|
||||||
import ( |
import ( |
||||||
"testing" |
|
||||||
|
|
||||||
"github.com/01-edu/z01" |
"github.com/01-edu/z01" |
||||||
|
|
||||||
solutions "../../solutions" |
solutions "../../solutions" |
||||||
) |
) |
||||||
|
|
||||||
func TestItoaBaseProg(t *testing.T) { |
func main() { |
||||||
for i := 0; i < 30; i++ { |
for i := 0; i < 30; i++ { |
||||||
value := z01.RandIntBetween(-1000000, 1000000) |
value := z01.RandIntBetween(-1000000, 1000000) |
||||||
base := z01.RandIntBetween(2, 16) |
base := z01.RandIntBetween(2, 16) |
||||||
z01.Challenge(t, ItoaBase, solutions.ItoaBase, value, base) |
z01.Challenge("ItoaBaseProg", ItoaBase, solutions.ItoaBase, value, base) |
||||||
} |
} |
||||||
for i := 0; i < 5; i++ { |
for i := 0; i < 5; i++ { |
||||||
base := z01.RandIntBetween(2, 16) |
base := z01.RandIntBetween(2, 16) |
||||||
z01.Challenge(t, ItoaBase, solutions.ItoaBase, z01.MaxInt, base) |
z01.Challenge("ItoaBaseProg", ItoaBase, solutions.ItoaBase, z01.MaxInt, base) |
||||||
z01.Challenge(t, ItoaBase, solutions.ItoaBase, z01.MinInt, base) |
z01.Challenge("ItoaBaseProg", ItoaBase, solutions.ItoaBase, z01.MinInt, base) |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -1,16 +1,14 @@ |
|||||||
package main |
package main |
||||||
|
|
||||||
import ( |
import ( |
||||||
"testing" |
|
||||||
|
|
||||||
"github.com/01-edu/z01" |
"github.com/01-edu/z01" |
||||||
|
|
||||||
solutions "../../solutions" |
solutions "../../solutions" |
||||||
) |
) |
||||||
|
|
||||||
func TestItoaProg(t *testing.T) { |
func main() { |
||||||
for i := 0; i < 50; i++ { |
for i := 0; i < 50; i++ { |
||||||
arg := z01.RandIntBetween(-2000000000, 2000000000) |
arg := z01.RandIntBetween(-2000000000, 2000000000) |
||||||
z01.Challenge(t, Itoa, solutions.Itoa, arg) |
z01.Challenge("ItoaProg", Itoa, solutions.Itoa, arg) |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -1,19 +1,17 @@ |
|||||||
package main |
package main |
||||||
|
|
||||||
import ( |
import ( |
||||||
"testing" |
|
||||||
|
|
||||||
"github.com/01-edu/z01" |
"github.com/01-edu/z01" |
||||||
|
|
||||||
solutions "../../solutions" |
solutions "../../solutions" |
||||||
) |
) |
||||||
|
|
||||||
func TestMaxProg(t *testing.T) { |
func main() { |
||||||
args := []int{z01.RandInt()} |
args := []int{z01.RandInt()} |
||||||
limit := z01.RandIntBetween(20, 50) |
limit := z01.RandIntBetween(20, 50) |
||||||
for i := 0; i < limit; i++ { |
for i := 0; i < limit; i++ { |
||||||
args = append(args, z01.RandInt()) |
args = append(args, z01.RandInt()) |
||||||
} |
} |
||||||
|
|
||||||
z01.Challenge(t, Max, solutions.Max, args) |
z01.Challenge("MaxProg", Max, solutions.Max, args) |
||||||
} |
} |
||||||
|
@ -1,22 +1,20 @@ |
|||||||
package main |
package main |
||||||
|
|
||||||
import ( |
import ( |
||||||
"testing" |
|
||||||
|
|
||||||
"github.com/01-edu/z01" |
"github.com/01-edu/z01" |
||||||
|
|
||||||
solutions "../../solutions" |
solutions "../../solutions" |
||||||
) |
) |
||||||
|
|
||||||
func TestPrintMemory(t *testing.T) { |
func main() { |
||||||
var table [10]int |
var table [10]int |
||||||
|
|
||||||
for j := 0; j < 5; j++ { |
for j := 0; j < 5; j++ { |
||||||
for i := 0; i < 10; i++ { |
for i := 0; i < 10; i++ { |
||||||
table[i] = z01.RandIntBetween(0, 1000) |
table[i] = z01.RandIntBetween(0, 1000) |
||||||
} |
} |
||||||
z01.Challenge(t, PrintMemory, solutions.PrintMemory, table) |
z01.Challenge("PrintMemory", PrintMemory, solutions.PrintMemory, table) |
||||||
} |
} |
||||||
table2 := [10]int{104, 101, 108, 108, 111, 16, 21, 42} |
table2 := [10]int{104, 101, 108, 108, 111, 16, 21, 42} |
||||||
z01.Challenge(t, PrintMemory, solutions.PrintMemory, table2) |
z01.Challenge("PrintMemory", PrintMemory, solutions.PrintMemory, table2) |
||||||
} |
} |
||||||
|
@ -1,20 +1,18 @@ |
|||||||
package student_test |
package main |
||||||
|
|
||||||
import ( |
import ( |
||||||
"testing" |
|
||||||
|
|
||||||
"github.com/01-edu/z01" |
"github.com/01-edu/z01" |
||||||
|
|
||||||
solutions "./solutions" |
solutions "./solutions" |
||||||
student "./student" |
student "./student" |
||||||
) |
) |
||||||
|
|
||||||
func TestToLower(t *testing.T) { |
func main() { |
||||||
table := append( |
table := append( |
||||||
z01.MultRandASCII(), |
z01.MultRandASCII(), |
||||||
"Hello! How are you?", |
"Hello! How are you?", |
||||||
) |
) |
||||||
for _, arg := range table { |
for _, arg := range table { |
||||||
z01.Challenge(t, student.ToLower, solutions.ToLower, arg) |
z01.Challenge("ToLower", student.ToLower, solutions.ToLower, arg) |
||||||
} |
} |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue