Questions tagged [boolean-logic]
An algebraic system developed by George Boole. Uses operations such as "And", "Or" and "Not" on Binary True/False values. It may be used to accomplish complex tasks.
1,795
questions
1
vote
0
answers
12
views
How to complete the truth table for a JK flip flop? And why? [migrated]
I saw this question, but am unsure how to solve it. I have tried various approaches and get some of the answers correct, but never all of them...so my method is obviously wrong
For example, what ...
0
votes
0
answers
36
views
Can MongoDB query (A AND B) OR (C AND D) with any mix of text and structured clauses?
I'm developing a search app that allows users to combine arbitrary combinations of structured and unstructured clauses with Boolean logic in a graphical editor.
I have it working with an elasticsearch ...
-3
votes
0
answers
38
views
The condition within the while statement
How can I write a condition that fulfills the same condition as inside the while clause without using a <stdbool.h>
void show_path(int a[][5])
{
int i = 0;
int j = 0;
int cost = 0;
cost = a[j][...
0
votes
1
answer
21
views
Does Python implement short-circuiting in built-in functions such as min()?
Does Python 3 implement short-circuiting in built-in functions whenever possible, just like it does for boolean statements?
A specific example, take the below code snippet:
min((20,11), key = lambda x ...
0
votes
1
answer
30
views
Calculating the time length of each binary/boolean column as reference
I have two columns. One is listed as True/False for a series of data. The entire dataset also has a timestep column. I want to write code that can read when the Boolean column changes to true, the ...
-3
votes
1
answer
46
views
Python why this if statement returns True?
I am wondering why it returns True:
if False or True and True == True and (False == True or False == (not True)) or False and False and True:
pass
doesn't it accept "and False" part in ...
-2
votes
0
answers
18
views
F=A.[B+C.(A.B+A.C)']. Simplify the following boolean expression
BOOLEAN ALGEBRA-:
Simplify the following Boolean expression. Mention the laws used at each step during simplification.
A.[B+C(A.B+A.C)']
= A.[B+C.(A'+B'.A'+C')]
-2
votes
0
answers
13
views
Boolean Algebra: (𝐴𝐵′ + 𝐴′𝐶)′. (𝐴 + 𝐶)
can anyone help me simplify (𝐴𝐵′ + 𝐴′𝐶)′. (𝐴 + 𝐶) using Boolean laws. My friend told me the answer is AB, this is for my assignment.
0
votes
0
answers
54
views
Understanding John McAfee's note about a seemingly novel, yet simple, anomaly in the XOR operation?
John McAfee (the founder of McAfee anti virus company) has two tweets (first and second) in which he shares a seemingly novel note about an anomaly in XOR operation. I understand how XOR operation ...
0
votes
0
answers
7
views
What is this quote about Boolean algebra?
It may have been George Boole himself who said it, but I can't find it anymore. It went something to the effect of, "Boolean algebra is the perfect system because it uses the universal numbers of ...
1
vote
1
answer
25
views
Conditional formatting: color a cell based on a comparison with another cell
Consider the following table in Google Sheets:
| A | B | C
----+---------+-------+--------
1 | product | price | target
2 | apple | 5 | 6
3 | pear | 7 |...
-2
votes
0
answers
43
views
why does 2 == true equate to false if nonzero numbers are truthy? [duplicate]
why do nonzero numbers equate to true if nonzero numbers are truthy?
For example, the following oddly prints.
'c == true is false'
if (c == true) {
console.log('c == true is true');
} else {
...
0
votes
1
answer
45
views
Extract values from Boolean Query
I want to extract values/variables from boolean query
For e.g
The boolean query is:
("Asset Data Management") AND "Data Scientist" AND ("Data Science & Analysis" OR &...
0
votes
0
answers
28
views
How to Simplify this Boolean Expression X' Y' Z + X' Y Z' + X Y' Z' + X Y Z
D = X' Y' Z + X' Y Z' + X Y' Z' + X Y Z
= Z (X' Y' + X Y) + Z'(X Y' + X' Y)
This is where I got so far..., please I would like to ask for some help on how to properly simplify this expression since ...
0
votes
1
answer
23
views
How To return the true condition only of a result on a list in r?
I have a problem with my R code.
Here, I have a list named bought_list with lists of customer and checkout (checkout is a data frame),
And this how checkout lists looks like:
items price qty ...
0
votes
1
answer
20
views
Conditional column value calculation, zip code to lat/long
I need help trying to figure out how to do this in R. I don't know how to generate latitude and longitude from zip code data so I am stuck on the first part.
I have a df that looks like:
ID
ZIP code
...
0
votes
2
answers
24
views
Unknown syntax error when coding boolean logic
I am trying to make a BMI calculator but keep getting a syntax error for line 6 every time I run it. Line 5 is similar and runs with no problem. I recently made the BMI variable a float and an integer ...
-1
votes
1
answer
47
views
Can anyone tell me why my program is giving me a output of fizz9 instead of just fizz? [duplicate]
Can anyone tell me why my program is giving me a output of fizz9 instead of just fizz?
import java.util.Scanner;
/**
* Write a description of class fizzbuzz here.
*
* @author (your name)
* @...
-1
votes
0
answers
36
views
Boolean expression not returning the expected value
Following the code to find the no. of instances when 2 elements from the array are removed while keeping the median of the whole array, the same in both the cases
#include <iostream>
using ...
2
votes
3
answers
73
views
Boolean logic using integers and strings
I want it to answer "true" if applicant meets all criteria, and "false" is they do not. This is what I have in VS:
namespace Boolean_Logic
{
class Program
{
...
-1
votes
0
answers
10
views
How to find the equivalent dual form of Boolean formula?
If I am given a Boolean formula F in SOP(sum of product), then I can get F’ by dualing and complement all the literals. But this complement is in POS form. Is there a possible way to get the ...
0
votes
1
answer
26
views
negating pandas isna function returning -2
I am a bit confused by inconsistency of how pd.isna() work in different settings. Any thoughts around why boolean not ~ doesn't work with pd.isna in number settings:
>>> import pandas as pd
&...
2
votes
1
answer
49
views
Rego regex to match a specific word from a sentence
I've written a regex
\blates(t|)?\b
to search for a word "latest" in a sentence "/man/service/man-aaaaaa-lllll-latest/zzzn2-iii-ooo-x00_00-gg".
I'm testing a rule in 'Rego' ...
0
votes
2
answers
49
views
Calculate total amount from Upwork after fee deduction using Python
I am trying to calculate total money after deduction of a Fee from Upwork. I found this website that does this but I want to make it using Python. Here is the guidelines from Upwork:
$0-$500 in ...
-2
votes
1
answer
64
views
to finishing the back-end algorithms for an application, the Boolean logic needs to be refreshed. Which of the following statements is true?
Prior to finishing the back-end algorithms for an application, the Boolean logic needs to be refreshed. Which of the following statements is true? O (4 < 5) and (6 > 7) O (1 == 2) or (2 == 2) O (...
2
votes
2
answers
69
views
Removing duplicates based on matching column values with boolean indexing
After merging two DF's I have the following dataset:
DB_ID
x_val
y_val
x01
405
407
x01
405
405
x02
308
306
x02
308
308
x03
658
658
x03
658
660
x04
None
658
x04
None
660
x05
658
660
x06
660
...
0
votes
0
answers
139
views
How can I swap variables in a BDD using Java BDD?
I am fairly new to BDD's and my goal is to be able to modify a BDD so that even-level variables disappear and odd-level variables are swapped for the ones that disappeared.
For example, I have the ...
1
vote
1
answer
470
views
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() - followed by a TypeError
I want to check if a dictionary already exists in a group of lists. Without the use of any() in the if-statement, I received the following error:
ValueError: The truth value of an array with more than ...
7
votes
1
answer
113
views
MISRA Violation 12.5 when using && and || in if-statement
I'm working on a project where we are appling MISRA 2004.
On most of the violations I got the reason, but one I don't understand:
Its in the if-statement with && and || operations.
Example:
...
0
votes
0
answers
49
views
How to convert the Boolean expression to Standard SoP form using Boolean Algebra based on given example?
How to convert the given Boolean expression to Standard SoP form using Boolean Algebra? Please show the calculation because I got confused
Z= AB’+C
0
votes
1
answer
60
views
Generating DIMACS CNF file using bc2cnf is missing AND
I tried using the bc2cnf tool to generate the DIMACS CNF file of a boolean equation.
The input file contains the equation of an AND gate as shown below :
BC1.1
f := A & B;
ASSIGN f;
Command used: ...
0
votes
2
answers
50
views
Change the value of a dataframe column to the value of a second column conditional on the value of a third column in pandas
I have data with current names of companies, old names, and the date of name changes. It looks like this:
name
former_name1
name_change_date1
ACMAT CORP
nan
NaT
ACME ELECTRIC CORP
nan
NaT
ACME ...
1
vote
3
answers
93
views
Can someone explain this JavaScript code please?
I am fairly beginner to JavaScript development and I would be obliged if someone could help explain this code to me.
m = function () {
let t = e.getCookie("cli-analytics"),
a = e....
1
vote
1
answer
44
views
IF TRUE then Variable name
I have a series of TRUE and FALSE variables representing search findings, ex: Cellphones, Knifes, Money, etc. My goal is to change the values TRUE for the name of the variable. Note that I would like ...
0
votes
1
answer
89
views
R. Display only TRUE values from a boolean expression?
Data science student here. New to R, in my first course. I've spent way too much time trying to figure out this exercise, so I figured I would ask someone on here.
I have created a dataframe built ...
0
votes
0
answers
50
views
Excel true to text
This excel function return true while I want it to be "Sam"
couldn't fix it any ideas ?
=OR(AND(R2=TRUE),AND(S2=TRUE),AND(T2=TRUE,"Sam","max"),AND(U2=TRUE))
2
votes
0
answers
46
views
The wonder of Boolean in python [duplicate]
The question is simple
>>> bull = False in [False] #Assigning value
>>> False == False in [False] #Note: Comparision is True
True
>>> False == bull #Que: Why not True?
False
...
-3
votes
2
answers
67
views
Shortcut for and/or evaluation
Is there a shortcut for the following evaluation? One where I do not need to specify value a twice?
(a && b || a && c)
Thank you. :)
-1
votes
2
answers
37
views
How do I create a simplified logic circuit of this given [(A’B’)’ + (A’+ B’)’]’ ? and What is the simplified Boolean expression?
I have to draw the simplified logic circuit of this given [(A’B’)’ + (A’+ B’)’]’ and also get the simplified boolean expression
0
votes
2
answers
159
views
Flutter Future<bool>, RX<bool>, and regular bool confusion and how to get the value of one from the other
I'm new to flutter and just learned about GetX so I'm trying to incorporate it into my app as much as possible. In this example I'm trying to get permissions for storage and have a widget reactive if ...
1
vote
1
answer
148
views
How to determine if two propositional formulas are equivalent in Prolog?
I'm new to Prolog and have some doubts.
I need to write a function form_equiv(A,B) that tells us if if B is equivalent to A
where A and B are supposed to be propositions.
I know that two propositions ...
0
votes
0
answers
15
views
comparing strings based only on the location in the file
I have two objects representing a string in the file (will call them new and old), i only have the string location (start & end line, start & end column). I want to know if the two strings ...
1
vote
1
answer
30
views
Distributivity of 'must' over 'should' in elasticsearch queries
I felt puzzled by this behavior while querying my index.
Whether you interpret it in a boolean fashion or as sets (OR being a union and AND being an intersection), I take for granted that X AND (Y OR ...
-1
votes
1
answer
39
views
error in logical function with booleans in C
I am learning to program in C and I am trying to do a basic function to light a candle, which consists of 3 scenarios: the candle is lit, the candle is out and I have a lighter, the candle is off and ...
0
votes
0
answers
76
views
Null coalescing operator in if-condition
I'm being confused as to how the null coalescing operator in PHP works and I'd like some explanation for the following if possible:
I have an associative array representing data posted to the server. ...
0
votes
1
answer
28
views
Construction of an AND Gate from NOR Gates
One of the alternate to getting the same output as an AND Gate, is to put together NOR gates. The operator for NOT gates is (A+B)', However there is a problem, I can't get the same output an AND gate ...
0
votes
0
answers
115
views
C++/C check and toggle a bool in single instruction
I am looking for a way in C++ bool type (or possibly C int), that checking (if statement) and editing the bool in a single instruction. Google search got me nowhere, maybe I am using wrong keywords.
...
0
votes
1
answer
100
views
Pandas create boolean column based on whether 3 column values are all negative or all positive
I have the following data frame,
f1 f2 f3 f4 f5 f6 f7
0 -0.004446 59.763107 x0 0 60.029999 59.160000 -0.014493
1 -0.003414 113.212220 x1 0 ...
-1
votes
1
answer
44
views
What's wrong with this list comprehension?
I have listA=[[0,1],[1,2]], and listB=[[0,1,2],[0,1,3],[0,2,3],[0,2,4]].
I want to find all elements b from listB such that b⊆a doesn't hold and a⊆b doesn't hold for all elements a from listA. Put it ...