[Question]
  [
Our boolean operators are `AND`, `OR`, `XOR`, `NAND`, `NOR`, `XNOR` and, in conjunction with one of those operators, `NOT`.
Our numbers are \$1\$ and \$0\$.
The challenge is to write a program or function that calculates the results of the input.
## Input
A string, array or other input format of your choice; containing alternating numbers and operators, e.g. `1 NOR 1` or `["1","OR","0","AND","1"]` or `0XOR0XNOR1`.
**As an exception, `NOT` must always come directly after another operator (e.g. `0 AND NOT 1`).**. You can't implement `NOT` by itself, and you won't ever get a chain of multiple NOTs (so `1 AND NOT NOT 0` is an invalid input).
The input must contain the *strings* for the operators (upper or lower-case is fine); no other representation can be used e.g. `.+^¬||&&` etc.
## Output
Return or print a single number (\$1\$ or \$0\$), derived using the calculation below. Invalid input can lead to any output you choose, or none.
## Calculation
We're ignoring any precedence rules here - just calculate them in the order they come in (i.e. left-to-right) - as if someone was typing it into a calculator and pressing Enter after each number. `NOT` is the only one that might cause some difficulties with that logic, as you need to figure out what it's `NOT`-ing before you can apply the other operator.
## Truth Tables
```
INPUT   OUTPUT
A   B   AND NAND OR NOR XOR XNOR
0   0    0   1   0   1   0   1
0   1    0   1   1   0   1   0
1   0    0   1   1   0   1   0
1   1    1   0   1   0   0   1
IN OUT
A  NOT A
0    1
1    0
```
## Examples
* `1 NOR 1` = `0`
* `1 NOR NOT 0` = `0` (equivalent to \$1\$ NOR \$1\$)
* `1 NOR NOT 0 AND 1` = `0` (equivalent to \$0\$ (from above) AND \$1\$)
* `1 NOR NOT 0 AND 1 OR 1` = `1` (equivalent to \$0\$ (from above) OR \$1\$)
* `1 NOR NOT 0 AND 1 OR 1 XNOR 1` = `1` (equivalent to \$1\$ (from above) XNOR \$1\$)
* `1 NOR NOT 0 AND 1 OR 1 XNOR 1 NAND 0` = `1` (equivalent to \$1\$ (from above) NAND \$1\$)
* `1 NOR NOT 0 AND 1 OR 1 XNOR 1 NAND 0 XOR NOT 0` = `0` (equivalent to \$1\$ (from above) XNOR NOT \$0\$ = \$1\$ XNOR \$1\$ = \$0\$)
## Scoring
This is code-golf, but with a twist.
Your score is the number of bytes in your code, *divided by* the number of operators your code implements. Smallest score wins.
For example, if you only implement `AND`, your score is the number of bytes of your code.
If you implement `AND`, `OR`, `XOR`, `NAND`, `NOR`, `XNOR`, `NOT` (the full list of operators); then you get to divide the number of bytes by 7.
You must implement at least one operator, and you cannot implement `NOT` by itself; as it *must* be preceded by another, different operator and so doesn't count as implemented otherwise.
*Just because someone has a low score already, don't let that put you off trying to get the best score for your language! It would be interesting to compare across different numbers of implemented operators too - e.g. you might have a bad score for 2 operators, but you might be able to implement 7 really efficiently.*
  
[Answer]
# [Python](https://docs.python.org/3/), 3 bytes ÷ 1 op = score 3
```
min
```
[Try it online!](https://tio.run/##K6gsycjPM/6fZhvzPzcz7395RmZOqoKhVUFRZl6JRppGallijkZmXkFpiYYmEPyPVjJQiuUCkToKSo5@LiDKEIsIuiyyiAEKGyKLrgabCPGyOHUBAA "Python 3 – Try It Online")
Implements `AND`, with inputs like `["1", "AND", "0", "AND", "0"]`. Simply takes the smallest string value, which is "0" if present and "1" otherwise. Since "AND" is later alphabetically, it can be ignored.
Another solution is `all`, using inputs like `[1, "AND", 0, "AND", 0]` since only `0` is Falsey. Python 2 could also do `min` with such inputs, since it has numbers as smaller than strings, whereas Python 3 refuses to compare them.
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 1 byte ÷ 2 = 0.5
```
v
```
[Try it online!](https://tio.run/##K6gsyfj/v@z/fyVDhcS8FIW8/BIFCMtQ6V9@QUlmfl7xf90UAA "Pyth – Try It Online")
This works for `and` and `not`. Works by evaluating the input as python code
[Answer]
# [Python 3](https://docs.python.org/3/), ~~16~~ 4 bytes / 2 = 2 score
```
eval
```
[Try it online!](https://tio.run/##K6gsycjPM/6fZhvzP7UsMed/QVFmXolGmoaSoUJiXoqCoZKmJheaWF5@iYIBirgBDnEk9XDT/gMA "Python 3 – Try It Online")
This works for `and` and `not` in any combinations. It partially works for `or` but only when not used in conjunction with `and` in certain cases due to operator precedence in Python. As such cases exist, my official score will only be divided by two (if half-points are allowed, this could maybe be divided by 2.5 instead to get a final score of 1.6)
[Answer]
Sorry to report that the task is trivial in some language, but anyway here it is.
# [J](http://jsoftware.com/), 2 bytes, score 2 ÷ 1 = 2
```
".
```
[Try it online!](https://tio.run/##y/qvpKegnqZga6WgrqNgoGAFxLp6Cs5BPm5Amf@a/w2AAoZA6OjnAmYBMRdMzD8IQygCSSxNQR2iD0qqcwEA "J – Try It Online")
Implements any one of AND, OR, or XOR. The three are defined in the J standard library as infix functions, so calling `".` (eval) on the string automagically evaluates the given expression as-is. The only problem is that J evaluates from right to left, so the three cannot be used at once.
Since it is boring, here are some attempts at adding features one at a time:
# [J](http://jsoftware.com/), 10 bytes, score 10 ÷ 3 = 3.33
```
[:".|.&.;:
```
[Try it online!](https://tio.run/##y/qvpKegnqZga6WgrqNgoGAFxLp6Cs5BPm7/o62U9Gr01PSsrf5r/jcAShgCoaOfC5gFxFwwMf8gDKEIJLE0BXWIPiipjiwCVogkYgAVAQA "J – Try It Online")
Implements all of AND, OR, and XOR. Since all six operators (except NOT) are symmetric, in order to fix the evaluation order, it suffices to reverse the order of words.
```
[:".|.&.;:  NB. Input: the expression with space-separated tokens
            NB. Example input '1 AND 1 XOR 0'
      &.;:  NB. Split into words ['1', 'AND', '1', 'XOR', '0']
    |.      NB. Reverse the order of words ['0', 'XOR', '1', 'AND', '1']
      &.;:  NB. Join the words back, with spaces in between '0 XOR 1 AND 1'
[:".        NB. Eval it
```
At this point, adding a feature is a matter of defining a named infix function.
# [J](http://jsoftware.com/), 18 bytes, score 18 ÷ 4 = 4.5
```
NOR=:+:
[:".|.&.;:
```
[Try it online!](https://tio.run/##y/r/388/yNZK24or2kpJr0ZPTc/a6n@arRUyT0HdUAGoSsFAIQJEqgMA "J – Try It Online")
Adds NOR (`+:`) to the list.
# [J](http://jsoftware.com/), 26 bytes, score 26 ÷ 5 = 5.2
```
XNOR=:=
NOR=:+:
[:".|.&.;:
```
[Try it online!](https://tio.run/##y/r/P8LPP8jWypYLTGlbcUVbKenV6KnpWVv9T7O1QuYpqBsqgFQrGChEAElDdQA "J – Try It Online")
Adds XNOR (`=`) to the list.
# [J](http://jsoftware.com/), 35 bytes, score 35 ÷ 6 = 5.83
```
NAND=:*:
XNOR=:=
NOR=:+:
[:".|.&.;:
```
[Try it online!](https://tio.run/##y/r/38/Rz8XWSsuKK8LPP8jWypYLTGlbcUVbKenV6KnpWVv9T7O1QuYpqBsqgFQrGChEAElDdQA "J – Try It Online")
Adds NAND (`*:`) to the list.
Using the same strategy to add NOT is a bit more tricky, since the word order would look like `1 NOT AND 1` instead of `1 AND NOT 1`, and it should negate the number on its left. I solved it by making it a "conjunction", which has higher precedence over regular functions or "verbs" and consumes two tokens on the both sides of it. It is defined as
```
NOT=:2 :'y v-.u'
```
and it evaluates like this: given `0 NOT AND 1`, `u`, `v`, `y` become `0`, `AND`, `1` respectively, and `y v-.u` becomes `1 AND -. 0` (where `-.` is a prefix function for logical negation), successfully negating the number on its left before applying the infix function.
# [J](http://jsoftware.com/), 52 bytes, score 52 ÷ 7 = 7.43
```
NOT=:2 :'y v-.u'
NAND=:*:
XNOR=:=
NOR=:+:
[:".|.&.;:
```
[Try it online!](https://tio.run/##y/r/388/xNbKSMFKvVKhTFevVJ3Lz9HPxdZKy4orws8/yNbKlgtMaVtxRVsp6dXoqelZW/1Ps7VC5imoGyoAVQFxiIKBAlC/gqECkGuoADICSIGMBEpEwJSoc5kaqZoDAA "J – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), score: 1 (1 [byte](https://github.com/Adriandmen/05AB1E/wiki/Codepage), 1 operator)
```
ß
```
Input as a list of strings for each digit/operator.  
Implements `AND`.
Port of [*@xnor*'s Python answer](https://codegolf.stackexchange.com/a/207094/52210).
[Try it online](https://tio.run/##yy9OTMpM/f//8Pz//6MNdZQc/VyUdAxgdCwA) or [verify a few more test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfeX/w/P/6/yPjlYyVNJRSsxLAZKGSrE6yHwDMN8ATd4ATR5ZP26TkGRiAQ).
**Explanation:**
```
ß    # Pop the (implicit) input-list and leave its minimum,
     # which is "0" if the input contains a "0", or "1" otherwise
     # (after which this is output implicitly as result)
```
---
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), score: ~7.857 (55 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage), 7 operators)
```
1ÝÂ„€– ìs:„€ƒ€—#„nxvDyìì}„&~SD'_«ì'^õšD'_«ìì:#ðš2ôí˜J.V
```
Input is a single lowercase string.  
Implements all 7 operators.
[Try it online](https://tio.run/##yy9OTMpM/f/f8PDcw02PGuY9alrzqGGywuE1xVYQ3rFJYKEpykBuXkWZS@XhNYfX1AI5anXBLurxh1YfXqMed3jr0YVQzuE1VsqHNxxdaHR4y@G1p@d46YUBDVfIyy8C4hIFA4XEvBQFQwUg11ChIg9M5YGEDBQqYEoA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9TVmmvpPCobZKCkn3lf8PDcw83PWqY96hpzaOGyQqH1xRbQXjHJoGFpigDuXkVZS6Vh9ccXlML5KjVBbuoxx9afXiNetzhrUcXQjmH11gpH95wdKHR4S2H156e46UX9l/nv6FCXn6RgiEXhM7LL1EwQGYrJOaloMpCRBTQNSEJK1TkEZZVyAMJGRClSKECpgQA).
**Explanation:**
***Step 1:*** Replace the `not 1`/`not 0` with `0`/`1` respectively:  
I.e. `1 nor not 0 and 1 or 1 xnor 1 nand 0 xor not 0` is converted to `1 nor 1 and 1 or 1 xnor 1 nand 0 xor 1`.
```
1Ý                   # Push list [0,1]
  Â                  # Bifurcate it (short for Duplicate & Reverse copy): [1,0]
   „€–               # Push dictionary string "not "
       ì             # Prepend it in front of both: ["not 1","not 0"]
        s            # Swap so the [0,1] is at the top of the list again
         :           # Replace all ["not 1","not 0"] with [0,1] in the (implicit) input
```
***Step 2:*** Replace all other operations `xnor`/`xor`/`nand`/`nor`/`and`/`or` with `^_`/`^`/`&_`/`~_`/`&`/`~` respectively:  
I.e. `1 nor 1 and 1 or 1 xnor 1 nand 0 xor 1` is converted to `1 ~_ 1 & 1 ~ 1 ^_ 1 &_ 0 ^ 1`.
```
„€ƒ€—                # Push dictionary string "and or"
     #               # Split it on spaces: ["and","or"]
      „nx            # Push string "nx"
         v           # Loop `y` of its characters:
          D          #  Duplicate the list at the top of the stack
           yì        #  Prepend the current letter to each string in the list
             ì       #  Prepend-merge the lists together
         }           # Stop the loop. We now have the list:
                     #  ["xnand","xnor","xand","xor","nand","nor","and","or"]
„&~                  # Push string "&~"
   S                 # Convert it to a list of characters: ["&","~"]
    D                # Duplicate it
     '_«            '# Append "_" to each: ["&_","~_"]
        ì            # Prepend-merge it: ["&_","~_","&","~"]
         '^         '# Push "^"
           õš        # Convert it to a list, and prepend an empty string: ["","^"]
             D       # Duplicate it
              '_«   '# Append "_" to each: ["_","^_"]
                 ì   # Prepend-merge it: ["_","^_","","^"]
                  ì  # Prepend-merge it: ["_","^_","","^","&_","~_","&","~"]
:                    # Replace all ["xnand","xnor","xand","xor","nand","nor","and","or"]
                     # with ["_","^_","","^","&_","~_","&","~"]
```
`&~^` are builtins for bitwise AND, OR, and XOR respectively. And `_` is the `==0` builtin (which converts `0` to `1` and vice-versa).
***Step 3:*** Convert it to Reverse Polish notation:  
I.e. `1 ~_ 1 & 1 ~ 1 ^_ 1 &_ 0 ^ 1` is converted to `1 1~_1&1~1^_0&_1^`.
```
 #                   # Split the string by spaces
  ðš                 # Prepend a leading " " to the list
    2ô               # Split the list into parts of size 2
      í              # Reverse each pair
       ˜J            # Flattened join everything together
```
***Step 4:*** Execute/evaluate it as 05AB1E code, and output the result:  
I.e. `1 1~_1&1~1^_0&_1^` results in `0`.
```
         .V          # Evaluate/execute it as 05AB1E code
                     # (after which the result is output implicitly)
```
[See this 05AB1E tip of mine (section *How to use the dictionary?*)](https://codegolf.stackexchange.com/a/166851/52210) to understand why `„€–`  is `"not "` and `„€ƒ€—` is `"and or"`.
[Answer]
# [Python 2](https://docs.python.org/2/), score 15.714 (~~132~~ ... ~~114~~ 110 bytes, 7 operators)
Input is a single string with lowercase operators.
```
b=c=d=49
for a in input().replace('t ','a').split():a=hash(a);c,d=[a|d,a&d,a^d^1][b%65%3]^b%45,c;b=a
print~c&1
```
[Try it online!](https://tio.run/##jU7LisMwDLz7K3RJnUAozfYBbfGxvfayt9KAbKskbLCN6rIpLPvrWYcuZR@XgoRGMyM04RYb714G4y0pKeWglVFWLdbi7BkQWpcqXGNeTJlCh4ZyGUGWEmUxvYSuTcoGVYOXJsdia0qrjvhhS5ykrm1dnY46Wy2z@anW2WJZmq1WKAK3Ln6aSTWkl0K8N21H8MpX2giAyLdxAFBPBsZgYsSGQoTdYb9j9nw3aCZ8G2QFLmWtpPhGzkeY/d4Anf3ruHPw//SHAL17Rgc3UrMnbdA/Qn4B "Python 2 – Try It Online")
The code uses the following numbers produced by Python 2's `hash` function:
```
+--------+----------------------+-----+--------+--------+
| string |    h=hash(string)    | h&1 | h%65%3 | h%45&1 |
+--------+----------------------+-----+--------+--------+
| and    |  1453079729200098176 |     |      0 |      0 |
| nand   | -4166578487142698835 |     |      0 |      1 |
| or     |    14208085359128317 |     |      1 |      0 |
| nor    |  5261102140395498078 |     |      1 |      1 |
| xor    | -5999452984713080668 |     |      2 |      0 |
| xnor   |   485507670233933377 |     |      2 |      1 |
|        |                      |     |        |        |
| 0      |           6144018481 |   1 |        |        |
| 1      |           6272018864 |   0 |        |        |
| noa0   | -4166584487129698722 |   0 |        |        |
| noa1   | -4166584487129698721 |   1 |        |        |
+--------+----------------------+-----+--------+--------+
```
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), ~~43~~ 36 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319 "When can APL characters be counted as 1 byte each?") ÷ 6 = 6
Thank you user41805 for the idea of combining definitions that are negations of each other and to tsh for noticing stray spaces.
```
DNAN←~DNA←∧ 
RON←~RO←∨ 
ROX←~RONX←=
⍎⌽
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///38XP0e9R24Q6IA2kHnUs5wryBwsE@YP5K4D8CAjfD0Tbcj3q7XvUs/d/GkgayOxqftS75lHvlkPrjR@1TXzUNzU4yBlIhnh4Bv9PU1A3VPDzD1IwVOfCzlZw9HPBJqKAXSFYWCHCj7Csgh9IyIAoRQoRYPMA "APL (Dyalog Unicode) – Try It Online")
Since APL is right-to-left, we define the functions with reversed names, then reverse the expression (`⌽`) and execute it (`⍎`).
---
# [APL (Dyalog Unicode)](https://www.dyalog.com/), ~~57~~ 50 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319 "When can APL characters be counted as 1 byte each?") ÷ 7 = 7.14
Thank you user41805 for the idea of combining definitions that are negations of each other and to tsh for noticing stray spaces.
```
DNAN←~DNA←∧ 
RON←~RO←∨ 
ROX←~RONX←=
TON←{⍵ ⍵⍵~⍺⍺}
⍎⌽
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///38XP0e9R24Q6IA2kHnUs5wryBwsE@YP5K4D8CAjfD0TbcoWA5asf9W5VAGIgqnvUuwuIarke9fY96tn7Pw2kEcjsan7Uu@ZR75ZD640ftU181Dc1OMgZSIZ4eAb/T1NQN1Tw8w9SMFTngrP9/EMUDND5Co5@LpiqIKIK2AxAklKI8CNOhYIfSMiAaIUKEXDnAgA "APL (Dyalog Unicode) – Try It Online")
Since APL is right-to-left, we define the functions with reversed names, then reverse the expression (`⌽`) and execute it (`⍎`). NOT (`TON`) requires special treatment. We define it as a dyadic operator (`{`…`}`) because this makes it bind stronger to its operands. We then negate the left (original right) operand (`~⍺⍺`) and apply the right operand (`⍵⍵` — originally on its left) with the right argument (`⍵` originally from its left) as left argument. The arguments' sides doesn't matter since all functions are commutative.
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 1 byte ÷ 1 = 1
```
e
```
[Try it online!](https://tio.run/##y0osKPn/P/X//2hDHQUlRz8XJR0FJFYsAA "Japt – Try It Online")
Implements only `and`. Works by checking if every element in the input has a truthy value.
[Answer]
# [FEU](https://github.com/TryItOnline/feu), 33 bytes, 2 operations, score 16.5
```
m/NOT 0/1/NOT 1/0/.*1.*/1/[^1]+/0
```
[Try it online!](https://tio.run/##S0st/f8/V9/PP0TBQN8QTBvqG@jraRnqaQH50XGGsdr6Bv//Gyr4BymAZQE "FEU – Try It Online")
Implements `NOT` and `OR`
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 84 bytes, score 12
```
NOT0
1
NOT1
0
^(0A|1NO|(0NA|1O))[A-Z]+.
$#2
}`^(1A|0O|0XO|1XN)[A-Z]+
}`^.[A-Z]+
NOT
```
[Try it online!](https://tio.run/##jYyxCsJQDEX3fEVAhRSxJP7BA@cEpMNDsT4HBxcH6Ri//flKW2hddLqXc27yuneP5y1viJqE6ZrVGgaBEgIMLXFwUXNiLcWq6hx2p8u2hvVqD@/UkgRnc47mEnW00Jt67OVTzoJqRxQYsiDkecegh6UdCH4fzTBG/W1Re8R/jTBOkw8 "Retina 0.8.2 – Try It Online") Link includes test suite that deletes spaces from the input for the convenience of the user. Explanation:
```
NOT0
1
NOT1
0
```
Handle the NOT operator.
```
^(0A|1NO|(0NA|1O))[A-Z]+.
$#2
```
`0 AND` and `1 NOR` are always `0`, while `0 NAND` and `1 OR` are always `1`, regardless of the RHS.
```
}`^(1A|0O|0XO|1XN)[A-Z]+
```
`1 AND`, `0 OR`, `0 XOR` and `1 XNOR` leave the RHS unchanged. Repeat the above operations until an operation that inverts the RHS is reached.
```
}`^.[A-Z]+
NOT
```
Replace this operation with a `NOT` and loop around to start processing operations again.
[Answer]
# [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 2 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319 "When can APL characters be counted as 1 byte each?") ÷ 1 = 2
```
~⍲
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn/v@5R76b/aY/aJjzq7XvU1fyod82j3i2H1hs/apv4qG9qcJAzkAzx8Az@n6ZgoKCemJeiDqcNuRBihkhihljUGaKrAwA "APL (Dyalog Extended) – Try It Online")
`⍲` (nand) returns 1 if and only if argument has a 0 anywhere (it ignores all other data)
`~` negates that
---
# [APL (dzaima/APL)](https://github.com/dzaima/APL), 2 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319 "When can APL characters be counted as 1 byte each?") ÷ 1 = 2
```
1∊
```
[Try it online!](https://tio.run/##SyzI0U2pSszMTfyf9qhtgsZ/w0cdXf81/6cpGCio5xepwykuuIghQsQQQ40hqpp/@QUlmfl5xf91iwE "APL (dzaima/APL) – Try It Online")
Simply asks *is there any 1 in the argument?*
[Answer]
# [Perl 5](https://www.perl.org/), 86 bytes / 7 operators = 12.29
```
s/not/!/g;s/\d//;$\=1*$1;$\=eval"$\ $_"=~s/(.*?[^a])n(.*)/!($1$2)/r for/.*?\d/g}{$\|=0
```
[Try it online!](https://tio.run/##FY3LCsMgFER/xYS7iIHkaiGbBMkPtMuualuEpkEQFZVS6OPTa83qDHMYxi/BDDlHtC5hhesUUd4QJ5CCt8A3Lg9lapAErrX4Rmz6dj5d1JnakihWDXDYUQzk7gIWV@br5wXyLVjOnLhAGHnagvJA2M/5pJ2NuTvsdUzjeEzaCK902KqhZ5zlzv8B "Perl 5 – Try It Online")
# [Perl 5](https://www.perl.org/), 9 bytes / 3 operators (`or`, `xor`, `not`) = 3
```
$_=0|eval
```
[Try it online!](https://tio.run/##K0gtyjH9/18l3tagJrUsMef/f0OFxLwUhbz8EgUDhYr8IgVDBRDxL7@gJDM/r/i/bgEA "Perl 5 – Try It Online")
[Answer]
# JavaScript (ES7), 77 bytes / 7 operators = 11
Expects a string with no separator, such as `"1NORNOT0"`.
```
f=s=>1/s?s:f(s.replace(/..*?\d/,s=>10142470953/2**(parseInt(s,36)%873%34)&1))
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/f8/zbbY1s5Qv9i@2CpNo1ivKLUgJzE5VUNfT0/LPiZFXwcka2BoYmRibmBpaqxvpKWlUZBYVJzqmVeiUaxjbKapamFurGpsoqlmqKn5Pzk/rzg/J1UvJz9dI01DydDPP8hQSVNTAR/Q11cw4MKi0c8/xACvXnwaHf1ccFtMSCNORwM1GhLQGIHVy8Rq9ANyUDxNksYIpEAD@fE/AA "JavaScript (Node.js) – Try It Online")
Or try [all possible sub-expressions](https://tio.run/##ZdDLCoJAFAbgfU9xNjUzaqOm3bEIatHGIFoE1WKysQviiEfaRM9uI12hzfnhfD8zcC7iKjDKz1nRTNVBlmUcYDBybRzjIKbIc5klIpLU5twYbw@2Vanj@i2/6/Tbnt0yDJqJHOU8LShaXofVe12v7vms4TJWDjdkEk6JBWSxrOb6GeFrGb62Ve54rPKZiE5UZRCM4FYD2JBna/WjqSrerAuOBe7XxFf@bP9rAAgBCDBBf2ZC9aYJ@@FHI5WiSiRP1JGiJqLbRKc@CWPv2p3VPqHHnZUP).
### How?
We use a recursive function to simplify the input string `s` until we get a single digit. When this happens, `1/s` is either `1` or `Infinity`, which are both truthy.
As long as `s` still contains at least one operator, we use the following regular expression to isolate the next sub-expression:
```
/..*?\d/
 .         a single character (must be 0 or 1)
  .*?      followed by several characters, non-greedily
     \d    followed by a digit
```
We use this hash function (which was brute-forced) to get the result of the sub-expression and replace it in `s`:
```
10142470953 / 2 ** (parseInt(s, 36) % 873 % 34) & 1
```
[Answer]
# SimpleTemplate, 361 bytes ÷ 4 operators = 90.25
It is a very big piece of code, but was very challenging!
```
{@fnP S}{@fnT.AND a,b}{@ifa}{@ifa is equalb}{@return1}{@/}{@/}{@return"0"}{@/}{@fnT.OR a,b}{@incbyb a}{@ifa}{@return1}{@/}{@return"0"}{@/}{@fnT.XOR a,b}{@ifa is equalb}{@return1}{@/}{@return"0"}{@/}{@whileS matches"@([01])(AND|X?OR)(NOT)?([01])@"P}{@callT.[P.2]intoR P.1,P.4}{@ifP.3}{@setT 1,0}{@setR T.[R]}{@/}{@callstr_replace intoS P.0,R,S}{@/}{@returnS}{@/}
```
This implements the AND, OR, XOR and NOT operators.
This was entirely implemented **without** using `AND`, `OR` and `XOR`, as those don't exist in my language, at all!
It was even more challenging due to a bug in the compiler, where `{@return 0}` returns null ... :/ 6 bytes right there ...
---
You can try it on: <http://sandbox.onlinephpfunctions.com/code/cb1855c48e83924bd7c81f4cda95f032c23b4abe>
---
**Usage:**
Simply call the function P and pass a single string without spaces.
Returns either 0 or 1, or the whole string for invalid inputs.
Example:
```
{@call P into result "1ORNOT0"}
{@echo result}
```
---
**Ungolfed:**
Since this is a massive mess, I've also prepared an human readable version:
```
{@fn parse string}
    {@fn this.AND a, b}
        {@if a}
            {@if a is equal to b}
                {@return 1}
            {@/}
        {@/}
        {@return "0"}
    {@/}
    
    {@fn this.OR a, b}
        {@inc by b a}
        {@if a}
            {@return 1}
        {@/}
        {@return "0"}
    {@/}
    
    {@fn this.XOR a, b}
        {@if a is equal to b}
            {@return 1}
        {@/}
        {@return "0"}
    {@/}
    
    {@while string matches "@([01])(AND|X?OR)(NOT)?([01])@" pieces}
        {@call this.[pieces.2] into result pieces.1, pieces.4}
        {@if pieces.3}
            {@set tmp 1, 0}
            {@set result tmp.[result]}
        {@/}
        {@call str_replace into string pieces.0, result, string}
    {@/}
    
    {@return string}
{@/}
```
This works exactly the same way, except the function is called "parse".
---
---
**Alternative**:
Below is a SUPER boring one that has EVERYTHING pre-calculated, but has a score of 276/7 = 39.428571428571... (428571 is recurring).
```
{@fnP S}{@setL.AND"001"}{@setL.NAND"110"}{@setL.OR"011"}{@setL.NOR"100"}{@setL.XOR"010"}{@setL.XNOR"101"}{@whileS matches"@([01])(N?AND|X?N?OR)(NOT)?([01])@"P}{@ifP.3}{@setT"10"}{@setP.4 T.[P.4]}{@/}{@incbyP.4 P.1}{@callstr_replace intoS P.0,L.[P.2].[P.1],S}{@/}{@returnS}{@/}
```
It implements all operators, but ... It is kinda cheating...
Below it the ungolfed version:
```
{@fn parse string}
    {@set table.AND 0, 0, 1}
    {@set table.NAND 1, 1, 0}
    {@set table.OR 0, 1, 1}
    {@set table.NOR 1, 0, 0}
    {@set table.XOR 0, 1, 0}
    {@set table.XNOR 1, 0, 1}
    
    {@while string matches "@([01])(N?AND|X?N?OR)(NOT)?([01])@" pieces}
        {@if pieces.3}
            {@set tmp 1, 0}
            {@set pieces.4 tmp.[pieces.4]}
        {@/}
        {@inc by pieces.4 pieces.1}
        {@set values table.[pieces.2]}
        {@call str_replace into string pieces.0, values.[pieces.1], string}
    {@/}
    
    {@return string}
{@/}
```
[Answer]
# [sed](https://www.gnu.org/software/sed/), 8 bytes ÷ 1 = 8
```
/0/c0
c1
```
[Try it online!](https://tio.run/##K05N0U3PK/3/X99AP9mAK9nw/39DhcS8FAUDMInCBgA "sed – Try It Online")
Implements only `and`.
## Explanation
```
/0/c0   # Set contents of line to 0 if line contains 0
c1      # Otherwise set contents to 1
```
[Answer]
# Haskell, \$225 \div 4 = 56.25\$
```
b(_:'A':'0':s)=b('0':s)
b(c:'A':_:s)=b(c:s)
b(_:'O':'1':s)=b('1':s)
b(c:'O':_:s)=b(c:s)
b('N':'0':s)=b('1':s)
b('N':_:s)=b('0':s)
b('0':'X':'0':s)=b('0':s)
b('1':'X':'1':s)=b('0':s)
b(_:'X':_:s)=b('1':s)
b x=x
f=(b.map(!!0))
```
Defines a function `f`, which given a list of the format `["1","AND","0"]` returns either `"1"` or `"0"`. Implements `AND`, `OR`, `NOT`, and `XOR`.
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 62 bytes ÷ 6 = 10.33
```
Boole@ToExpression[Capitalize@#~StringRiffle~"~"]/.a:0|1:>a>0&
```
[Try it online!](https://tio.run/##PYvNCoJAFEZf5TKCKyndGokUCUWLSHfDLIacqQvjXNEJpB9f3Uyp3cc536mku6lKOrzIQcN62BAZlRa06@pGtS2S5VtZo5MGHyr1@tw1aK9n1NqonvVMLBcyDl9RnMgk9IfTaB0vaL5xL4C9re8uo6YSAbAYWACae0KAD8sUMjLlEVvHD4Q2gLnKa4OOP1kElhqIxoJJW87jB7q/sl8XTmxCbyFWwwc "Wolfram Language (Mathematica) – Try It Online") Pure function. Takes a list of lowercase strings as input and returns 0 or 1 as output. Supports every operation except NOT.
---
### [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 87 bytes ÷ 7 = 12.43
```
Boole@ToExpression@StringReplace[Capitalize@#~StringRiffle~"~","t~"->"t@"]/.a:0|1:>a>0&
```
[Try it online!](https://tio.run/##PYtPS8NAEMW/yjCBnlabXCOGpWJB8SC2t2UPQ7vRgc3OkowQ/JOvHtNWPTze473360jfQkfKB5pbuJ03IjHYvdyPuQ/DwJLsTntOry8hRzoEd0eZlSJ/BFtMvxO3bQwTTmhQJ7xqUC369TXV5VdVN9SUq/l5Oarby4VwhYGHlN91K33nDWANaKB1hfewgrWFrcTjEw/qHoWTgQu1y5HVfWIFSfpFCuVCIaUjVKewlGcf019Kp@18Gv@Jb@9v5h8) Similar to the previous solution, but it also supports NOT.
---
### [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 15 bytes ÷ 1 = 15
```
Boole@*FreeQ[0]
```
[Try it online!](https://tio.run/##RcqxCsIwGEXhV7kkUFQCVrspQnAodFPsFjIE/VsLTVLSdCp99pjN7eNwrIlfsiYOb5M63NLd@5HkoQ5ET1Xq9AiDi6r1r5jRKy7QuGmJtQ9WC7ALmECnuNYocJTYrflgxn1y5uc/qw3FHlJKtMs00qzWUuC0CVT6mn4) Function. Takes a list of strings and integers as input and returns 0 or 1 as output. Only supports AND.
[Answer]
# [JavaScript (V8)](https://v8.dev/), 141 bytes ÷ 7 operators, score 20.14
```
f=i=>'01'[i]||f(i.replace(/NOT./,n=>'10'[n[3]]).replace(/(.)(..)\D*(.)/,(_,a,o,b)=>({AN:a&b,OR:a|b,XO:a^b,NA:a&b^1,NO:(a|b)^1,XN:a^b^1})[o]))
```
[Try it online!](https://tio.run/##jVXxb5pAFP65/hXPxnh3G0PZfthCZxvTdsmSBhZdMhKK66Fg6QgQwG6L8re7d6ACCl1NlPO77/vee8fduyf@zJN57EXpu@dP26078kaXZKgQ07M2G5d6cuxEPp87dKDp3@WBFOC0MiRmYH6wLFbOUplRWWb3N29wNJDoT4lLoWSz0SVdjzWV921Jn6h8Y0uGrvKZLWljAc4USdNVijjDoaGJqZmSMTO0GNu6q2CeemEAqZOk1AuiVSqB8ydy5qmz0Fcp/mew7gB@5mGQpBDmGIzALdjsojK5F@I0XQ9VMiQSKCpR8OFyP3FUyKE0XomhQjCLeiyr6hbxJEGn0nQ02oUvWaHvyH64pA@9dU6/AgLwbTydEsAIBnwZf70jGeSpotd5b50Ps/OHXeKeC7QrpPsyj52JAPY5qKRcHazjb@SE7gHYOTYa8Hm64r4KgAZFDQd58XcnzvLf2ElXcZAvwEUn63R8J4XfYfzLC5Z6JNbExIXqmDnXJBzG2g3Y6Nw5o1wCm8HoEjj0wbakA0efNFA2NYrRyJnVOFpTrC7No7Eqr8FL0DZ1mtHGm9V5Iioej8Yqu0dlNvM2dZ7RSpzViVpb6KLo7knVbdzNEdd4iTxrM85XgrfZY0K8XSUW51hKa1qGw/8ZFImfpkAbrBgWwtnrDNu21kvOTbvuZfvWF/@KQPutYcluGN/y@SOlZhhhb8Mmakng5T5FFxEnVhxfZzH2fTywouUVJxylQMU0Bzz85hA7pMVK1K6iZUcqvfqjolfj1JmYCaPyiuCDpYTJloAtALsCgAAIYdJeLnIvFqFzVutBojFWovbBg8/wkVX6kBytkkcaRijL8Nup9eP74EdBBD1yYi7umEQF2ltX9L4TLNPHjIleXBVXKE@hF1ByHxAGbyF/7gKl2GMXzl3uIG4jOQ2naYwqyna@KKA12Avm/mrhJJS4FP2u4D3eEcOTzK/RFwpjpkJvXcbJHo7JZHqtT27FrVDJZgAnNR7rMIEhbschvgjYjZXdWKngSoEfLY8Q6JODVp8cpCWq5GiD0KgojYq0givGXrz9Bw "JavaScript (V8) – Try It Online")
Takes input as a string with capitalised operators and no padding, like `0AND1OR0`.
Recursively calculates the next value based on the first two characters of the operator. (not before replacing `NOT`s with their counterparts)
[Answer]
# [Japt](https://github.com/ETHproductions/japt) v2.0a0, 36 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1) ÷ 7 ≈ 5.14
```
e/..*?\d/@1&#e4#÷0953÷2pXn36 %873%34
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=2.0a0&code=ZS8uLio/XGQvQDEmI2U0I/cwOTUz9zJwWG4zNiAlODczJTM0&input=IjFOT1JOT1QwQU5EMU9SMVhOT1IxTkFORDBYT1JOT1QwIg)  
[Try all testcases](https://petershaggynoble.github.io/Japt-Interpreter/?v=2.0a0&flags=LW0&code=ZS8uLio/XGQvQDEmI2U0I/cwOTUz9zJwWG4zNiAlODczJTM0&input=WyIxTk9SMSIsICIxTk9STk9UMCIsICIxTk9STk9UMEFORDEiLCAiMU5PUk5PVDBBTkQxT1IxIiwgIjFOT1JOT1QwQU5EMU9SMVhOT1IxIiwgIjFOT1JOT1QwQU5EMU9SMVhOT1IxTkFORDAiLCAiMU5PUk5PVDBBTkQxT1IxWE5PUjFOQU5EMFhPUk5PVDAiXQ)  
[Try all possible sub-expressions](https://petershaggynoble.github.io/Japt-Interpreter/?v=2.0a0&flags=LW0&code=ZS8uLio/XGQvQDEmI2U0I/cwOTUz9zJwWG4zNiAlODczJTM0&input=WyIwQU5EMCIsICIwQU5EMSIsICIxQU5EMCIsICIxQU5EMSIsICIwQU5ETk9UMCIsICIwQU5ETk9UMSIsICIxQU5ETk9UMCIsICIxQU5ETk9UMSIsICIwT1IwIiwgIjBPUjEiLCAiMU9SMCIsICIxT1IxIiwgIjBPUk5PVDAiLCAiME9STk9UMSIsICIxT1JOT1QwIiwgIjFPUk5PVDEiLCAiMFhPUjAiLCAiMFhPUjEiLCAiMVhPUjAiLCAiMVhPUjEiLCAiMFhPUk5PVDAiLCAiMFhPUk5PVDEiLCAiMVhPUk5PVDAiLCAiMVhPUk5PVDEiLCAiME5BTkQwIiwgIjBOQU5EMSIsICIxTkFORDAiLCAiMU5BTkQxIiwgIjBOQU5ETk9UMCIsICIwTkFORE5PVDEiLCAiMU5BTkROT1QwIiwgIjFOQU5ETk9UMSIsICIwTk9SMCIsICIwTk9SMSIsICIxTk9SMCIsICIxTk9SMSIsICIwTk9STk9UMCIsICIwTk9STk9UMSIsICIxTk9STk9UMCIsICIxTk9STk9UMSIsICIwWE5PUjAiLCAiMFhOT1IxIiwgIjFYTk9SMCIsICIxWE5PUjEiLCAiMFhOT1JOT1QwIiwgIjBYTk9STk9UMSIsICIxWE5PUk5PVDAiLCAiMVhOT1JOT1QxIl0)
A direct port of @Arnauld's [answer](https://codegolf.stackexchange.com/a/207143/91267) to Japt
## Explanation
```
e/..*?\d/@1&#e4#÷0953÷2pXn36 %873%34
e                                     // Repeatedly replace
 /..*?\d/                             // the regex /..*?\d/g with output of
         @                            // a function which takes the match as arg named X
          1&#e4#÷0953÷2pXn36 %873%34  // and returns 1 & 10142470953 / 2 ** (parseInt(X, 36) % 873 % 34)
```
The expression `1 & 10142470953 / 2 ** (parseInt(X, 36) % 873 % 34)` was brute-forced by @Arnauld
[Answer]
# [brainfuck](https://github.com/TryItOnline/brainfuck), 130 bytes / 1 operator = 130
`+>>+<,[------------------------------------------------[<->[-]]<[>>[-]<<-]><+>,]>++++++++++++++++++++++++++++++++++++++++++++++++.`
[Try it online!](https://tio.run/##nZJdSyMxFIavk1/x3mmprjPgxaLDgKwfFJYK9c6ikGYyNkyaUzKZ9ePPd09SxbruhRjCMJyc95znfCyCsr4ddLfZ3JgIZ9oIbZxDJJTYH3rToKUATT4GciM5rmWJAoUE7qVMmmAflp9F/BuTybasH3wDhWIk63GV5eVW/ptojbgMNDwsYf16iFDs6oi6nLU4xeRVf4LG6GBWxu9mlAdzjvcL5VECQg4qboZFDEpHHP9EG2gF1Wtrt/GlOEwH3/hKwZlWHDMlE2/JmC@Xbnt48i8m0C7ph36yai6FOP/wyoaKQwu@V4SF0l1yXdmmcSY3YxGM6kDcGmpTZ9bsWc8P76TgO7nE9Hp6ezG7lqJIfd2i3eeXrbncNWfedyiGLk/QfxpigX2XR8MkqjPoh2Bg416PVGDGmqAhv8fz0to2XIxy7hn0x4TW0eNIioqLrRNnVSXW@kusRd6sV9KZ6Xc3kkPy7v1bzsyoBt48sc9SpaGbcJp2LnM@qv5tef7TxQMp72Qtx@ngG98fm02Js@l5auFf "brainfuck – Try It Online")
Link is for a readable, commented version. Only implements `AND`. Although technically all it does is print `1` unless there is a `0` in your input, in which case it prints `0`. It might be possible to shorten this by replacing the spots where I add/subtract 48 times, but I'm lazy, so I'm going to leave it as is.
[Answer]
# [Scala](http://www.scala-lang.org/),  ~~183 bytes~~ 164 bytes / 7 ops = ~23.43
```
"OR".+(_).split("(?<=\\d)")./:(0>1){(b,o)=>val s=o.replace("NOT","")
val c=s!=o^(o.last>48)
s.count(_==78)==1^(if(s toSet 65)!(b&c)else if(s toSet 88)b^c
else b|c)}
```
[Try it online!](https://tio.run/##jY9Pa4NAEMXvforJEsoMDVahfyR0LSm91kDSQw7BsK6rWBZXsttSsH52axJahOaQ27zfezzeWCm06E32rqSDV1HVoL6cqnMLi6aB1vM@hYZyDmu3r@oSeAzPxmglauA9W66Yf4078m2jK4cMnx75dpsTI/9mjkEcUovZzBCPDy2WG3@vGi2kQpYs39iMMTr2S24n3KRofC2si28j8qwvzUftcMf5Q0SchylWBVpwZq0c3N/RBLMrSUpbBSMjiihLpXfE2bekrs9VAYP/@wEBh2Y4nK7Rsqkd5LQt0VI3bPEKZCEkyxWEg/oTw1YI/gFYJC9ncicMZztGHmySCyOQHFBweRI2o81e1/8A "Scala – Try It Online")
The operators are uppercase (whitespace doesn't matter), and the output is a `Boolean`.
]