1,074 questions
0
votes
1
answer
98
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 ...
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 ...
3
votes
2
answers
87
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&...
-2
votes
1
answer
40
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.
0
votes
1
answer
121
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 ...
1
vote
1
answer
85
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
285
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, ...
0
votes
0
answers
119
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 ...
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 ...
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):
...
0
votes
2
answers
143
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 ...
0
votes
2
answers
326
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' +...
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
48
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
95
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
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 ...
-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
...
0
votes
1
answer
126
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
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
2
answers
572
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) (...
-2
votes
2
answers
63
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
172
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
vote
1
answer
88
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 ...
-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
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 ...