Counting bits or Hamming Weight

Counting bits, also known as the “Hamming Weight” or the “population count”, refers to counting the number of 1 bits in the binary representation of a number. This is a common problem in computer science, often used in various applications such as cryptography, algorithms, and network address calculation. In Kotlin, you can solve the counting … Read more

Swap Two variable using Bit Manipulation

Swapping two numbers using bit manipulation involves a technique that makes use of XOR (^) operator. The XOR operator has a unique property where if you XOR any number with itself, the result is 0, and if you XOR any number with 0, the result is the number itself. This property allows swapping without a … Read more

Pattern Printing in Kotlin.

What is pattern ? Pattern printing is a common exercise in programming and is useful for building logic and understanding loops. Pattern printing involves printing out various shapes or figures made up of symbols such as asterisks or spaces. There are several different types of pattern printing, including right triangles, pyramids, diamonds, and many more. … Read more