# Working out which logic gates need to go where

I have something as below featuring XOR, AND, OR, XNOR, NAND and NOR gates. I have to get the bottom 3 outputs set to 1. As you can see, I've managed to do it as below but was wondering out of the 720 possible combinations, how many are there actually? Am I missing some logic myself or is there an online resource to help?

For the benefit of this, the inputs remain the same. Only the position of the gates can change.

• Which "720 possible combinations"? Input combinations? Dec 18, 2021 at 15:49
• 6 gates as mentioned which is 6! combinations they can be in Dec 18, 2021 at 15:50
• There only 4 inputs. So you only have to worry about 2^4=16 input possibilities. Dec 18, 2021 at 15:52
• for such a small example, even an exhaustive search would be trivial.
– user16324
Dec 18, 2021 at 16:06
• @pee2pee Simply create every combination and test it (in VHDL or a Python script or whatever). If there were billions of combinations it wouldn't be trivial, of course, in terms of resources, but for fewer than a thousand...
– user16324
Dec 21, 2021 at 14:48

What I would do is use something called LogicFriday. By drawing out the circuit, the associated truth table can be generated to show all the combinations that meet the needed criteria

So there are 4 combinations which produce 0b111 output

Unfortunately the site did not renew the domain, but can still be found here: https://web.archive.org/web/20131022021257/http://www.sontrak.com/

With 4 input's there is 16 combinations that need to be scanned, this is viable by hand

• How would you do it for every combination of gate in the image/post? Dec 21, 2021 at 9:31
• For every combination of gates? Do you mean changing the physical gates or the inputs? Every combination of inputs is shown in the image within the truth table
– user16222
Dec 21, 2021 at 9:35
• Gates, hence the remark about 720 possible combinations as I think it'll be 6! Dec 21, 2021 at 9:42
• @JonRB It is a puzzle. Inputs and outputs are given and we have to find the permutations of the 6 gates in the 6 positions which, given the inputs, provide the desired outputs. So it is just a brute force search for all possible combinations/permutations. Dec 21, 2021 at 10:41