# 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

# Generate all possible combinations of the values in an array JS

I’ve been struggling to get my code to work, but I’m new to recursion and permutation, so couldn’t make it work, but what I would like to do is something to get all possible combinations of the values in an array, also including repeated values like "11". For instance, let’s say I have this array:… Read More Generate all possible combinations of the values in an array JS

# 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)

# Is it possible to combine a list of words in C# like this?

I want to create an array like this Array Input: {A, B, C} Output: {A, B, C}, {AB, C}, {A, BC}, {ABC} Array Input: {A, B, C, D} Output: {A, B, C, D}, {AB, C, D}, {ABC, D}, {AB, CD}, {ABCD}, {A, BC, D}, {A, BCD}, {A B CD} I was thinking about making it… Read More Is it possible to combine a list of words in C# like this?

# Remove character from a string and list all possible permutations

I’m trying to go through a string and every time I come across an asterisk (*) replace it with every letter in the alphabet. Once that is done and another asterisk is hit, do the same again in both positions and so on. if possible saving these permutations to a .txt file or just printing… Read More Remove character from a string and list all possible permutations

# 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?

# Recursion Function that prints all possible binary permutations

I am trying to write a recursive function that generates all binary permutations with a given input of the amount of ‘A’ and ‘B’ elements that a string should have. For example function(a, b) when a = 2 and b = 2 should generate: AABB ABAB ABBA BAAB BABA BBAA Would appreciate your help. Thanks!.… Read More Recursion Function that prints all possible binary permutations

# 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?

# DISTINCT, SUBSTR & MAX in Oracle Database

I have a table like below on which I want to return the distinct server name with max value of last 4 digits from all permutations in that table: ServerName APPQTV1234 IISLUG60DF XCCPTV401D SO basically I can get the unique combination using following query: select DISTINCT SUBSTR(ServerName,1,6) from MYTABLE; This gives me: ServerName APPQTV IISLUG… Read More DISTINCT, SUBSTR & MAX in Oracle Database