diff --git a/src/main/kotlin/ru/otus/homework/fizzbuzz.kt b/src/main/kotlin/ru/otus/homework/fizzbuzz.kt index 6e04be1..3693a25 100644 --- a/src/main/kotlin/ru/otus/homework/fizzbuzz.kt +++ b/src/main/kotlin/ru/otus/homework/fizzbuzz.kt @@ -2,5 +2,18 @@ package ru.otus.homework fun fizzbuzz(n: Int): Array { - TODO("Выполните задание") -} \ No newline at end of file + + val list = mutableListOf() + + for(i in 0..n - 1){ + if ( i % 3 == 0 && i % 5 == 0) + list.add("FizzBuzz") + else if ( i % 3 == 0 ) + list.add("Fizz") + else if ( i % 5 == 0) + list.add("Buzz") + else + list.add(i.toString()) + } + return list.toTypedArray() +} diff --git a/src/main/kotlin/ru/otus/homework/sumoftwo.kt b/src/main/kotlin/ru/otus/homework/sumoftwo.kt index 70d72e5..8874cfa 100644 --- a/src/main/kotlin/ru/otus/homework/sumoftwo.kt +++ b/src/main/kotlin/ru/otus/homework/sumoftwo.kt @@ -2,5 +2,12 @@ package ru.otus.homework fun sumOfTwo(numbers: IntArray, target: Int): IntArray { - TODO("Выполните задание") -} \ No newline at end of file + val n = numbers.size + for (i in 0..n-1){ + for ( j in i+1..n-1){ + if( numbers[i] + numbers[j] == target) + return intArrayOf(i, j) + } + } + throw IllegalArgumentException() +}