Browse Source

mb:go x$ pwd

/Users/x/x/01/public/tests/go
mb:go x$ goimports -w .
mb:go x$
pull/533/head
Xavier Petit 5 years ago committed by xpetit
parent
commit
59b9bf9b7a
  1. 3
      tests/go/activebits_test.go
  2. 3
      tests/go/any_test.go
  3. 3
      tests/go/appendrange_test.go
  4. 3
      tests/go/btreesearchitem_test.go
  5. 3
      tests/go/btreetransplant_test.go
  6. 3
      tests/go/enigma_test.go
  7. 3
      tests/go/join_test.go
  8. 3
      tests/go/max_test.go
  9. 3
      tests/go/pilot_test.go
  10. 3
      tests/go/printalphabet_test.go
  11. 3
      tests/go/printdigits_test.go
  12. 3
      tests/go/printprogramname_test.go
  13. 3
      tests/go/printreversealphabet_test.go
  14. 3
      tests/go/raid2_test.go
  15. 3
      tests/go/revparams_test.go
  16. 4
      tests/go/solutions/anagram/anagram_test.go
  17. 3
      tests/go/solutions/brainfuck/main.go
  18. 3
      tests/go/solutions/comparetrees.go
  19. 2
      tests/go/solutions/findprevprimeprog/main.go
  20. 20
      tests/go/solutions/inverttree/inverttree_test.go
  21. 1
      tests/go/solutions/inverttree/main.go
  22. 6
      tests/go/solutions/itoabaseprog/main.go
  23. 16
      tests/go/solutions/lcm.go
  24. 2
      tests/go/solutions/nenokku/main.go
  25. 8
      tests/go/solutions/nenokku/nenokku_test.go
  26. 3
      tests/go/solutions/onlyz/onlyz_test.go
  27. 1
      tests/go/solutions/piglatin/main.go
  28. 3
      tests/go/solutions/pilot/pilot.go
  29. 3
      tests/go/solutions/printalphabetprog/printalphabetprog_test.go
  30. 3
      tests/go/solutions/printchessboard.go
  31. 3
      tests/go/solutions/printchessboard/main.go
  32. 3
      tests/go/solutions/printchessboard/printchessboard_test.go
  33. 3
      tests/go/solutions/printdigitsprog/printdigitsprog_test.go
  34. 3
      tests/go/solutions/repeatalpha/main.go
  35. 3
      tests/go/solutions/robottoorigin/main.go
  36. 1
      tests/go/solutions/robottoorigin/robottoorigin_test.go
  37. 10
      tests/go/solutions/sametree.go
  38. 10
      tests/go/solutions/sametree/main.go
  39. 25
      tests/go/solutions/sametree/sametree_test.go
  40. 3
      tests/go/solutions/searchreplace/main.go
  41. 3
      tests/go/solutions/strrevprog/main.go
  42. 3
      tests/go/solutions/swapbits/swapbits_test.go
  43. 3
      tests/go/solutions/testConvertBase/main.go
  44. 2
      tests/go/solutions/twosum.go
  45. 3
      tests/go/solutions/twosum/main.go
  46. 2
      tests/go/solutions/twosum/twosum_test.go
  47. 3
      tests/go/solutions/uniqueoccurences/main.go
  48. 1
      tests/go/solutions/uniqueoccurences/uniqueoccurences_test.go
  49. 3
      tests/go/solutions/ztail/main.go
  50. 3
      tests/go/sortparams_test.go
  51. 3
      tests/go/swapbits_test.go
  52. 3
      tests/go/ztail_test.go

3
tests/go/activebits_test.go

