How to Reverse Letters in Kotlin
The challenge
Given a string str, reverse it omitting all non-alphabetic characters.
Examples:
For str = "krishan", the output should be …
19 articles about kotlin development, tools, and best practices
Given a string str, reverse it omitting all non-alphabetic characters.
Examples:
For str = "krishan", the output should be …
Get the ASCII value of a character.
Option 1:
val getAscii = Char::toInt
Option 2:
fun getAscii(c: Char) = c.code …
Read Article →
Coroutines are a way to handle multithreading in Kotlin, read more about it from the official docs: …
Read Article →val pair: Pair<String, Int> = "myKey" to 2
A utility class when you want to return 2 values that are not related …
Read Article →There are times when you need to extract an object into a number of variables.
Let’s take the example below:
val (id, name, position, …
Read Article →
Unit corresponds to the void keyword in Java.
Unit in Kotlin?If you have a function that does not return a value, you can return a Unit …
Functions are reusable pieces of code, often called Blocks, that as the name suggests, act as building blocks to piece together a program.
Each …
Read Article →Among all the many keywords that Kotlin comes with, there exists val and var. What are they used for? What are the differences, and why would you use …
Your task is to construct a building which will be a pile of n cubes. The cube at the bottom will have a volume of n^3, the cube above …
Read Article →Consider the sequence U(n, x) = x + 2x**2 + 3x**3 + .. + nx**n where x is a real number and n a positive integer.
When n goes to …
Given a set of numbers, return the additive inverse of each. Each positive becomes negatives, and the negatives become positives. …
Read Article →A number system with moduli is defined by a vector of k moduli, [m1,m2, ···,mk].
The moduli must be pairwise co-prime, which means that, …
Given an array X of positive integers, its elements are to be transformed by running the following operation on them as many times as …
Read Article →Given
I = [l, u) (l is in interval I but u is not) l and u being floating numbers (0 <= l < u),Create an NxN multiplication table, of size provided in parameter.
for example, when given size is 3:
1 2 3
2 4 6
3 6 9
for given …
Read Article →Complete the solution so that it strips all text that follows any of a set of comment markers passed in. Any whitespace at the end of …
Read Article →Consider the sequence S(n, z) = (1 - z)(z + z**2 + z**3 + ... + z**n) where z is a complex number and n a positive integer (n > 0). …
Let us consider this example (array written in general format):
ls = [0, 1, 3, 6, 10]
Its following parts:
ls = [0, 1, 3, 6, 10]
ls = …
Read Article →
In mathematics, a Diophantine equation is a polynomial equation, usually with two or more unknowns, such that only the integer solutions …
Read Article →