I am having a difficulty in finding a way to access some list elements that are represented on a binary access pattern. What I mean is:
Suppose that we have a binary number Bin of 4 digits: Bin = 0b0000
We also have a list (or set or tuple, does not matter) of same length as Bin, lets say: list = [A, B, C, D]
Now, I want to combinatory access the elements that are represented by 1 in Bin meaning that as the counter increments +1 on each loop if we are at Bin = 0b0101 (which means Bin = 10) then I want to access the corresponding indices, hence B and D elements in the list.
Same goes until the loop ends when Bin = 0b1111 or Bin = 15 where I finally access all elements of list A, B, C, D.
Thanks in advance.
1in the number? Use an operator maybe?