Skip to content

sk67dev/KotlinChallenges

Repository files navigation

Kotlin Challenges 💻

KOTLIN CODING CHALLENGES This repository contains a set of Kotlin coding challenges together with the solutions. Kotlin Challenges Part 2 is here

Challenge Questions: All of the challenges are listed below.

Solutions: The links to solutions are provided below the questions.

CHALLENGES:

1. Add, Subtract, Multiply Or Divide: Write a function that takes two numbers and returns if they should be added, subtracted, multiplied or divided to get 24. If none of the operations can give 24, print a string to reflect this.

Solution

2. Area of triangle: Write a function that takes the base and height of a triangle and print its area.

Solution

3. Check Num: Have the function checkNum(num1,num2) take both parameters being passed and return the string true if num2 is greater than num1, otherwise return the string false. If the parameter values are equal to each other then return the string -1.

Solution

4. Compare Strings: Create a function that takes two strings as arguments and return either true or false depending on whether the total number of characters in the first string is equal to the total number of characters in the second string.

Solution

5. Concatenate Arrays: : Create a function to concatenate two integer arrays.

Solution

6. Count The Vowels: Create a function that takes a string and print the number of vowels contained within it.

Solution

7. Date & Time: 📅 - Print the current date and time in default format. - Print the current date and time in localised style. - Print the current date and time with a pattern.

Solution

8. Divisible by 5: Create a function that prints true if an integer is divisible by 5, and false otherwise.

Solution

9. Factorial: This challenge requires you to return the factorial of a given number. A factorial of a number (num), is num multiplied by (num-1) multiplied by (num-2) and so forth until you reach the number 1. For example, the factorial of 4 is 4 * 3 * 2 * 1 = 24. Loop from 1 to num, multiplying each number by the previous one, until you reach the number.

Solution

10. Fibonacci: The Fibonacci Sequence is a sequence of numbers whose sum is the two preceding numbers (e.g. 0, 1, 1, 2, 3, etc). Using 0 and 1 as the starting values, create a function that prints an array containing all of the Fibonacci numbers up to 10000.

Solution

11. FizzBuzz: Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.

Solution

12. Capitalize Letters: Create a function that converts the first character of each word to uppercase. Print the newly formatted string.

Solution

13. Multilpy and Skip: Print the multiples of 5 whilst skipping the multiples of 3.

Solution

14. NameChange:
Change your surname using a constructor, initializer block and object instance.

Solution

15. Palindrome: Given a string of text, print true or false indicating whether or not the text is a palindrome. A palindrome is a word, number, or other sequence of characters which reads the same backward as forward, such as "madam" or "racecar". You can also create an int palindrome.

Solution

16. Remove Characters: Remove the first and last characters from a string.

Solution

17. Share the Pizza: 🍕 Create a function that determines whether or not it's possible to share the pizza fairly given these three parameters: Total slices, Recipients, Slices each. It's fine not to use the entire pizza (in real life though...not really! 😄 Print true if the pizza can be shared equally, otherwise print false.

Solution

18. Sum Elements of Array: Given an array of integers, find the sum of its elements. For example, if the array = [1,2,3,4,5,6,7,8,9,10] print the answer of 55 (1+2+3+4+5+6+7+8+9+10 = 55)

Solution

About

Kotlin Challenges

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages