1,074 questions
0
votes
1
answer
103
views
Problem faced in CP-SAT when using OnlyEnforceIf
I have the following excerpt from my Python code
For emp in employees:
Model.Add(d[emp] >= 25) .OnlyEnforceIf(d120[emp])
Model.Add(d[emp] < 25) .OnlyEnforceIf(d121[emp])
It is my ...
0
votes
0
answers
79
views
Why does R evaluate `NA==T|F` as NA, but `NA==F|T` as True? (and related Qs) [duplicate]
If you run the following lines of code in R, you may be surprised by the results (printed above each line as a comment)
#1: NA
NA==T
#2: NA
NA==F
#3: NA
NA==T&T
#4: FALSE
NA==F&F
#5: NA
NA==F&...
1
vote
2
answers
107
views
truthy values == false return true
So I am a beginner at javascript and learnt that there are only a limited falsy values: false, 0, -0, BigInt 0n, “”, null, undefined, NaN
Yet when I use the == operator with truthy values, this ...
0
votes
1
answer
45
views
Troubleshooting of Boolean combination of AND and OR conditions in Excel Formula [duplicate]
I am trying to set up an Excel conditional formula with both AND and OR criteria.
However, the last 2 criteria OR(Table1[Col5]=$J$4,Table1[Col5]=$K$4) and OR(Table1[Col6]=Pivot!$J$5,Table1[Col6]=Pivot!...
3
votes
2
answers
89
views
Odd boolean expression
I'm trying to debug (rewrite?) someone else's Python/cherrypy web app, and I ran across the following 'if' statement:
if not filename.endswith(".dat") and (
filename.endswith(".dat&...
0
votes
0
answers
58
views
Logical condition equivalent with restrictions
I am developing an Azure DevOps custom task. Part of the setting of the inputs is a VisibleRule which can contain a condition which will determine if the input will be visible, if the condition is ...
-2
votes
1
answer
46
views
Can a contradiction Boolean expression with variables 𝑎 and 𝑏 be represented in NAND form? [closed]
I have f(a,b) = 0 and want to represent it in NAND form (only using NAND gates) in terms of a and b, but I don't think is possible.
9
votes
0
answers
321
views
Limiting the depth of Boolean expressions
I am given a Boolean expression of arbitrary depth, like (A or (B and (C or (~D and E) or F) or (G and H))). There can be any number of terms at each level.
I want to limit the depth of the ...
0
votes
1
answer
122
views
In pytorch, how can I parallelize of a set of boolean functions that are executed (on a GPU) repeatedly?
I have a set of Boolean functions that are independent, and (hypothetically) can be executed in parallel. I want to call those same functions repeatedly. See the code below, in which the outputs of ...
0
votes
1
answer
47
views
Re-fomulate bitwise boolean expressions between register bits in terms of register values
Suppose we have two e.g. 32-bit input registers and one equally wide output register, with boolean functions linking individual bits of these registers. Is there a method to express these bitwise ...
1
vote
1
answer
91
views
How to simplify boolean expression given kmap
Can someone explain to me how to find the simplified boolean expression given the kmap below?
kmap
I'm grouping the 1's in the upper left corner, top row, and wrap-around in the fourth column but am ...
1
vote
2
answers
159
views
How to detect whether each element of a list of element-nodes does feature a specific css-class name?
Given the following test environment ...
const nodeList = document.querySelectorAll('p');
const testArray = Array.from(nodeList);
testArray.every(function (elmNode) {
if (elmNode.classList....
1
vote
2
answers
290
views
Simplify a boolean expression with 4 variables to 3 variables
I'm doing some simplifications for a circuit and I ended up getting the following expression:
A.C'.D' + A.B'.C' + B.C.D' + B'.C.D + A'.B'.D'
which translates to the truth table where 0, 2, 3, 6, 8, 9, ...
-2
votes
2
answers
216
views
What actually happens when we put conditions without [] (brackets) in if else block in a bash script?
final=''
if [ $final ]; then echo "final"; else echo "not final"; fi;
Look at this code above. How would it apply and why, if I remove the brackets in the if block?
How does it ...
0
votes
0
answers
120
views
Updating items of Boolean array in For Each loop
How to update each item of a Boolean array in a For... Each loop?
This code updates item variable in every loop but it doesn't update the array items themselves.
Dim BoolArr(1 to 4) as Boolean
Dim ...
1
vote
0
answers
79
views
Python: How to slice a 2d array to specified range of x and y values? Also how to improve this code?
I have a meshgrid given by X and Y of unequal length and a 2d array of values vx2. I want to create a sub-2d array Z from a certain xlim and ylim. I want to create a contour plot but since matplotlib ...
0
votes
2
answers
58
views
Google Sheets - formula for multiple values from different columns are fulfilled
I need to find a formula that can tell me if certain conditions are met in multiple columns.
I have Column A "Day of Week" and Column B "24 Hr Clock"
In column C I would like to ...
5
votes
3
answers
1k
views
Checking for False when variable can also be None or True
Update: please see my discussion if you want to delve further into this topic! Thank you everyone for your feedback on this!
I have a boolean(ish) flag that can be True or False, with None as an ...
0
votes
1
answer
54
views
implement a function to group cells when simplifying Boolean expression using K-map
In order to implement simplification of a 5-variable Boolean expression using Karnaugh map, I write a JavaScript function to group cells (which input is a list of integers specifying minterms):
...
1
vote
0
answers
58
views
QueryDSL BooleanExpression exclude data if the field is null
I have a problem when try to use a filter in a query that have a null field.
if (StringUtils.isNotBlank(query)){
expression = expression.and(qAdopt.name.containsIgnoreCase(query)
...
0
votes
2
answers
145
views
Evaluating logical expressions recognized by ANTLR using the System.Linq.Expressions namespace
I've defined a grammar, which I have to parse in C# and evaluate the resulted "constraints" on a list of dictionaries. The grammar is mainly boolean algebra.
Here you can check it:
grammar ...
-1
votes
1
answer
124
views
What is the most elegant way of checking if multiple objects exist, in Node.js? [duplicate]
Suppose I have several environment variables, going by the hypothetical names OBJECT_A, OBJECT_B, OBJECT_C, etc.
I must implement a function doTheyExist() that must return a boolean.
I want to know ...
0
votes
2
answers
327
views
How is this (xy)' + (yz) simplified into this (x’+y’)+z in boolean algebra? [closed]
I not understand how the first Boolean expression on the question can be simplified into the last. Please help me.
My attempt:
1. (xy)' + (yz)
2. (x' + y') + (yz) # Using de Morgan's law.
3. x' + (y' +...
0
votes
1
answer
63
views
Octave: Boolean AND returns wrong number
I am trying for several hours to calculate a boolean AND operation in Octave.
It return a wrong number.
I want to calculate following numbers:
result = 4037 & 63
result should be 5 but i get 1.
I ...
1
vote
2
answers
114
views
How do I get this code to accommodate any given number by only using boolean logic (no conditionals/ functions)
Here is the problem:
number = 1101
#You may modify the lines of code above, but don't move them!
#When you Submit your code, we'll change these lines to
#assign different values to the variables.
#
#...
0
votes
1
answer
117
views
Can reification predicates from CLP(FD) be used to check equality of logic expressions?
According to the documentation (section A.9.12), CLP(FD) constraints such as #>, #=, #/\ etc. can be reified.
Constraint #<==>/2 is supposed to be
True iff P and Q are equivalent
according ...
0
votes
1
answer
52
views
Trouble with boolean logic in if (else) statements
I am trying to create a function that returns a different greeting depending on two variables: the country and time provided.
If time is greater than or equal to 0 but less than 12 it will be morning. ...
0
votes
1
answer
127
views
designing a circuit with 3 3-bit inputs and 4 1-bit outputs
The inputs are A[2:0], B[2:0] and C[2:0] respectively. The outputs are E,RA,RB,RC.
If at least at one of the inputs (A,B,C) none of the bits are equal to 1 or if at least at one input the bits that ...
0
votes
1
answer
96
views
Yacc : Boolean and Arithmetic expression grammars conflict
I'm implementing a compiler as part of a class, for a language which is supposed to support both arithmetic and boolean expression. Unfortunately, I'm having some trouble implementing rules for both ...
-1
votes
1
answer
86
views
Confusion with Boolean Expressions in C / < and > are reversed? [closed]
I am a bit confused.
< means that the right side of the number is bigger, no?
So natually, the while condition
while (height > 0 && height < 9);
in
#include <cs50.h>
#include &...
1
vote
2
answers
117
views
What is a good way to verify if arguments of a function are numbers
I have a function which takes in 3 arguments and I want to make sure those three arguments are numbers.
As of right now, I've made this after a bit of experimenting and it seems to work but I'm not ...
2
votes
1
answer
143
views
Reduce if/else-if on a bunch of partially overlapping conditions
I was trying to solve a coding problem which ended up with these conditionals:
x_A2 <= x_B1 OR x_A1 >= X_B2 --> 0
x_A1 <= x_B1 <= x_A2 --> x_A2 - X_B1
x_B1 <= x_A1 <= x_B2 --...
-3
votes
1
answer
53
views
Booleans Values
Which of the following will be fully evaluated that first option will be checked inclusive the second option, if the following variables represent the following boolean values
a = True
b = False
...
-2
votes
1
answer
122
views
How is boolean xx = (43.3L == 3.333f) syntactically correct
I'm have a problem with understanding this question about syntax it says the answer is
boolean xx = (43.3L == 3.333f);
but i don't understand how it is
Which of the following Java statements are NOT ...
0
votes
1
answer
133
views
Why is '(x in list_1) == True' is True but 'x in list_1 == True' is False? [duplicate]
I know this is can be a very basic question, but I found something curious on Python. I will try to explain this with the following example:
l = [1,2,3,4,5]
n1 = 1
We know the following:
print( n1 in ...
1
vote
2
answers
68
views
Subsetting a Boolean variable in Python
When a DataFrame ("Given_DF") has a Boolean variable (such as B below),how can one subset the DataFrame to keep only rows of Variable B with True value?.
Given_DF
ID A B
0 123 ...
-1
votes
1
answer
49
views
PHP - false == 0 but false != "00" [duplicate]
I had a problem with checking falsy conditions and don't understand how 'false' works.
I tested the code above,
echo (0 == false); //->true
echo ("0" == false); //->true
echo ("0&...
1
vote
1
answer
66
views
check to see whether an object exists in dict
a = {1 : 4}
print(4 in a) # case 1: False
a = {1 : 's'}
print('s' in a) # case 2: False
a = {1 : None}
print(None in a) # case 3: False
a = {1: True}
print(True in a) # case 4: True
so my ...
1
vote
2
answers
578
views
How to solve " Controlling expression is not an 'essentially Boolean' expression " in MISRA code?
I have a simple macro function which will check the condition and return an Boolean value. Below is the snippet of code
assume: #define boolean bool
Test.h file
#define CHECK_STATE(X) (...
0
votes
1
answer
99
views
Bool in C# works something unclear for me
Here goes an example of C# code. I did not get why in first case we will have 1 instead of 0.
Why does it return 1 instead?
static void Main(string[] args)
{
int firstNumber = 0;
bool ...
-2
votes
2
answers
64
views
Boolean Logic and For Loops
I was wondering if those familiar with codingbat's problems might be able to help me with understanding the differences between these two solutions and why one doesn't work.
The problem:
Given a ...
-2
votes
1
answer
203
views
How exactly does the "and not" operation in python works [duplicate]
i am trying to learn python and for that i am watching a course, in which the core concepts of the language are being taught.
I wrote the following code, in which a secret word has to be guessed:
I ...
2
votes
1
answer
173
views
Resolve Java Interface ambiguity in method parameters
I have a tree of boolean operations from a boolean expression that I have to run in Java. The tree would be something like this:
And I would need to run it in Java iteratively so that it returns me a ...
-1
votes
2
answers
197
views
How do I identify the Boolean Expression of this logic circuit?
As the title says, what can be the possible boolean expression of the logic circuit given? The Truth table is also included.Logic Circuit
I have tried to solve my own Boolean Expression and coded it ...
1
vote
1
answer
95
views
Can I use a boolean mask to find if a DateTime value falls between two other DateTime values in a different dataframe
I want to filter the datapoints I have, until I only have the datapoints were the participant was asleep left. I have my dataframe with DateTime values and the values I am researching, and a different ...
0
votes
1
answer
94
views
Python: real order of execution for equalities/inequalities in expressions? [duplicate]
Imagine this "sneaky" python code:
>>> 1 == 2 < 3
False
According to Python documentation all of the operators in, not in, is, is not, <, <=, >, >=, !=, == have the ...
-1
votes
1
answer
95
views
Boolean operator 'and', expect False answer if one expression is False?
I´m a 1 week self taught python3 guy, and i´m into the comparison and boolean operators and learn this:
True and True True
True and False False
False and True False
False and False ...
0
votes
0
answers
284
views
How to Convert string to boolean with function CASE WHEN in PostgreSQL
Full Query:
SELECT
'' as [id],
a.OrganizationId as [organization_id],
a.AdmissionNo as [admission_no],
a.AdmissionDate as [admission_date],
p.MrNo as [mr_no],
...
0
votes
1
answer
48
views
Why does IF statement fail?
I have a horrible feeling that the answer to this question is going to be obvious, but...
I am reading data from a small file in MicroPython. The value of the line I read determines whether a bool ...
0
votes
1
answer
252
views
Generalized product-of-sums Boolean expression with n true variables out of m total variables
Problem
How do you write a "product-of-sums" Boolean expression, in m Boolean variables, which enforces at least n of those variables being 1/true?
Attempt
Starting in the "sum-of-...