diff --git a/src/main/kotlin/ru/otus/homework/fizzbuzz.kt b/src/main/kotlin/ru/otus/homework/fizzbuzz.kt index 6e04be1..9a89a9f 100644 --- a/src/main/kotlin/ru/otus/homework/fizzbuzz.kt +++ b/src/main/kotlin/ru/otus/homework/fizzbuzz.kt @@ -1,6 +1,18 @@ package ru.otus.homework - -fun fizzbuzz(n: Int): Array { - TODO("Выполните задание") +fun fizzbuzz(n: Int): Array{ + val array = Array(n){it} + val expectedArray = Array(n){""} + for (i in array) { + if (i%3==0) { + expectedArray[i] += "Fizz" + } + if (i%5==0) { + expectedArray[i] += "Buzz" + } + if (expectedArray[i] == "") { + expectedArray[i] = i.toString() + } + } + return expectedArray } \ No newline at end of file diff --git a/src/main/kotlin/ru/otus/homework/sumoftwo.kt b/src/main/kotlin/ru/otus/homework/sumoftwo.kt index 70d72e5..28f3644 100644 --- a/src/main/kotlin/ru/otus/homework/sumoftwo.kt +++ b/src/main/kotlin/ru/otus/homework/sumoftwo.kt @@ -1,6 +1,14 @@ package ru.otus.homework - fun sumOfTwo(numbers: IntArray, target: Int): IntArray { - TODO("Выполните задание") + + if (numbers.size<2) throw IllegalArgumentException() + + for (i in numbers.indices){ + for (j in i+1.. { + sumOfTwo(intArrayOf(2), 6) + } + } } \ No newline at end of file