docs(checkpoints-exercises): remove piscine imports

This commit is contained in:
miguel 2023-07-03 18:47:41 +01:00 committed by MSilva95
parent f19d5f5341
commit 4974a86b84
36 changed files with 140 additions and 178 deletions

View File

@ -23,12 +23,11 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.BeZero([]int{1, 2, 3, 4, 5, 6}))
fmt.Println(piscine.BeZero([]int{}))
fmt.Println(BeZero([]int{1, 2, 3, 4, 5, 6}))
fmt.Println(BeZero([]int{}))
}
```

View File

@ -23,15 +23,13 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.ByeByeFirst([]string{}))
fmt.Println(piscine.ByeByeFirst([]string{"one arg"}))
fmt.Println(piscine.ByeByeFirst([]string{"first", "second"}))
fmt.Println(piscine.ByeByeFirst([]string{"", "abcd", "efg"}))
fmt.Println(ByeByeFirst([]string{}))
fmt.Println(ByeByeFirst([]string{"one arg"}))
fmt.Println(ByeByeFirst([]string{"first", "second"}))
fmt.Println(ByeByeFirst([]string{"", "abcd", "efg"}))
}
```

View File

@ -36,17 +36,15 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.CamelToSnakeCase("HelloWorld"))
fmt.Println(piscine.CamelToSnakeCase("helloWorld"))
fmt.Println(piscine.CamelToSnakeCase("camelCase"))
fmt.Println(piscine.CamelToSnakeCase("CAMELtoSnackCASE"))
fmt.Println(piscine.CamelToSnakeCase("camelToSnakeCase"))
fmt.Println(piscine.CamelToSnakeCase("hey2"))
fmt.Println(CamelToSnakeCase("HelloWorld"))
fmt.Println(CamelToSnakeCase("helloWorld"))
fmt.Println(CamelToSnakeCase("camelCase"))
fmt.Println(CamelToSnakeCase("CAMELtoSnackCASE"))
fmt.Println(CamelToSnakeCase("camelToSnakeCase"))
fmt.Println(CamelToSnakeCase("hey2"))
}
```

View File

@ -17,14 +17,16 @@ Here is a possible program to test your function:
```go
package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.CheckNumber("Hello"))
fmt.Println(piscine.CheckNumber("Hello1"))
fmt.Println(CheckNumber("Hello"))
fmt.Println(CheckNumber("Hello1"))
}
```
And its output:

View File

@ -3,6 +3,7 @@
### Instructions
Write a function `ConcatAlternate()` that receives two slices of an `int` as arguments and returns a new slice with the result of the alternated values of each slice.
- The input slices can be of different lengths.
- The new slice should start with an element of the largest slice.
- If the slices are of equal length, the new slice should return the elements of the first slice first and then the elements of the second slice.
@ -24,14 +25,13 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.ConcatAlternate([]int{1, 2, 3}, []int{4, 5, 6}))
fmt.Println(piscine.ConcatAlternate([]int{2, 4, 6, 8, 10}, []int{1, 3, 5, 7, 9, 11}))
fmt.Println(piscine.ConcatAlternate([]int{1, 2, 3}, []int{4, 5, 6, 7, 8, 9}))
fmt.Println(piscine.ConcatAlternate([]int{1, 2, 3}, []int{}))
fmt.Println(ConcatAlternate([]int{1, 2, 3}, []int{4, 5, 6}))
fmt.Println(ConcatAlternate([]int{2, 4, 6, 8, 10}, []int{1, 3, 5, 7, 9, 11}))
fmt.Println(ConcatAlternate([]int{1, 2, 3}, []int{4, 5, 6, 7, 8, 9}))
fmt.Println(ConcatAlternate([]int{1, 2, 3}, []int{}))
}
```

View File

