Browse Source

Intermediate commit

content-update
Xavier Petit 4 years ago committed by xpetit
parent
commit
2d3ec80c73
  1. 2
      tests/go/solutions/abort.go
  2. 2
      tests/go/solutions/activebits.go
  3. 2
      tests/go/solutions/addlinkednumbers.go
  4. 6
      tests/go/solutions/addlinkednumbers/test_addlinkednumbers.go
  5. 2
      tests/go/solutions/advancedsortwordarr.go
  6. 2
      tests/go/solutions/alphacount.go
  7. 2
      tests/go/solutions/any.go
  8. 2
      tests/go/solutions/appendrange.go
  9. 2
      tests/go/solutions/atoi.go
  10. 2
      tests/go/solutions/atoibase.go
  11. 4
      tests/go/solutions/atoibaseprog/test_atoibaseprog.go
  12. 4
      tests/go/solutions/atoiprog/test_atoiprog.go
  13. 2
      tests/go/solutions/basicatoi.go
  14. 2
      tests/go/solutions/basicatoi2.go
  15. 2
      tests/go/solutions/basicjoin.go
  16. 2
      tests/go/solutions/btree.go
  17. 2
      tests/go/solutions/capitalize.go
  18. 2
      tests/go/solutions/challenge.go
  19. 2
      tests/go/solutions/changeorder.go
  20. 6
      tests/go/solutions/changeorder/test_changeorder.go
  21. 2
      tests/go/solutions/chunk.go
  22. 4
      tests/go/solutions/chunk/test_chunk.go
  23. 2
      tests/go/solutions/collatzcountdown.go
  24. 2
      tests/go/solutions/compact.go
  25. 2
      tests/go/solutions/compare.go
  26. 2
      tests/go/solutions/concat.go
  27. 2
      tests/go/solutions/concatparams.go
  28. 2
      tests/go/solutions/convertbase.go
  29. 2
      tests/go/solutions/countif.go
  30. 2
      tests/go/solutions/createelem.go
  31. 2
      tests/go/solutions/divmod.go
  32. 2
      tests/go/solutions/doppelganger.go
  33. 4
      tests/go/solutions/doppelgangerprog/test_doppelgangerprog.go
  34. 2
      tests/go/solutions/eightqueens.go
  35. 2
      tests/go/solutions/enigma.go
  36. 2
      tests/go/solutions/fib.go
  37. 4
      tests/go/solutions/fib/test_fib.go
  38. 2
      tests/go/solutions/fibonacci.go
  39. 2
      tests/go/solutions/findnextprime.go
  40. 2
      tests/go/solutions/findprevprime.go
  41. 4
      tests/go/solutions/findprevprimeprog/test_findprevprimeprog.go
  42. 2
      tests/go/solutions/firstrune.go
  43. 4
      tests/go/solutions/firstruneprog/test_firstruneprog.go
  44. 2
      tests/go/solutions/foldint.go
  45. 4
      tests/go/solutions/foldint/test_foldint.go
  46. 2
      tests/go/solutions/foreach.go
  47. 4
      tests/go/solutions/foreachprog/test_foreachprog.go
  48. 2
      tests/go/solutions/game23.go
  49. 4
      tests/go/solutions/game23/test_game23.go
  50. 2
      tests/go/solutions/halfcontest.go
  51. 4
      tests/go/solutions/halfcontestprog/test_halfcontestprog.go
  52. 2
      tests/go/solutions/index.go
  53. 2
      tests/go/solutions/interestingnumber.go
  54. 4
      tests/go/solutions/interestingnumber/test_interestingnumber.go
  55. 2
      tests/go/solutions/inverttree.go
  56. 6
      tests/go/solutions/inverttree/test_inverttree.go
  57. 2
      tests/go/solutions/isalpha.go
  58. 2
      tests/go/solutions/isanagram.go
  59. 4
      tests/go/solutions/isanagram/test_isanagram.go
  60. 2
      tests/go/solutions/islower.go
  61. 2
      tests/go/solutions/isnegative.go
  62. 2
      tests/go/solutions/isnumeric.go
  63. 2
      tests/go/solutions/isprime.go
  64. 2
      tests/go/solutions/isprintable.go
  65. 2
      tests/go/solutions/issorted.go
  66. 2
      tests/go/solutions/isupper.go
  67. 2
      tests/go/solutions/iterativefactorial.go
  68. 2
      tests/go/solutions/iterativepower.go
  69. 2
      tests/go/solutions/itoa.go
  70. 2
      tests/go/solutions/itoabase.go
  71. 3
      tests/go/solutions/itoabaseprog/main.go
  72. 8
      tests/go/solutions/itoabaseprog/test_itoabaseprog.go
  73. 4
      tests/go/solutions/itoaprog/test_itoaprog.go
  74. 2
      tests/go/solutions/join.go
  75. 2
      tests/go/solutions/lastrune.go
  76. 4
      tests/go/solutions/lastruneprog/test_lastruneprog.go
  77. 2
      tests/go/solutions/lcm.go
  78. 4
      tests/go/solutions/lcm/test_lcm.go
  79. 2
      tests/go/solutions/listat.go
  80. 2
      tests/go/solutions/listclear.go
  81. 2
      tests/go/solutions/listfind.go
  82. 2
      tests/go/solutions/listforeach.go
  83. 2
      tests/go/solutions/listforeachif.go
  84. 2
      tests/go/solutions/listlast.go
  85. 2
      tests/go/solutions/listmerge.go
  86. 2
      tests/go/solutions/listpushback.go
  87. 2
      tests/go/solutions/listpushfront.go
  88. 2
      tests/go/solutions/listremoveif.go
  89. 20
      tests/go/solutions/listremoveifprog/test_listremoveifprog.go
  90. 2
      tests/go/solutions/listreverse.go
  91. 2
      tests/go/solutions/listsize.go
  92. 17
      tests/go/solutions/listsizeprog/test_listsizeprog.go
  93. 2
      tests/go/solutions/listsort.go
  94. 2
      tests/go/solutions/makerange.go
  95. 2
      tests/go/solutions/map.go
  96. 2
      tests/go/solutions/max.go
  97. 4
      tests/go/solutions/maxprog/test_maxprog.go
  98. 2
      tests/go/solutions/merge.go
  99. 6
      tests/go/solutions/merge/test_merge.go
  100. 2
      tests/go/solutions/nauuo.go
  101. Some files were not shown because too many files changed in this diff diff.show_more

