I'm looking for the best way to do this using python\excel\sql\google sheets - I need to find all rows which fits to k values from list of n values.
For example I have this table called Animals:
| Name | mammal | move | dive |
+----------+--------+--------+-------+
| Giraffe | 1 | 1 | 0 |
| Frog | 0 | 1 | 1 |
| Dolphin | 1 | 1 | 1 |
| Snail | 0 | 1 | 0 |
| Bacteria | 0 | 0 | 0 |
And I want to write a function foo that do behave like that:
foo(tuple of Boolean values, minimum matches)
foo((1,1,1),3) -> Dolphin
foo((1,1,1),2) -> Giraffe, Dolphin, Frog
foo((1,1,1),1) -> Giraffe, Dolphin, Frog, Snail
foo((1,1,0),2) -> Giraffe, Dolphin
foo((0,1,1),2) -> Dolphin, Frog
foo((0,1,1),1) -> Giraffe, Dolphin, Frog, Snail
foo((1,1,1),0) -> Giraffe, Dolphin, Frog, Snail, Bacteria
What's the best way you think about?