/KotlinChallenges

Repository contains Kotlin coding challenges.

Primary LanguageKotlinApache License 2.0Apache-2.0

KotlinChallenges

Repository contains Kotlin coding challenges.

  1. Write a function that checks whether a string contains unique characters or not. Return the string reversed only if the string characters are unique, otherwise return null.

  2. Have the function String.ABCheck() receive String and return the string true if the characters a and b are separated by exactly 3 places anywhere in the string at least once (i.e. "lane borrowed" would result in true because there is exactly three characters between a and b). Otherwise, return the string false.

  3. Have the function Int.additivePersistence() receives an int which will always be a positive integer and returns its additive persistence which is the number of times you must add the digits in num until you reach a single digit and the final stop value. For example: if num is 2718 then your program should return 2 because 2 + 7 + 1 + 8 = 18 and 1 + 8 = 9, and you stop at 9 and loop count is 2.