diff --git a/SOLUTIONS/BeginnerProblem2.go b/SOLUTIONS/BeginnerProblem2.go new file mode 100644 index 00000000..7eef1f5d --- /dev/null +++ b/SOLUTIONS/BeginnerProblem2.go @@ -0,0 +1,36 @@ +package main + +import "fmt" + +func main() { + // - input number of iteration + I := 0 + fmt.Scanf("%d", &I) + for i := 0; i < I; i++ { + fmt.Printf("Iteration#%d\n", i+1) + N := 0 + arr := []int{} + fmt.Scanf("%d", &N) + + // - input number to check + for j := 0; j < N; j++ { + tmp := 0 + fmt.Scanf("%d", &tmp) + arr = append(arr, tmp) + } + // - print out result + res := divBy2(arr) + fmt.Printf("Output#%d: %d\n\n", (i + 1), res) + } + +} + +func divBy2(arr []int) (counter int) { + for i := 0; i < len(arr); i++ { + if arr[i]%2 == 0 { + counter++ + } + } + + return +} diff --git a/SOLUTIONS/FizzBuzz.go b/SOLUTIONS/FizzBuzz.go new file mode 100644 index 00000000..8307f097 --- /dev/null +++ b/SOLUTIONS/FizzBuzz.go @@ -0,0 +1,26 @@ +package main + +import "fmt" + +func main() { + I := 0 + fmt.Scanf("%d", &I) + for i := 0; i < I; i++ { + fmt.Printf("Iteration#%d\n", i+1) + N := 0 + fmt.Scanf("%d", &N) + + for n := 1; n <= N; n++ { + if n%3 == 0 && n%5 == 0 { + fmt.Println("FizzBuzz") + } else if n%3 == 0 { + fmt.Println("Fizz") + } else if n%5 == 0 { + fmt.Println("Buzz") + } else { + fmt.Println(n) + } + } + } + +}