@ -21,13 +21,12 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.ConcatSlice([]int{1, 2, 3}, []int{4, 5, 6}))
fmt.Println(piscine.ConcatSlice([]int{}, []int{4, 5, 6, 7, 8, 9}))
fmt.Println(piscine.ConcatSlice([]int{1, 2, 3}, []int{}))
fmt.Println(ConcatSlice([]int{1, 2, 3}, []int{4, 5, 6}))
fmt.Println(ConcatSlice([]int{}, []int{4, 5, 6, 7, 8, 9}))
fmt.Println(ConcatSlice([]int{1, 2, 3}, []int{}))
}
```

View File

@ -21,14 +21,12 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.CountAlpha("Hello world"))
fmt.Println(piscine.CountAlpha("H e l l o"))
fmt.Println(piscine.CountAlpha("H1e2l3l4o"))
fmt.Println(CountAlpha("Hello world"))
fmt.Println(CountAlpha("H e l l o"))
fmt.Println(CountAlpha("H1e2l3l4o"))
}
```

View File

@ -1,7 +1,9 @@
## count-character
### Instructions
write a function that takes a string and a character as arguments and returns the number of times the character appears in the string.
- if the character is not in the string return 0
- if the string is empty return 0
@ -20,17 +22,17 @@ Here is a possible program to test your function:
```go
package main
import (
"fmt"
"piscine"
import (
"fmt"
)
func main() {
fmt.Println(piscine.CountChar("Hello World", 'l'))
fmt.Println(piscine.CountChar("5 balloons",5))
fmt.Println(piscine.CountChar(" ", ' '))
fmt.Println(piscine.CountChar("The 7 deadly sins", '7'))
fmt.Println(CountChar("Hello World", 'l'))
fmt.Println(CountChar("5 balloons", 5))
fmt.Println(CountChar(" ", ' '))
fmt.Println(CountChar("The 7 deadly sins", '7'))
}
```
And its output :
@ -42,4 +44,3 @@ $ go run .
1
1
```

View File

@ -24,14 +24,13 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.DigitLen(100, 10))
fmt.Println(piscine.DigitLen(100, 2))
fmt.Println(piscine.DigitLen(-100, 16))
fmt.Println(piscine.DigitLen(100, -1))
fmt.Println(DigitLen(100, 10))
fmt.Println(DigitLen(100, 2))
fmt.Println(DigitLen(-100, 16))
fmt.Println(DigitLen(100, -1))
}
```

View File

@ -25,13 +25,12 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Print(piscine.FifthAndSkip("abcdefghijklmnopqrstuwxyz"))
fmt.Print(piscine.FifthAndSkip("This is a short sentence"))
fmt.Print(piscine.FifthAndSkip("1234"))
fmt.Print(FifthAndSkip("abcdefghijklmnopqrstuwxyz"))
fmt.Print(FifthAndSkip("This is a short sentence"))
fmt.Print(FifthAndSkip("1234"))
}
```

View File

@ -27,13 +27,12 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.FishAndChips(4))
fmt.Println(piscine.FishAndChips(9))
fmt.Println(piscine.FishAndChips(6))
fmt.Println(FishAndChips(4))
fmt.Println(FishAndChips(9))
fmt.Println(FishAndChips(6))
}
```

View File

@ -26,14 +26,13 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Print(piscine.FromTo(1, 10))
fmt.Print(piscine.FromTo(10, 1))
fmt.Print(piscine.FromTo(10, 10))
fmt.Print(piscine.FromTo(100, 10))
fmt.Print(FromTo(1, 10))
fmt.Print(FromTo(10, 1))
fmt.Print(FromTo(10, 10))
fmt.Print(FromTo(100, 10))
}
```

View File

@ -21,12 +21,11 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.HalfSlice([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}))
fmt.Println(piscine.HalfSlice([]int{1, 2, 3}))
fmt.Println(HalfSlice([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}))
fmt.Println(HalfSlice([]int{1, 2, 3}))
}
```

View File

@ -23,15 +23,16 @@ Here is a possible program to test your function:
```go
package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.HashCode("A"))
fmt.Println(piscine.HashCode("AB"))
fmt.Println(piscine.HashCode("BAC"))
fmt.Println(piscine.HashCode("Hello World"))
fmt.Println(HashCode("A"))
fmt.Println(HashCode("AB"))
fmt.Println(HashCode("BAC"))
fmt.Println(HashCode("Hello World"))
}
```

View File

