M sedek - 1 year ago 59

Python Question

Given two coins, the number of outcomes will be 2^2 (two coins with only two possibilities(head(up) or tail(down)). Gives the following possible combinations:

`00`

01

10

11

Where, 0 means head(up) and 1 means tail(down).

Here is the code to print the previous combinations:

`for n=1:2^2`

r(n) = dec2bin(n);

end

What I want to do is to print all the possible combinations for the same two coins but with three different possibilities (head(up), tail(down) and in between (not up or down))

To give something like:

`00`

01

10

11

0B

B0

B1

1B

BB

Where, " B " means one of the two coins is In between (not up or down)

Any Ideas ??

Thanks

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

Python solution:

```
from itertools import product
possible_values = '01B'
number_of_coins = 2
for result in product(possible_values, repeat=number_of_coins):
print(''.join(result))
# Output:
# 00
# 01
# 0B
# 10
# 11
# 1B
# B0
# B1
# BB
```

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**