Skip to main content
replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

Golf all the 16 logic gates with 2 inputs and 1 output!

This questionThis question asked for 16 independent functions. I would like the opposite: a single function that takes an additional parameter that specifies which of the 16 logic gates is required using an integer from 0 to 15. If you don't want to use a 0-based index of the list in the linked question then you should specify which integers map to which logic gate (but they should still be 0 to 15).

Examples:

 0,0,0  falsey
 1,0,1  falsey
 2,1,0  truthy
 3,1,1  truthy
 4,1,1  falsey
 5,0,1  truthy
 6,1,0  truthy
 7,0,0  falsey
 8,0,0  truthy
 9,0,1  falsey
10,1,0  truthy
11,1,1  truthy
12,1,1  falsey
13,0,1  truthy
14,1,0  truthy
15,0,0  truthy

This is , so the shortest answer in bytes wins.

Golf all the 16 logic gates with 2 inputs and 1 output!

This question asked for 16 independent functions. I would like the opposite: a single function that takes an additional parameter that specifies which of the 16 logic gates is required using an integer from 0 to 15. If you don't want to use a 0-based index of the list in the linked question then you should specify which integers map to which logic gate (but they should still be 0 to 15).

Examples:

 0,0,0  falsey
 1,0,1  falsey
 2,1,0  truthy
 3,1,1  truthy
 4,1,1  falsey
 5,0,1  truthy
 6,1,0  truthy
 7,0,0  falsey
 8,0,0  truthy
 9,0,1  falsey
10,1,0  truthy
11,1,1  truthy
12,1,1  falsey
13,0,1  truthy
14,1,0  truthy
15,0,0  truthy

This is , so the shortest answer in bytes wins.

Golf all the 16 logic gates with 2 inputs and 1 output!

This question asked for 16 independent functions. I would like the opposite: a single function that takes an additional parameter that specifies which of the 16 logic gates is required using an integer from 0 to 15. If you don't want to use a 0-based index of the list in the linked question then you should specify which integers map to which logic gate (but they should still be 0 to 15).

Examples:

 0,0,0  falsey
 1,0,1  falsey
 2,1,0  truthy
 3,1,1  truthy
 4,1,1  falsey
 5,0,1  truthy
 6,1,0  truthy
 7,0,0  falsey
 8,0,0  truthy
 9,0,1  falsey
10,1,0  truthy
11,1,1  truthy
12,1,1  falsey
13,0,1  truthy
14,1,0  truthy
15,0,0  truthy

This is , so the shortest answer in bytes wins.

Source Link
Neil
  • 177.2k
  • 20
  • 9

Golf all the 16 logic gates with 2 inputs and 1 output!

This question asked for 16 independent functions. I would like the opposite: a single function that takes an additional parameter that specifies which of the 16 logic gates is required using an integer from 0 to 15. If you don't want to use a 0-based index of the list in the linked question then you should specify which integers map to which logic gate (but they should still be 0 to 15).

Examples:

 0,0,0  falsey
 1,0,1  falsey
 2,1,0  truthy
 3,1,1  truthy
 4,1,1  falsey
 5,0,1  truthy
 6,1,0  truthy
 7,0,0  falsey
 8,0,0  truthy
 9,0,1  falsey
10,1,0  truthy
11,1,1  truthy
12,1,1  falsey
13,0,1  truthy
14,1,0  truthy
15,0,0  truthy

This is , so the shortest answer in bytes wins.