@ -24,16 +24,15 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.IsCapitalized("Hello! How are you?"))
fmt.Println(piscine.IsCapitalized("Hello How Are You"))
fmt.Println(piscine.IsCapitalized("Whats 4this 100K?"))
fmt.Println(piscine.IsCapitalized("Whatsthis4"))
fmt.Println(piscine.IsCapitalized("!!!!Whatsthis4"))
fmt.Println(piscine.IsCapitalized(""))
fmt.Println(IsCapitalized("Hello! How are you?"))
fmt.Println(IsCapitalized("Hello How Are You"))
fmt.Println(IsCapitalized("Whats 4this 100K?"))
fmt.Println(IsCapitalized("Whatsthis4"))
fmt.Println(IsCapitalized("!!!!Whatsthis4"))
fmt.Println(IsCapitalized(""))
}
```

View File

@ -23,13 +23,12 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.IsSameString("hello world!", "HELLO WORLD!"))
fmt.Println(piscine.IsSameString("0101 is awesome", "0101 is AWESOME"))
fmt.Println(piscine.IsSameString("foo baz", "foo bar"))
fmt.Println(IsSameString("hello world!", "HELLO WORLD!"))
fmt.Println(IsSameString("0101 is awesome", "0101 is AWESOME"))
fmt.Println(IsSameString("foo baz", "foo bar"))
}
```

View File

@ -25,15 +25,14 @@ package main
import (
"fmt"
"piscine"
)
func main() {
a1 := []int{0, 1, 2, 3, 4, 5}
a2 := []int{0, 2, 1, 3}
result1 := piscine.IsSorted(f, a1)
result2 := piscine.IsSorted(f, a2)
result1 := IsSorted(f, a1)
result2 := IsSorted(f, a2)
fmt.Println(result1)
fmt.Println(result2)

View File

@ -27,14 +27,12 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.MultOrSum([]int{1, 2, 3, 4}, 3))
fmt.Println(piscine.MultOrSum([]int{1, 2, 3, 4}, 0))
fmt.Println(piscine.MultOrSum([]int{1, -2, 3, 4}, 0))
fmt.Println(MultOrSum([]int{1, 2, 3, 4}, 3))
fmt.Println(MultOrSum([]int{1, 2, 3, 4}, 0))
fmt.Println(MultOrSum([]int{1, -2, 3, 4}, 0))
}
```

View File

@ -23,15 +23,13 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Print(piscine.PrintIfNot("abcdefz"))
fmt.Print(piscine.PrintIfNot("abc"))
fmt.Print(piscine.PrintIfNot(""))
fmt.Print(piscine.PrintIfNot("14"))
fmt.Print(PrintIfNot("abcdefz"))
fmt.Print(PrintIfNot("abc"))
fmt.Print(PrintIfNot(""))
fmt.Print(PrintIfNot("14"))
}
```

View File

@ -6,7 +6,6 @@ Write a function `QuarterOfAYear()` that takes an `int`, from 1 to 12, as an arg
- If the number is not between 1 and 12 return `-1`.
### Expected function
```go
@ -24,17 +23,17 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.QuarterOfAYear(2))
fmt.Println(piscine.QuarterOfAYear(5))
fmt.Println(piscine.QuarterOfAYear(9))
fmt.Println(piscine.QuarterOfAYear(11))
fmt.Println(piscine.QuarterOfAYear(13))
fmt.Println(piscine.QuarterOfAYear(-5))
fmt.Println(QuarterOfAYear(2))
fmt.Println(QuarterOfAYear(5))
fmt.Println(QuarterOfAYear(9))
fmt.Println(QuarterOfAYear(11))
fmt.Println(QuarterOfAYear(13))
fmt.Println(QuarterOfAYear(-5))
}
```
And its output:

View File

