diff --git a/docs/addition_of_exercise_draft.md b/docs/addition_of_exercise_draft.md index f2f5050c..4d2a5db1 100644 --- a/docs/addition_of_exercise_draft.md +++ b/docs/addition_of_exercise_draft.md @@ -1,5 +1,7 @@ # THE ADDITION OF EXERCISE PROCEDURE +**Needs to be updated since the refactor** + ##### This is for a go exercise in the piscine-go ## **1. Writing the subject and / or writing the solution** diff --git a/subjects/brainfuck.en.md b/subjects/brainfuck.en.md index 32cd7830..ec03c50d 100644 --- a/subjects/brainfuck.en.md +++ b/subjects/brainfuck.en.md @@ -29,7 +29,6 @@ student@ubuntu:~/[[ROOT]]/brainfuck$ ./brainfuck "+++++[>++++[>++++H>+++++i<<-]> Hi$ student@ubuntu:~/[[ROOT]]/brainfuck$ ./brainfuck "++++++++++[>++++++++++>++++++++++>++++++++++<<<-]>---.>--.>-.>++++++++++." | cat -e abc$ -student@ubuntu:~/[[ROOT]]/brainfuck$ ./brainfuck | cat -e -$ +student@ubuntu:~/[[ROOT]]/brainfuck$ ./brainfuck student@ubuntu:~/[[ROOT]]/brainfuck$ ``` diff --git a/subjects/doppelgangerprog.en.md b/subjects/doppelganger.en.md similarity index 100% rename from subjects/doppelgangerprog.en.md rename to subjects/doppelganger.en.md diff --git a/subjects/findprevprimeprog.en.md b/subjects/findprevprime.en.md similarity index 100% rename from subjects/findprevprimeprog.en.md rename to subjects/findprevprime.en.md diff --git a/tests/go/solutions/brainfuck/main.go b/tests/go/solutions/brainfuck/main.go index 64915c30..e8e3bf0c 100644 --- a/tests/go/solutions/brainfuck/main.go +++ b/tests/go/solutions/brainfuck/main.go @@ -9,60 +9,59 @@ import ( const SIZE = 2048 func main() { - if len(os.Args) == 2 { - progpoint := []byte(os.Args[1]) - var arby [SIZE]byte - pos := 0 - openBr := 0 //opened brackets - i := 0 //iterates through the source code passed in the argument - N := len(progpoint) //length of the source code - for i >= 0 && i < N { - switch progpoint[i] { - case '>': - // Increment the pointer - pos++ - case '<': - // decrement the pointes - pos-- - case '+': - // increment the pointed byte - arby[pos]++ - case '-': - // decrement the pointed byte - arby[pos]-- - case '.': - // print the pointed byte on std output - z01.PrintRune(rune(arby[pos])) - case '[': - // go to the matching ']' if the pointed byte is 0 (while start) - openBr = 0 - if arby[pos] == 0 { - for i < N && (progpoint[i] != byte(']') || openBr > 1) { - if progpoint[i] == byte('[') { - openBr++ - } else if progpoint[i] == byte(']') { - openBr-- - } - i++ + if len(os.Args) != 2 { + return + } + progpoint := []byte(os.Args[1]) + var arby [SIZE]byte + pos := 0 + openBr := 0 // opened brackets + i := 0 // iterates through the source code passed in the argument + N := len(progpoint) // length of the source code + for i >= 0 && i < N { + switch progpoint[i] { + case '>': + // Increment the pointer + pos++ + case '<': + // decrement the pointes + pos-- + case '+': + // increment the pointed byte + arby[pos]++ + case '-': + // decrement the pointed byte + arby[pos]-- + case '.': + // print the pointed byte on std output + z01.PrintRune(rune(arby[pos])) + case '[': + // go to the matching ']' if the pointed byte is 0 (while start) + openBr = 0 + if arby[pos] == 0 { + for i < N && (progpoint[i] != byte(']') || openBr > 1) { + if progpoint[i] == byte('[') { + openBr++ + } else if progpoint[i] == byte(']') { + openBr-- } + i++ } - case ']': - // go to the matching '[' if the pointed byte is not 0 (while end) - openBr = 0 - if arby[pos] != 0 { - for i >= 0 && (progpoint[i] != byte('[') || openBr > 1) { - if progpoint[i] == byte(']') { - openBr++ - } else if progpoint[i] == byte('[') { - openBr-- - } - i-- + } + case ']': + // go to the matching '[' if the pointed byte is not 0 (while end) + openBr = 0 + if arby[pos] != 0 { + for i >= 0 && (progpoint[i] != byte('[') || openBr > 1) { + if progpoint[i] == byte(']') { + openBr++ + } else if progpoint[i] == byte('[') { + openBr-- } + i-- } } - i++ } - } else { - z01.PrintRune('\n') + i++ } } diff --git a/tests/go/test_compact.go b/tests/go/test_compact.go index c5a2ee20..f400abd1 100644 --- a/tests/go/test_compact.go +++ b/tests/go/test_compact.go @@ -15,7 +15,7 @@ func main() { for i := 0; i < 20; i++ { n := z01.RandIntBetween(5, 20) // random size of the slice - orig := make([]string, n) //slice with the original value + orig := make([]string, n) // slice with the original value num_pos := z01.RandIntBetween(1, n-1) // random number of positions to be written diff --git a/tests/go/test_doppelganger.go b/tests/go/test_doppelganger.go index c75c18ec..1cf669d7 100644 --- a/tests/go/test_doppelganger.go +++ b/tests/go/test_doppelganger.go @@ -48,6 +48,6 @@ func main() { } for _, arg := range table { - z01.Challenge("DoppelGangerProg", student.DoppelGanger, correct.DoppelGanger, arg.big, arg.little) + z01.Challenge("DoppelGanger", student.DoppelGanger, correct.DoppelGanger, arg.big, arg.little) } } diff --git a/tests/go/test_raid3.go b/tests/go/test_raid3.go index 4952522a..da043133 100644 --- a/tests/go/test_raid3.go +++ b/tests/go/test_raid3.go @@ -37,11 +37,11 @@ func main() { // builds all the files for testing, student, solution and relevant files execFatal("go", "build", "-o", "raid3", "solutions/raid3/main.go") execFatal("go", "build", "-o", "raid3_student", "student/raid3/main.go") - execFatal("go", "build", "solutions/raid3/raid1aProg/raid1a.go") - execFatal("go", "build", "solutions/raid3/raid1bProg/raid1b.go") - execFatal("go", "build", "solutions/raid3/raid1cProg/raid1c.go") - execFatal("go", "build", "solutions/raid3/raid1dProg/raid1d.go") - execFatal("go", "build", "solutions/raid3/raid1eProg/raid1e.go") + execFatal("go", "build", "solutions/raid3/raid1aprog/raid1a.go") + execFatal("go", "build", "solutions/raid3/raid1bprog/raid1b.go") + execFatal("go", "build", "solutions/raid3/raid1cprog/raid1c.go") + execFatal("go", "build", "solutions/raid3/raid1dprog/raid1d.go") + execFatal("go", "build", "solutions/raid3/raid1eprog/raid1e.go") // testing all raids1 table := []string{"raid1a", "raid1b", "raid1c", "raid1d", "raid1e"} diff --git a/tests/go/test_ztail.go b/tests/go/test_ztail.go index 3d7fd048..e0fec4d4 100644 --- a/tests/go/test_ztail.go +++ b/tests/go/test_ztail.go @@ -31,4 +31,6 @@ func main() { } } -// TODO: never use programs we didn't wrote (do not run the true cat but instead code our own solution) +// TODO: +// never use programs we didn't wrote (do not run the true cat but instead code our own solution) +// to be fixed