Adrian Lita

Blog

Below you can find a list of my blog posts. Some of the most used keywords found in posts:

#snippet 4 #academic 3 #strings 2 #string 2 #counter 1 #ubuntu18 1 #binary-counter 1 #combinations 1 #heap 1 #permutation 1 #xor 1 #xorswap 1 #variables 1 #swapping 1 #32bit 1 #embedded 1 #c 1 #fast-sqrt 1 #sqrt 1 #files 1 #apache2 1 #mysql 1 #cron 1 #bash 1 #backup 1

 
Latest posts with keyword binary-counter:

Generating all combinations of a string using the binary counter method

By: Adrian Lita

Published on: 2018-06-26

Keywords: #combinations #string #strings #binary-counter #academic #snippet #counter

 

Generating all k-combinations of n elements can be done in various ways. Here I'm preseting to you, for academic purpose, the binary counter method. First of all, let's calculate how many k-combinations of n exists: /* Calculates kCn kCn = n!/(k! * (n-k)!) */ unsigned int total_combinations(int n, int k) { //error if (k > n) { return 0; } unsigned int c = 1; //final result //check which one is greater,...

Read More >