@ -23,14 +23,12 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.RectPerimeter(10, 2))
fmt.Println(piscine.RectPerimeter(434343, 898989))
fmt.Println(piscine.RectPerimeter(10, -2))
fmt.Println(RectPerimeter(10, 2))
fmt.Println(RectPerimeter(434343, 898989))
fmt.Println(RectPerimeter(10, -2))
}
```

View File

@ -23,14 +23,12 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.RemoveDuplicate([]int{1, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10}))
fmt.Println(piscine.RemoveDuplicate([]int{1, 1, 2, 2, 3}))
fmt.Println(piscine.RemoveDuplicate([]int{}))
fmt.Println(RemoveDuplicate([]int{1, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10}))
fmt.Println(RemoveDuplicate([]int{1, 1, 2, 2, 3}))
fmt.Println(RemoveDuplicate([]int{}))
}
```

View File

@ -25,14 +25,13 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(solutions.RetainFirstHalf("This is the 1st halfThis is the 2nd half"))
fmt.Println(solutions.RetainFirstHalf("A"))
fmt.Println(solutions.RetainFirstHalf(""))
fmt.Println(solutions.RetainFirstHalf("Hello World"))
fmt.Println(RetainFirstHalf("This is the 1st halfThis is the 2nd half"))
fmt.Println(RetainFirstHalf("A"))
fmt.Println(RetainFirstHalf(""))
fmt.Println(RetainFirstHalf("Hello World"))
}
```

View File

@ -27,14 +27,13 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.RevConcatAlternate([]int{1, 2, 3}, []int{4, 5, 6}))
fmt.Println(piscine.RevConcatAlternate([]int{1, 2, 3}, []int{4, 5, 6, 7, 8, 9}))
fmt.Println(piscine.RevConcatAlternate([]int{1, 2, 3, 9, 8}, []int{4, 5}))
fmt.Println(piscine.RevConcatAlternate([]int{1, 2, 3}, []int{}))
fmt.Println(RevConcatAlternate([]int{1, 2, 3}, []int{4, 5, 6}))
fmt.Println(RevConcatAlternate([]int{1, 2, 3}, []int{4, 5, 6, 7, 8, 9}))
fmt.Println(RevConcatAlternate([]int{1, 2, 3, 9, 8}, []int{4, 5}))
fmt.Println(RevConcatAlternate([]int{1, 2, 3}, []int{}))
}
```

View File

@ -25,13 +25,12 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Print(piscine.ReverseSecondHalf("This is the 1st half This is the 2nd half"))
fmt.Print(piscine.ReverseSecondHalf(""))
fmt.Print(piscine.ReverseSecondHalf("Hello World"))
fmt.Print(ReverseSecondHalf("This is the 1st half This is the 2nd half"))
fmt.Print(ReverseSecondHalf(""))
fmt.Print(ReverseSecondHalf("Hello World"))
}
```

View File

@ -13,6 +13,7 @@ func SaveAndMiss(arg string, num int) string {
}
```
### Usage
Here is a possible program to test your function:
@ -22,16 +23,15 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.SaveAndMiss("123456789", 3))
fmt.Println(piscine.SaveAndMiss("abcdefghijklmnopqrstuvwyz", 3))
fmt.Println(piscine.SaveAndMiss("", 3))
fmt.Println(piscine.SaveAndMiss("hello you all ! ", 0))
fmt.Println(piscine.SaveAndMiss("what is your name?", 0))
fmt.Println(piscine.SaveAndMiss("go Exercise Save and Miss", -5))
fmt.Println(SaveAndMiss("123456789", 3))
fmt.Println(SaveAndMiss("abcdefghijklmnopqrstuvwyz", 3))
fmt.Println(SaveAndMiss("", 3))
fmt.Println(SaveAndMiss("hello you all ! ", 0))
fmt.Println(SaveAndMiss("what is your name?", 0))
fmt.Println(SaveAndMiss("go Exercise Save and Miss", -5))
}
```

View File

@ -29,15 +29,14 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.SetSpace("HelloWorld"))
fmt.Println(piscine.SetSpace("HelloWorld12"))
fmt.Println(piscine.SetSpace("Hello World"))
fmt.Println(piscine.SetSpace(""))
fmt.Println(piscine.SetSpace("LoremIpsumWord"))
fmt.Println(SetSpace("HelloWorld"))
fmt.Println(SetSpace("HelloWorld12"))
fmt.Println(SetSpace("Hello World"))
fmt.Println(SetSpace(""))
fmt.Println(SetSpace("LoremIpsumWord"))
}
```