@ -1,10 +1,11 @@
package student_test
import (
"testing"
solutions "./solutions"
student "./student"
"github.com/01-edu/z01"
"testing"
)
func TestActiveBits(t *testing.T) {

3
tests/go/any_test.go

@ -1,10 +1,11 @@
package student_test
import (
"testing"
solutions "./solutions"
student "./student"
"github.com/01-edu/z01"
"testing"
)
func TestAny(t *testing.T) {

3
tests/go/appendrange_test.go

@ -1,9 +1,10 @@
package student_test
import (
"github.com/01-edu/z01"
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)

3
tests/go/btreesearchitem_test.go

@ -5,9 +5,10 @@ import (
"github.com/01-edu/z01"
"fmt"
solutions "./solutions"
student "./student"
"fmt"
)
func errorMessage_search(t *testing.T, fn interface{}, root, a *solutions.TreeNode, b *student.TreeNode,

3
tests/go/btreetransplant_test.go

@ -5,9 +5,10 @@ import (
"github.com/01-edu/z01"
"fmt"
solutions "./solutions"
student "./student"
"fmt"
)
func parentListTransp(root *student.TreeNode) string {

3
tests/go/enigma_test.go

@ -1,10 +1,11 @@
package student_test
import (
"testing"
solutions "./solutions"
student "./student"
"github.com/01-edu/z01"
"testing"
)
func TestEnigma(t *testing.T) {

3
tests/go/join_test.go

@ -1,10 +1,11 @@
package student_test
import (
"testing"
solutions "./solutions"
student "./student"
"github.com/01-edu/z01"
"testing"
)
func TestJoin(t *testing.T) {

3
tests/go/max_test.go

@ -1,10 +1,11 @@
package student_test
import (
"testing"
solutions "./solutions"
student "./student"
"github.com/01-edu/z01"
"testing"
)
func TestMax(t *testing.T) {

3
tests/go/pilot_test.go

@ -1,8 +1,9 @@
package student_test
import (
"github.com/01-edu/z01"
"testing"
"github.com/01-edu/z01"
)
func TestPilot(t *testing.T) {

3
tests/go/printalphabet_test.go

@ -1,8 +1,9 @@
package student_test
import (
"github.com/01-edu/z01"
"testing"
"github.com/01-edu/z01"
)
func TestPrintAlphabet(t *testing.T) {

3
tests/go/printdigits_test.go

@ -1,8 +1,9 @@
package student_test
import (
"github.com/01-edu/z01"
"testing"
"github.com/01-edu/z01"
)
func TestPrintDigits(t *testing.T) {

3
tests/go/printprogramname_test.go

@ -1,9 +1,10 @@
package student_test
import (
"github.com/01-edu/z01"
"strings"
"testing"
"github.com/01-edu/z01"
)
func TestPrintProgramName(t *testing.T) {

3
tests/go/printreversealphabet_test.go

@ -1,8 +1,9 @@
package student_test
import (
"github.com/01-edu/z01"
"testing"
"github.com/01-edu/z01"
)
func TestPrintReverseAlphabet(t *testing.T) {

3
tests/go/raid2_test.go

@ -1,8 +1,9 @@
package student_test
import (
"github.com/01-edu/z01"
"testing"
"github.com/01-edu/z01"
)
func TestRaid2(t *testing.T) {

3
tests/go/revparams_test.go

@ -1,8 +1,9 @@
package student_test
import (
"github.com/01-edu/z01"
"testing"
"github.com/01-edu/z01"
)
func TestRevParams(t *testing.T) {

4
tests/go/solutions/anagram/anagram_test.go

@ -36,7 +36,7 @@ func TestIsAnagram(t *testing.T) {
)
for i := 0; i < 15; i++ {
value := node {
value := node{
s: z01.RandStr(z01.RandIntBetween(15, 20), "qwertyuiopasdfghjklzxcvbnm "),
t: z01.RandStr(z01.RandIntBetween(15, 20), "qwertyuiopasdfghjklzxcvbnm "),
}
@ -44,7 +44,7 @@ func TestIsAnagram(t *testing.T) {
table = append(table, value)
}
for _, arg := range(table) {
for _, arg := range table {
z01.Challenge(t, IsAnagram, solutions.IsAnagram, arg.s, arg.t)
}
}

3
tests/go/solutions/brainfuck/main.go

@ -1,8 +1,9 @@
package main
import (
"github.com/01-edu/z01"
"os"
"github.com/01-edu/z01"
)
const SIZE = 2048

3
tests/go/solutions/comparetrees.go

@ -3,8 +3,9 @@
package solutions
import (
student "../student"
"testing"
student "../student"
)
func CompareTrees(root *solutions.TreeNode, rootS *student.TreeNode, t *testing.T) {

2
tests/go/solutions/findprevprimeprog/main.go

@ -1,6 +1,6 @@
package main
func main(){
func main() {
}

20
tests/go/solutions/inverttree/inverttree_test.go

@ -5,8 +5,8 @@ import (
// "os"
"fmt"
"math/rand"
"testing"
"strconv"
"testing"
// "github.com/01-edu/z01"
solutions "../../solutions"
@ -95,34 +95,34 @@ func solPrint(w io.Writer, node *solNode, ns int, ch rune) {
}
func returnStuTree(root *stuNode) string {
if (root == nil) {
if root == nil {
return ""
}
ans := strconv.Itoa(root.Val)
if (root.Left == nil && root.Right == nil) {
if root.Left == nil && root.Right == nil {
return ans
}
if (root.Left != nil) {
if root.Left != nil {
ans += " " + returnStuTree(root.Left)
}
if (root.Right != nil) {
if root.Right != nil {
ans += " " + returnStuTree(root.Right)
}
return ans
}
func returnSolTree(root *solNode) string{
if (root == nil) {
func returnSolTree(root *solNode) string {
if root == nil {
return ""
}
ans := strconv.Itoa(root.Val)
if (root.Left == nil && root.Right == nil) {
if root.Left == nil && root.Right == nil {
return ans
}
if (root.Left != nil) {
if root.Left != nil {
ans += " " + returnSolTree(root.Left)
}
if (root.Right != nil) {
if root.Right != nil {
ans += " " + returnSolTree(root.Right)
}
return ans

1
tests/go/solutions/inverttree/main.go

@ -25,4 +25,3 @@ func InvertTree(root *TNode) *TNode {
func main() {
}

6
tests/go/solutions/itoabaseprog/main.go

@ -2,11 +2,13 @@ package main
import (
"fmt"
"github.com/01-edu/z01"
"strconv"
student "../../student"
"github.com/01-edu/z01"
"strings"
student "../../student"
)
func ItoaBase(value, base int) string {

16
tests/go/solutions/lcm.go

@ -1,19 +1,19 @@
package solutions
//This solution is the comparing file of the staff
// This solution is the comparing file of the staff
// Because the solution is a function,
//
//1) here the package is solutions
//2) it does not need an empty func main(){}
//3) its location is 1 level below the folder of the nauuo_test.go file
// 1) here the package is solutions
// 2) it does not need an empty func main(){}
// 3) its location is 1 level below the folder of the nauuo_test.go file
func gcd(first, second int) int {
if (second == 0) {
return (first)
if second == 0 {
return first
}
return (gcd(second, first % second))
return gcd(second, first%second)
}
func Lcm(first, second int) int {
return (first / gcd(second, first % second) * second)
return first / gcd(second, first%second) * second
}

2
tests/go/solutions/nenokku/main.go

@ -1,8 +1,8 @@
package main
import (
"os"
"fmt"
"os"
"strings"
)

8
tests/go/solutions/nenokku/nenokku_test.go

@ -2,6 +2,7 @@ package main
import (
"testing"
"github.com/01-edu/z01"
)
@ -27,13 +28,13 @@ func TestNenokku(t *testing.T) {
},
)
sets := [][]string {
sets := [][]string{
[]string{"An", "array", "variable", "denotes", "the", "entire", "array"},
[]string{"This", "means", "that", "when", "you", "assign", "or", "pass"},
[]string{"To", "avoid", "the", "copy", "you", "could", "pass"},
[]string{"struct", "but", "with", "indexed", "rather", "than", "named", "fields"},
}
ops := []string {
ops := []string{
"?", "x", "A",
}
@ -44,12 +45,11 @@ func TestNenokku(t *testing.T) {
for j := 0; j < nOps; j++ {
k := z01.RandIntBetween(0, len(ops)-1)
s := z01.RandIntBetween(0, len(sets[index])-1)
result = append(result, ops[k] + " " + sets[index][s])
result = append(result, ops[k]+" "+sets[index][s])
}
table = append(table, node{result})
}
for _, arg := range table {
z01.ChallengeMainExam(t, arg.operations...)
}

3
tests/go/solutions/onlyz/onlyz_test.go

@ -1,8 +1,9 @@
package main
import (
"github.com/01-edu/z01"
"testing"
"github.com/01-edu/z01"
)
func TestOnlyz(t *testing.T) {

1
tests/go/solutions/piglatin/main.go

@ -3,6 +3,7 @@ package main
import (
"fmt"
"os"
"github.com/01-edu/z01"
)

3
tests/go/solutions/pilot/pilot.go

@ -1,8 +1,9 @@
package main
import (
student ".."
"fmt"
student ".."
)
func main() {

3
tests/go/solutions/printalphabetprog/printalphabetprog_test.go

@ -1,8 +1,9 @@
package main
import (
"github.com/01-edu/z01"
"testing"
"github.com/01-edu/z01"
)
func TestPrintAlphabetProg(t *testing.T) {

3
tests/go/solutions/printchessboard.go

@ -1,9 +1,10 @@
package solutions
import (
"github.com/01-edu/z01"
"os"
"strconv"
"github.com/01-edu/z01"
)
func printLineCh(str string) {

3
tests/go/solutions/printchessboard/main.go

@ -1,9 +1,10 @@
package main
import (
"github.com/01-edu/z01"
"os"
"strconv"
"github.com/01-edu/z01"
)
func printLine(str string) {

3
tests/go/solutions/printchessboard/printchessboard_test.go

@ -1,9 +1,10 @@
package main
import (
"github.com/01-edu/z01"
"strconv"
"testing"
"github.com/01-edu/z01"
)
func TestPrintChessBoard(t *testing.T) {

3
tests/go/solutions/printdigitsprog/printdigitsprog_test.go

@ -1,8 +1,9 @@
package main
import (
"github.com/01-edu/z01"
"testing"
"github.com/01-edu/z01"
)
func TestPrintDigitsProg(t *testing.T) {

3
tests/go/solutions/repeatalpha/main.go

@ -1,8 +1,9 @@
package main
import (
"github.com/01-edu/z01"
"os"
"github.com/01-edu/z01"
)
func toLowerCase(a rune) rune {

3
tests/go/solutions/robottoorigin/main.go

@ -1,8 +1,9 @@
package main
import (
"github.com/01-edu/z01"
"os"
"github.com/01-edu/z01"
)
func solve(str string) bool {

1
tests/go/solutions/robottoorigin/robottoorigin_test.go

@ -2,6 +2,7 @@ package main
import (
"testing"
"github.com/01-edu/z01"
)

10
tests/go/solutions/sametree.go

@ -7,21 +7,21 @@ type TreeNodeL struct {
}
func IsSameTree(p *TreeNodeL, q *TreeNodeL) bool {
if (p == nil && q == nil) {
if p == nil && q == nil {
return true
}
if (checkIfEq(p, q) == true) {
if checkIfEq(p, q) == true {
return true
}
return false
}
func checkIfEq(t1 *TreeNodeL, t2 *TreeNodeL) bool {
if (t1 == nil && t2 == nil) {
if t1 == nil && t2 == nil {
return true
}
if (t1 == nil || t2 == nil) {
return false;
if t1 == nil || t2 == nil {
return false
}
return (t1.Val == t2.Val && checkIfEq(t1.Right, t2.Right) && checkIfEq(t1.Left, t2.Left))
}

10
tests/go/solutions/sametree/main.go

@ -7,21 +7,21 @@ type TreeNodeL struct {
}
func IsSameTree(p *TreeNodeL, q *TreeNodeL) bool {
if (p == nil && q == nil) {
if p == nil && q == nil {
return true
}
if (checkIfEq(p, q) == true) {
if checkIfEq(p, q) == true {
return true
}
return false
}
func checkIfEq(t1 *TreeNodeL, t2 *TreeNodeL) bool {
if (t1 == nil && t2 == nil) {
if t1 == nil && t2 == nil {
return true
}
if (t1 == nil || t2 == nil) {
return false;
if t1 == nil || t2 == nil {
return false
}
return (t1.Val == t2.Val && checkIfEq(t1.Right, t2.Right) && checkIfEq(t1.Left, t2.Left))
}

25
tests/go/solutions/sametree/sametree_test.go

@ -1,11 +1,12 @@
package main
import (
"testing"
"math/rand"
"strconv"
"github.com/01-edu/z01"
"testing"
solutions "../../solutions"
"github.com/01-edu/z01"
)
type stuTreeNode = TreeNodeL
@ -47,41 +48,40 @@ func New(n, k int) (*solTreeNode, *stuTreeNode, *solTreeNode) {
return cop, stu, sol
}
func returnSolTree(root *solTreeNode) string{
if (root == nil) {
func returnSolTree(root *solTreeNode) string {
if root == nil {
return ""
}
ans := strconv.Itoa(root.Val)
if (root.Left == nil && root.Right == nil) {
if root.Left == nil && root.Right == nil {
return ans
}
if (root.Left != nil) {
if root.Left != nil {
ans += " " + returnSolTree(root.Left)
}
if (root.Right != nil) {
if root.Right != nil {
ans += " " + returnSolTree(root.Right)
}
return ans
}
func returnStuTree(root *stuTreeNode) string {
if (root == nil) {
if root == nil {
return ""
}
ans := strconv.Itoa(root.Val)
if (root.Left == nil && root.Right == nil) {
if root.Left == nil && root.Right == nil {
return ans
}
if (root.Left != nil) {
if root.Left != nil {
ans += " " + returnStuTree(root.Left)
}
if (root.Right != nil) {
if root.Right != nil {
ans += " " + returnStuTree(root.Right)
}
return ans
}
func compareResults(t *testing.T, stuResult, solResult bool, solTree1, solTree2 *solTreeNode) {
if stuResult != solResult {
tree1 := returnSolTree(solTree1)
@ -121,4 +121,3 @@ func TestMerge(t *testing.T) {
compareResults(t, stuResult, solResult, cop1, cop1)
}
}

3
tests/go/solutions/searchreplace/main.go

@ -1,8 +1,9 @@
package main
import (
"github.com/01-edu/z01"
"os"
"github.com/01-edu/z01"
)
func main() {

3
tests/go/solutions/strrevprog/main.go

@ -1,9 +1,10 @@
package main
import (
solutions ".."
"fmt"
"os"
solutions ".."
)
func main() {

3
tests/go/solutions/swapbits/swapbits_test.go

@ -1,10 +1,11 @@
package main
import (
"github.com/01-edu/z01"
"reflect"
"testing"
"github.com/01-edu/z01"
solutions "../../solutions"
)

3
tests/go/solutions/testConvertBase/main.go

@ -1,8 +1,9 @@
package main
import (
solutions "../../solutions"
"fmt"
solutions "../../solutions"
)
func main() {

2
tests/go/solutions/twosum.go

@ -3,7 +3,7 @@ package solutions
func TwoSum(nums []int, target int) []int {
for i := 0; i < len(nums); i++ {
for j := i + 1; j < len(nums); j++ {
if (nums[i] + nums[j] == target) {
if nums[i]+nums[j] == target {
return []int{i, j}
}
}

3
tests/go/solutions/twosum/main.go

@ -3,7 +3,7 @@ package main
func TwoSum(nums []int, target int) []int {
for i := 0; i < len(nums); i++ {
for j := i + 1; j < len(nums); j++ {
if (nums[i] + nums[j] == target) {
if nums[i]+nums[j] == target {
return []int{i, j}
}
}
@ -14,4 +14,3 @@ func TwoSum(nums []int, target int) []int {
func main() {
}

2
tests/go/solutions/twosum/twosum_test.go

@ -4,8 +4,8 @@ import (
"math/rand"
"testing"
"github.com/01-edu/z01"
solutions "../../solutions"
"github.com/01-edu/z01"
)
func TestTwoSum(t *testing.T) {

3
tests/go/solutions/uniqueoccurences/main.go

@ -1,8 +1,9 @@
package main
import (
"github.com/01-edu/z01"
"os"
"github.com/01-edu/z01"
)
func solve(str string) bool {

1
tests/go/solutions/uniqueoccurences/uniqueoccurences_test.go

@ -2,6 +2,7 @@ package main
import (
"testing"
"github.com/01-edu/z01"
)

3
tests/go/solutions/ztail/main.go

@ -2,9 +2,10 @@ package main
import (
"fmt"
"github.com/01-edu/z01"
"os"
"strconv"
"github.com/01-edu/z01"
)
func numberOfBytes(args []string) (int, []string) {

3
tests/go/sortparams_test.go

@ -1,8 +1,9 @@
package student_test
import (
"github.com/01-edu/z01"
"testing"
"github.com/01-edu/z01"
)
func TestSortParams(t *testing.T) {

3
tests/go/swapbits_test.go

@ -1,10 +1,11 @@
package student_test
import (
"github.com/01-edu/z01"
"reflect"
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)

3
tests/go/ztail_test.go

@ -1,9 +1,10 @@
package student_test
import (
"github.com/01-edu/z01"
"strings"
"testing"
"github.com/01-edu/z01"
)
//Compares only the stdout of each program

Loading…
Cancel
Save