diff --git a/subjects/printnbrinorder.en.md b/subjects/printnbrinorder.en.md index 832b6cb7..42ee8b7d 100644 --- a/subjects/printnbrinorder.en.md +++ b/subjects/printnbrinorder.en.md @@ -34,7 +34,7 @@ And its output : ```console student@ubuntu:~/[[ROOT]]/test$ go build -student@ubuntu:~/[[ROOT]]/test$ ./test -1230123 +student@ubuntu:~/[[ROOT]]/test$ ./test | cat -e +1230123$ student@ubuntu:~/[[ROOT]]/test$ ``` diff --git a/tests/go/func/broken/correct/printnbrbase.go b/tests/go/func/broken/correct/printnbrbase.go index fa8b158c..26a373d0 100644 --- a/tests/go/func/broken/correct/printnbrbase.go +++ b/tests/go/func/broken/correct/printnbrbase.go @@ -1,6 +1,6 @@ package correct -import "github.com/01-edu/z01" +import "fmt" func PrintNbrBase(n int, base string) { if validBase(base) { @@ -8,17 +8,16 @@ func PrintNbrBase(n int, base string) { sign := 1 rbase := []rune(base) if n < 0 { - z01.PrintRune('-') + fmt.Print("-") sign = -1 } if n < length && n >= 0 { - z01.PrintRune(rbase[n]) + fmt.Printf("%c", rbase[n]) } else { PrintNbrBase(sign*(n/length), base) - z01.PrintRune(rbase[sign*(n%length)]) + fmt.Printf("%c", rbase[sign*(n%length)]) } } else { - z01.PrintRune('N') - z01.PrintRune('V') + fmt.Print("NV") } } diff --git a/tests/go/func/correct/eightqueens.go b/tests/go/func/correct/eightqueens.go index c5a28670..7b2961e0 100644 --- a/tests/go/func/correct/eightqueens.go +++ b/tests/go/func/correct/eightqueens.go @@ -1,6 +1,6 @@ package correct -import "github.com/01-edu/z01" +import "fmt" const size = 8 @@ -44,13 +44,13 @@ func printQueens() { for y < size { if board[x][y] { // We have found a queen, let's print her y - z01.PrintRune(rune(y) + '1') + fmt.Printf("%c", rune(y)+'1') } y++ } x++ } - z01.PrintRune('\n') + fmt.Println() } // tryX tries, for a given x (column) to find a y (row) so that the queen on (x, y) is a part diff --git a/tests/go/func/correct/printchessboard.go b/tests/go/func/correct/printchessboard.go index 0a24e296..45c588fe 100644 --- a/tests/go/func/correct/printchessboard.go +++ b/tests/go/func/correct/printchessboard.go @@ -1,19 +1,11 @@ package correct import ( + "fmt" "os" "strconv" - - "github.com/01-edu/z01" ) -func printLineCh(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 += " " } } - printLineCh(line) + fmt.Println(line) } } func main() { args := os.Args[1:] if len(args) != 2 { - printLineCh("Error") + fmt.Println("Error") return } x, _ := strconv.Atoi(args[1]) y, _ := strconv.Atoi(args[0]) if x <= 0 || y <= 0 { - printLineCh("Error") + fmt.Println("Error") return } solve(x, y) diff --git a/tests/go/func/correct/printcomb.go b/tests/go/func/correct/printcomb.go index c5e98d48..3a81cd9f 100644 --- a/tests/go/func/correct/printcomb.go +++ b/tests/go/func/correct/printcomb.go @@ -1,19 +1,16 @@ package correct -import "github.com/01-edu/z01" +import "fmt" func PrintComb() { for i := '0'; i <= '7'; i++ { for j := i + 1; j <= '8'; j++ { for k := j + 1; k <= '9'; k++ { - z01.PrintRune(rune(i)) - z01.PrintRune(rune(j)) - z01.PrintRune(rune(k)) + fmt.Printf("%c%c%c", i, j, k) if i < '7' { - z01.PrintRune(rune(',')) - z01.PrintRune(rune(' ')) + fmt.Printf(", ") } else { - z01.PrintRune(rune('\n')) + fmt.Println() } } } diff --git a/tests/go/func/correct/printmemory.go b/tests/go/func/correct/printmemory.go index ae967584..309a4b0f 100644 --- a/tests/go/func/correct/printmemory.go +++ b/tests/go/func/correct/printmemory.go @@ -1,9 +1,8 @@ package correct import ( + "fmt" "unicode" - - "github.com/01-edu/z01" ) func printBase(nbr int) int { @@ -28,7 +27,7 @@ func printBase(nbr int) int { i = 2 } for j := i - 1; j >= 0; j-- { - z01.PrintRune(result[j]) + fmt.Printf("%c", result[j]) a++ } return a @@ -41,42 +40,42 @@ func printLine(arr [10]int, start int) { for a < start+16 && a < size { if a%4 == 0 && a != 0 { - z01.PrintRune('\n') + fmt.Println() } b = 8 - printBase(arr[a]) for aux != b { if b == 6 { - z01.PrintRune('0') + fmt.Print("0") } if aux == 1 { - z01.PrintRune(' ') + fmt.Print(" ") } if b < 6 { - z01.PrintRune('0') + fmt.Print("0") } aux++ } - z01.PrintRune(' ') + fmt.Print(" ") aux = 0 a++ } - z01.PrintRune('\n') + fmt.Println() c := start for c < start+16 && c < size { if unicode.IsPrint(rune(arr[c])) { - z01.PrintRune(rune(arr[c])) + fmt.Printf("%c", rune(arr[c])) } else { - z01.PrintRune('.') + fmt.Print(".") } c++ } - z01.PrintRune('\n') + fmt.Println() } -func PrintMemory(arr [10]int) { +func PrintMemory(a [10]int) { i := 0 - for i < len(arr) { - printLine(arr, i) + for i < len(a) { + printLine(a, i) i += 16 } } diff --git a/tests/go/func/correct/printnbrinorder.go b/tests/go/func/correct/printnbrinorder.go index ff436b8f..1a435b3a 100644 --- a/tests/go/func/correct/printnbrinorder.go +++ b/tests/go/func/correct/printnbrinorder.go @@ -1,9 +1,8 @@ package correct import ( + "fmt" "sort" - - "github.com/01-edu/z01" ) func intToDigits(n int) (digits []int) { @@ -20,12 +19,13 @@ func intToDigits(n int) (digits []int) { func PrintNbrInOrder(n int) { if n == 0 { - z01.PrintRune('0') + fmt.Print("0") return } digits := intToDigits(n) sort.Ints(digits) for _, i := range digits { - z01.PrintRune(rune(i) + '0') + fmt.Printf("%c", rune(i)+'0') } + fmt.Println() } diff --git a/tests/go/func/correct/raid1a.go b/tests/go/func/correct/raid1a.go index 288d99a5..c32d2184 100644 --- a/tests/go/func/correct/raid1a.go +++ b/tests/go/func/correct/raid1a.go @@ -1,24 +1,23 @@ package correct -import "github.com/01-edu/z01" +import "fmt" -func drawLine(x int, str string) { - strConverted := []rune(str) - beg := strConverted[0] - med := strConverted[1] - end := strConverted[2] +func drawLine(x int, s string) { + beg := s[0] + med := s[1] + end := s[2] if x >= 1 { - z01.PrintRune(beg) + fmt.Printf("%c", beg) } if x > 2 { for i := 0; i < (x - 2); i++ { - z01.PrintRune(med) + fmt.Printf("%c", med) } } if x > 1 { - z01.PrintRune(end) + fmt.Printf("%c", end) } - z01.PrintRune('\n') + fmt.Println() } func printTheLines(x, y int, strBeg, strMed, strEnd string) { diff --git a/tests/go/func/correct/raid1b.go b/tests/go/func/correct/raid1b.go index dbe96fae..a7629dcf 100644 --- a/tests/go/func/correct/raid1b.go +++ b/tests/go/func/correct/raid1b.go @@ -1,24 +1,23 @@ package correct -import "github.com/01-edu/z01" +import "fmt" -func drawLineRaid1b(x int, str string) { - strConverted := []rune(str) - beg := strConverted[0] - med := strConverted[1] - end := strConverted[2] +func drawLineRaid1b(x int, s string) { + beg := s[0] + med := s[1] + end := s[2] if x >= 1 { - z01.PrintRune(beg) + fmt.Printf("%c", beg) } if x > 2 { for i := 0; i < (x - 2); i++ { - z01.PrintRune(med) + fmt.Printf("%c", med) } } if x > 1 { - z01.PrintRune(end) + fmt.Printf("%c", end) } - z01.PrintRune('\n') + fmt.Println() } func Raid1b(x, y int) { diff --git a/tests/go/func/correct/raid1c.go b/tests/go/func/correct/raid1c.go index fb4e5515..bb61d9ba 100644 --- a/tests/go/func/correct/raid1c.go +++ b/tests/go/func/correct/raid1c.go @@ -1,24 +1,23 @@ package correct -import "github.com/01-edu/z01" +import "fmt" -func drawLineRaid1c(x int, str string) { - strConverted := []rune(str) - beg := strConverted[0] - med := strConverted[1] - end := strConverted[2] +func drawLineRaid1c(x int, s string) { + beg := s[0] + med := s[1] + end := s[2] if x >= 1 { - z01.PrintRune(beg) + fmt.Printf("%c", beg) } if x > 2 { for i := 0; i < (x - 2); i++ { - z01.PrintRune(med) + fmt.Printf("%c", med) } } if x > 1 { - z01.PrintRune(end) + fmt.Printf("%c", end) } - z01.PrintRune('\n') + fmt.Println() } func Raid1c(x, y int) { diff --git a/tests/go/func/correct/raid1d.go b/tests/go/func/correct/raid1d.go index a18b3814..eedf5e74 100644 --- a/tests/go/func/correct/raid1d.go +++ b/tests/go/func/correct/raid1d.go @@ -1,24 +1,23 @@ package correct -import "github.com/01-edu/z01" +import "fmt" -func drawLineRaid1d(x int, str string) { - strConverted := []rune(str) - beg := strConverted[0] - med := strConverted[1] - end := strConverted[2] +func drawLineRaid1d(x int, s string) { + beg := s[0] + med := s[1] + end := s[2] if x >= 1 { - z01.PrintRune(beg) + fmt.Printf("%c", beg) } if x > 2 { for i := 0; i < (x - 2); i++ { - z01.PrintRune(med) + fmt.Printf("%c", med) } } if x > 1 { - z01.PrintRune(end) + fmt.Printf("%c", end) } - z01.PrintRune('\n') + fmt.Println() } func Raid1d(x, y int) { diff --git a/tests/go/func/correct/raid1e.go b/tests/go/func/correct/raid1e.go index a2190d65..4eb967e9 100644 --- a/tests/go/func/correct/raid1e.go +++ b/tests/go/func/correct/raid1e.go @@ -1,24 +1,23 @@ package correct -import "github.com/01-edu/z01" +import "fmt" -func drawLineRaid1e(x int, str string) { - strConverted := []rune(str) - beg := strConverted[0] - med := strConverted[1] - end := strConverted[2] +func drawLineRaid1e(x int, s string) { + beg := s[0] + med := s[1] + end := s[2] if x >= 1 { - z01.PrintRune(beg) + fmt.Printf("%c", beg) } if x > 2 { for i := 0; i < (x - 2); i++ { - z01.PrintRune(med) + fmt.Printf("%c", med) } } if x > 1 { - z01.PrintRune(end) + fmt.Printf("%c", end) } - z01.PrintRune('\n') + fmt.Println() } func Raid1e(x, y int) { diff --git a/tests/go/prog/test_tetrisoptimizer.go b/tests/go/prog/test_tetrisoptimizer.go index 558afdc2..e2f8fe16 100644 --- a/tests/go/prog/test_tetrisoptimizer.go +++ b/tests/go/prog/test_tetrisoptimizer.go @@ -28,8 +28,7 @@ type ( tetromino [3]vect ) -// load a tetromino composed of the rune r in the map s -// example : +// load a tetromino composed of the rune r in the map s, example : // // read(`...... // ...... @@ -40,7 +39,6 @@ type ( // `, // 'X', // ) == tetromino{{-2, 1}, {-1, 1}, {0, 1}} - func read(s string, r rune) (t tetromino) { var origin vect i := 0