Number of combinations of bytes ordered by value

I can’t wrap my head around a mathematical question regarding combinations/permutations: 1 byte can store 256 possible combinations (2^8). 2 bytes can store 65536 possible combinations (2^16). 3 bytes can store 16777216 possible combinations (2^24). This works only, because I have all possible combinations for each byte. Given the requirement that the bytes need to… Read More Number of combinations of bytes ordered by value

How to form all possible combination of given digits to form a n-digit number without repetition of digits?(python)

Question Let say we have a list of given digits and n (to form n-digit number) digits = [0, 1, 2] n = 3 List digit can not contain duplicate values. How we can form all possible n digit numbers without repetition of digits. n can be any positive integer and list digits can have… Read More How to form all possible combination of given digits to form a n-digit number without repetition of digits?(python)

What is the relationship between the product function and the concept of permutations with repetitions?

from itertools import permutations,product,combinations_with_replacement colours = [‘r’,’g’,’b’] y = list(product(colours,repeat =2 )) x = list(combinations_with_replacement(colours,2)) print(y) print(x) I understand permutation of a set of objects is an ordering of those objects. When some of those objects are identical, the situation is transformed into permutations with repetition. >Solution : This may provide some insight: colours =… Read More What is the relationship between the product function and the concept of permutations with repetitions?

Optimizing finding a string that matches the characters in a substring in any order?

Assuming a list as follows: list_of_strings = [‘foo’, ‘bar’, ‘soap’, ‘sseo’, ‘spaseo’, ‘oess’] and a sub string to_find = ‘seos’ I would like to find the string(s) in the list_of_strings that: Have the same length as to_find Have the same characters as to_find (irresepective of the order of the characters) The output from the list_of_strings… Read More Optimizing finding a string that matches the characters in a substring in any order?

In R, how to use string values in one column to ID and select rows from another column in the same dataframe, varying per group?

I have a dataframe that contains all possible order permutations that participants could be presented with, and a column that contains a permutation ID (i.e. presentation order) that each individual participant actually was presented with. How do I use the permutation ID to select the values of the corresponding column for each participant? To illustrate… Read More In R, how to use string values in one column to ID and select rows from another column in the same dataframe, varying per group?