diff --git a/tests/go/prog/addprimesum/main.go b/tests/go/prog/addprimesum/main.go index 781bb32a..e722cd38 100644 --- a/tests/go/prog/addprimesum/main.go +++ b/tests/go/prog/addprimesum/main.go @@ -4,8 +4,6 @@ import ( "fmt" "os" "strconv" - - "github.com/01-edu/z01" ) func isPrime(nb int) bool { @@ -31,14 +29,12 @@ func isPrime(nb int) bool { func main() { if len(os.Args) != 2 { - z01.PrintRune('0') - z01.PrintRune('\n') + fmt.Println("0") } else { argument, _ := strconv.Atoi(os.Args[1]) if argument < 0 { - z01.PrintRune('0') - z01.PrintRune('\n') + fmt.Println("0") } else { result := 0 for ; argument >= 0; argument-- { diff --git a/tests/go/prog/boolean/main.go b/tests/go/prog/boolean/main.go index 611016a1..86314ad9 100644 --- a/tests/go/prog/boolean/main.go +++ b/tests/go/prog/boolean/main.go @@ -1,33 +1,14 @@ package main import ( + "fmt" "os" - - "github.com/01-edu/z01" ) -func printStr(str string) { - arrayStr := []rune(str) - - for i := 0; i < len(arrayStr); i++ { - z01.PrintRune(arrayStr[i]) - } - z01.PrintRune('\n') -} - -func isEven(nbr int) bool { - return nbr%2 == 0 -} - func main() { - EvenMsg := "I have an even number of arguments" - OddMsg := "I have an odd number of arguments" - - lenOfArg := len(os.Args) - 1 - - if isEven(lenOfArg) { - printStr(EvenMsg) + if len(os.Args)-1%2 == 0 { + fmt.Println("I have an even number of arguments") } else { - printStr(OddMsg) + fmt.Println("I have an odd number of arguments") } } diff --git a/tests/go/prog/brainfuck/main.go b/tests/go/prog/brainfuck/main.go index e8e3bf0c..d1afa176 100644 --- a/tests/go/prog/brainfuck/main.go +++ b/tests/go/prog/brainfuck/main.go @@ -1,9 +1,8 @@ package main import ( + "fmt" "os" - - "github.com/01-edu/z01" ) const SIZE = 2048 @@ -34,7 +33,7 @@ func main() { arby[pos]-- case '.': // print the pointed byte on std output - z01.PrintRune(rune(arby[pos])) + fmt.Printf("%c", rune(arby[pos])) case '[': // go to the matching ']' if the pointed byte is 0 (while start) openBr = 0 diff --git a/tests/go/prog/displayalpham/main.go b/tests/go/prog/displayalpham/main.go index 44ffb600..67f54a2b 100644 --- a/tests/go/prog/displayalpham/main.go +++ b/tests/go/prog/displayalpham/main.go @@ -1,15 +1,15 @@ package main -import "github.com/01-edu/z01" +import "fmt" func main() { diff := 'a' - 'A' for c := 'a'; c <= 'z'; c++ { if c%2 == 0 { - z01.PrintRune(c - diff) + fmt.Printf("%c", c-diff) } else { - z01.PrintRune(c) + fmt.Printf("%c", c) } } - z01.PrintRune('\n') + fmt.Println() } diff --git a/tests/go/prog/displayalrevm/main.go b/tests/go/prog/displayalrevm/main.go index f0ff0eb3..87f45afb 100644 --- a/tests/go/prog/displayalrevm/main.go +++ b/tests/go/prog/displayalrevm/main.go @@ -1,15 +1,15 @@ package main -import "github.com/01-edu/z01" +import "fmt" func main() { diff := 'a' - 'A' for c := 'z'; c >= 'a'; c-- { if c%2 == 0 { - z01.PrintRune(c) + fmt.Printf("%c", c) } else { - z01.PrintRune(c - diff) + fmt.Printf("%c", c-diff) } } - z01.PrintRune('\n') + fmt.Println() } diff --git a/tests/go/prog/firstword/main.go b/tests/go/prog/firstword/main.go index b4e83155..cbdbb6b7 100644 --- a/tests/go/prog/firstword/main.go +++ b/tests/go/prog/firstword/main.go @@ -3,26 +3,22 @@ package main import ( "fmt" "os" - - "github.com/01-edu/z01" ) func main() { if len(os.Args) == 2 { for i := 0; i < len(os.Args[1]); i++ { if os.Args[1][i] != ' ' { - z01.PrintRune(rune(os.Args[1][i])) + fmt.Printf("%c", rune(os.Args[1][i])) if i != len(os.Args[1])-1 { if os.Args[1][i+1] == ' ' { - z01.PrintRune('\n') + fmt.Println() return } } } } - z01.PrintRune('\n') - } else { fmt.Println() } } diff --git a/tests/go/prog/fprime/main.go b/tests/go/prog/fprime/main.go index 6e744739..9f28f583 100644 --- a/tests/go/prog/fprime/main.go +++ b/tests/go/prog/fprime/main.go @@ -4,8 +4,6 @@ import ( "fmt" "os" "strconv" - - "github.com/01-edu/z01" ) func fprime(value int) { @@ -19,13 +17,13 @@ func fprime(value int) { value = value / divisionIterator if value > 1 { - z01.PrintRune('*') + fmt.Print("*") } divisionIterator-- } divisionIterator++ } - z01.PrintRune('\n') + fmt.Println() } func main() { diff --git a/tests/go/prog/hiddenp/main.go b/tests/go/prog/hiddenp/main.go index e1909c6c..0888e02d 100644 --- a/tests/go/prog/hiddenp/main.go +++ b/tests/go/prog/hiddenp/main.go @@ -1,9 +1,8 @@ package main import ( + "fmt" "os" - - "github.com/01-edu/z01" ) func main() { @@ -15,13 +14,11 @@ func main() { second := os.Args[2] if first == "" { - z01.PrintRune('1') - z01.PrintRune('\n') + fmt.Println("1") return } if second == "" { - z01.PrintRune('0') - z01.PrintRune('\n') + fmt.Println("0") return } @@ -47,9 +44,8 @@ func main() { } if count == len(first) { - z01.PrintRune('1') + fmt.Println("1") } else { - z01.PrintRune('0') + fmt.Println("0") } - z01.PrintRune('\n') } diff --git a/tests/go/prog/nbrconvertalpha/main.go b/tests/go/prog/nbrconvertalpha/main.go index 614b6de7..85fc73b7 100644 --- a/tests/go/prog/nbrconvertalpha/main.go +++ b/tests/go/prog/nbrconvertalpha/main.go @@ -1,15 +1,15 @@ package main import ( + "fmt" "os" "strconv" - - "github.com/01-edu/z01" + "unicode" ) -func IsNumeric(str string) bool { - for i := 0; i < len(str); i++ { - if !(str[i] >= '0' && str[i] <= '9') { +func IsNumeric(s string) bool { + for _, r := range s { + if !unicode.IsDigit(r) { return false } } @@ -28,18 +28,18 @@ func main() { if number <= 26 && number >= 1 && !boole { number += 96 - z01.PrintRune(rune(number)) + fmt.Printf("%c", rune(number)) } else if number <= 26 && number >= 1 && boole { number += 64 - z01.PrintRune(rune(number)) + fmt.Printf("%c", rune(number)) } else { - z01.PrintRune(' ') + fmt.Print(" ") } } else { if !(arguments[i] == "--upper" && i == 0) { - z01.PrintRune(' ') + fmt.Print(" ") } } } - z01.PrintRune('\n') + fmt.Println() } diff --git a/tests/go/prog/onlya/main.go b/tests/go/prog/onlya/main.go index 9f0fad4c..712c4759 100644 --- a/tests/go/prog/onlya/main.go +++ b/tests/go/prog/onlya/main.go @@ -1,7 +1,7 @@ package main -import "github.com/01-edu/z01" +import "fmt" func main() { - z01.PrintRune('a') + fmt.Print("a") } diff --git a/tests/go/prog/onlyz/main.go b/tests/go/prog/onlyz/main.go index 60703188..e80f2923 100644 --- a/tests/go/prog/onlyz/main.go +++ b/tests/go/prog/onlyz/main.go @@ -1,7 +1,7 @@ package main -import "github.com/01-edu/z01" +import "fmt" func main() { - z01.PrintRune('z') + fmt.Print("z") } diff --git a/tests/go/prog/piglatin/main.go b/tests/go/prog/piglatin/main.go index 8d44b494..3dba5587 100644 --- a/tests/go/prog/piglatin/main.go +++ b/tests/go/prog/piglatin/main.go @@ -3,13 +3,23 @@ package main import ( "fmt" "os" - - "github.com/01-edu/z01" ) +func firstNotVowel(letters []rune) int { + index := 0 + for i := 0; i < len(letters); i++ { + if letters[i] == 'a' || letters[i] == 'e' || letters[i] == 'i' || letters[i] == 'o' || letters[i] == 'u' || + letters[i] == 'A' || letters[i] == 'E' || letters[i] == 'I' || letters[i] == 'O' || letters[i] == 'U' { + return index + } + index++ + } + return 0 +} + func main() { if len(os.Args) != 2 || os.Args[1] == "" { - z01.PrintRune('\n') + fmt.Println() return } letters := []rune(os.Args[1]) @@ -25,15 +35,3 @@ func main() { } } } - -func firstNotVowel(letters []rune) int { - index := 0 - for i := 0; i < len(letters); i++ { - if letters[i] == 'a' || letters[i] == 'e' || letters[i] == 'i' || letters[i] == 'o' || letters[i] == 'u' || - letters[i] == 'A' || letters[i] == 'E' || letters[i] == 'I' || letters[i] == 'O' || letters[i] == 'U' { - return index - } - index++ - } - return 0 -} diff --git a/tests/go/prog/printchessboard/main.go b/tests/go/prog/printchessboard/main.go index 0a683c33..349b3e4b 100644 --- a/tests/go/prog/printchessboard/main.go +++ b/tests/go/prog/printchessboard/main.go @@ -1,19 +1,11 @@ package main import ( + "fmt" "os" "strconv" - - "github.com/01-edu/z01" ) -func printLine(str string) { - for _, c := range str { - z01.PrintRune(c) - } - z01.PrintRune('\n') -} - func solve(x, y int) { for i := 0; i < x; i++ { line := "" @@ -28,20 +20,20 @@ func solve(x, y int) { line += " " } } - printLine(line) + fmt.Println(line) } } func main() { args := os.Args[1:] if len(args) != 2 { - printLine("Error") + fmt.Println("Error") return } x, _ := strconv.Atoi(args[1]) y, _ := strconv.Atoi(args[0]) if x <= 0 || y <= 0 { - printLine("Error") + fmt.Println("Error") return } solve(x, y) diff --git a/tests/go/prog/printdigits/main.go b/tests/go/prog/printdigits/main.go index e2df9aa1..d67da467 100644 --- a/tests/go/prog/printdigits/main.go +++ b/tests/go/prog/printdigits/main.go @@ -1,10 +1,10 @@ package main -import "github.com/01-edu/z01" +import "fmt" func main() { for i := '0'; i <= '9'; i++ { - z01.PrintRune(i) + fmt.Printf("%c", i) } - z01.PrintRune('\n') + fmt.Println() } diff --git a/tests/go/prog/printhex/main.go b/tests/go/prog/printhex/main.go index b5149230..5218b8fd 100644 --- a/tests/go/prog/printhex/main.go +++ b/tests/go/prog/printhex/main.go @@ -4,8 +4,6 @@ import ( "fmt" "os" "strconv" - - "github.com/01-edu/z01" ) func printBase(nbr int, base string) { @@ -19,18 +17,18 @@ func printBase(nbr int, base string) { nbr = nbr / baseSize } for j := len(result) - 1; j >= 0; j-- { - z01.PrintRune(result[j]) + fmt.Printf("%c", result[j]) } } func main() { if len(os.Args) != 2 { - z01.PrintRune('\n') + fmt.Println() } else { nbr, _ := strconv.Atoi(os.Args[1]) if nbr != 0 { printBase(nbr, "0123456789abcdef") - z01.PrintRune('\n') + fmt.Println() } else { fmt.Println(0) } diff --git a/tests/go/prog/raid2/main.go b/tests/go/prog/raid2/main.go index 362b50b3..8e4c22ee 100644 --- a/tests/go/prog/raid2/main.go +++ b/tests/go/prog/raid2/main.go @@ -3,20 +3,18 @@ package main import ( "fmt" "os" - - "github.com/01-edu/z01" ) // Prints in standard output the sudoku board func printBoard(board [][]rune) { for _, row := range board { for i, e := range row { - z01.PrintRune(e) + fmt.Printf("%c", e) if i != len(row)-1 { - z01.PrintRune(' ') + fmt.Print(" ") } } - z01.PrintRune('\n') + fmt.Println() } } diff --git a/tests/go/prog/repeatalpha/main.go b/tests/go/prog/repeatalpha/main.go index 42b14a28..d2ec0712 100644 --- a/tests/go/prog/repeatalpha/main.go +++ b/tests/go/prog/repeatalpha/main.go @@ -1,23 +1,22 @@ package main import ( + "fmt" "os" "unicode" - - "github.com/01-edu/z01" ) func main() { if len(os.Args) == 2 { for _, r := range os.Args[1] { - z01.PrintRune(r) + fmt.Printf("%c", r) if unicode.IsLetter(r) { rep := unicode.ToLower(r) - 'a' for i := 0; i < int(rep); i++ { - z01.PrintRune(r) + fmt.Printf("%c", r) } } } - z01.PrintRune('\n') + fmt.Println() } } diff --git a/tests/go/prog/rot13/main.go b/tests/go/prog/rot13/main.go index 8609493f..fdcfb4bd 100644 --- a/tests/go/prog/rot13/main.go +++ b/tests/go/prog/rot13/main.go @@ -1,9 +1,8 @@ package main import ( + "fmt" "os" - - "github.com/01-edu/z01" ) func main() { @@ -22,8 +21,8 @@ func main() { r += 13 } } - z01.PrintRune(r) + fmt.Printf("%c", r) } - z01.PrintRune('\n') + fmt.Println() } } diff --git a/tests/go/prog/uniqueoccurences/main.go b/tests/go/prog/uniqueoccurences/main.go index 354815ac..1b24a108 100644 --- a/tests/go/prog/uniqueoccurences/main.go +++ b/tests/go/prog/uniqueoccurences/main.go @@ -1,9 +1,8 @@ package main import ( + "fmt" "os" - - "github.com/01-edu/z01" ) func solve(str string) bool { @@ -23,14 +22,14 @@ func solve(str string) bool { func print(str string) { for _, v := range str { - z01.PrintRune(v) + fmt.Printf("%c", v) } } func main() { args := os.Args[1:] if len(args) != 1 { - z01.PrintRune('\n') + fmt.Println() return } result := solve(args[0]) diff --git a/tests/go/prog/ztail/main.go b/tests/go/prog/ztail/main.go index 58163174..e10a213a 100644 --- a/tests/go/prog/ztail/main.go +++ b/tests/go/prog/ztail/main.go @@ -4,8 +4,6 @@ import ( "fmt" "os" "strconv" - - "github.com/01-edu/z01" ) func numberOfBytes(args []string) (int, []string) { @@ -77,11 +75,11 @@ func main() { } for _, c := range read { - z01.PrintRune(rune(c)) + fmt.Printf("%c", rune(c)) } if j < len(files)-1 { - z01.PrintRune('\n') + fmt.Println() } fi.Close()