2
tests/go/solutions/abort.go

@ -1,4 +1,4 @@
package solutions package correct
import "sort" import "sort"

2
tests/go/solutions/activebits.go

@ -1,4 +1,4 @@
package solutions package correct
// Function that return the number of active bits in the number passed as the argument // Function that return the number of active bits in the number passed as the argument
func ActiveBits(n int) (total int) { func ActiveBits(n int) (total int) {

2
tests/go/solutions/addlinkednumbers.go

@ -1,4 +1,4 @@
package solutions package correct
type NodeAddL struct { type NodeAddL struct {
Next *NodeAddL Next *NodeAddL

6
tests/go/solutions/addlinkednumbers/test_addlinkednumbers.go

@ -5,11 +5,11 @@ import (
"github.com/01-edu/z01" "github.com/01-edu/z01"
solutions "../../solutions" correct "./correct"
) )
type stuNode = NodeAddL type stuNode = NodeAddL
type solNode = solutions.NodeAddL type solNode = correct.NodeAddL
func stuPushFront(node *stuNode, num int) *stuNode { func stuPushFront(node *stuNode, num int) *stuNode {
tmp := &stuNode{Num: num} tmp := &stuNode{Num: num}
@ -112,7 +112,7 @@ func main() {
for _, arg := range args { for _, arg := range args {
stuResult := AddLinkedNumbers(stuNumToList(arg[0]), stuNumToList(arg[1])) stuResult := AddLinkedNumbers(stuNumToList(arg[0]), stuNumToList(arg[1]))
solResult := solutions.AddLinkedNumbers(solNumToList(arg[0]), solNumToList(arg[1])) solResult := correct.AddLinkedNumbers(solNumToList(arg[0]), solNumToList(arg[1]))
compareNodes(stuResult, solResult, arg[0], arg[1]) compareNodes(stuResult, solResult, arg[0], arg[1])
} }

2
tests/go/solutions/advancedsortwordarr.go

@ -1,4 +1,4 @@
package solutions package correct
import "sort" import "sort"

2
tests/go/solutions/alphacount.go

@ -1,4 +1,4 @@
package solutions package correct
import "unicode" import "unicode"

2
tests/go/solutions/any.go

@ -1,4 +1,4 @@
package solutions package correct
func Any(f func(string) bool, arr []string) bool { func Any(f func(string) bool, arr []string) bool {
for _, el := range arr { for _, el := range arr {

2
tests/go/solutions/appendrange.go

@ -1,4 +1,4 @@
package solutions package correct
func AppendRange(min, max int) []int { func AppendRange(min, max int) []int {
size := max - min size := max - min

2
tests/go/solutions/atoi.go

@ -1,4 +1,4 @@
package solutions package correct
import "strconv" import "strconv"

2
tests/go/solutions/atoibase.go

@ -1,4 +1,4 @@
package solutions package correct
import "strings" import "strings"

4
tests/go/solutions/atoibaseprog/test_atoibaseprog.go

@ -5,7 +5,7 @@ import (
"./base" "./base"
solutions "../../solutions" correct "./correct"
) )
// this is the function that creates the TESTS // this is the function that creates the TESTS
@ -43,7 +43,7 @@ func main() {
node{s: "bbbbbab", base: "-ab"}, node{s: "bbbbbab", base: "-ab"},
) )
for _, arg := range table { for _, arg := range table {
z01.Challenge("AtoiBaseProg", AtoiBase, solutions.AtoiBase, arg.s, arg.base) z01.Challenge("AtoiBaseProg", AtoiBase, correct.AtoiBase, arg.s, arg.base)
} }
} }

4
tests/go/solutions/atoiprog/test_atoiprog.go

@ -5,7 +5,7 @@ import (
"github.com/01-edu/z01" "github.com/01-edu/z01"
solutions "../../solutions" correct "./correct"
) )
func main() { func main() {
@ -32,6 +32,6 @@ func main() {
"123a45", "123a45",
) )
for _, arg := range table { for _, arg := range table {
z01.Challenge("AtoiProg", Atoi, solutions.Atoi, arg) z01.Challenge("AtoiProg", Atoi, correct.Atoi, arg)
} }
} }

2
tests/go/solutions/basicatoi.go

@ -1,4 +1,4 @@
package solutions package correct
import "strconv" import "strconv"

2
tests/go/solutions/basicatoi2.go

@ -1,4 +1,4 @@
package solutions package correct
import "strconv" import "strconv"

2
tests/go/solutions/basicjoin.go

@ -1,4 +1,4 @@
package solutions package correct
func BasicJoin(a []string) (b string) { func BasicJoin(a []string) (b string) {
for _, s := range a { for _, s := range a {

2
tests/go/solutions/btree.go

@ -1,4 +1,4 @@
package solutions package correct
type TreeNode struct { type TreeNode struct {
Left, Right, Parent *TreeNode Left, Right, Parent *TreeNode

2
tests/go/solutions/capitalize.go

@ -1,4 +1,4 @@
package solutions package correct
import ( import (
"strings" "strings"

2
tests/go/solutions/challenge.go

@ -1,4 +1,4 @@
package solutions package correct
import ( import (
"reflect" "reflect"

2
tests/go/solutions/changeorder.go

@ -1,4 +1,4 @@
package solutions package correct
func pushBack(node *NodeAddL, num int) *NodeAddL { func pushBack(node *NodeAddL, num int) *NodeAddL {
nw := &NodeAddL{Num: num} nw := &NodeAddL{Num: num}

6
tests/go/solutions/changeorder/test_changeorder.go

@ -5,11 +5,11 @@ import (
"github.com/01-edu/z01" "github.com/01-edu/z01"
solutions "../../solutions" correct "./correct"
) )
type stuNode = NodeAddL type stuNode = NodeAddL
type solNode = solutions.NodeAddL type solNode = correct.NodeAddL
func stuPushFront(node *stuNode, num int) *stuNode { func stuPushFront(node *stuNode, num int) *stuNode {
tmp := &stuNode{Num: num} tmp := &stuNode{Num: num}
@ -99,7 +99,7 @@ func main() {
for _, arg := range table { for _, arg := range table {
stuResult := Changeorder(stuNumToList(arg)) stuResult := Changeorder(stuNumToList(arg))
solResult := solutions.Changeorder(solNumToList(arg)) solResult := correct.Changeorder(solNumToList(arg))
compareNodes(stuResult, solResult, arg) compareNodes(stuResult, solResult, arg)
} }

2
tests/go/solutions/chunk.go

@ -1,4 +1,4 @@
package solutions package correct
import "fmt" import "fmt"

4
tests/go/solutions/chunk/test_chunk.go

@ -3,7 +3,7 @@ package main
import ( import (
"github.com/01-edu/z01" "github.com/01-edu/z01"
solutions "../../solutions" correct "./correct"
) )
func randomSize() []int { func randomSize() []int {
@ -36,6 +36,6 @@ func main() {
ch: 0, ch: 0,
}) })
for _, args := range table { for _, args := range table {
z01.Challenge("Chunk", Chunk, solutions.Chunk, args.slice, args.ch) z01.Challenge("Chunk", Chunk, correct.Chunk, args.slice, args.ch)
} }
} }

2
tests/go/solutions/collatzcountdown.go

@ -1,4 +1,4 @@
package solutions package correct
func CollatzCountdown(start int) int { func CollatzCountdown(start int) int {
if start <= 0 { if start <= 0 {

2
tests/go/solutions/compact.go

@ -1,4 +1,4 @@
package solutions package correct
func Compact(slice *[]string) int { func Compact(slice *[]string) int {
count := 0 count := 0

2
tests/go/solutions/compare.go

@ -1,4 +1,4 @@
package solutions package correct
import "strings" import "strings"

2
tests/go/solutions/concat.go

@ -1,4 +1,4 @@
package solutions package correct
func Concat(a, b string) string { func Concat(a, b string) string {
return a + b return a + b

2
tests/go/solutions/concatparams.go

@ -1,4 +1,4 @@
package solutions package correct
import "strings" import "strings"

2
tests/go/solutions/convertbase.go

@ -1,4 +1,4 @@
package solutions package correct
func ConvertNbrBase(n int, base string) string { func ConvertNbrBase(n int, base string) string {
var result string var result string

2
tests/go/solutions/countif.go

@ -1,4 +1,4 @@
package solutions package correct
func CountIf(f func(string) bool, arr []string) int { func CountIf(f func(string) bool, arr []string) int {
counter := 0 counter := 0

2
tests/go/solutions/createelem.go

@ -1,4 +1,4 @@
package solutions package correct
type Node struct { type Node struct {
Data int Data int

2
tests/go/solutions/divmod.go

@ -1,4 +1,4 @@
package solutions package correct
func DivMod(a, b int, div, mod *int) { func DivMod(a, b int, div, mod *int) {
*div = a / b *div = a / b

2
tests/go/solutions/doppelganger.go

@ -1,4 +1,4 @@
package solutions package correct
import "strings" import "strings"

4
tests/go/solutions/doppelgangerprog/test_doppelgangerprog.go

@ -3,7 +3,7 @@ package main
import ( import (
"github.com/01-edu/z01" "github.com/01-edu/z01"
solutions "../../solutions" correct "./correct"
) )
type node struct { type node struct {
@ -47,6 +47,6 @@ func main() {
} }
for _, arg := range table { for _, arg := range table {
z01.Challenge("DoppelGangerProg", DoppelGanger, solutions.DoppelGanger, arg.big, arg.little) z01.Challenge("DoppelGangerProg", DoppelGanger, correct.DoppelGanger, arg.big, arg.little)
} }
} }

2
tests/go/solutions/eightqueens.go

@ -1,4 +1,4 @@
package solutions package correct
import "github.com/01-edu/z01" import "github.com/01-edu/z01"

2
tests/go/solutions/enigma.go

@ -1,4 +1,4 @@
package solutions package correct
// this function will put a in c; c in d; d in b and b in a // this function will put a in c; c in d; d in b and b in a
func Enigma(a ***int, b *int, c *******int, d ****int) { func Enigma(a ***int, b *int, c *******int, d ****int) {

2
tests/go/solutions/fib.go

@ -1,4 +1,4 @@
package solutions package correct
func rec(a, b, cnt int) int { func rec(a, b, cnt int) int {
if a > b { if a > b {

4
tests/go/solutions/fib/test_fib.go

@ -3,7 +3,7 @@ package main
import ( import (
"github.com/01-edu/z01" "github.com/01-edu/z01"
solutions "../../solutions" correct "./correct"
) )
func main() { func main() {
@ -15,6 +15,6 @@ func main() {
} }
table = append(table, z01.MultRandIntBetween(-100, 150)...) table = append(table, z01.MultRandIntBetween(-100, 150)...)
for _, arg := range table { for _, arg := range table {
z01.Challenge("Fib", Fib, solutions.Fib, arg) z01.Challenge("Fib", Fib, correct.Fib, arg)
} }
} }

2
tests/go/solutions/fibonacci.go

@ -1,4 +1,4 @@
package solutions package correct
func Fibonacci(value int) int { func Fibonacci(value int) int {
if value < 0 { if value < 0 {

2
tests/go/solutions/findnextprime.go

@ -1,4 +1,4 @@
package solutions package correct
import "math" import "math"

2
tests/go/solutions/findprevprime.go

@ -1,4 +1,4 @@
package solutions package correct
func FindPrevPrime(nbr int) int { func FindPrevPrime(nbr int) int {
if nbr < 2 { if nbr < 2 {

4
tests/go/solutions/findprevprimeprog/test_findprevprimeprog.go

@ -3,12 +3,12 @@ package main
import ( import (
"github.com/01-edu/z01" "github.com/01-edu/z01"
solutions "../../solutions" correct "./correct"
) )
func main() { func main() {
a := append(z01.MultRandIntBetween(0, 99999), 5, 4, 1) a := append(z01.MultRandIntBetween(0, 99999), 5, 4, 1)
for _, elem := range a { for _, elem := range a {
z01.Challenge("FindPrevPrimeProg", FindPrevPrime, solutions.FindPrevPrime, elem) z01.Challenge("FindPrevPrimeProg", FindPrevPrime, correct.FindPrevPrime, elem)
} }
} }

2
tests/go/solutions/firstrune.go

@ -1,4 +1,4 @@
package solutions package correct
func FirstRune(s string) rune { func FirstRune(s string) rune {
runes := []rune(s) runes := []rune(s)

4
tests/go/solutions/firstruneprog/test_firstruneprog.go

@ -3,7 +3,7 @@ package main
import ( import (
"github.com/01-edu/z01" "github.com/01-edu/z01"
solutions "../../solutions" correct "./correct"
) )
func main() { func main() {
@ -15,6 +15,6 @@ func main() {
"♥01", "♥01",
) )
for _, arg := range table { for _, arg := range table {
z01.Challenge("FirstRuneProg", FirstRune, solutions.FirstRune, arg) z01.Challenge("FirstRuneProg", FirstRune, correct.FirstRune, arg)
} }
} }

2
tests/go/solutions/foldint.go

@ -1,4 +1,4 @@
package solutions package correct
import "fmt" import "fmt"

4
tests/go/solutions/foldint/test_foldint.go

@ -3,7 +3,7 @@ package main
import ( import (
"github.com/01-edu/z01" "github.com/01-edu/z01"
solutions "../../solutions" correct "./correct"
) )
func main() { func main() {
@ -41,7 +41,7 @@ func main() {
for _, v := range table { for _, v := range table {
for _, f := range v.functions { for _, f := range v.functions {
z01.Challenge("FoldInt", FoldInt, solutions.FoldInt, f, v.arr, v.n) z01.Challenge("FoldInt", FoldInt, correct.FoldInt, f, v.arr, v.n)
} }
} }
} }

2
tests/go/solutions/foreach.go

@ -1,4 +1,4 @@
package solutions package correct
func ForEach(f func(int), a []int) { func ForEach(f func(int), a []int) {
for _, el := range a { for _, el := range a {

4
tests/go/solutions/foreachprog/test_foreachprog.go

@ -5,7 +5,7 @@ import (
"github.com/01-edu/z01" "github.com/01-edu/z01"
solutions "../../solutions" correct "./correct"
) )
func add0(i int) { func add0(i int) {
@ -46,6 +46,6 @@ func main() {
}) })
for _, arg := range table { for _, arg := range table {
z01.Challenge("ForEachProg", ForEach, solutions.ForEach, arg.f, arg.a) z01.Challenge("ForEachProg", ForEach, correct.ForEach, arg.f, arg.a)
} }
} }

2
tests/go/solutions/game23.go

@ -1,4 +1,4 @@
package solutions package correct
func Game23(a, b int) int { func Game23(a, b int) int {
if a > b { if a > b {

4
tests/go/solutions/game23/test_game23.go

@ -3,7 +3,7 @@ package main
import ( import (
"github.com/01-edu/z01" "github.com/01-edu/z01"
solutions "../../solutions" correct "./correct"
) )
func nd(a, b int) int { func nd(a, b int) int {
@ -55,6 +55,6 @@ func main() {
table = append(table, value) table = append(table, value)
} }
for _, arg := range table { for _, arg := range table {
z01.Challenge("Game23", Game23, solutions.Game23, arg.init, arg.fin) z01.Challenge("Game23", Game23, correct.Game23, arg.init, arg.fin)
} }
} }

2
tests/go/solutions/halfcontest.go

@ -1,4 +1,4 @@
package solutions package correct
func Halfcontest(h1, m1, h2, m2 int) int { func Halfcontest(h1, m1, h2, m2 int) int {
t1 := h1*60 + m1 t1 := h1*60 + m1

4
tests/go/solutions/halfcontestprog/test_halfcontestprog.go

@ -3,7 +3,7 @@ package main
import ( import (
"github.com/01-edu/z01" "github.com/01-edu/z01"
solutions "../../solutions" correct "./correct"
) )
func main() { func main() {
@ -28,6 +28,6 @@ func main() {
} }
for _, arg := range table { for _, arg := range table {
z01.Challenge("HalfContestProg", Halfcontest, solutions.Halfcontest, arg.h1, arg.m1, arg.h2, arg.m2) z01.Challenge("HalfContestProg", Halfcontest, correct.Halfcontest, arg.h1, arg.m1, arg.h2, arg.m2)
} }
} }

2
tests/go/solutions/index.go

@ -1,4 +1,4 @@
package solutions package correct
import "strings" import "strings"

2
tests/go/solutions/interestingnumber.go

@ -1,4 +1,4 @@
package solutions package correct
func isInteresting(n int) bool { func isInteresting(n int) bool {
s := 0 s := 0

4
tests/go/solutions/interestingnumber/test_interestingnumber.go

@ -3,7 +3,7 @@ package main
import ( import (
"github.com/01-edu/z01" "github.com/01-edu/z01"
solutions "../../solutions" correct "./correct"
) )
func main() { func main() {
@ -16,6 +16,6 @@ func main() {
table = append(table, z01.MultRandIntBetween(1, 1500)...) table = append(table, z01.MultRandIntBetween(1, 1500)...)
for _, arg := range table { for _, arg := range table {
z01.Challenge("InterestingNumber", InterestingNumber, solutions.InterestingNumber, arg) z01.Challenge("InterestingNumber", InterestingNumber, correct.InterestingNumber, arg)
} }
} }

2
tests/go/solutions/inverttree.go

@ -1,4 +1,4 @@
package solutions package correct
type TNode struct { type TNode struct {
Val int Val int

6
tests/go/solutions/inverttree/test_inverttree.go

@ -8,11 +8,11 @@ import (
"github.com/01-edu/z01" "github.com/01-edu/z01"
solutions "../../solutions" correct "./correct"
) )
type stuNode = TNode type stuNode = TNode
type solNode = solutions.TNode type solNode = correct.TNode
func solInsert(N *solNode, newVal int) { func solInsert(N *solNode, newVal int) {
if N == nil { if N == nil {
@ -140,7 +140,7 @@ func main() {
solInsert(tree, val3) solInsert(tree, val3)
solInsert(tree, val4) solInsert(tree, val4)
// solPrint(os.Stdout, tree, 0, 'M') // solPrint(os.Stdout, tree, 0, 'M')
solutions.InvertTree(tree) correct.InvertTree(tree)
// solPrint(os.Stdout, tree, 0, 'M') // solPrint(os.Stdout, tree, 0, 'M')
TestTree = &stuNode{Val: root, Left: nil, Right: nil} TestTree = &stuNode{Val: root, Left: nil, Right: nil}

2
tests/go/solutions/isalpha.go

@ -1,4 +1,4 @@
package solutions package correct
import "unicode" import "unicode"

2
tests/go/solutions/isanagram.go

@ -1,4 +1,4 @@
package solutions package correct
func IsAnagram(s, t string) bool { func IsAnagram(s, t string) bool {
alph := make([]int, 26) alph := make([]int, 26)

4
tests/go/solutions/isanagram/test_isanagram.go

@ -3,7 +3,7 @@ package main
import ( import (
"github.com/01-edu/z01" "github.com/01-edu/z01"
solutions "../../solutions" correct "./correct"
) )
func main() { func main() {
@ -33,6 +33,6 @@ func main() {
} }
for _, arg := range table { for _, arg := range table {
z01.Challenge("IsAnagram", IsAnagram, solutions.IsAnagram, arg[0], arg[1]) z01.Challenge("IsAnagram", IsAnagram, correct.IsAnagram, arg[0], arg[1])
} }
} }

2
tests/go/solutions/islower.go

@ -1,4 +1,4 @@
package solutions package correct
import "unicode" import "unicode"

2
tests/go/solutions/isnegative.go

@ -1,4 +1,4 @@
package solutions package correct
import "fmt" import "fmt"

2
tests/go/solutions/isnumeric.go

@ -1,4 +1,4 @@
package solutions package correct
import "unicode" import "unicode"

2
tests/go/solutions/isprime.go

@ -1,4 +1,4 @@
package solutions package correct
import "math" import "math"

2
tests/go/solutions/isprintable.go

@ -1,4 +1,4 @@
package solutions package correct
import "unicode" import "unicode"

2
tests/go/solutions/issorted.go

@ -1,4 +1,4 @@
package solutions package correct
func IsSorted(f func(int, int) int, arr []int) bool { func IsSorted(f func(int, int) int, arr []int) bool {
ascendingOrdered := true ascendingOrdered := true

2
tests/go/solutions/isupper.go

@ -1,4 +1,4 @@
package solutions package correct
func IsUpper(s string) bool { func IsUpper(s string) bool {
for _, r := range s { for _, r := range s {

2
tests/go/solutions/iterativefactorial.go

@ -1,4 +1,4 @@
package solutions package correct
import "math/bits" import "math/bits"

2
tests/go/solutions/iterativepower.go

@ -1,4 +1,4 @@
package solutions package correct
import "math" import "math"

2
tests/go/solutions/itoa.go

@ -1,4 +1,4 @@
package solutions package correct
import "strconv" import "strconv"

2
tests/go/solutions/itoabase.go

@ -1,4 +1,4 @@
package solutions package correct
import ( import (
"strconv" "strconv"

3
tests/go/solutions/itoabaseprog/main.go

@ -3,11 +3,10 @@ package main
import ( import (
"fmt" "fmt"
"strconv" "strconv"
"strings"
"github.com/01-edu/z01" "github.com/01-edu/z01"
"strings"
student "../../student" student "../../student"
) )

8
tests/go/solutions/itoabaseprog/test_itoabaseprog.go

@ -3,18 +3,18 @@ package main
import ( import (
"github.com/01-edu/z01" "github.com/01-edu/z01"
solutions "../../solutions" correct "./correct"
) )
func main() { 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("ItoaBaseProg", ItoaBase, solutions.ItoaBase, value, base) z01.Challenge("ItoaBaseProg", ItoaBase, correct.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("ItoaBaseProg", ItoaBase, solutions.ItoaBase, z01.MaxInt, base) z01.Challenge("ItoaBaseProg", ItoaBase, correct.ItoaBase, z01.MaxInt, base)
z01.Challenge("ItoaBaseProg", ItoaBase, solutions.ItoaBase, z01.MinInt, base) z01.Challenge("ItoaBaseProg", ItoaBase, correct.ItoaBase, z01.MinInt, base)
} }
} }

4
tests/go/solutions/itoaprog/test_itoaprog.go

@ -3,12 +3,12 @@ package main
import ( import (
"github.com/01-edu/z01" "github.com/01-edu/z01"
solutions "../../solutions" correct "./correct"
) )
func main() { 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("ItoaProg", Itoa, solutions.Itoa, arg) z01.Challenge("ItoaProg", Itoa, correct.Itoa, arg)
} }
} }

2
tests/go/solutions/join.go

@ -1,4 +1,4 @@
package solutions package correct
import "strings" import "strings"

2
tests/go/solutions/lastrune.go

@ -1,4 +1,4 @@
package solutions package correct
func LastRune(s string) rune { func LastRune(s string) rune {
runes := []rune(s) runes := []rune(s)

4
tests/go/solutions/lastruneprog/test_lastruneprog.go

@ -3,7 +3,7 @@ package main
import ( import (
"github.com/01-edu/z01" "github.com/01-edu/z01"
solutions "../../solutions" correct "./correct"
) )
func main() { func main() {
@ -15,6 +15,6 @@ func main() {
z01.RandStr(z01.RandIntBetween(1, 15), z01.RandAlnum()), z01.RandStr(z01.RandIntBetween(1, 15), z01.RandAlnum()),
) )
for _, arg := range table { for _, arg := range table {
z01.Challenge("LastRuneProg", LastRune, solutions.LastRune, arg) z01.Challenge("LastRuneProg", LastRune, correct.LastRune, arg)
} }
} }

2
tests/go/solutions/lcm.go

@ -1,4 +1,4 @@
package solutions package correct
func gcd(first, second int) int { func gcd(first, second int) int {
if second == 0 { if second == 0 {

4
tests/go/solutions/lcm/test_lcm.go

@ -3,7 +3,7 @@ package main
import ( import (
"github.com/01-edu/z01" "github.com/01-edu/z01"
solutions "../../solutions" correct "./correct"
) )
func main() { func main() {
@ -23,6 +23,6 @@ func main() {
} }
for _, arg := range table { for _, arg := range table {
z01.Challenge("Lcm", Lcm, solutions.Lcm, arg[0], arg[1]) z01.Challenge("Lcm", Lcm, correct.Lcm, arg[0], arg[1])
} }
} }

2
tests/go/solutions/listat.go

@ -1,4 +1,4 @@
package solutions package correct
// returs the node in a given position // returs the node in a given position
func ListAt(l *NodeL, nbr int) *NodeL { func ListAt(l *NodeL, nbr int) *NodeL {

2
tests/go/solutions/listclear.go

@ -1,4 +1,4 @@
package solutions package correct
func ListClear(l *List) { func ListClear(l *List) {
temp := l.Head temp := l.Head

2
tests/go/solutions/listfind.go

@ -1,4 +1,4 @@
package solutions package correct
// finds the element and returns the first data from the node that is a string // finds the element and returns the first data from the node that is a string
func ListFind(l *List, ref interface{}, comp func(a, b interface{}) bool) *interface{} { func ListFind(l *List, ref interface{}, comp func(a, b interface{}) bool) *interface{} {

2
tests/go/solutions/listforeach.go

@ -1,4 +1,4 @@
package solutions package correct
// applies a function in argument to each element of the linked list // applies a function in argument to each element of the linked list
func ListForEach(l *List, f func(*NodeL)) { func ListForEach(l *List, f func(*NodeL)) {

2
tests/go/solutions/listforeachif.go

@ -1,4 +1,4 @@
package solutions package correct
// compare each element of the linked list to see if it is a String // compare each element of the linked list to see if it is a String
func IsPositive_node(node *NodeL) bool { func IsPositive_node(node *NodeL) bool {

2
tests/go/solutions/listlast.go

@ -1,4 +1,4 @@
package solutions package correct
// gives the last element of the list // gives the last element of the list
func ListLast(l *List) interface{} { func ListLast(l *List) interface{} {

2
tests/go/solutions/listmerge.go

@ -1,4 +1,4 @@
package solutions package correct
// merges the 2 lists in one (in the end of the first list) // merges the 2 lists in one (in the end of the first list)
func ListMerge(l1 *List, l2 *List) { func ListMerge(l1 *List, l2 *List) {

2
tests/go/solutions/listpushback.go

@ -1,4 +1,4 @@
package solutions package correct
type NodeL struct { type NodeL struct {
Data interface{} Data interface{}

2
tests/go/solutions/listpushfront.go

@ -1,4 +1,4 @@
package solutions package correct
// inserts node on the first position of the list // inserts node on the first position of the list
func ListPushFront(l *List, data interface{}) { func ListPushFront(l *List, data interface{}) {

2
tests/go/solutions/listremoveif.go

@ -1,4 +1,4 @@
package solutions package correct
// removes all elements that are equal to the data_ref // removes all elements that are equal to the data_ref
func ListRemoveIf(l *List, data_ref interface{}) { func ListRemoveIf(l *List, data_ref interface{}) {

20
tests/go/solutions/listremoveifprog/test_listremoveifprog.go

@ -5,12 +5,12 @@ import (
"github.com/01-edu/z01" "github.com/01-edu/z01"
solution "../../solutions" correct "./correct"
) )
type Node10 = NodeL type Node10 = NodeL
type List10 = solution.List type List10 = correct.List
type NodeS10 = solution.NodeL type NodeS10 = correct.NodeL
type ListS10 = List type ListS10 = List
func listToStringStu12(l *ListS10) string { func listToStringStu12(l *ListS10) string {
@ -56,11 +56,11 @@ func comparFuncList10(l1 *List10, l2 *ListS10, data interface{}) {
for l1.Head != nil || l2.Head != nil { for l1.Head != nil || l2.Head != nil {
if (l1.Head == nil && l2.Head != nil) || (l1.Head != nil && l2.Head == nil) { if (l1.Head == nil && l2.Head != nil) || (l1.Head != nil && l2.Head == nil) {
z01.Fatalf("\ndata used: %v\nstudent list:%s\nlist:%s\n\nListRemoveIf() == %v instead of %v\n\n", z01.Fatalf("\ndata used: %v\nstudent list:%s\nlist:%s\n\nListRemoveIf() == %v instead of %v\n\n",
data, listToStringStu12(l2), solution.ListToString(l1.Head), l2.Head, l1.Head) data, listToStringStu12(l2), correct.ListToString(l1.Head), l2.Head, l1.Head)
} }
if l1.Head.Data != l2.Head.Data { if l1.Head.Data != l2.Head.Data {
z01.Fatalf("\ndata used: %v\nstudent list:%s\nlist:%s\n\nListRemoveIf() == %v instead of %v\n\n", z01.Fatalf("\ndata used: %v\nstudent list:%s\nlist:%s\n\nListRemoveIf() == %v instead of %v\n\n",
data, listToStringStu12(l2), solution.ListToString(l1.Head), l2.Head.Data, l1.Head.Data) data, listToStringStu12(l2), correct.ListToString(l1.Head), l2.Head.Data, l1.Head.Data)
} }
l1.Head = l1.Head.Next l1.Head = l1.Head.Next
l2.Head = l2.Head.Next l2.Head = l2.Head.Next
@ -71,12 +71,12 @@ func comparFuncList10(l1 *List10, l2 *ListS10, data interface{}) {
func main() { func main() {
link1 := &List10{} link1 := &List10{}
link2 := &ListS10{} link2 := &ListS10{}
table := []solution.NodeTest{} table := []correct.NodeTest{}
table = solution.ElementsToTest(table) table = correct.ElementsToTest(table)
table = append(table, table = append(table,
solution.NodeTest{ correct.NodeTest{
Data: []interface{}{"hello", "hello1", "hello2", "hello3"}, Data: []interface{}{"hello", "hello1", "hello2", "hello3"},
}, },
) )
@ -91,11 +91,11 @@ func main() {
if link1.Head != nil && link2.Head != nil { if link1.Head != nil && link2.Head != nil {
cho := arg.Data[index] cho := arg.Data[index]
ListRemoveIf(link2, cho) ListRemoveIf(link2, cho)
solution.ListRemoveIf(link1, cho) correct.ListRemoveIf(link1, cho)
comparFuncList10(link1, link2, cho) comparFuncList10(link1, link2, cho)
} else { } else {
ListRemoveIf(link2, 1) ListRemoveIf(link2, 1)
solution.ListRemoveIf(link1, 1) correct.ListRemoveIf(link1, 1)
comparFuncList10(link1, link2, 1) comparFuncList10(link1, link2, 1)
} }

2
tests/go/solutions/listreverse.go

@ -1,4 +1,4 @@
package solutions package correct
func ListReverse(l *List) { func ListReverse(l *List) {
current := l.Head current := l.Head

2
tests/go/solutions/listsize.go

@ -1,4 +1,4 @@
package solutions package correct
func ListSize(l *List) int { func ListSize(l *List) int {
count := 0 count := 0

17
tests/go/solutions/listsizeprog/test_listsizeprog.go

@ -1,13 +1,14 @@
package main package main
import ( import (
solution "../../solutions"
"github.com/01-edu/z01" "github.com/01-edu/z01"
correct "./correct"
) )
type Node2 = NodeL type Node2 = NodeL
type List2 = solution.List type List2 = correct.List
type NodeS2 = solution.NodeL type NodeS2 = correct.NodeL
type ListS2 = List type ListS2 = List
func listPushBackTest2(l *ListS2, l1 *List2, data interface{}) { func listPushBackTest2(l *ListS2, l1 *List2, data interface{}) {
@ -37,10 +38,10 @@ func listPushBackTest2(l *ListS2, l1 *List2, data interface{}) {
func main() { func main() {
link := &List2{} link := &List2{}
link2 := &ListS2{} link2 := &ListS2{}
table := []solution.NodeTest{} table := []correct.NodeTest{}
table = solution.ElementsToTest(table) table = correct.ElementsToTest(table)
table = append(table, table = append(table,
solution.NodeTest{ correct.NodeTest{
Data: []interface{}{"Hello", "man", "how are you"}, Data: []interface{}{"Hello", "man", "how are you"},
}, },
) )
@ -48,10 +49,10 @@ func main() {
for i := 0; i < len(arg.Data); i++ { for i := 0; i < len(arg.Data); i++ {
listPushBackTest2(link2, link, arg.Data[i]) listPushBackTest2(link2, link, arg.Data[i])
} }
aux := solution.ListSize(link) aux := correct.ListSize(link)
aux2 := ListSize(link2) aux2 := ListSize(link2)
if aux != aux2 { if aux != aux2 {
z01.Fatalf("ListSize(%v) == %d instead of %d\n", solution.ListToString(link.Head), aux2, aux) z01.Fatalf("ListSize(%v) == %d instead of %d\n", correct.ListToString(link.Head), aux2, aux)
} }
link = &List2{} link = &List2{}
link2 = &ListS2{} link2 = &ListS2{}

2
tests/go/solutions/listsort.go

@ -1,4 +1,4 @@
package solutions package correct
func ListSort(l *NodeI) *NodeI { func ListSort(l *NodeI) *NodeI {
head := l head := l

2
tests/go/solutions/makerange.go

@ -1,4 +1,4 @@
package solutions package correct
func MakeRange(min, max int) []int { func MakeRange(min, max int) []int {
size := max - min size := max - min

2
tests/go/solutions/map.go

@ -1,4 +1,4 @@
package solutions package correct
func IsPositive(value int) bool { func IsPositive(value int) bool {
return value > 0 return value > 0

2
tests/go/solutions/max.go

@ -1,4 +1,4 @@
package solutions package correct
import "sort" import "sort"

4
tests/go/solutions/maxprog/test_maxprog.go

@ -3,7 +3,7 @@ package main
import ( import (
"github.com/01-edu/z01" "github.com/01-edu/z01"
solutions "../../solutions" correct "./correct"
) )
func main() { func main() {
@ -13,5 +13,5 @@ func main() {
args = append(args, z01.RandInt()) args = append(args, z01.RandInt())
} }
z01.Challenge("MaxProg", Max, solutions.Max, args) z01.Challenge("MaxProg", Max, correct.Max, args)
} }

2
tests/go/solutions/merge.go

@ -1,4 +1,4 @@
package solutions package correct
type TreeNodeM struct { type TreeNodeM struct {
Left *TreeNodeM Left *TreeNodeM

6
tests/go/solutions/merge/test_merge.go

@ -6,11 +6,11 @@ import (
"github.com/01-edu/z01" "github.com/01-edu/z01"
solutions "../../solutions" correct "./correct"
) )
type stuTreeNode = TreeNodeM type stuTreeNode = TreeNodeM
type solTreeNode = solutions.TreeNodeM type solTreeNode = correct.TreeNodeM
func New(n, k int) (*solTreeNode, *stuTreeNode, *solTreeNode) { func New(n, k int) (*solTreeNode, *stuTreeNode, *solTreeNode) {
var cop *solTreeNode var cop *solTreeNode
@ -166,7 +166,7 @@ func main() {
cop1, stuTree1, solTree1 := New(arg.n, arg.k) cop1, stuTree1, solTree1 := New(arg.n, arg.k)
cop2, stuTree2, solTree2 := New(arg.n, arg.k) cop2, stuTree2, solTree2 := New(arg.n, arg.k)
stuResult := MergeTrees(stuTree1, stuTree2) stuResult := MergeTrees(stuTree1, stuTree2)
solResult := solutions.MergeTrees(solTree1, solTree2) solResult := correct.MergeTrees(solTree1, solTree2)
compareTrees(stuResult, solResult, cop1, cop2) compareTrees(stuResult, solResult, cop1, cop2)
} }

2
tests/go/solutions/nauuo.go

@ -1,4 +1,4 @@
package solutions package correct
func Nauuo(plus, minus, rand int) string { func Nauuo(plus, minus, rand int) string {
if rand == 0 { if rand == 0 {

Some files were not shown because too many files changed in this diff diff.show_more

Loading…
Cancel
Save