How to Reverse Letters in Kotlin
The challenge
Given a string str
, reverse it omitting all non-alphabetic characters.
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.
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, …