From d438e5f04a7626c0376bb7eff5cbb732deb3894c Mon Sep 17 00:00:00 2001 From: estlop Date: Fri, 8 Jul 2022 09:02:34 +0100 Subject: [PATCH] docs: Write readme for multorsum subject --- subjects/multorsum/README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 subjects/multorsum/README.md diff --git a/subjects/multorsum/README.md b/subjects/multorsum/README.md new file mode 100644 index 000000000..10a4a3942 --- /dev/null +++ b/subjects/multorsum/README.md @@ -0,0 +1,35 @@ +## multorsum + +### Instructions + +Write a function that receives a slice of int and and int representing the initial value. If the int is odd it should multiply the accumulated value. If it is even, it should be added instead. Return the result. If the slice is empty return 0. + +### Expected function + +```go +func MultOrSum(ints []int, init int) { +} +``` + +### Usage + +Here is a possible program to test your function : + +```go +package main + +func main() { + 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 )) +} +``` + +And its output : + +```console +$ go run . | cat -e +19$ +10$ +-2$ +```