View File

@ -23,13 +23,11 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.SliceAdd([]int{1, 2, 3}, 4))
fmt.Println(piscine.SliceAdd([]int{}, 4))
fmt.Println(SliceAdd([]int{1, 2, 3}, 4))
fmt.Println(SliceAdd([]int{}, 4))
}
```

View File

@ -23,14 +23,12 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.SliceRemove([]int{1, 2, 3}, 2))
fmt.Println(piscine.SliceRemove([]int{4, 3}, 4))
fmt.Println(piscine.SliceRemove([]int{}, 1))
fmt.Println(SliceRemove([]int{1, 2, 3}, 2))
fmt.Println(SliceRemove([]int{4, 3}, 4))
fmt.Println(SliceRemove([]int{}, 1))
}
```

View File

@ -6,7 +6,6 @@ Write a function that takes a `string` as an argument and returns a `boolean`.
- If the `string` equals `True`, `T` or `t` return `true`, otherwise return `false`.
### Expected function
```go
@ -24,14 +23,13 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.StringToBool("True"))
fmt.Println(piscine.StringToBool("T"))
fmt.Println(piscine.StringToBool("False"))
fmt.Println(piscine.StringToBool("TTFF"))
fmt.Println(StringToBool("True"))
fmt.Println(StringToBool("T"))
fmt.Println(StringToBool("False"))
fmt.Println(StringToBool("TTFF"))
}
```

View File

@ -23,13 +23,12 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.SwapFirst([]int{1, 2, 3, 4}))
fmt.Println(piscine.SwapFirst([]int{3, 4, 6}))
fmt.Println(piscine.SwapFirst([]int{1}))
fmt.Println(SwapFirst([]int{1, 2, 3, 4}))
fmt.Println(SwapFirst([]int{3, 4, 6}))
fmt.Println(SwapFirst([]int{1}))
}
```

View File

@ -2,7 +2,7 @@
### Instructions
Write a function that takes as an argument a slice of integers and return another slice of integers with the last two elements swapped.
Write a function that takes as an argument a slice of integers and return another slice of integers with the last two elements swapped.
> If the slice contains less than two elements return the same slice.
@ -23,13 +23,12 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.SwapLast([]int{1, 2, 3, 4}))
fmt.Println(piscine.SwapLast([]int{3, 4, 5}))
fmt.Println(piscine.SwapLast([]int{1}))
fmt.Println(SwapLast([]int{1, 2, 3, 4}))
fmt.Println(SwapLast([]int{3, 4, 5}))
fmt.Println(SwapLast([]int{1}))
}
```

View File

@ -25,14 +25,13 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Print(piscine.ThirdTimeIsACharm("123456789"))
fmt.Print(piscine.ThirdTimeIsACharm(""))
fmt.Print(piscine.ThirdTimeIsACharm("a b c d e f"))
fmt.Print(piscine.ThirdTimeIsACharm("12"))
fmt.Print(ThirdTimeIsACharm("123456789"))
fmt.Print(ThirdTimeIsACharm(""))
fmt.Print(ThirdTimeIsACharm("a b c d e f"))
fmt.Print(ThirdTimeIsACharm("12"))
}
```

View File

@ -24,14 +24,12 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.WeAreUnique("foo", "boo"))
fmt.Println(piscine.WeAreUnique("", ""))
fmt.Println(piscine.WeAreUnique("abc", "def"))
fmt.Println(WeAreUnique("foo", "boo"))
fmt.Println(WeAreUnique("", ""))
fmt.Println(WeAreUnique("abc", "def"))
}
```

View File

@ -25,14 +25,13 @@ package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Print(piscine.WordFlip("First second last"))
fmt.Print(piscine.WordFlip(""))
fmt.Print(piscine.WordFlip(" "))
fmt.Print(piscine.WordFlip(" hello all of you! "))
fmt.Print(WordFlip("First second last"))
fmt.Print(WordFlip(""))
fmt.Print(WordFlip(" "))
fmt.Print(WordFlip(" hello all of you! "))
}
```

View File

@ -23,7 +23,6 @@ package main
import (
"fmt"
"piscine"
)
func main() {