Browse Source

Convert last "prog" exercises as functions exercises (the end ?)

pull/533/head
Xavier Petit 4 years ago committed by xpetit
parent
commit
d7e4cfd33b
  1. 2
      docs/addition_of_exercise_draft.md
  2. 3
      subjects/brainfuck.en.md
  3. 0
      subjects/doppelganger.en.md
  4. 0
      subjects/findprevprime.en.md
  5. 13
      tests/go/solutions/brainfuck/main.go
  6. 2
      tests/go/test_compact.go
  7. 2
      tests/go/test_doppelganger.go
  8. 10
      tests/go/test_raid3.go
  9. 4
      tests/go/test_ztail.go

2
docs/addition_of_exercise_draft.md

@ -1,5 +1,7 @@
# THE ADDITION OF EXERCISE PROCEDURE # THE ADDITION OF EXERCISE PROCEDURE
**Needs to be updated since the refactor**
##### This is for a go exercise in the piscine-go ##### This is for a go exercise in the piscine-go
## **1. Writing the subject and / or writing the solution** ## **1. Writing the subject and / or writing the solution**

3
subjects/brainfuck.en.md

@ -29,7 +29,6 @@ student@ubuntu:~/[[ROOT]]/brainfuck$ ./brainfuck "+++++[>++++[>++++H>+++++i<<-]>
Hi$ Hi$
student@ubuntu:~/[[ROOT]]/brainfuck$ ./brainfuck "++++++++++[>++++++++++>++++++++++>++++++++++<<<-]>---.>--.>-.>++++++++++." | cat -e student@ubuntu:~/[[ROOT]]/brainfuck$ ./brainfuck "++++++++++[>++++++++++>++++++++++>++++++++++<<<-]>---.>--.>-.>++++++++++." | cat -e
abc$ abc$
student@ubuntu:~/[[ROOT]]/brainfuck$ ./brainfuck | cat -e student@ubuntu:~/[[ROOT]]/brainfuck$ ./brainfuck
$
student@ubuntu:~/[[ROOT]]/brainfuck$ student@ubuntu:~/[[ROOT]]/brainfuck$
``` ```

0
subjects/doppelgangerprog.en.md → subjects/doppelganger.en.md

0
subjects/findprevprimeprog.en.md → subjects/findprevprime.en.md

13
tests/go/solutions/brainfuck/main.go

@ -9,13 +9,15 @@ import (
const SIZE = 2048 const SIZE = 2048
func main() { func main() {
if len(os.Args) == 2 { if len(os.Args) != 2 {
return
}
progpoint := []byte(os.Args[1]) progpoint := []byte(os.Args[1])
var arby [SIZE]byte var arby [SIZE]byte
pos := 0 pos := 0
openBr := 0 //opened brackets openBr := 0 // opened brackets
i := 0 //iterates through the source code passed in the argument i := 0 // iterates through the source code passed in the argument
N := len(progpoint) //length of the source code N := len(progpoint) // length of the source code
for i >= 0 && i < N { for i >= 0 && i < N {
switch progpoint[i] { switch progpoint[i] {
case '>': case '>':
@ -62,7 +64,4 @@ func main() {
} }
i++ i++
} }
} else {
z01.PrintRune('\n')
}
} }

2
tests/go/test_compact.go

@ -15,7 +15,7 @@ func main() {
for i := 0; i < 20; i++ { for i := 0; i < 20; i++ {
n := z01.RandIntBetween(5, 20) // random size of the slice 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 num_pos := z01.RandIntBetween(1, n-1) // random number of positions to be written

2
tests/go/test_doppelganger.go

@ -48,6 +48,6 @@ func main() {
} }
for _, arg := range table { 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)
} }
} }

10
tests/go/test_raid3.go

@ -37,11 +37,11 @@ func main() {
// builds all the files for testing, student, solution and relevant files // 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", "solutions/raid3/main.go")
execFatal("go", "build", "-o", "raid3_student", "student/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/raid1aprog/raid1a.go")
execFatal("go", "build", "solutions/raid3/raid1bProg/raid1b.go") execFatal("go", "build", "solutions/raid3/raid1bprog/raid1b.go")
execFatal("go", "build", "solutions/raid3/raid1cProg/raid1c.go") execFatal("go", "build", "solutions/raid3/raid1cprog/raid1c.go")
execFatal("go", "build", "solutions/raid3/raid1dProg/raid1d.go") execFatal("go", "build", "solutions/raid3/raid1dprog/raid1d.go")
execFatal("go", "build", "solutions/raid3/raid1eProg/raid1e.go") execFatal("go", "build", "solutions/raid3/raid1eprog/raid1e.go")
// testing all raids1 // testing all raids1
table := []string{"raid1a", "raid1b", "raid1c", "raid1d", "raid1e"} table := []string{"raid1a", "raid1b", "raid1c", "raid1d", "raid1e"}

4
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

Loading…
Cancel
Save